2 #include <msp/io/memory.h>
3 #include "builtinsource.h"
4 #include "collection.h"
11 void BuiltinSource::add_object(const string &name, const char *content, unsigned size)
13 objects[name] = Object(content, size);
16 void BuiltinSource::add_object(const string &name, const char *content)
18 add_object(name, content, strlen(content));
21 bool BuiltinSource::is_loadable(const CollectionItemTypeBase &, const string &name) const
23 return objects.count(name);
26 CollectionSource::NameList BuiltinSource::get_names(const CollectionItemTypeBase &type) const
29 for(ObjectMap::const_iterator i=objects.begin(); i!=objects.end(); ++i)
30 if(type.match_name(i->first))
31 names.push_back(i->first);
35 void BuiltinSource::load(Collection &coll, const CollectionItemTypeBase &type, const string &name) const
37 ObjectMap::const_iterator i = objects.find(name);
40 IO::Memory in(i->second.data, i->second.size);
41 Parser parser(in, name);
42 type.load_item(coll, parser, name);
46 IO::Seekable *BuiltinSource::open(const string &name) const
48 ObjectMap::const_iterator i = objects.find(name);
50 return new IO::Memory(i->second.data, i->second.size);
56 BuiltinSource::Object::Object():
61 BuiltinSource::Object::Object(const char *d, unsigned s):
66 } // namespace DataFile