models_archive_reader.h 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. #pragma once
  2. #include <util/generic/fwd.h>
  3. #include <util/generic/ptr.h>
  4. #include <util/generic/hash_set.h>
  5. class IInputStream;
  6. class TBlob;
  7. class IModelsArchiveReader {
  8. public:
  9. virtual ~IModelsArchiveReader() = default;
  10. virtual size_t Count() const = 0;
  11. virtual TString KeyByIndex(size_t n) const = 0;
  12. virtual bool Has(const TStringBuf key) const = 0;
  13. virtual TAutoPtr<IInputStream> ObjectByKey(const TStringBuf key) const = 0;
  14. virtual TBlob ObjectBlobByKey(const TStringBuf key) const = 0;
  15. virtual TBlob BlobByKey(const TStringBuf key) const = 0;
  16. virtual bool Compressed() const = 0;
  17. virtual THashSet<TStringBuf> FilterByPrefix(TStringBuf prefix, TStringBuf suffix) const {
  18. THashSet<TStringBuf> result;
  19. for (size_t ind = 0; ind < Count(); ++ind) {
  20. TStringBuf path = KeyByIndex(ind);
  21. if (path.StartsWith(prefix) && path.EndsWith(suffix)) {
  22. result.insert(path);
  23. }
  24. }
  25. return result;
  26. }
  27. };