]> git.tdb.fi Git - libs/datafile.git/blob - source/builtinsource.h
Move the definition of Input's operator bool to the header
[libs/datafile.git] / source / builtinsource.h
1 #ifndef MSP_DATAFILE_BUILTINSOURCE_H_
2 #define MSP_DATAFILE_BUILTINSOURCE_H_
3
4 #include "collectionsource.h"
5 #include "mspdatafile_api.h"
6
7 namespace Msp {
8 namespace DataFile {
9
10 class MSPDATAFILE_API BuiltinSource: public CollectionSource
11 {
12 private:
13         struct Object
14         {
15                 const char *data = nullptr;
16                 std::size_t size = 0;
17
18                 Object() = default;
19                 Object(const char *, std::size_t);
20         };
21
22         std::map<std::string, Object> objects;
23
24 public:
25         void add_object(const std::string &, const char *, std::size_t);
26         void add_object(const std::string &, const char *);
27
28         bool is_loadable(const CollectionItemTypeBase &, const std::string &) const override;
29         NameList get_names(const CollectionItemTypeBase &) const override;
30         void load(Collection &, const CollectionItemTypeBase &, const std::string &) const override;
31         IO::Seekable *open(const std::string &) const override;
32 };
33
34 } // namespace DataFile
35 } // namespace Msp
36
37 #endif