Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
TemplateHandler.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
18// A SAX-Handler for loading templates
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
23#include <xercesc/sax/HandlerBase.hpp>
24#include <xercesc/sax/AttributeList.hpp>
25#include <xercesc/sax/SAXParseException.hpp>
26#include <xercesc/sax/SAXException.hpp>
27#include <string>
28
29
30// ===========================================================================
31// class declarations
32// ===========================================================================
33
34class OptionsCont;
35
36// ===========================================================================
37// class definitions
38// ===========================================================================
43class TemplateHandler : public XERCES_CPP_NAMESPACE::HandlerBase {
44
45public:
47 static void parseTemplate(OptionsCont& options, const std::string& templateString);
48
49private:
52
55
58
63 void startElement(const XMLCh* const name, XERCES_CPP_NAMESPACE::AttributeList& attributes);
64
66 bool addOption(std::string value, const std::string& synonymes, const std::string& type,
67 const std::string& help, bool required, bool positional, const std::string& listSep) const;
68
73 void endElement(const XMLCh* const name);
74
76
79
84 void warning(const XERCES_CPP_NAMESPACE::SAXParseException& exception);
85
90 void error(const XERCES_CPP_NAMESPACE::SAXParseException& exception);
91
96 void fatalError(const XERCES_CPP_NAMESPACE::SAXParseException& exception);
97
99
102
105
108
110 std::string myOptionName;
111
113 std::string mySubTopic;
114
116 static const std::string INVALID_INT_STR;
117
119 static const std::string INVALID_DOUBLE_STR;
120
123
126};
A storage for options typed value containers)
Definition OptionsCont.h:89
A SAX-Handler for loading options.
void fatalError(const XERCES_CPP_NAMESPACE::SAXParseException &exception)
Called on an XML-fatal error.
TemplateHandler(const TemplateHandler &s)=delete
invalid copy constructor
static const std::string INVALID_DOUBLE_STR
invalid double in string format
TemplateHandler & operator=(const TemplateHandler &s)=delete
invalid assignment operator
void endElement(const XMLCh *const name)
Called on the end of an element.
bool myError
The information whether an error occurred.
int myLevel
The nesting level of parsed elements.
std::string mySubTopic
current subtopic
std::string myOptionName
The name of the current option.
void startElement(const XMLCh *const name, XERCES_CPP_NAMESPACE::AttributeList &attributes)
Called on the occurrence of the beginning of a tag.
OptionsCont & myOptions
The options to fill.
~TemplateHandler()
destructor
void error(const XERCES_CPP_NAMESPACE::SAXParseException &exception)
Called on an XML-error.
static void parseTemplate(OptionsCont &options, const std::string &templateString)
run parser
static const std::string INVALID_INT_STR
invalid int in string format
bool addOption(std::string value, const std::string &synonymes, const std::string &type, const std::string &help, bool required, bool positional, const std::string &listSep) const
add option
void warning(const XERCES_CPP_NAMESPACE::SAXParseException &exception)
Called on an XML-warning.