xmlconfig.h 915 B

1234567891011121314151617181920212223242526272829303132333435
  1. #ifndef FOUNDATION_SETTINGS_XMLCONFIG_H
  2. #define FOUNDATION_SETTINGS_XMLCONFIG_H
  3. #ifndef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include <tinyxml2/tinyxml2.h>
  7. #ifndef __cplusplus
  8. }
  9. #endif
  10. #include <functional>
  11. #include <map>
  12. #include <string>
  13. #include <utils/logger.h>
  14. namespace settings {
  15. class XmlConfig {
  16. public:
  17. XmlConfig();
  18. ~XmlConfig();
  19. bool Load(const std::string &path);
  20. void GetElemValue(const std::string &father, std::function<void(std::map<std::string, std::string> &)>);
  21. const std::string GetElemValueString(const std::string &father, const std::string elem);
  22. const int32_t GetElemValueInt(const std::string &father, const std::string elem);
  23. const bool GetElemValueBool(const std::string &father, const std::string elem);
  24. private:
  25. tinyxml2::XMLDocument xmlDocument_;
  26. tinyxml2::XMLElement *xmlRoot_;
  27. };
  28. } // namespace settings
  29. #endif // FOUNDATION_WEBCONFIG_XMLCONFIG_H