/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file TemplateHandler.h14/// @author Pablo Alvarez Lopez15/// @date Dec 202216///17// A SAX-Handler for loading templates18/****************************************************************************/19#pragma once20#include <config.h>2122#include <xercesc/sax/HandlerBase.hpp>23#include <xercesc/sax/AttributeList.hpp>24#include <xercesc/sax/SAXParseException.hpp>25#include <xercesc/sax/SAXException.hpp>26#include <string>272829// ===========================================================================30// class declarations31// ===========================================================================3233class OptionsCont;3435// ===========================================================================36// class definitions37// ===========================================================================38/**39* @class TemplateHandler40* @brief A SAX-Handler for loading options41*/42class TemplateHandler : public XERCES_CPP_NAMESPACE::HandlerBase {4344public:45/// @brief run parser46static void parseTemplate(OptionsCont& options, const std::string& templateString);4748private:49/// @brief Constructor50TemplateHandler(OptionsCont& options);5152/// @brief destructor53~TemplateHandler();5455/// @name Handlers for the SAX DocumentHandler interface56/// @{5758/** @brief Called on the occurrence of the beginning of a tag59*60* Sets the name of the last item61*/62void startElement(const XMLCh* const name, XERCES_CPP_NAMESPACE::AttributeList& attributes);6364/// @brief add option65bool addOption(std::string value, const std::string& synonymes, const std::string& type,66const std::string& help, bool required, bool positional, const std::string& listSep) const;6768/** @brief Called on the end of an element69*70* Resets the element name71*/72void endElement(const XMLCh* const name);7374/// @}7576/// @name Handlers for the SAX ErrorHandler interface77/// @{7879/** @brief Called on an XML-warning80*81* The warning is reported to the warning-instance of MsgHandler82*/83void warning(const XERCES_CPP_NAMESPACE::SAXParseException& exception);8485/** @brief Called on an XML-error86*87* The warning is reported to the error-instance of MsgHandler88*/89void error(const XERCES_CPP_NAMESPACE::SAXParseException& exception);9091/** @brief Called on an XML-fatal error92*93* The warning is reported to the error-instance of MsgHandler94*/95void fatalError(const XERCES_CPP_NAMESPACE::SAXParseException& exception);9697/// @}9899/// @brief The information whether an error occurred100bool myError;101102/// @brief The nesting level of parsed elements103int myLevel;104105/// @brief The options to fill106OptionsCont& myOptions;107108/// @brief The name of the current option109std::string myOptionName;110111/// @brief current subtopic112std::string mySubTopic;113114/// @brief invalid int in string format115static const std::string INVALID_INT_STR;116117/// @brief invalid double in string format118static const std::string INVALID_DOUBLE_STR;119120/// @brief invalidate default onstructor121TemplateHandler() = delete;122123/// @brief invalid copy constructor124TemplateHandler(const TemplateHandler& s) = delete;125126/// @brief invalid assignment operator127TemplateHandler& operator=(const TemplateHandler& s) = delete;128};129130131