options.hpp 1.4KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #ifndef N_OPTIONS_H_
  2. #define N_OPTIONS_H_
  3. #include <iostream>
  4. #include <string>
  5. #include <exception>
  6. #include <stdexcept>
  7. #include <vector>
  8. #include <glm/glm.hpp>
  9. static std::string validStringArguments[] = { "borderSize", "padding", "color", "shader", "highlight", "format" };
  10. static char validCharArguments[] = { 'b', 'p', 'c', 's', 'h', 'f' };
  11. // 0 for flag, 1 for how many arguments to eat up
  12. static unsigned int isFlagArgument[] = { false, false, false, false, true, false };
  13. static unsigned int validArgumentCount = 6;
  14. static unsigned int maxFloatingValues = 0;
  15. class Options {
  16. private:
  17. std::vector<std::string> arguments;
  18. std::vector<std::string> values;
  19. std::vector<std::string> floatingValues;
  20. int parseCharOption( int argc, char** argv, int argumentIndex, int validIndex );
  21. int parseStringOption( int argc, char** argv, int argumentIndex, int validIndex );
  22. int validateStringOption( int argc, char** argv, int argumentIndex );
  23. int validateCharOption( int argc, char** argv, int argumentIndex );
  24. void validate( int argc, char** argv );
  25. public:
  26. Options( int argc, char** argv );
  27. bool getFloat( std::string name, char namec, float& found );
  28. bool getInt( std::string name, char namec, int& found );
  29. bool getString( std::string name, char namec, std::string& found );
  30. bool getColor( std::string name, char namec, glm::vec4& found );
  31. bool getBool( std::string name, char namec, bool& found );
  32. };
  33. #endif // N_OPTIONS_H_