ROSE 0.11.145.147
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));
Describes one command-line switch.
IntegerParser< T >::Ptr integerParser()
Factory for value parsers.
@ SAVE_AUGMENTED
Save the first value, or modify previously saved value.

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

#include <Sawyer/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.
 
- Public Types inherited from Sawyer::CommandLine::ValueAugmenter
typedef SharedPointer< ValueAugmenterPtr
 Reference counting pointer for this class.
 

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.
 
- Public Member Functions inherited from Sawyer::SharedObject
 SharedObject ()
 Default constructor.
 
 SharedObject (const SharedObject &)
 Copy constructor.
 
virtual ~SharedObject ()
 Virtual destructor.
 
SharedObjectoperator= (const SharedObject &)
 Assignment.
 

Static Public Member Functions

static Ptr instance ()
 Allocating constructor.
 

Protected Member Functions

 Sum ()
 Constructor for derived classes.
 

Member Typedef Documentation

◆ Ptr

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

Reference counting pointer for this class.

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

Constructor & Destructor Documentation

◆ Sum()

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

Constructor for derived classes.

Non-subclass users should use instance instead.

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

Member Function Documentation

◆ instance()

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

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

◆ operator()()

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

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


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