11 #ifndef EVIO_6_0_EVIOXMLDICTIONARY_H
12 #define EVIO_6_0_EVIOXMLDICTIONARY_H
20 #include <unordered_map>
29 #include "pugixml.hpp"
60 static const std::string DICT_TOP_LEVEL;
63 static const std::string ENTRY;
66 static const std::string ENTRY_ALT;
69 static const std::string ENTRY_BANK;
72 static const std::string ENTRY_LEAF;
75 static const std::string DESCRIPTION;
78 static const std::string FORMAT;
81 static const std::string TYPE;
84 static const std::string NAME;
87 static const std::string TAG;
90 static const std::string NUM;
97 static std::regex pattern_regex;
103 std::string
const delimiter =
".";
105 pugi::xml_document doc;
115 std::unordered_map<std::shared_ptr<EvioDictionaryEntry>, std::string>
tagNumMap;
123 std::unordered_map<std::shared_ptr<EvioDictionaryEntry>, std::string>
tagOnlyMap;
131 std::unordered_map<std::shared_ptr<EvioDictionaryEntry>, std::string>
tagRangeMap;
142 std::unordered_map<std::string, std::shared_ptr<EvioDictionaryEntry>> reverseMap;
149 std::unordered_map<std::string, std::shared_ptr<EvioDictionaryEntry>> tagNumReverseMap;
155 pugi::xml_node topLevelDoc;
161 std::string stringRepresentation;
173 void parseXML(pugi::xml_parse_result &domDocument);
177 const std::unordered_map<std::string, std::shared_ptr<EvioDictionaryEntry>> &
getMap()
const;
183 void addHierarchicalDictEntries(std::vector<pugi::xml_node> &kidList,
184 std::string
const &parentName);
188 std::string
getName(std::shared_ptr<BaseStructure> &structure);
189 std::string
getName(uint16_t tag);
190 std::string
getName(uint16_t tag, uint8_t num);
191 std::string
getName(uint16_t tag, uint8_t num, uint16_t tagEnd);
192 std::string
getName(uint16_t tag, uint8_t num, uint16_t tagEnd,
193 uint16_t pTag, uint8_t pNum, uint16_t pTagEnd);
194 std::string
getName(uint16_t tag, uint8_t num, uint16_t tagEnd,
195 uint16_t pTag, uint8_t pNum, uint16_t pTagEnd,
196 bool numValid =
true,
bool parentValid =
false,
197 bool parentNumValid =
false);
203 std::string
getName(std::shared_ptr<EvioDictionaryEntry> key);
204 std::shared_ptr<EvioDictionaryEntry> entryLookupByData(uint16_t tag, uint8_t num, uint16_t tagEnd);
205 std::shared_ptr<EvioDictionaryEntry> entryLookupByName(std::string
const &name);
212 std::string
getDescription(uint16_t tag, uint8_t num, uint16_t tagEnd);
215 std::string
getFormat(uint16_t tag, uint8_t num);
216 std::string
getFormat(uint16_t tag, uint8_t num, uint16_t tagEnd);
217 std::string
getFormat(std::string
const &name);
223 bool getTagNum(std::string
const &name, uint16_t *tag, uint8_t *num, uint16_t *tagEnd);
224 bool getTag(std::string
const &name, uint16_t *tag);
225 bool getTagEnd(std::string
const &name, uint16_t *tagEnd);
227 bool getNum(std::string
const &name, uint8_t *num);
236 #endif //EVIO_6_0_EVIOXMLDICTIONARY_H
std::unordered_map< std::shared_ptr< EvioDictionaryEntry >, std::string > tagOnlyMap
Some dictionary entries have only a tag and no num.
Definition: EvioXMLDictionary.h:123
bool getNum(std::string const &name, uint8_t *num)
Returns the num corresponding to the name of a dictionary entry.
Definition: EvioXMLDictionary.cpp:1528
size_t size() const
Get the number of entries in this dictionary.
Definition: EvioXMLDictionary.cpp:470
static const std::string & NO_NAME_STRING()
Get a string used to indicate that no name can be determined.
Definition: EvioXMLDictionary.cpp:61
EvioXMLDictionary(std::string const &path)
Create an EvioXMLDictionary from an xml file.
Definition: EvioXMLDictionary.cpp:70
const std::unordered_map< std::string, std::shared_ptr< EvioDictionaryEntry > > & getMap() const
Get the map in which the key is the entry name and the value is an object containing its data (tag...
Definition: EvioXMLDictionary.cpp:479
std::string getFormat(uint16_t tag, uint8_t num)
Returns the format, if any, associated with the given tag and num.
Definition: EvioXMLDictionary.cpp:1366
void parseXML(pugi::xml_parse_result &domDocument)
Create an EvioXMLDictionary from an xml Document object.
Definition: EvioXMLDictionary.cpp:114
std::string toString()
Get a string representation of the dictionary.
Definition: EvioXMLDictionary.cpp:1543
bool getTagEnd(std::string const &name, uint16_t *tagEnd)
Returns the tagEnd corresponding to the name of a dictionary entry.
Definition: EvioXMLDictionary.cpp:1508
DataType getType(uint16_t tag, uint8_t num)
Returns the type, if any, associated with the given tag and num.
Definition: EvioXMLDictionary.cpp:1412
bool getTag(std::string const &name, uint16_t *tag)
Returns the tag corresponding to the name of a dictionary entry.
Definition: EvioXMLDictionary.cpp:1489
std::string getName(std::shared_ptr< BaseStructure > &structure)
Returns the name of a given evio structure.
Definition: EvioXMLDictionary.cpp:849
Numerical values associated with evio data types.
Definition: DataType.h:32
std::string getDescription(uint16_t tag, uint8_t num)
Returns the description, if any, associated with the given tag and num.
Definition: EvioXMLDictionary.cpp:1320
std::unordered_map< std::shared_ptr< EvioDictionaryEntry >, std::string > tagRangeMap
Some dictionary entries have only a tag range and no num.
Definition: EvioXMLDictionary.h:131
This was developed to read the xml dictionary that Maurizio uses for GEMC.
Definition: EvioXMLDictionary.h:55
std::unordered_map< std::shared_ptr< EvioDictionaryEntry >, std::string > tagNumMap
This is the heart of the dictionary in which a key is composed of a tag/num pair & other entry data a...
Definition: EvioXMLDictionary.h:115
bool getTagNum(std::string const &name, uint16_t *tag, uint8_t *num, uint16_t *tagEnd)
Returns the tag/num/tagEnd values, in an Integer object array, corresponding to the name of a diction...
Definition: EvioXMLDictionary.cpp:1470