LanguageManager.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * LanguageManager.h
  3. *
  4. * Created on: Mar 6, 2018
  5. * Author: guoxs
  6. */
  7. #ifndef _MANAGER_LANGUAGE_MANAGER_H_
  8. #define _MANAGER_LANGUAGE_MANAGER_H_
  9. #include <vector>
  10. #include <string>
  11. #include "json/json.h"
  12. typedef struct {
  13. char code[16]; // 国家码
  14. char language[64]; // 语言名称
  15. } SLanguageInfo;
  16. class LanguageManager {
  17. public:
  18. static LanguageManager* getInstance();
  19. const std::vector<SLanguageInfo>& getLanguageInfos() const {
  20. return mLanguageInfos;
  21. }
  22. bool setCurrentCode(const char *code);
  23. const std::string& getCurrentCode() const {
  24. return mCurrentCode;
  25. }
  26. const std::string& getCurrentLanguage() const {
  27. return mCurrentLanguage;
  28. }
  29. std::string getValue(const char *name);
  30. private:
  31. LanguageManager();
  32. ~LanguageManager();
  33. private:
  34. std::vector<SLanguageInfo> mLanguageInfos;
  35. std::string mCurrentCode;
  36. std::string mCurrentLanguage;
  37. Json::Value mContent;
  38. Json::Value mInternalContent;
  39. };
  40. #define LANGUAGEMANAGER LanguageManager::getInstance()
  41. #endif /* _MANAGER_LANGUAGE_MANAGER_H_ */