42 #include <libxml/xmlstring.h> 52 const std::string & sURI)
58 xmlNodePtr pRoot{xmlDocGetRootElement(pDoc)};
60 if (!xmlStrEqual(pRoot->name, reinterpret_cast<const xmlChar *>(pszName)))
64 throw makeException<ParseException>(
65 "Failed to parse document in %s.\n\n" 66 "Possible reason(s):\n" 67 " * %s: Document root node is not '%s'\n",
97 xmlNodePtr pNode = pParent->children;
101 if (pNode->type == XML_ELEMENT_NODE)
103 if (xmlStrEqual(pNode->name,
104 reinterpret_cast<const xmlChar*>(
"param")))
108 else if(xmlStrEqual(pNode->name,
109 reinterpret_cast<const xmlChar*>(
"paramlist")))
133 xmlNodePtr pParamNode)
135 std::string sItemName{
getAttrVal(pParamNode,
"name")};
137 if(paramMap.find(sItemName) != paramMap.end())
139 throw makeException<ParseException>(
140 "Failed to parse configuration document.\n\n" 141 "Possible reason(s):\n" 142 " * Duplicate configuration item '%s'\n",
147 std::make_pair(sItemName,
148 ParamStringValues{
getAttrVal(pParamNode,
"value")}));
154 xmlNodePtr pParamlistNode)
156 std::string sItemName{
getAttrVal(pParamlistNode,
"name")};
158 if(paramMap.find(sItemName) != paramMap.end())
160 throw makeException<ParseException>(
161 "Failed to parse configuration document.\n\n" 162 "Possible reason(s):\n" 163 " * Duplicate configuration item '%s'\n",
167 paramMap.insert(std::make_pair(sItemName, ParamStringValues{}));
169 xmlNodePtr pItem = pParamlistNode->children;
174 if(xmlStrEqual(pItem->name, reinterpret_cast<const xmlChar*>(
"item")))
176 paramMap[sItemName].push_back(
getAttrVal(pItem,
"value"));
186 const char * attributename)
191 xmlGetProp(pNode, reinterpret_cast<const xmlChar*>(attributename));
195 sVal =
reinterpret_cast<const char*
>(pxzVal);
206 const char * attributename)
216 ParamMap localParamMap{};
220 for(
auto param : localParamMap)
222 ParamMapIter pos{
params_.find(param.first)};
239 request.push_back(std::make_pair(param.first, param.second));
263 return sDefinitionPath_;
270 return sDefinitionFile_;
278 size_t pos = sURI.npos;
280 if ((pos = sURI.rfind(
"/")) != sURI.npos)
283 sDefinitionPath_ = sURI.substr(0, pos+1);
284 sDefinitionFile_ = sURI.substr(pos+1);
286 else if ( (pos = sURI.rfind(
"\\")) != sURI.npos)
289 sDefinitionPath_ = sURI.substr(0, pos+1);
290 sDefinitionFile_ = sURI.substr(pos+1);
294 sDefinitionPath_ =
"";
295 sDefinitionFile_ = sURI;
virtual void doProcessChildNode(xmlNodePtr pNode)
virtual void doProcessChildren(xmlNodePtr pParent, ParamMap ¶mMap)
std::string getDefinitionPath() const
std::string getLibrary() const
Wrapper around the libxml2 XML parsing capabilities for EMANE.
xmlDocPtr parse(const std::string &sURI)
std::uint16_t getAttrValNumeric(xmlNodePtr pNode, const char *attributename)
void doProcessParam(ParamMap ¶mMap, xmlNodePtr pParamNode)
std::string getDefinitionFile() const
std::string getType() const
void processDefinition(const char *pxzName, const std::string &sURI)
const ConfigurationUpdateRequest getConfigurationUpdateRequest()
void overlayParams(xmlNodePtr pNode)
LayerConfiguration(std::string sType)
std::vector< ConfigurationNameStringValues > ConfigurationUpdateRequest
virtual void doProcessRootAttributes(xmlNodePtr pRoot)
void setPathAndFile(const std::string sURI)
Parameter conversion class with range checks.
std::string getAttrVal(xmlNodePtr pNode, const char *attributename)
void doProcessParamlist(ParamMap ¶mMap, xmlNodePtr pParamlistNode)