ROSE 0.11.145.147
|
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 Sawyer/CommandLine.h.
#include <Sawyer/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. | |
static Ptr | instance (const ValueSaver::Ptr &valueSaver) |
Allocating constructor. | |
Protected Member Functions | |
AnyParser () | |
Constructor for derived classes. | |
AnyParser (const ValueSaver::Ptr &valueSaver) | |
Constructor for derived classes. | |
Protected Member Functions inherited from Sawyer::CommandLine::ValueParser | |
ValueParser () | |
Constructor for derived classes. | |
ValueParser (const ValueSaver::Ptr &valueSaver) | |
Constructor for derived classes. | |
Additional Inherited Members | |
Public Member Functions inherited from Sawyer::CommandLine::ValueParser | |
ParsedValue | matchString (const std::string &) |
Parse the entire string and return a value. | |
ParsedValue | match (Cursor &) |
Parse a value from the beginning of the specified string. | |
Ptr | valueSaver (const ValueSaver::Ptr &f) |
Property: functor responsible for saving a parsed value in user storage. | |
const ValueSaver::Ptr | valueSaver () const |
Property: functor responsible for saving a parsed value in user storage. | |
Public Member Functions inherited from Sawyer::SharedObject | |
SharedObject () | |
Default constructor. | |
SharedObject (const SharedObject &) | |
Copy constructor. | |
virtual | ~SharedObject () |
Virtual destructor. | |
SharedObject & | operator= (const SharedObject &) |
Assignment. | |
Public Member Functions inherited from Sawyer::SharedFromThis< ValueParser > | |
SharedPointer< ValueParser > | sharedFromThis () |
Create a shared pointer from this . | |
SharedPointer< const ValueParser > | sharedFromThis () const |
Create a shared pointer from this . | |
typedef SharedPointer<AnyParser> Sawyer::CommandLine::AnyParser< T >::Ptr |
Reference counting pointer for this class.
Definition at line 874 of file Sawyer/CommandLine.h.
|
inlineprotected |
Constructor for derived classes.
Non-subclass users should use instance instead.
Definition at line 868 of file 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 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 Sawyer/CommandLine.h.
Referenced by Sawyer::CommandLine::anyParser(), and 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 Sawyer/CommandLine.h.
References Sawyer::CommandLine::AnyParser< T >::AnyParser(), and Sawyer::CommandLine::ValueParser::valueSaver().