27 #include <xercesc/framework/XMLPScanToken.hpp>
28 #include <xercesc/parsers/SAXParser.hpp>
29 #include <xercesc/sax/HandlerBase.hpp>
30 #include <xercesc/sax/AttributeList.hpp>
31 #include <xercesc/util/PlatformUtils.hpp>
32 #include <xercesc/sax/SAXParseException.hpp>
33 #include <xercesc/sax/SAXException.hpp>
67 myArgC = (int)args.size() + 1;
68 char** argv =
new char* [
myArgC];
70 for (
int i = 1; i <
myArgC; i++) {
71 argv[i] =
new char[args[i - 1].size() + 1];
72 std::strcpy(argv[i], args[i - 1].c_str());
83 if (!commandLineOnly) {
92 throw ProcessError(
"Could not parse commandline options.");
104 if (!oc.
exists(
"configuration-file") || !oc.
isSet(
"configuration-file")) {
107 const std::string path = oc.
getString(
"configuration-file");
114 XERCES_CPP_NAMESPACE::SAXParser parser;
115 parser.setValidationScheme(XERCES_CPP_NAMESPACE::SAXParser::Val_Auto);
116 parser.setDoNamespaces(
false);
117 parser.setDoSchema(
false);
121 parser.setDocumentHandler(&handler);
122 parser.setErrorHandler(&handler);
123 parser.parse(path.c_str());
125 throw ProcessError(
"Could not load configuration '" + path +
"'.");
127 }
catch (
const XERCES_CPP_NAMESPACE::XMLException& e) {
143 XERCES_CPP_NAMESPACE::SAXParser parser;
147 parser.setDocumentHandler(&handler);
148 parser.setErrorHandler(&handler);
149 XERCES_CPP_NAMESPACE::XMLPScanToken token;
151 throw ProcessError(
"Could not open '" + filename +
"'.");
154 zstr::ifstream istream(filename.c_str(), std::fstream::in | std::fstream::binary);
156 const bool result = parser.parseFirst(inputStream, token);
158 const bool result = parser.parseFirst(filename.c_str(), token);
161 throw ProcessError(
"Can not read XML-file '" + filename +
"'.");
163 while (parser.parseNext(token) && handler.
getItem() ==
"");
165 throw ProcessError(
"Could not load '" + filename +
"'.");
167 }
catch (
const XERCES_CPP_NAMESPACE::XMLException& e) {
#define PROGRESS_DONE_MESSAGE()
#define PROGRESS_BEGIN_MESSAGE(msg)
static bool isReadable(std::string path)
Checks whether the given file is readable.
static bool isDirectory(std::string path)
Checks whether the given file is a directory.
A storage for options typed value containers)
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
bool exists(const std::string &name) const
Returns the information whether the named option is known.
void resetWritable()
Resets all options to be writeable.
static OptionsCont & getOptions()
Retrieves the options.
void relocateFiles(const std::string &configuration) const
Modifies file name options according to the configuration path.
static void loadConfiguration()
Loads and parses the configuration.
static void setArgs(int argc, char **argv)
Stores the command line arguments for later parsing.
static void getOptions(const bool commandLineOnly=false)
Parses the command line arguments and loads the configuration.
static std::string getRoot(const std::string &filename)
Retrieves the XML root element of a supposed configuration or net.
A SAX-Handler for loading options.
const std::string & getItem() const
Returns the last item read.
bool errorOccurred() const
Returns the information whether an error occurred.
static bool parse(int argc, char **argv)
Parses the given command line arguments.
static std::string transcode(const XMLCh *const data)
converts a 0-terminated XMLCh* array (usually UTF-16, stemming from Xerces) into std::string in UTF-8