Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef CONFIGVALIDATOR_H
- #define CONFIGVALIDATOR_H
- /* C system icnludes */
- /* C++ system icnludes */
- #include <iostream>
- #include <string>
- /* Third-party icnludes */
- /* Own icnludes */
- /* Forward Declaration */
- #include "sdl_utils/config/MonitorConfig.h"
- class ConfigValidator {
- public:
- static int32_t checkConfig(const std::string &configValue, configType type) {
- if (configValue == "") {
- std::cerr << "Configuration value is empty. " << std::endl;
- return EXIT_FAILURE;
- }
- switch (type) {
- case INT:
- if (!stoi(configValue)) {
- std::cerr << "Configuration type Integer is with wrong value: " << configValue << std::endl;
- return EXIT_FAILURE;
- }
- break;
- case STRING:
- // n/a
- break;
- case BOOLEAN:
- if (configValue != "1" || configValue != "0") {
- std::cerr << "Configuration type Boolean is with wrong value: " << configValue << std::endl;
- return EXIT_FAILURE;
- }
- break;
- default:
- std::cerr << "Wrong configType passed to switch statment. Type value: " << type << std::endl;
- return EXIT_FAILURE;
- break;
- }
- return EXIT_SUCCESS;
- }
- };
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement