| 612 | } |
| 613 | |
| 614 | void ReadBinaryDouble(double* value) { |
| 615 | size_t needToRead = sizeof(double); |
| 616 | |
| 617 | while (needToRead != 0) { |
| 618 | if (TBaseStream::IsEmpty()) { |
| 619 | TBaseStream::Refresh(); |
| 620 | continue; |
| 621 | } |
| 622 | |
| 623 | size_t chunkSize = Min(needToRead, TBaseStream::Length()); |
| 624 | if (chunkSize == 0) { |
| 625 | ythrow TYsonException() << "Error parsing binary double literal"; |
| 626 | } |
| 627 | std::copy( |
| 628 | TBaseStream::Begin(), |
| 629 | TBaseStream::Begin() + chunkSize, |
| 630 | reinterpret_cast<char*>(value) + (sizeof(double) - needToRead)); |
| 631 | needToRead -= chunkSize; |
| 632 | TBaseStream::Advance(chunkSize); |
| 633 | } |
| 634 | } |
| 635 | |
| 636 | /// Helpers |
| 637 | void SkipCharToken(char symbol) { |