| 258 | } |
| 259 | |
| 260 | double 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 |
no test coverage detected