summaryrefslogtreecommitdiff
path: root/include/mbgl/util/blob.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/mbgl/util/blob.hpp')
-rw-r--r--include/mbgl/util/blob.hpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/include/mbgl/util/blob.hpp b/include/mbgl/util/blob.hpp
new file mode 100644
index 0000000000..df8fddc773
--- /dev/null
+++ b/include/mbgl/util/blob.hpp
@@ -0,0 +1,34 @@
+#pragma once
+
+#include <memory>
+#include <string>
+
+namespace mbgl {
+
+class Blob {
+public:
+ Blob();
+ Blob(std::shared_ptr<const std::string> bytes, bool gzip);
+ Blob(std::string&& bytes, bool compressed);
+
+ // Return uncompressed/compressed data.
+ std::shared_ptr<const std::string> uncompressedData() const;
+ std::shared_ptr<const std::string> compressedData() const;
+
+ // Transform the blob to being uncompressed.
+ void uncompress();
+
+ bool isCompressed() const {
+ return compressed;
+ }
+
+ explicit operator bool() const {
+ return (bool)bytes;
+ }
+
+private:
+ std::shared_ptr<const std::string> bytes;
+ bool compressed;
+};
+
+} // namespace mbgl