ROSE  0.11.145.0
Public Types | Static Public Member Functions | Protected Member Functions | List of all members
Sawyer::CommandLine::AnyParser< T > Class Template Reference

Description

template<typename T>
class Sawyer::CommandLine::AnyParser< T >

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:

int i;

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.

See also
anyParser factory method, and Command line parser factories

Definition at line 865 of file util/Sawyer/CommandLine.h.

#include <util/Sawyer/CommandLine.h>

Inheritance diagram for Sawyer::CommandLine::AnyParser< T >:
Inheritance graph
[legend]
Collaboration diagram for Sawyer::CommandLine::AnyParser< T >:
Collaboration graph
[legend]

Public Types

typedef SharedPointer< AnyParserPtr
 Reference counting pointer for this class. More...
 
- Public Types inherited from Sawyer::CommandLine::ValueParser
typedef SharedPointer< ValueParserPtr
 Reference counting pointer for this class. More...
 

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...
 
SharedObjectoperator= (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...
 

Member Typedef Documentation

template<typename T >
typedef SharedPointer<AnyParser> Sawyer::CommandLine::AnyParser< T >::Ptr

Reference counting pointer for this class.

Definition at line 874 of file util/Sawyer/CommandLine.h.

Constructor & Destructor Documentation

template<typename T >
Sawyer::CommandLine::AnyParser< T >::AnyParser ( )
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().

template<typename T >
Sawyer::CommandLine::AnyParser< T >::AnyParser ( const ValueSaver::Ptr valueSaver)
inlineprotected

Constructor for derived classes.

Non-subclass users should use instance instead.

Definition at line 871 of file util/Sawyer/CommandLine.h.

Member Function Documentation

template<typename T >
static Ptr Sawyer::CommandLine::AnyParser< T >::instance ( )
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.

See also
Command line parser factories

Definition at line 879 of file util/Sawyer/CommandLine.h.

Referenced by Sawyer::CommandLine::anyParser().

template<typename T >
static Ptr Sawyer::CommandLine::AnyParser< T >::instance ( const ValueSaver::Ptr valueSaver)
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.

See also
Command line parser factories

Definition at line 884 of file util/Sawyer/CommandLine.h.

References Sawyer::CommandLine::AnyParser< T >::AnyParser().


The documentation for this class was generated from the following file: