123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- /* options.hpp: parses arguments from the commandline.
- *
- * Copyright (C) 2014: Dalton Nell, Slop Contributors (https://github.com/naelstrof/slop/graphs/contributors).
- *
- * This file is part of Slop.
- *
- * Slop is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Slop is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Slop. If not, see <http://www.gnu.org/licenses/>.
- */
-
- #ifndef N_OPTIONS_H_
- #define N_OPTIONS_H_
-
- #include <iostream>
- #include <string>
- #include <exception>
- #include <stdexcept>
- #include <vector>
- #include <glm/glm.hpp>
-
- static std::string validStringArguments[] = { "bordersize", "padding", "color", "shader", "highlight", "format" };
- static char validCharArguments[] = { 'b', 'p', 'c', 's', 'h', 'f' };
- // 0 for flag, 1 for how many arguments to eat up
- static unsigned int isFlagArgument[] = { false, false, false, false, true, false };
- static unsigned int validArgumentCount = 6;
- static unsigned int maxFloatingValues = 0;
-
- class Options {
- private:
- std::vector<std::string> arguments;
- std::vector<std::string> values;
- std::vector<std::string> floatingValues;
- int parseCharOption( int argc, char** argv, int argumentIndex, int validIndex );
- int parseStringOption( int argc, char** argv, int argumentIndex, int validIndex );
- int validateStringOption( int argc, char** argv, int argumentIndex );
- int validateCharOption( int argc, char** argv, int argumentIndex );
- void validate( int argc, char** argv );
- public:
- Options( int argc, char** argv );
- bool getFloat( std::string name, char namec, float& found );
- bool getInt( std::string name, char namec, int& found );
- bool getString( std::string name, char namec, std::string& found );
- bool getColor( std::string name, char namec, glm::vec4& found );
- bool getBool( std::string name, char namec, bool& found );
- };
-
- #endif // N_OPTIONS_H_
|