]> git.tdb.fi Git - libs/datafile.git/blob - source/rawdata.h
Add a class for loading raw bulk data
[libs/datafile.git] / source / rawdata.h
1 #ifndef MSP_DATAFILE_RAWDATA_H_
2 #define MSP_DATAFILE_RAWDATA_H_
3
4 #include <string>
5 #include <msp/core/noncopyable.h>
6 #include <msp/io/base.h>
7
8 namespace Msp {
9 namespace DataFile {
10
11 class Collection;
12
13 class RawData: public NonCopyable
14 {
15 private:
16         enum Flags
17         {
18                 COMPRESSED = 1
19         };
20
21         std::string src_name;
22         IO::Base *in = nullptr;
23         bool in_owned = false;
24         IO::Base *compressed = nullptr;
25         std::size_t size = 0;
26         char *data = nullptr;
27         char *owned_data = nullptr;
28
29 public:
30         ~RawData();
31
32         void open_file(Collection &, const std::string &);
33         void open_io(IO::Base &, const std::string &);
34         void load();
35         void load_into(void *);
36
37         std::size_t get_size() const { return size; }
38         const void *get_data() const { return data; }
39 };
40
41 } // namespace DataFile
42 } // namespace Msp
43
44 #endif