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

Description

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

Sums all previous and current values.

The template argument must match the type of the summed values.

This augmenter can be used for switches that increment a value, such as a debug switch where each occurrence of the switch increments a debug level:

int debugLevel = 0;
switchGroup.insert(Switch("debug", "d")
.intrinsicValue("1", integerParser(debugLevel))
.valueAugmenter(sum<int>())
.whichValue(SAVE_AUGMENTED));

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

#include <CommandLine.h>

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

Public Types

typedef SharedPointer< SumPtr
 Reference counting pointer for this class. More...
 
- Public Types inherited from Sawyer::CommandLine::ValueAugmenter
typedef SharedPointer< ValueAugmenterPtr
 Reference counting pointer for this class. More...
 

Public Member Functions

virtual ParsedValues operator() (const ParsedValues &savedValues, const ParsedValues &newValues)
 Called when a switch's value is about to be stored into the ParserResult. 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...
 

Static Public Member Functions

static Ptr instance ()
 Allocating constructor. More...
 

Protected Member Functions

 Sum ()
 Constructor for derived classes. More...
 

Member Typedef Documentation

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

Reference counting pointer for this class.

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

Constructor & Destructor Documentation

template<typename T >
Sawyer::CommandLine::Sum< T >::Sum ( )
inlineprotected

Constructor for derived classes.

Non-subclass users should use instance instead.

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

Member Function Documentation

template<typename T >
static Ptr Sawyer::CommandLine::Sum< T >::instance ( )
inlinestatic

Allocating constructor.

Returns a pointer to a new Sum object. Uses will most likely want to use the sum factory instead, which requires less typing.

See also
Command line value augmenter factories, and the ValueAugmenter class.

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

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

template<typename T >
virtual ParsedValues Sawyer::CommandLine::Sum< T >::operator() ( const ParsedValues savedValues,
const ParsedValues newValues 
)
inlinevirtual

Called when a switch's value is about to be stored into the ParserResult.

The previously stored switch values for all switch occurrences that used this same key are provided in the first arugment. The recently parsed value (or values if the switch value was a list that was then exploded) is provided as the second argument. The function should return a new value (or values) that will replace the values passed on the command-line.

Implements Sawyer::CommandLine::ValueAugmenter.

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

References Sawyer::CommandLine::sum(), and Sawyer::CommandLine::ParsedValue::value().


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