ConfigParser.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #ifndef __CONFIG_PARSER_H__
  2. #define __CONFIG_PARSER_H__
  3. #include <string>
  4. #include <vector>
  5. #include "cocos2d.h"
  6. #include "json/document-wrapper.h"
  7. #include "ProjectConfig/SimulatorConfig.h"
  8. #include "ProjectConfig/ProjectConfig.h"
  9. #include "SimulatorExport.h"
  10. using namespace std;
  11. USING_NS_CC;
  12. #define CONFIG_FILE "config.json"
  13. typedef vector<SimulatorScreenSize> ScreenSizeArray;
  14. class CC_LIBSIM_DLL ConfigParser
  15. {
  16. public:
  17. static ConfigParser *getInstance(void);
  18. static void purge();
  19. void readConfig(const string &filepath = "");
  20. // predefined screen size
  21. int getScreenSizeCount(void);
  22. cocos2d::Size getInitViewSize();
  23. string getInitViewName();
  24. string getEntryFile();
  25. rapidjson::Document& getConfigJsonRoot();
  26. const SimulatorScreenSize getScreenSize(int index);
  27. void setConsolePort(int port);
  28. void setUploadPort(int port);
  29. int getConsolePort();
  30. int getUploadPort();
  31. int getDebugPort();
  32. bool isLanscape();
  33. bool isWindowTop();
  34. void setEntryFile(const std::string &file);
  35. void setInitViewSize(const cocos2d::Size &size);
  36. void setBindAddress(const std::string &address);
  37. const std::string &getBindAddress();
  38. private:
  39. ConfigParser(void);
  40. void setDebugPort(int port);
  41. static ConfigParser *s_sharedConfigParserInstance;
  42. ScreenSizeArray _screenSizeArray;
  43. cocos2d::Size _initViewSize;
  44. string _viewName;
  45. string _entryfile;
  46. bool _isLandscape;
  47. bool _isWindowTop;
  48. int _consolePort;
  49. int _uploadPort;
  50. int _debugPort;
  51. string _bindAddress;
  52. rapidjson::Document _docRootjson;
  53. };
  54. #endif // __CONFIG_PARSER_H__