| 524 | } |
| 525 | |
| 526 | void ReadBinaryString(TStringBuf* value) { |
| 527 | ui32 ulength = 0; |
| 528 | if (!TBaseStream::ReadVarint32(&ulength)) { |
| 529 | ythrow TYsonException() << "Error parsing varint value"; |
| 530 | } |
| 531 | |
| 532 | i32 length = ZigZagDecode32(ulength); |
| 533 | if (length < 0) { |
| 534 | ythrow TYsonException() << "Negative binary string literal length " << length; |
| 535 | } |
| 536 | |
| 537 | if (TBaseStream::Begin() + length <= TBaseStream::End()) { |
| 538 | *value = TStringBuf(TBaseStream::Begin(), length); |
| 539 | TBaseStream::Advance(length); |
| 540 | } else { // reading in Buffer |
| 541 | size_t needToRead = length; |
| 542 | Buffer_.clear(); |
| 543 | while (needToRead) { |
| 544 | if (TBaseStream::IsEmpty()) { |
| 545 | TBaseStream::Refresh(); |
| 546 | continue; |
| 547 | } |
| 548 | size_t readingBytes = Min(needToRead, TBaseStream::Length()); |
| 549 | |
| 550 | Buffer_.insert(Buffer_.end(), TBaseStream::Begin(), TBaseStream::Begin() + readingBytes); |
| 551 | CheckMemoryLimit(); |
| 552 | needToRead -= readingBytes; |
| 553 | TBaseStream::Advance(readingBytes); |
| 554 | } |
| 555 | *value = TStringBuf(Buffer_.data(), Buffer_.size()); |
| 556 | } |
| 557 | } |
| 558 | |
| 559 | template <bool AllowFinish> |
| 560 | bool ReadBoolean() { |
nothing calls this directly
no test coverage detected