]> git.tdb.fi Git - libs/datafile.git/blob - source/rawdata.h
Add a function to detect raw data signature
[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         static const char signature[4];
30
31 public:
32         ~RawData();
33
34         static bool detect_signature(const std::string &);
35
36         void open_file(Collection &, const std::string &);
37         void open_io(IO::Base &, const std::string &);
38         void load();
39         void load_into(void *);
40
41         std::size_t get_size() const { return size; }
42         const void *get_data() const { return data; }
43 };
44
45 } // namespace DataFile
46 } // namespace Msp
47
48 #endif