appconfigparser.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include "appconfigparser.h"
  2. #include "loghelper.h"
  3. AppConfigParser::AppConfigParser()
  4. {
  5. }
  6. bool AppConfigParser::readConfig(QString content)
  7. {
  8. QString errorStr;
  9. int errorLine;
  10. int errorColumn;
  11. QDomDocument doc;
  12. if(!doc.setContent(content,false,&errorStr,&errorLine,&errorColumn))
  13. {
  14. LogHelper::writeLog(errorStr + " " +\
  15. QString::number(errorLine) + " " +QString::number(errorColumn));
  16. return false;
  17. }
  18. QDomElement root = doc.documentElement();
  19. if (root.tagName()!="SpeedNumCube")
  20. {
  21. return false;
  22. }
  23. parseConfigElement(root);
  24. return true;
  25. }
  26. void AppConfigParser::parseConfigElement(const QDomElement &element)
  27. {
  28. QDomNode child = element.firstChild();
  29. if (!child.isNull())
  30. {
  31. if(child.toElement().tagName()=="versioninfo")
  32. {
  33. minVer = child.toElement().attribute("minver");
  34. maxVer = child.toElement().attribute("maxver");
  35. }
  36. }
  37. }