12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- /* 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>
-
- class Argument {
- public:
- std::string name;
- char cname;
- bool isFlagArgument;
- Argument( std::string name, char cname, bool isFlagArgument ) : name(name), cname(cname), isFlagArgument(isFlagArgument) {}
- };
-
- static std::vector<Argument> validArguments;
- 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_
|