Architecture::Loader::Loader(Architecture &a):
- arch(a)
+ DataFile::ObjectLoader<Architecture>(a)
{
add("prefix", &Architecture::cross_prefix);
}
class Architecture
{
public:
- class Loader: public Msp::DataFile::Loader
+ class Loader: public Msp::DataFile::ObjectLoader<Architecture>
{
- private:
- Architecture &arch;
-
public:
Loader(Architecture &);
- Architecture &get_object() { return arch; }
};
typedef std::list<Pattern> PatternList;
BinaryPackage::Loader::Loader(BinaryPackage &p):
- Package::Loader(p)
+ DataFile::DerivedObjectLoader<BinaryPackage, Package>(p)
{
add("need_path", &BinaryPackage::need_path);
add("build_info", &Loader::build_info);
void BinaryPackage::Loader::build_info()
{
- load_sub(static_cast<BinaryPackage &>(pkg).export_binfo);
+ load_sub(obj.export_binfo);
}
class BinaryPackage: public Package
{
public:
- class Loader: public Package::Loader
+ class Loader: public Msp::DataFile::DerivedObjectLoader<BinaryPackage, Package>
{
public:
Loader(BinaryPackage &);
- BinaryPackage &get_object() { return static_cast<BinaryPackage &>(pkg); }
private:
void build_info();
};
Builder::Loader::Loader(Builder &b, const FS::Path &s):
- bld(b),
+ DataFile::ObjectLoader<Builder>(b),
src(s)
{
add("binary_package", &Loader::binpkg);
void Builder::Loader::binpkg(const string &n)
{
- BinaryPackage *pkg = new BinaryPackage(bld, n);
+ BinaryPackage *pkg = new BinaryPackage(obj, n);
load_sub(*pkg);
}
void Builder::Loader::cross_prefix(const string &a, const string &p)
{
- bld.cross_prefixes[a] = p;
+ obj.cross_prefixes[a] = p;
}
void Builder::Loader::profile(const string &n)
StringMap prf;
ProfileLoader ldr(prf);
load_sub_with(ldr);
- bld.profile_tmpl.insert(ProfileTemplateMap::value_type(n, prf));
+ obj.profile_tmpl.insert(ProfileTemplateMap::value_type(n, prf));
}
void Builder::Loader::package(const string &n)
{
- SourcePackage *pkg = new SourcePackage(bld, n, src);
- if(!bld.main_pkg)
- bld.main_pkg = pkg;
+ SourcePackage *pkg = new SourcePackage(obj, n, src);
+ if(!obj.main_pkg)
+ obj.main_pkg = pkg;
load_sub(*pkg);
}
class Builder: public Msp::RegisteredApplication<Builder>
{
private:
- class Loader: public Msp::DataFile::Loader
+ class Loader: public Msp::DataFile::ObjectLoader<Builder>
{
private:
- Builder &bld;
Msp::FS::Path src;
public:
Component::Loader::Loader(Component &c):
- comp(c)
+ DataFile::ObjectLoader<Component>(c)
{
add("source", &Loader::source);
add("install", &Component::install);
void Component::Loader::source(const string &s)
{
- comp.sources.push_back(s);
+ obj.sources.push_back(s);
}
void Component::Loader::require(const string &n)
{
- Package *req = comp.pkg.get_builder().get_package_manager().find_package(n);
+ Package *req = obj.pkg.get_builder().get_package_manager().find_package(n);
if(req)
- comp.requires.push_back(req);
+ obj.requires.push_back(req);
}
void Component::Loader::build_info()
{
- load_sub(comp.build_info);
+ load_sub(obj.build_info);
}
void Component::Loader::install_map()
{
- load_sub(comp.install_map, comp.pkg.get_source());
+ load_sub(obj.install_map, obj.pkg.get_source());
}
#define COMPONENT_H_
#include <string>
-#include <msp/datafile/loader.h>
+#include <msp/datafile/objectloader.h>
#include <msp/fs/path.h>
#include "buildinfo.h"
#include "installmap.h"
class Component
{
public:
- class Loader: public Msp::DataFile::Loader
+ class Loader: public Msp::DataFile::ObjectLoader<Component>
{
- private:
- Component ∁
-
public:
Loader(Component &);
- Component &get_object() { return comp; }
private:
void source(const std::string &);
void require(const std::string &);
Condition::Loader::Loader(Condition &c):
- cond(c)
+ DataFile::ObjectLoader<Condition>(c)
{
add("require", &Loader::require);
add("build_info", &Loader::build_info);
void Condition::Loader::require(const string &pkg)
{
- cond.requires.push_back(pkg);
+ obj.requires.push_back(pkg);
}
void Condition::Loader::build_info()
{
- load_sub(cond.build_info);
+ load_sub(obj.build_info);
}
class Condition
{
public:
- class Loader: public Msp::DataFile::Loader
+ class Loader: public Msp::DataFile::ObjectLoader<Condition>
{
- private:
- Condition &cond;
-
public:
Loader(Condition &);
private:
Config::Loader::Loader(Config &c):
- conf(c)
+ DataFile::ObjectLoader<Config>(c)
{
add("option", &Loader::option);
}
void Config::Loader::option(const string &n, const string &v)
{
- conf.set_option(n, v);
+ obj.set_option(n, v);
}
typedef std::map<std::string, Option> OptionMap;
private:
- class Loader: public Msp::DataFile::Loader
+ class Loader: public Msp::DataFile::ObjectLoader<Config>
{
- private:
- Config &conf;
-
public:
Loader(Config &);
private:
Package::Loader::Loader(Package &p):
- pkg(p)
+ DataFile::ObjectLoader<Package>(p)
{
add("require", &Loader::require);
}
void Package::Loader::require(const string &n)
{
- Package *req = pkg.builder.get_package_manager().find_package(n);
+ Package *req = obj.builder.get_package_manager().find_package(n);
if(req)
- pkg.requires.push_back(req);
+ obj.requires.push_back(req);
}
#include <list>
#include <string>
-#include <msp/datafile/loader.h>
+#include <msp/datafile/objectloader.h>
#include "buildinfo.h"
class Builder;
class Package
{
public:
- class Loader: public Msp::DataFile::Loader
+ class Loader: public Msp::DataFile::ObjectLoader<Package>
{
public:
Loader(Package &);
- Package &get_object() { return pkg; }
- protected:
- Package &pkg;
-
+ private:
void require(const std::string &);
};
}
-SourcePackage::Loader::Loader(Package &p):
- Package::Loader(p)
+SourcePackage::Loader::Loader(SourcePackage &p):
+ DataFile::DerivedObjectLoader<SourcePackage, Package>(p)
{
add("version", &SourcePackage::version);
add("description", &SourcePackage::description);
void SourcePackage::Loader::finish()
{
- SourcePackage &spkg = static_cast<SourcePackage &>(pkg);
- spkg.components.sort(component_sort);
+ obj.components.sort(component_sort);
for(map<string, string>::const_iterator i=install_map.begin(); i!=install_map.end(); ++i)
{
- for(ComponentList::iterator j=spkg.components.begin(); j!=spkg.components.end(); ++j)
+ for(ComponentList::iterator j=obj.components.begin(); j!=obj.components.end(); ++j)
{
const StringList &sources = j->get_sources();
for(StringList::const_iterator k=sources.begin(); k!=sources.end(); ++k)
{
if(!i->first.compare(0, k->size(), *k))
{
- const_cast<InstallMap &>(j->get_install_map()).add_mapping(spkg.source/i->first, i->second);
+ const_cast<InstallMap &>(j->get_install_map()).add_mapping(obj.source/i->first, i->second);
}
}
}
feat.descr = d;
feat.def_value = "no";
load_sub(feat);
- static_cast<SourcePackage &>(pkg).features.push_back(feat);
+ obj.features.push_back(feat);
}
void SourcePackage::Loader::condition(const string &c)
{
- SourcePackage &spkg = static_cast<SourcePackage &>(pkg);
- Condition cond(spkg, c);
+ Condition cond(obj, c);
load_sub(cond);
- spkg.conditions.push_back(cond);
+ obj.conditions.push_back(cond);
}
template<Component::Type t>
void SourcePackage::Loader::component(const string &n)
{
- SourcePackage &spkg = static_cast<SourcePackage &>(pkg);
- Component comp(spkg, t, n);
+ Component comp(obj, t, n);
load_sub(comp);
- spkg.components.push_back(comp);
+ obj.components.push_back(comp);
}
void SourcePackage::Loader::build_info()
{
- load_sub(static_cast<SourcePackage &>(pkg).build_info);
+ load_sub(obj.build_info);
}
void SourcePackage::Loader::headers(const string &n)
{
IO::print("%s: Note: headers components are deprecated\n", get_source());
- SourcePackage &spkg = static_cast<SourcePackage &>(pkg);
- Component comp(spkg, Component::LIBRARY, n);
+ Component comp(obj, Component::LIBRARY, n);
load_sub(comp);
const StringList &sources = comp.get_sources();
for(StringList::const_iterator i=sources.begin(); i!=sources.end(); ++i)
void SourcePackage::Loader::tarball(const string &n)
{
- SourcePackage &spkg = static_cast<SourcePackage &>(pkg);
if(n=="@src")
{
- for(ComponentList::iterator i=spkg.components.begin(); i!=spkg.components.end(); ++i)
+ for(ComponentList::iterator i=obj.components.begin(); i!=obj.components.end(); ++i)
if(i->get_type()==Component::TARBALL && i->get_name()==n)
load_sub(*i);
}
else
{
- Component trbl(spkg, Component::TARBALL, n);
+ Component trbl(obj, Component::TARBALL, n);
load_sub(trbl);
}
}
void SourcePackage::Loader::tar_file(const string &f)
{
IO::print("%s: Note: tar_file is deprecated\n", get_source());
- SourcePackage &spkg = static_cast<SourcePackage &>(pkg);
- for(ComponentList::iterator i=spkg.components.begin(); i!=spkg.components.end(); ++i)
+ for(ComponentList::iterator i=obj.components.begin(); i!=obj.components.end(); ++i)
if(i->get_type()==Component::TARBALL && i->get_name()=="@src")
- const_cast<StringList &>(i->get_sources()).push_back((spkg.source/f).str());
+ const_cast<StringList &>(i->get_sources()).push_back((obj.source/f).str());
}
DATA = 8
};
- class Loader: public Package::Loader
+ class Loader: public Msp::DataFile::DerivedObjectLoader<SourcePackage, Package>
{
private:
std::map<std::string, std::string> install_map;
public:
- Loader(Package &);
- SourcePackage &get_object() { return static_cast<SourcePackage &>(pkg); }
+ Loader(SourcePackage &);
private:
virtual void finish();
void feature(const std::string &, const std::string &);