#include <stdio.h>
#include <unistd.h>
#include <algorithm>
#include <array>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <iterator>
#include <ostream>
#include <sstream>
#include <stdexcept>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
Go to the source code of this file.
Classes | |
struct | argagg::unexpected_argument_error |
This exception is thrown when a long option is parsed and is given an argument using the "=" syntax but the option doesn't expect an argument. More... | |
struct | argagg::unexpected_option_error |
This exception is thrown when an option is parsed unexpectedly such as when an argument was expected for a previous option or if an option was found that has not been defined. More... | |
struct | argagg::option_lacks_argument_error |
This exception is thrown when an option requires an argument but is not provided one. This can happen if another flag was found after the option or if we simply reach the end of the command line arguments. More... | |
struct | argagg::invalid_flag |
This exception is thrown when an option's flag is invalid. This can be the case if the flag is not prefixed by one or two hyphens or contains non alpha-numeric characters after the hypens. See is_valid_flag_definition() for more details. More... | |
struct | argagg::option_result |
Represents a single option parse result. More... | |
struct | argagg::option_results |
Represents multiple option parse results for a single option. If treated as a single parse result it defaults to the last parse result. Note that an instance of this struct is always created even if no option results are parsed for a given definition. In that case it will simply be empty. More... | |
struct | argagg::parser_results |
Represents all results of the parser including options and positional arguments. More... | |
struct | argagg::definition |
An option definition which essentially represents what an option is. More... | |
struct | argagg::parser_map |
Contains two maps which aid in option parsing. The first map, short_map, maps from a short flag (just a character) to a pointer to the original definition that the flag represents. The second map, long_map, maps from a long flag (an std::string) to a pointer to the original definition that the flag represents. More... | |
struct | argagg::parser |
A list of option definitions used to inform how to parse arguments. More... | |
struct | argagg::fmt_ostream |
A convenience output stream that will accumulate what is streamed to it and then, on destruction, format the accumulated string using the fmt program (via the argagg::fmt_string() function) to the provided std::ostream. More... | |
Namespaces | |
argagg | |
There are only two hard things in Computer Science: cache invalidation and naming things (Phil Karlton). | |
argagg::convert | |
The set of template instantiations that convert C-strings to other types for the option_result::as(), option_results::as(), parser_results::as(), and parser_results::all_as() methods are placed in this namespace. | |
Macros | |
#define | ARGAGG_ARGAGG_ARGAGG_HPP |
#define | DEFINE_CONVERSION_FROM_LONG_(TYPE) |
#define | DEFINE_CONVERSION_FROM_LONG_LONG_(TYPE) |
Functions | |
template<typename T > | |
T | argagg::convert::arg (const char *arg) |
Explicit instantiations of this function are used to convert arguments to types. More... | |
bool | argagg::cmd_line_arg_is_option_flag (const char *s) |
Checks whether or not a command line argument should be processed as an option flag. This is very similar to is_valid_flag_definition() but must allow for short flag groups (e.g. "-abc") and equal-assigned long flag arguments (e.g. "--output=foo.txt"). More... | |
bool | argagg::is_valid_flag_definition (const char *s) |
Checks whether a flag in an option definition is valid. I suggest reading through the function source to understand what dictates a valid. More... | |
bool | argagg::flag_is_short (const char *s) |
Tests whether or not a valid flag is short. Assumes the provided cstring is already a valid flag. More... | |
parser_map | argagg::validate_definitions (const std::vector< definition > &definitions) |
Validates a collection (specifically an std::vector) of definition objects by checking if the contained flags are valid. If the set of definition objects is not valid then an exception is thrown. Upon successful validation a parser_map object is returned. More... | |
std::string | argagg::fmt_string (const std::string &s) |
Processes the provided string using the fmt util and returns the resulting output as a string. Not the most efficient (in time or space) but gets the job done. More... | |
std::ostream & | operator<< (std::ostream &os, const argagg::parser &x) |
Writes the option help to the given stream. More... | |
template<typename T > | |
T | argagg::convert::long_ (const char *arg) |
Templated function for conversion to T using the std::strtol() function. This is used for anything long length or shorter (long, int, short, char). More... | |
template<typename T > | |
T | argagg::convert::long_long_ (const char *arg) |
Templated function for conversion to T using the std::strtoll() function. This is used for anything long long length or shorter (long long). More... | |
template<> | |
bool | argagg::convert::arg (const char *arg) |
Explicit instantiations of this function are used to convert arguments to types. More... | |
template<> | |
float | argagg::convert::arg (const char *arg) |
Explicit instantiations of this function are used to convert arguments to types. More... | |
template<> | |
double | argagg::convert::arg (const char *arg) |
Explicit instantiations of this function are used to convert arguments to types. More... | |
template<> | |
const char * | argagg::convert::arg (const char *arg) |
Explicit instantiations of this function are used to convert arguments to types. More... | |
template<> | |
std::string | argagg::convert::arg (const char *arg) |
Explicit instantiations of this function are used to convert arguments to types. More... | |
#define ARGAGG_ARGAGG_ARGAGG_HPP |
Definition at line 32 of file argagg.hpp.
#define DEFINE_CONVERSION_FROM_LONG_ | ( | TYPE | ) |
Definition at line 1348 of file argagg.hpp.
#define DEFINE_CONVERSION_FROM_LONG_LONG_ | ( | TYPE | ) |
Definition at line 1368 of file argagg.hpp.
|
inline |
Writes the option help to the given stream.
Definition at line 1531 of file argagg.hpp.