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.");
85 if (!commandLineOnly) {
100 if (!oc.
exists(
"configuration-file") || !oc.
isSet(
"configuration-file")) {
103 std::string path = oc.
getString(
"configuration-file");
109 XERCES_CPP_NAMESPACE::SAXParser parser;
110 parser.setValidationScheme(XERCES_CPP_NAMESPACE::SAXParser::Val_Auto);
111 parser.setDoNamespaces(
false);
112 parser.setDoSchema(
false);
116 parser.setDocumentHandler(&handler);
117 parser.setErrorHandler(&handler);
118 parser.parse(path.c_str());
120 throw ProcessError(
"Could not load configuration '" + path +
"'.");
122 }
catch (
const XERCES_CPP_NAMESPACE::XMLException& e) {
133 XERCES_CPP_NAMESPACE::SAXParser parser;
137 parser.setDocumentHandler(&handler);
138 parser.setErrorHandler(&handler);
139 XERCES_CPP_NAMESPACE::XMLPScanToken token;
140 if (!parser.parseFirst(filename.c_str(), token)) {
141 throw ProcessError(
"Can not read XML-file '" + filename +
"'.");
143 while (parser.parseNext(token) && handler.
getItem() ==
"");
145 throw ProcessError(
"Could not load '" + filename +
"'.");
147 }
catch (
const XERCES_CPP_NAMESPACE::XMLException& e) {
void resetWritable()
Resets all options to be writeable.
static void getOptions(const bool commandLineOnly=false)
Parses the command line arguments and loads the configuration.
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.
bool errorOccured() const
Returns the information whether an error occured.
#define PROGRESS_BEGIN_MESSAGE(msg)
A SAX-Handler for loading options.
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()
static std::string _2str(const int var)
convert int to string
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.