ROSE
0.11.96.11
|
Parses any argument as plain text.
This parser consumes the entire following string and then attempts to convert it to type T, or throw an std::runtime_error
. This differs from most other parsers which consume only those characters they recognize. For instance:
The anyParser(i)
will throw an error for a command line like -n123x
, but the integerParser(i)
will consume only the "123" and leave "x" alone (which is presumably the "-x" nestled short switch). The integerParser
will also provide more informative error messages for overflows.
This parser is primarily intended for parsing arbitrary strings as std::string
, and uses that type when no other type is provided by template argument or constructor argument.
The boost::lexical_cast
package is used for the conversion, but boost::bad_lexical_cast
exceptions are caught and rethrown as std::runtime_error
as required by the ValueParser interface.
Definition at line 865 of file util/Sawyer/CommandLine.h.
#include <CommandLine.h>
Public Types | |
typedef SharedPointer< AnyParser > | Ptr |
Reference counting pointer for this class. | |
Public Types inherited from Sawyer::CommandLine::ValueParser | |
typedef SharedPointer< ValueParser > | Ptr |
Reference counting pointer for this class. | |
Static Public Member Functions | |
static Ptr | instance () |
Allocating constructor. More... | |
static Ptr | instance (const ValueSaver::Ptr &valueSaver) |
Allocating constructor. More... | |
Protected Member Functions | |
AnyParser () | |
Constructor for derived classes. More... | |
AnyParser (const ValueSaver::Ptr &valueSaver) | |
Constructor for derived classes. More... | |
Protected Member Functions inherited from Sawyer::CommandLine::ValueParser | |
ValueParser () | |
Constructor for derived classes. More... | |
ValueParser (const ValueSaver::Ptr &valueSaver) | |
Constructor for derived classes. More... | |
Additional Inherited Members | |
Public Member Functions inherited from Sawyer::CommandLine::ValueParser | |
ParsedValue | matchString (const std::string &) |
Parse the entire string and return a value. More... | |
ParsedValue | match (Cursor &) |
Parse a value from the beginning of the specified string. More... | |
Ptr | valueSaver (const ValueSaver::Ptr &f) |
Property: functor responsible for saving a parsed value in user storage. More... | |
const ValueSaver::Ptr | valueSaver () const |
Property: functor responsible for saving a parsed value in user storage. More... | |
Public Member Functions inherited from Sawyer::SharedObject | |
SharedObject () | |
Default constructor. More... | |
SharedObject (const SharedObject &) | |
Copy constructor. More... | |
virtual | ~SharedObject () |
Virtual destructor. More... | |
SharedObject & | operator= (const SharedObject &) |
Assignment. More... | |
Public Member Functions inherited from Sawyer::SharedFromThis< ValueParser > | |
SharedPointer< ValueParser > | sharedFromThis () |
Create a shared pointer from this . More... | |
SharedPointer< const ValueParser > | sharedFromThis () const |
Create a shared pointer from this . More... | |
|
inlineprotected |
Constructor for derived classes.
Non-subclass users should use instance instead.
Definition at line 868 of file util/Sawyer/CommandLine.h.
Referenced by Sawyer::CommandLine::AnyParser< T >::instance().
|
inlineprotected |
Constructor for derived classes.
Non-subclass users should use instance instead.
Definition at line 871 of file util/Sawyer/CommandLine.h.
|
inlinestatic |
Allocating constructor.
Returns a pointer to a new AnyParser object. Uses will most likely want to use the anyParser factory instead, which requires less typing.
Definition at line 879 of file util/Sawyer/CommandLine.h.
Referenced by Sawyer::CommandLine::anyParser().
|
inlinestatic |
Allocating constructor.
Returns a pointer to a new AnyParser object. Uses will most likely want to use the anyParser factory instead, which takes the same arguments, but requires less typing.
Definition at line 884 of file util/Sawyer/CommandLine.h.
References Sawyer::CommandLine::AnyParser< T >::AnyParser(), and Sawyer::CommandLine::ValueParser::valueSaver().