summaryrefslogtreecommitdiff
path: root/project2/commonObjects.cpp
blob: 2ca484680b62a4146ae40f03d5c27ca1147f6c7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "commonObjects.h"
#include <libxml++/parsers/domparser.h>
#include <libxml/xinclude.h>

RowSetPtr
CommonObjects::getSource(const std::string & name) const
{
	RowSets::index<bySOName>::type::const_iterator i = rowSets.get<bySOName>().find(name);
	if (i != rowSets.get<bySOName>().end()) {
		return *i;
	}
	throw CommonObjects::DataSourceNotFound(name);
}

DataSources::index<bySOName>::type::const_iterator
CommonObjects::loadDataSource(const std::string & name) const
{
	xmlpp::DomParser xml("datasources/" + name + ".xml");
	while (xmlXIncludeProcessFlags(xml.get_document()->cobj(), XML_PARSE_NOXINCNODE) > 0);

	LoaderBase loader("http://project2.randomdan.homeip.net", true);
	loader.supportedStorers.insert(Storer::into(&datasources));
	loader.collectAll(xml.get_document()->get_root_node(), false);

	DataSources::index<bySOName>::type::const_iterator i = datasources.get<bySOName>().find(name);
	if (i == datasources.get<bySOName>().end()) {
		throw DataSourceNotFound(name);
	}
	return i;
}