OSVR-Core
|
Header containing some simple args-handling routines: nothing sophisticated, just enough to keep the hand-written stuff from taking over main(). More...
#include <algorithm>
#include <cstddef>
#include <initializer_list>
#include <iterator>
#include <string>
#include <utility>
#include <vector>
Go to the source code of this file.
Classes | |
struct | osvr::util::args::detail::StringEqualityComparisonPolicy |
Namespaces | |
osvr | |
The main namespace for all C++ elements of the framework, internal and external. | |
osvr::util | |
The Util library: Functionality not necessarily coupled to any particular core library, serving more as a common base layer behind all systems. | |
Typedefs | |
using | osvr::util::args::ArgList = std::vector< std::string > |
Functions | |
ArgList | osvr::util::args::makeArgList (int argc, char *argv[]) |
Constructs a vector containing the arguments excluding argv[0]. | |
template<typename F > | |
std::size_t | osvr::util::args::handle_arg (ArgList &c, F &&f) |
Takes a predicate to find arguments. More... | |
template<typename ComparisonPolicy , typename SequenceType > | |
bool | osvr::util::args::detail::generic_handle_has_switch (ArgList &c, SequenceType &&argSwitch) |
template<typename SequenceType > | |
bool | osvr::util::args::handle_has_switch (ArgList &c, SequenceType &&argSwitch) |
Takes a "sequence" (something with operator== with std::string) to compare (case-sensitive) with every arg. More... | |
template<typename F , typename G > | |
std::size_t | osvr::util::args::handle_value_arg (ArgList &c, F &&predicate, G &&action) |
Takes a predicate to find arguments. More... | |
template<typename ComparisonPolicy , typename SequenceType > | |
bool | osvr::util::args::detail::generic_handle_has_any_switch_of (ArgList &c, std::initializer_list< SequenceType > const &argSwitches) |
template<typename SequenceType > | |
bool | osvr::util::args::handle_has_any_switch_of (ArgList &c, std::initializer_list< SequenceType > const &argSwitches) |
Takes a list of "sequences" (something with operator== with std::string) to compare (case-sensitive) with every arg. More... | |
Header containing some simple args-handling routines: nothing sophisticated, just enough to keep the hand-written stuff from taking over main().
Define OSVR_HAVE_BOOST before including if you want to be able to use the case-insensitive comparisons, etc.
|
inline |
Takes a predicate to find arguments.
Any found arguments are counted and removed from the arg list. Count is returned.
|
inline |
Takes a list of "sequences" (something with operator== with std::string) to compare (case-sensitive) with every arg.
Wraps handle_arg()
(so it "consumes" those args it finds)
|
inline |
Takes a "sequence" (something with operator== with std::string) to compare (case-sensitive) with every arg.
Wraps handle_arg()
(so it "consumes" those args it finds)
|
inline |
Takes a predicate to find arguments.
Found arguments not immediately followed by another argument or the end of the argument list have the following argument passed to the action and are removed from the arg list. Count of valid action invocations is returned.
Loop through all but the last element (since we can't start a value arg there)
found a flag, next thing is an arg.
not a flag - steal it for the remaining args list.
Move the last arg to the remaining list, if the last thing we did wasn't to accept an argument (and thus consume the last one)
Remaining args are now the only args.