MCPcopy Create free account
hub / github.com/catboost/catboost / ParseDoubleFromYsonString

Function ParseDoubleFromYsonString

library/cpp/yt/yson_string/convert.cpp:260–281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

258}
259
260double ParseDoubleFromYsonString(const TYsonStringBuf& str)
261{
262 YT_ASSERT(str.GetType() == EYsonType::Node);
263 auto strBuf = str.AsStringBuf();
264 TMemoryInput input(strBuf.data(), strBuf.length());
265 char ch;
266 if (!input.ReadChar(ch)) {
267 throw TYsonLiteralParseException("Missing type marker");
268 }
269 if (ch != NDetail::DoubleMarker) {
270 throw TYsonLiteralParseException(Format("Unexpected %v",
271 FormatUnexpectedMarker(ch)));
272 }
273 if (input.Avail() != sizeof(double)) {
274 throw TYsonLiteralParseException(Format("Incorrect remaining string length: expected %v, got %v",
275 sizeof(double),
276 input.Avail()));
277 }
278 double result;
279 YT_VERIFY(input.Read(&result, sizeof(result)));
280 return result;
281}
282
283} // namespace
284

Callers 2

Calls 10

FormatUnexpectedMarkerFunction · 0.85
ReadCharMethod · 0.80
FormatFunction · 0.50
GetTypeMethod · 0.45
AsStringBufMethod · 0.45
dataMethod · 0.45
lengthMethod · 0.45
AvailMethod · 0.45
ReadMethod · 0.45

Tested by

no test coverage detected