Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-02 08:43:50

0001 #ifndef XML_PARSER_H
0002 #define XML_PARSER_H
0003 
0004 /**
0005  * @file XMLParser.h
0006  * @author Bryan BERTHOU (SPhN / CEA Saclay)
0007  * @author Adrien KIELB (Modulo PI - Paris)
0008  * @date July 06, 2015
0009  * @version 1.0
0010  */
0011 
0012 #include <stddef.h>
0013 #include <string>
0014 
0015 #include "../parameters/Parameters.h"
0016 
0017 namespace ElemUtils {
0018 
0019 /**
0020  * @class XMLParser
0021  *
0022  * @brief FIFO
0023  */
0024 
0025 class XMLParser {
0026 public:
0027     XMLParser();
0028     virtual ~XMLParser();
0029 
0030     /**
0031      *
0032      *
0033      * @param file content of the file as a string
0034      */
0035     void analyse(const std::string & file);
0036 
0037     void loop(const std::string& file, size_t startIndex = 0);
0038 
0039     virtual void startElement(const std::string &elementName,
0040             Parameters attributes, const std::string &elementData) = 0;
0041 
0042     virtual void emptyStartElement(const std::string &elementName,
0043             Parameters attributes) = 0;
0044 
0045     virtual void endElement(const std::string &elementName) = 0;
0046 
0047 private:
0048     static const char TAB_CHARACTER;
0049     static const char XML_VERSION_CHARACTER_IDENTIFIER;
0050     static const char XML_COMMENT_CHARACTER_IDENTIFIER;
0051     static const char XML_END_TAG_CHARACTER_IDENTIFIER;
0052 
0053     static const std::string ATTRIBUTE_KEY_VALUE_SEPARATOR_CHARACTER;
0054     static const std::string XML_END_TAG_VERSION_IDENTIFIER;
0055     static const std::string XML_END_TAG_COMMENT_IDENTIFIER;
0056     static const std::string XML_TAG_NAME_ALLOWED_CHARACTERS;
0057     static const std::string XML_START_ELEMENT_TAG_NAME;
0058     static const std::string XML_END_ELEMENT_TAG_NAME;
0059 
0060     size_t m_fileSize;
0061 
0062     size_t findIndexOf(const std::string &string, size_t startIndex);
0063 
0064     void parseElement(const std::string& file, const size_t &xmlStartTagIndex,
0065             const size_t &xmlEndTagIndex);
0066 
0067     void parseNode(size_t startIndex);
0068 
0069     void parseAttributesFromXMLElement(const std::string& file,
0070             Parameters &attributes, const size_t attributesStartIndex,
0071             const size_t xmlEndTagIndex);
0072 };
0073 
0074 } // namespace ElemUtils
0075 
0076 #endif /* XML_PARSER_H */