yarchive.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #pragma once
  2. #include "models_archive_reader.h"
  3. #include <util/generic/fwd.h>
  4. #include <util/generic/ptr.h>
  5. class IInputStream;
  6. class IOutputStream;
  7. class TBlob;
  8. //noncompressed data will be stored with default alignment DEVTOOLS-4384
  9. static constexpr size_t ArchiveWriterDefaultDataAlignment = 16;
  10. class TArchiveWriter {
  11. public:
  12. explicit TArchiveWriter(IOutputStream* out, bool compress = true);
  13. ~TArchiveWriter();
  14. void Flush();
  15. void Finish();
  16. void Add(const TString& key, IInputStream* src);
  17. void AddSynonym(const TString& existingKey, const TString& newKey);
  18. private:
  19. class TImpl;
  20. THolder<TImpl> Impl_;
  21. };
  22. class TArchiveReader : public IModelsArchiveReader {
  23. public:
  24. explicit TArchiveReader(const TBlob& data);
  25. ~TArchiveReader() override;
  26. size_t Count() const noexcept override;
  27. TString KeyByIndex(size_t n) const override;
  28. bool Has(TStringBuf key) const override;
  29. TAutoPtr<IInputStream> ObjectByKey(TStringBuf key) const override;
  30. TBlob ObjectBlobByKey(TStringBuf key) const override;
  31. TBlob BlobByKey(TStringBuf key) const override;
  32. bool Compressed() const override;
  33. private:
  34. class TImpl;
  35. THolder<TImpl> Impl_;
  36. };