|
19 | 19 | #include "settings.h" |
20 | 20 | #include "preprocessor.h" // Preprocessor |
21 | 21 | #include "utils.h" |
| 22 | +#include "tinyxml2.h" |
22 | 23 |
|
23 | 24 | #include <fstream> |
24 | 25 | #include <set> |
@@ -272,8 +273,40 @@ bool Settings::platform(PlatformType type) |
272 | 273 |
|
273 | 274 | bool Settings::platformFile(const std::string &filename) |
274 | 275 | { |
275 | | - (void)filename; |
276 | | - /** @todo TBD */ |
| 276 | + // open file.. |
| 277 | + tinyxml2::XMLDocument doc; |
| 278 | + if (doc.LoadFile(filename.c_str()) != tinyxml2::XML_NO_ERROR) |
| 279 | + return false; |
277 | 280 |
|
278 | | - return false; |
| 281 | + const tinyxml2::XMLElement * const rootnode = doc.FirstChildElement(); |
| 282 | + |
| 283 | + if (!rootnode || std::strcmp(rootnode->Name(),"platform") != 0) |
| 284 | + return false; |
| 285 | + |
| 286 | + for (const tinyxml2::XMLElement *node = rootnode->FirstChildElement(); node; node = node->NextSiblingElement()) { |
| 287 | + if (std::strcmp(node->Name(), "defaultSign") == 0) |
| 288 | + defaultSign = *node->GetText(); |
| 289 | + else if (std::strcmp(node->Name(), "char_bit") == 0) |
| 290 | + char_bit = std::atoi(node->GetText()); |
| 291 | + else if (std::strcmp(node->Name(), "sizeof") == 0) { |
| 292 | + for (const tinyxml2::XMLElement *sz = node->FirstChildElement(); sz; sz = sz->NextSiblingElement()) { |
| 293 | + if (std::strcmp(node->Name(), "short") == 0) |
| 294 | + sizeof_short = std::atoi(node->GetText()); |
| 295 | + if (std::strcmp(node->Name(), "int") == 0) |
| 296 | + sizeof_int = std::atoi(node->GetText()); |
| 297 | + if (std::strcmp(node->Name(), "long") == 0) |
| 298 | + sizeof_long = std::atoi(node->GetText()); |
| 299 | + if (std::strcmp(node->Name(), "long-long") == 0) |
| 300 | + sizeof_long_long = std::atoi(node->GetText()); |
| 301 | + if (std::strcmp(node->Name(), "float") == 0) |
| 302 | + sizeof_float = std::atoi(node->GetText()); |
| 303 | + if (std::strcmp(node->Name(), "double") == 0) |
| 304 | + sizeof_double = std::atoi(node->GetText()); |
| 305 | + if (std::strcmp(node->Name(), "pointer") == 0) |
| 306 | + sizeof_pointer = std::atoi(node->GetText()); |
| 307 | + } |
| 308 | + } |
| 309 | + } |
| 310 | + |
| 311 | + return true; |
279 | 312 | } |
0 commit comments