]> git.tdb.fi Git - libs/datafile.git/blob - source/rawdata.h
Move the definition of Input's operator bool to the header
[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 #include "mspdatafile_api.h"
8
9 namespace Msp {
10 namespace DataFile {
11
12 class Collection;
13
14 class MSPDATAFILE_API RawData: public NonCopyable
15 {
16 private:
17         enum Flags
18         {
19                 COMPRESSED = 1
20         };
21
22         std::string src_name;
23         IO::Base *in = nullptr;
24         bool in_owned = false;
25         IO::Base *compressed = nullptr;
26         std::size_t size = 0;
27         char *data = nullptr;
28         char *owned_data = nullptr;
29
30         static const char signature[4];
31
32 public:
33         ~RawData();
34
35         static bool detect_signature(const std::string &);
36
37         void open_file(Collection &, const std::string &);
38         void open_io(IO::Base &, const std::string &);
39         void load();
40         void load_into(void *);
41
42         void write_io(IO::Base &, bool = false);
43
44         std::size_t get_size() const { return size; }
45         const void *get_data() const { return data; }
46 };
47
48 } // namespace DataFile
49 } // namespace Msp
50
51 #endif