Advertisement
Guest User

ConfigApplier.h

a guest
Oct 17th, 2021
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. #ifndef CONFIGAPPLIER_H
  2. #define CONFIGAPPLIER_H
  3. /* C system icnludes */
  4.  
  5. /* C++ system icnludes */
  6. #include <cstdint>
  7.  
  8. /* Third-party icnludes */
  9.  
  10. /* Own icnludes */
  11. #include "sdl_utils/config/tools/ConfigValidator.h"
  12.  
  13. /* Forward Declaration */
  14.  
  15. class ConfigApplier {
  16. private:
  17. static std::string applyConfig(const configData &data, displayConfig name, configType type) {
  18.  
  19. const std::string configName = displayConfigStr[name];
  20.  
  21. auto it = data.find(configName);
  22. if (it == data.end()) {
  23. std::cerr << "There is no " << configName << " in the configurations data." << std::endl;
  24. }
  25. const std::string configValue;
  26. if (EXIT_SUCCESS != ConfigValidator::checkConfig(configValue, type)) {
  27. std::cerr << "Validation of config data failed." << std::endl;
  28. }
  29. return configValue;
  30. }
  31.  
  32. public:
  33. static void setConfigs(const configData &data, MonitorConfig &outConfig) {
  34. /* String configurations: */
  35. outConfig.windowName = applyConfig(data, WINDOW_NAME, STRING);
  36.  
  37. /* Integer configurations: */
  38. outConfig.windowHeight = stoi(applyConfig(data, DISPLAY_HEIGHT, INT));
  39. outConfig.windowWidth = stoi(applyConfig(data, DISPLAY_WIDTH, INT));
  40.  
  41. /* Boolean configurations: */
  42. outConfig.windowFlags = WINDOW_SHOWN;
  43. }
  44. };
  45. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement