load the XML file with offsets
| 228 | |
| 229 | // load the XML file with offsets |
| 230 | bool VersionInfoFactory::loadFile(std::filesystem::path path_to_xml) |
| 231 | { |
| 232 | TiXmlDocument doc( path_to_xml.string().c_str() ); |
| 233 | std::cerr << "Loading " << path_to_xml << " ... "; |
| 234 | //bool loadOkay = doc.LoadFile(); |
| 235 | if (!doc.LoadFile()) |
| 236 | { |
| 237 | error = true; |
| 238 | cerr << "failed!\n"; |
| 239 | throw Error::SymbolsXmlParse(doc.ErrorDesc(), doc.ErrorId(), doc.ErrorRow(), doc.ErrorCol()); |
| 240 | } |
| 241 | else |
| 242 | { |
| 243 | cerr << "OK\n"; |
| 244 | } |
| 245 | TiXmlHandle hDoc(&doc); |
| 246 | TiXmlElement* pElem; |
| 247 | TiXmlHandle hRoot(0); |
| 248 | |
| 249 | // block: name |
| 250 | { |
| 251 | pElem=hDoc.FirstChildElement().Element(); |
| 252 | // should always have a valid root but handle gracefully if it does |
| 253 | if (!pElem) |
| 254 | { |
| 255 | error = true; |
| 256 | throw Error::SymbolsXmlNoRoot(); |
| 257 | } |
| 258 | string m_name=pElem->Value(); |
| 259 | if(m_name != "data-definition") |
| 260 | { |
| 261 | error = true; |
| 262 | throw Error::SymbolsXmlNoRoot(); |
| 263 | } |
| 264 | // save this for later |
| 265 | hRoot=TiXmlHandle(pElem); |
| 266 | } |
| 267 | // transform elements |
| 268 | { |
| 269 | clear(); |
| 270 | // For each version |
| 271 | TiXmlElement * pMemInfo=hRoot.FirstChild( "symbol-table" ).Element(); |
| 272 | for( ; pMemInfo; pMemInfo=pMemInfo->NextSiblingElement("symbol-table")) |
| 273 | { |
| 274 | const char *name = pMemInfo->Attribute("name"); |
| 275 | if(name) |
| 276 | { |
| 277 | auto version = std::make_shared<VersionInfo>(); |
| 278 | ParseVersion( pMemInfo , version.get() ); |
| 279 | versions.push_back(version); |
| 280 | } |
| 281 | } |
| 282 | } |
| 283 | error = false; |
| 284 | std::cerr << "Loaded " << versions.size() << " DF symbol tables." << std::endl; |
| 285 | return true; |
| 286 | } |
no test coverage detected