Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
memoryzipstream.h
Go to the documentation of this file.
1 
18 #ifndef ION_BASE_MEMORYZIPSTREAM_H_
19 #define ION_BASE_MEMORYZIPSTREAM_H_
20 
21 #include <memory>
22 #include <string>
23 
24 #include "base/integral_types.h"
25 #include "ion/base/allocatable.h"
27 
28 namespace ion {
29 namespace base {
30 
33 class MemoryZipStream : public Allocatable {
34  public:
36 
38  struct ZipStreamInfo;
39 
45  explicit MemoryZipStream(const DataVector& data);
50  explicit MemoryZipStream(DataVector* data);
51  ~MemoryZipStream() override;
52 
56  void AddFile(const std::string& filename, const DataVector& data);
60  void AddFile(const std::string& filename, const std::string& data);
61 
63  bool ContainsFile(const std::string& filename);
64 
67  const DataVector GetFileData(const std::string& filename);
68 
70  const DataVector& GetData() const;
71 
72  private:
74  void InitCallbacks();
75 
76  std::unique_ptr<ZipStreamInfo> info_;
77 };
78 
79 } // namespace base
80 } // namespace ion
81 
82 #endif // ION_BASE_MEMORYZIPSTREAM_H_
void AddFile(const std::string &filename, const DataVector &data)
Compresses and adds a vector of data to this, associating it with the passed filename.
const DataVector GetFileData(const std::string &filename)
Returns the file data for filename.
A MemoryZipStream represents ZIP data in memory; the data may represent one or more files or director...
Allocatable is an abstract base class for classes whose memory is managed by an Allocator.
Definition: allocatable.h:60
MemoryZipStream()
Constructs an empty MemoryZipStream.
AllocVector< uint8 > DataVector
bool ContainsFile(const std::string &filename)
Returns whether this contains filename.
const DataVector & GetData() const
Gets the memory buffer backing this.