34 #include <xercesc/framework/XMLPScanToken.hpp> 35 #include <xercesc/parsers/SAXParser.hpp> 36 #include <xercesc/sax/HandlerBase.hpp> 37 #include <xercesc/sax/AttributeList.hpp> 38 #include <xercesc/util/PlatformUtils.hpp> 39 #include <xercesc/sax/SAXParseException.hpp> 40 #include <xercesc/sax/SAXException.hpp> 50 #ifdef CHECK_MEMORY_LEAKS 52 #endif // CHECK_MEMORY_LEAKS 83 throw ProcessError(
"Could not parse commandline options.");
98 if (!oc.
exists(
"configuration-file") || !oc.
isSet(
"configuration-file")) {
101 std::string path = oc.
getString(
"configuration-file");
107 XERCES_CPP_NAMESPACE::SAXParser parser;
108 parser.setValidationScheme(XERCES_CPP_NAMESPACE::SAXParser::Val_Auto);
109 parser.setDoNamespaces(
false);
110 parser.setDoSchema(
false);
114 parser.setDocumentHandler(&handler);
115 parser.setErrorHandler(&handler);
116 parser.parse(path.c_str());
118 throw ProcessError(
"Could not load configuration '" + path +
"'.");
120 }
catch (
const XERCES_CPP_NAMESPACE::XMLException& e) {
131 XERCES_CPP_NAMESPACE::SAXParser parser;
135 parser.setDocumentHandler(&handler);
136 parser.setErrorHandler(&handler);
137 XERCES_CPP_NAMESPACE::XMLPScanToken token;
138 if (!parser.parseFirst(filename.c_str(), token)) {
139 throw ProcessError(
"Can not read XML-file '" + filename +
"'.");
141 while (parser.parseNext(token) && handler.
getItem() ==
"");
143 throw ProcessError(
"Could not load '" + filename +
"'.");
145 }
catch (
const XERCES_CPP_NAMESPACE::XMLException& e) {
void resetWritable()
Resets all options to be writeable.
static bool isReadable(std::string path)
Checks whether the given file is readable.
const std::string & getItem() const
Returns the last item read.
static void setArgs(int argc, char **argv)
Stores the command line arguments for later parsing.
static OptionsCont & getOptions()
Retrieves the options.
static bool parse(int argc, char **argv)
Parses the given command line arguments.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
static void loadConfiguration()
Loads and parses the configuration.
static std::string _2str(const E *const data)
bool errorOccured() const
Returns the information whether an error occured.
#define PROGRESS_BEGIN_MESSAGE(msg)
A SAX-Handler for loading options.
static void getOptions()
Parses the command line arguments and loads the configuration.
void relocateFiles(const std::string &configuration) const
Modifies file name options according to the configuration path.
A storage for options typed value containers)
static std::string getRoot(const std::string &filename)
Retrieves the XML root element of a supposed configuration or net.
#define PROGRESS_DONE_MESSAGE()
bool exists(const std::string &name) const
Returns the information whether the named option is known.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.