Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. #pragma once
  2. #include <iostream>
  3. #include <vector>
  4. template< typename T >
  5. class ConfigItem
  6. {
  7. std::string category, name;
  8. T* value;
  9. public:
  10. ConfigItem(std::string category, std::string name, T* value)
  11. {
  12. this->category = category;
  13. this->name = name;
  14. this->value = value;
  15. }
  16. };
  17.  
  18. template< typename T >
  19. class ConfigValue
  20. {
  21. public:
  22. ConfigValue(std::string category_, std::string name_, T* value_)
  23. {
  24. category = category_;
  25. name = name_;
  26. value = value_;
  27. }
  28.  
  29. std::string category, name;
  30. T* value;
  31. };
  32.  
  33. class CConfig
  34. {
  35. protected:
  36. std::vector< ConfigValue< int >* > ints;
  37. std::vector< ConfigValue< bool >* > bools;
  38. std::vector< ConfigValue< float >* > floats;
  39. private:
  40.  
  41. void SetupValue(int&, int, std::string, std::string);
  42. void SetupValue(bool&, bool, std::string, std::string);
  43. void SetupValue(bool * value, bool def, int size, std::string category, std::string name);
  44. void SetupValue(float&, float, std::string, std::string);
  45. public:
  46. CConfig()
  47. {
  48. Setup();
  49. }
  50.  
  51. void Setup();
  52.  
  53. void export_to_clipboard(std::string file);
  54. bool import_from_clipboard(std::string file);
  55. void Save(std::string ConfigName);
  56. void Load(std::string ConfigName);
  57. };
  58.  
  59. extern CConfig* Config2;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement