]> git.tdb.fi Git - libs/datafile.git/blobdiff - source/rawdata.h
Add a class for loading raw bulk data
[libs/datafile.git] / source / rawdata.h
diff --git a/source/rawdata.h b/source/rawdata.h
new file mode 100644 (file)
index 0000000..2db390b
--- /dev/null
@@ -0,0 +1,44 @@
+#ifndef MSP_DATAFILE_RAWDATA_H_
+#define MSP_DATAFILE_RAWDATA_H_
+
+#include <string>
+#include <msp/core/noncopyable.h>
+#include <msp/io/base.h>
+
+namespace Msp {
+namespace DataFile {
+
+class Collection;
+
+class RawData: public NonCopyable
+{
+private:
+       enum Flags
+       {
+               COMPRESSED = 1
+       };
+
+       std::string src_name;
+       IO::Base *in = nullptr;
+       bool in_owned = false;
+       IO::Base *compressed = nullptr;
+       std::size_t size = 0;
+       char *data = nullptr;
+       char *owned_data = nullptr;
+
+public:
+       ~RawData();
+
+       void open_file(Collection &, const std::string &);
+       void open_io(IO::Base &, const std::string &);
+       void load();
+       void load_into(void *);
+
+       std::size_t get_size() const { return size; }
+       const void *get_data() const { return data; }
+};
+
+} // namespace DataFile
+} // namespace Msp
+
+#endif