#include <policy.hpp>
Inheritance diagram for commandl::policy:
Public Methods | |
policy (std::vector< std::string >, std::vector< std::string >, std::bitset< 8 >, std::pair< std::string, std::string >=std::make_pair(std::string("["), std::string("]")), std::pair< std::string, std::string >=std::make_pair(std::string("<"), std::string(">"))) | |
policy () | |
virtual std::vector< std::string > | prefixes () const |
Returns the vector of prefixes allowed for this policy. More... | |
virtual std::vector< std::string > | assignments () const |
Returns the vector of assignments allowed for this policy. More... | |
virtual std::pair< std::string, std::string > | optional_brackets () const |
Returns the pair of strings that are intended to enclose optional elements in a usage statement. More... | |
virtual std::pair< std::string, std::string > | value_brackets () const |
Returns the pair of strings that are intended to enclose value elements in a usage statement. More... | |
virtual bool | is_empty_valid_prefix () const |
Is the empty string a valid prefix? More... | |
virtual bool | is_empty_valid_assignment () const |
Is the empty string a valid assignment? More... | |
virtual bool | is_token_separator_assignment () const |
Is the token separator a valid assignment? More... | |
virtual bool | no_prefix_keep_going () const |
No prefix has been found on the element, should parsing continue? More... | |
virtual bool | no_prefix_keep_element () const |
No prefix has been found on the element, should element be kept? More... | |
virtual bool | no_key_keep_going () const |
No key has been found in the element, should parsing continue? More... | |
virtual bool | no_key_keep_element () const |
No key has been found in the element, should element be kept? More... | |
virtual bool | ignore_prefix_if_value_required () const |
If a value is required, should the next element be taken? More... | |
virtual void | add_prefix (const std::string &) |
Adds a string to the end of this policy's list of valid prefixes. More... | |
virtual void | add_assignment (const std::string &) |
Adds a string to the end of this policy's list of valid assignments. More... | |
virtual void | set_optional_brackets (const std::pair< std::string, std::string > &) |
Sets the pair used to enclose optional elements. More... | |
virtual void | set_value_brackets (const std::pair< std::string, std::string > &) |
Sets the pair used to enclose value elements. More... | |
virtual void | is_empty_valid_prefix (bool) |
Sets whether the empty string is a valid prefix. More... | |
virtual void | is_empty_valid_assignment (bool) |
Sets whether the empty string is a valid assignment. More... | |
virtual void | is_token_separator_assignment (bool) |
Sets whether the boundary between elements is a valid assignment. More... | |
virtual void | no_prefix_keep_going (bool) |
Sets whether to keep going or stop if no prefix is found. More... | |
virtual void | no_prefix_keep_element (bool) |
Sets whether an element with no prefix should be kept. More... | |
virtual void | no_key_keep_going (bool) |
Sets whether to keep going or stop if no key is found. More... | |
virtual void | no_key_keep_element (bool) |
Sets whether an element with no key should be kept. More... | |
virtual void | ignore_prefix_if_value_required (bool) |
Sets whether elements with a valid prefix should be consumed by preceding arguments with required values. More... | |
Protected Attributes | |
std::vector< std::string > | Prefixes |
std::vector< std::string > | Assignments |
std::pair< std::string, std::string > | Optional_Brackets |
The strings that will bracket option elements in usage statements. More... | |
std::pair< std::string, std::string > | Value_Brackets |
The strings that will bracket value elements in usages statements. More... | |
bool | Empty_Is_Prefix |
Is the empty string a valid prefix? More... | |
bool | Empty_Is_Assignment |
Is the empty string a valid assignment? More... | |
bool | Separator_Is_Assignment |
Is the boundary between tokens a valid assignment? More... | |
bool | No_Prefix_Keep_Going |
Should the parser keep going if there is an element with no prefix? More... | |
bool | No_Prefix_Keep_Element |
If there is an element with no prefix, should it be kept? More... | |
bool | No_Key_Keep_Going |
Should the parser keep going if there is an element with no valid key? More... | |
bool | No_Key_Keep_Element |
If there is an element with no key, should it be kept? More... | |
bool | Ignore_Prefix |
Policy objects are pretty much just data storage objects. They contain a number of boolean values and other basic information like what the acceptable prefix tokens are (or if no prefix token is required), what the assignment operators are (or if no assignment operator is needed), and things like whether the parser should keep going if a token doesn't match and if it should keep track of those things which don't match. Handy, but simple was the idea here.
|
|
|
|
|
Adds a string to the end of this policy's list of valid assignments.
|
|
Adds a string to the end of this policy's list of valid prefixes.
|
|
Returns the vector of assignments allowed for this policy.
The returned vector contains all of the strings which are valid assignments for this policy.
|
|
Sets whether elements with a valid prefix should be consumed by preceding arguments with required values.
|
|
If a value is required, should the next element be taken?
When the parser has matched a key with an argument, and the argument requires a value, but the next element that could be considered as a value begins with a valid prefix, what should be done? If this returns true, then that next element is taken as a value (even though it starts with a prefix). If this returns false, then the required value for the argument is not given (most likely causing an exception), but the element with a prefix remains in the list of un-parsed elements.
|
|
Sets whether the empty string is a valid assignment.
|
|
Is the empty string a valid assignment?
This is most commonly true when you want the key and the value in the same element without having to specify an explicit assignment character. For example, if the element is "-afoo", and the key is "a", and you would like "foo" to be recognized as the value, then this should be true.
|
|
Sets whether the empty string is a valid prefix.
|
|
Is the empty string a valid prefix?
Usually this is no, but sometimes you'd like to eliminate the need for a special prefix character when parsing elements based purely on position.
|
|
Sets whether the boundary between elements is a valid assignment.
|
|
Is the token separator a valid assignment?
Instead of explicitly naming an assignment character like "=" in the following "-a=foo", you'd like to just say "-a foo", where "-a" would be one element and "foo" would be the next. In this case you would want the token separator to be considered an assignment, so the the separation between "-a" and "foo" would be considered an assignment assigning the value "foo" to the key "a".
|
|
Sets whether an element with no key should be kept.
|
|
No key has been found in the element, should element be kept?
When the parser has found a matching prefix, but no matching key, and no_key_keep_going() returns true, should the element be kept by the parser or ignored?
|
|
Sets whether to keep going or stop if no key is found.
|
|
No key has been found in the element, should parsing continue?
When the parser has found a matching prefix, but no matching key, what should it do? This return value tells it to keep going, or stop.
|
|
Sets whether an element with no prefix should be kept.
|
|
No prefix has been found on the element, should element be kept?
When the parser has found no matching prefixes that match the beginning of this element (including the empty string if valid), and no_prefix_keep_going() returns true, should the element be kept by the parser or ignored?
|
|
Sets whether to keep going or stop if no prefix is found.
|
|
No prefix has been found on the element, should parsing continue?
When the parser has found no matching prefixes that match the beginning of this element (including the empty string if valid), what should it do? This return value tells it to keep going, or stop.
|
|
Returns the pair of strings that are intended to enclose optional elements in a usage statement.
|
|
Returns the vector of prefixes allowed for this policy.
The returned vector contains all of the strings which are valid prefixes for this policy.
|
|
Sets the pair used to enclose optional elements.
This doesn't really affect the parsing behavior at all, it's mostly to make usage statements look the way you want them to.
|
|
Sets the pair used to enclose value elements.
This doesn't really affect the parsing behavior at all, it's mostly to make usage statements look the way you want them to.
|
|
Returns the pair of strings that are intended to enclose value elements in a usage statement.
|
|
This vector contains all of the strings that are valid assignments for this policy. Again, order is important, see Prefixes. |
|
Is the empty string a valid assignment?
|
|
Is the empty string a valid prefix?
|
|
In the case of arguments with required values, if the next element has a valid prefix, should it be taken as a value anyway? |
|
If there is an element with no key, should it be kept?
|
|
Should the parser keep going if there is an element with no valid key?
|
|
If there is an element with no prefix, should it be kept?
|
|
Should the parser keep going if there is an element with no prefix?
|
|
The strings that will bracket option elements in usage statements.
|
|
This vector contains all of the strings that are valid prefixes for this policy. Order is important, if you wanted both "--" and "-" to be valid prefixes for this policy, then "--" should be closer to the front of the vector of prefixes than just "-". If a potential key was foo, and the command line to parse had "--foo" in it, if "-" were before "--", then the parser would match the first "-" and use "-foo" as the key to pass to the matcher. Probably not the behavior that you want. |
|
Is the boundary between tokens a valid assignment?
|
|
The strings that will bracket value elements in usages statements.
|