config_parser.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #ifndef FOUNDATION_SETTINGS_CONFIG_PARSER_H
  2. #define FOUNDATION_SETTINGS_CONFIG_PARSER_H
  3. #include "xmlconfig.h"
  4. #include <unordered_map>
  5. #include <vector>
  6. namespace settings {
  7. class ConfigParser {
  8. public:
  9. ConfigParser();
  10. ~ConfigParser();
  11. struct DataCenter {
  12. std::string name;
  13. std::string ID;
  14. std::string key;
  15. std::string host;
  16. int32_t port;
  17. bool isTls;
  18. int32_t protoType;
  19. int32_t yunID;
  20. };
  21. struct LoginUser {
  22. std::string user;
  23. std::string passwd;
  24. };
  25. struct Channel {
  26. int32_t type;
  27. std::string devPath;
  28. };
  29. enum ChnType { CHN_COM = 0, CHN_TCP, CHN_UDP, CHN_LORA, CHN_MAX };
  30. std::vector<DataCenter> GetDataCenter() const;
  31. std::vector<LoginUser> GetLoginUsers() const;
  32. int16_t GetWWWPort() const;
  33. int32_t GetRetryTimes();
  34. std::unordered_map<std::string, Channel> GetChannels() const;
  35. Channel FindChannel(const std::string &name);
  36. private:
  37. XmlConfig *xmlConfig_;
  38. };
  39. } // namespace settings
  40. #endif // FOUNDATION_SETTINGS_CONFIG_PARSER_H