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>
60 char** codedArgv =
new char* [
myArgC];
61 for (
int i = 0; i < argc; i++) {
63 codedArgv[i] =
new char[a.size() + 1];
64 std::strcpy(codedArgv[i], a.c_str());
73 myArgC = (int)args.size() + 1;
74 char** argv =
new char* [
myArgC];
76 for (
int i = 1; i <
myArgC; i++) {
77 argv[i] =
new char[args[i - 1].size() + 1];
78 std::strcpy(argv[i], args[i - 1].c_str());
89 if (!commandLineOnly) {
98 throw ProcessError(
"Could not parse commandline options.");
110 if (!oc.
exists(
"configuration-file") || !oc.
isSet(
"configuration-file")) {
113 const std::string path = oc.
getString(
"configuration-file");
117 const bool verbose = !oc.
exists(
"verbose") || oc.
getBool(
"verbose");
123 XERCES_CPP_NAMESPACE::SAXParser parser;
124 parser.setValidationScheme(XERCES_CPP_NAMESPACE::SAXParser::Val_Auto);
125 parser.setDoNamespaces(
false);
126 parser.setDoSchema(
false);
130 parser.setDocumentHandler(&handler);
131 parser.setErrorHandler(&handler);
134 throw ProcessError(
"Could not load configuration '" + path +
"'.");
136 }
catch (
const XERCES_CPP_NAMESPACE::XMLException& e) {
154 XERCES_CPP_NAMESPACE::SAXParser parser;
158 parser.setDocumentHandler(&handler);
159 parser.setErrorHandler(&handler);
160 XERCES_CPP_NAMESPACE::XMLPScanToken token;
162 throw ProcessError(
"Could not open '" + filename +
"'.");
167 const bool result = parser.parseFirst(inputStream, token);
172 throw ProcessError(
"Can not read XML-file '" + filename +
"'.");
174 while (parser.parseNext(token) && handler.
getItem() ==
"");
176 throw ProcessError(
"Could not load '" + filename +
"'.");
178 }
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.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
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
static std::string transcodeToLocal(const std::string &utf8String)
convert a string from UTF-8 to the local codepage
static std::string transcodeFromLocal(const std::string &localString)
convert a string from the local codepage to UTF-8