ysaveload.cpp 779 B

12345678910111213141516171819202122
  1. #include "ysaveload.h"
  2. #include <util/generic/buffer.h>
  3. void TSerializer<TBuffer>::Save(IOutputStream* rh, const TBuffer& buf) {
  4. ::SaveSize(rh, buf.Size());
  5. ::SavePodArray(rh, buf.Data(), buf.Size());
  6. }
  7. void TSerializer<TBuffer>::Load(IInputStream* rh, TBuffer& buf) {
  8. const size_t s = ::LoadSize(rh);
  9. buf.Resize(s);
  10. ::LoadPodArray(rh, buf.Data(), buf.Size());
  11. }
  12. [[noreturn]] void NPrivate::ThrowLoadEOFException(size_t typeSize, size_t realSize, TStringBuf structName) {
  13. ythrow TLoadEOF() << "can not load " << structName << "(" << typeSize << ", " << realSize << " bytes)";
  14. }
  15. [[noreturn]] void NPrivate::ThrowUnexpectedVariantTagException(ui8 tagIndex) {
  16. ythrow TLoadEOF() << "Unexpected tag value " << tagIndex << " while loading TVariant";
  17. }