ROSE  0.9.10.69
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
Sawyer::CommandLine::ListParser Class Reference

Description

Parses a list of values.

Parses a list of values separated by specified regular expressions. Each member of the list may have its own parser and following separator. The final parser and separator are reused as often as necessary. The return value is a ParsedValue whose value is an STL list with members that are the ParsedValue objects return by the list element parsers.

See also
Command line parser factories

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

#include <CommandLine.h>

Inheritance diagram for Sawyer::CommandLine::ListParser:
Inheritance graph
[legend]
Collaboration diagram for Sawyer::CommandLine::ListParser:
Collaboration graph
[legend]

Public Types

typedef SharedPointer< ListParserPtr
 Reference counting pointer for this class. More...
 
typedef std::list< ParsedValueValueList
 Value type for list ParsedValue. More...
 
- Public Types inherited from Sawyer::CommandLine::ValueParser
typedef SharedPointer< ValueParserPtr
 Reference counting pointer for this class. More...
 

Public Member Functions

Ptr nextMember (const ValueParser::Ptr &elmtType, const std::string &separatorRe="[,;:]\\s*")
 Specifies element type and separator. More...
 
Ptr limit (size_t minLength, size_t maxLength)
 Specify limits for the number of values parsed. More...
 
Ptr limit (size_t maxLength)
 Specify limits for the number of values parsed. More...
 
Ptr exactly (size_t length)
 Specify limits for the number of values parsed. More...
 
- 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...
 

Static Public Member Functions

static Ptr instance (const ValueParser::Ptr &firstElmtType, const std::string &separatorRe="[,;:]\\s*")
 Allocating constructor. More...
 

Protected Member Functions

 ListParser (const ValueParser::Ptr &firstElmtType, const std::string &separatorRe)
 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...
 

Member Typedef Documentation

Reference counting pointer for this class.

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

Value type for list ParsedValue.

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

Constructor & Destructor Documentation

Sawyer::CommandLine::ListParser::ListParser ( const ValueParser::Ptr firstElmtType,
const std::string &  separatorRe 
)
inlineprotected

Constructor for derived classes.

Non-subclass users should use instance instead.

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

Member Function Documentation

static Ptr Sawyer::CommandLine::ListParser::instance ( const ValueParser::Ptr firstElmtType,
const std::string &  separatorRe = "[,;:]\\s*" 
)
inlinestatic

Allocating constructor.

The firstElmtType is the parser for the first value (and the remaining values also if no subsequent parser is specified), and the separatorRe is the regular expression describing how values of this type are separated from subsequent values. The default separator is a comma, semicolon, or colon followed by zero or more white space characters. Users will most likely want to use the listParser factory instead, which takes the same arguments but requires less typing.

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

Ptr Sawyer::CommandLine::ListParser::nextMember ( const ValueParser::Ptr elmtType,
const std::string &  separatorRe = "[,;:]\\s*" 
)
inline

Specifies element type and separator.

Adds another element type and separator to this parser. The specified values are also used for all the following list members unless a subsequent type and separator are supplied. I.e., the final element type and separator are repeated as necessary when parsing. The default separator is a comma, semicolon, or colon followed by zero ore more white space characters.

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

Ptr Sawyer::CommandLine::ListParser::limit ( size_t  minLength,
size_t  maxLength 
)

Specify limits for the number of values parsed.

By default, a list parser parses zero or more values with no limit. The limit method provides separate lower and upper bounds (the one argument version sets only the upper bound), and the exactly method is a convenience to set the lower and upper bound to the same value.

Ptr Sawyer::CommandLine::ListParser::limit ( size_t  maxLength)
inline

Specify limits for the number of values parsed.

By default, a list parser parses zero or more values with no limit. The limit method provides separate lower and upper bounds (the one argument version sets only the upper bound), and the exactly method is a convenience to set the lower and upper bound to the same value.

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

References limit().

Referenced by limit().

Ptr Sawyer::CommandLine::ListParser::exactly ( size_t  length)
inline

Specify limits for the number of values parsed.

By default, a list parser parses zero or more values with no limit. The limit method provides separate lower and upper bounds (the one argument version sets only the upper bound), and the exactly method is a convenience to set the lower and upper bound to the same value.

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


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