ROSE 0.11.145.192
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 1319 of file Sawyer/CommandLine.h.

#include <Sawyer/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.
 
typedef std::list< ParsedValueValueList
 Value type for list ParsedValue.
 
- Public Types inherited from Sawyer::CommandLine::ValueParser
typedef SharedPointer< ValueParserPtr
 Reference counting pointer for this class.
 

Public Member Functions

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

Static Public Member Functions

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

Protected Member Functions

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

Member Typedef Documentation

◆ Ptr

Reference counting pointer for this class.

Definition at line 1333 of file Sawyer/CommandLine.h.

◆ ValueList

Value type for list ParsedValue.

Definition at line 1336 of file Sawyer/CommandLine.h.

Constructor & Destructor Documentation

◆ ListParser()

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 1327 of file Sawyer/CommandLine.h.

Member Function Documentation

◆ instance()

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 1345 of file Sawyer/CommandLine.h.

◆ nextMember()

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 1355 of file Sawyer/CommandLine.h.

References Sawyer::SharedPointer< T >::dynamicCast().

◆ limit() [1/2]

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.

◆ limit() [2/2]

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 1367 of file Sawyer/CommandLine.h.

References limit().

Referenced by limit().

◆ exactly()

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 1368 of file Sawyer/CommandLine.h.


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