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

Description

template<class Functor>
class Sawyer::CommandLine::UserAction< Functor >

Wrapper around a user functor.

User code doesn't often use reference counting smart pointers for functors, but more often creates functors in global data or on the stack. The purpose of UserAction is to be a wrapper around these functors, to be a bridge between the world of reference counting pointers and objects or object references. For example, say the user has a function like this:

void showRawManPage(const ParserResult *cmdline) {
std::cout <<cmdline->parser()->manpage();
exit(0);
}

Then the functor/function can be used like this:

switchGroup.insert(Switch("raw-man")
.action(userAction(showRawManPage))
.doc("Prints the raw nroff man page to standard output."));

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

#include <util/Sawyer/CommandLine.h>

Inheritance diagram for Sawyer::CommandLine::UserAction< Functor >:
Inheritance graph
[legend]
Collaboration diagram for Sawyer::CommandLine::UserAction< Functor >:
Collaboration graph
[legend]

Public Types

typedef SharedPointer< class UserActionPtr
 Reference counting pointer for this class. More...
 
- Public Types inherited from Sawyer::CommandLine::SwitchAction
typedef SharedPointer< SwitchActionPtr
 Reference counting pointer for this class. More...
 

Static Public Member Functions

static Ptr instance (Functor &f)
 Allocating constructor. More...
 

Protected Member Functions

 UserAction (Functor &f)
 Constructor for derived classes. More...
 
virtual void operator() (const ParserResult &parserResult)
 

Additional Inherited Members

- Public Member Functions inherited from Sawyer::CommandLine::SwitchAction
void run (const ParserResult &parserResult)
 Runs the action. 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...
 

Member Typedef Documentation

template<class Functor >
typedef SharedPointer<class UserAction> Sawyer::CommandLine::UserAction< Functor >::Ptr

Reference counting pointer for this class.

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

Constructor & Destructor Documentation

template<class Functor >
Sawyer::CommandLine::UserAction< Functor >::UserAction ( Functor &  f)
inlineprotected

Constructor for derived classes.

Non-subclass users should use instance instead.

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

Referenced by Sawyer::CommandLine::UserAction< Functor >::instance().

Member Function Documentation

template<class Functor >
static Ptr Sawyer::CommandLine::UserAction< Functor >::instance ( Functor &  f)
inlinestatic

Allocating constructor.

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

See also
Command line action factories, and the SwitchAction class.

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

References Sawyer::CommandLine::UserAction< Functor >::UserAction().

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


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