senf::console::Executor Class Reference

Execute config/console commands. More...

#include <senf/Utils/Console/Executor.hh>

Inheritance diagram for senf::console::Executor:

Classes

struct  ExitException
 Thrown by built-in 'exit' command. More...
 
struct  IgnoreCommandException
 Thrown by the SecurityPolicy to silently ignore a command. More...
 

Public Types

typedef boost::function< void(DirectoryNode &, std::string const &)> SecurityPolicy
 Executor policy function. More...
 
typedef void result_type
 

Public Member Functions

void execute (std::ostream &output, ParseCommandInfo const &command)
 Execute command. More...
 
void operator() (std::ostream &output, ParseCommandInfo const &command)
 Execute command. More...
 
GenericNodegetNode (ParseCommandInfo const &command)
 
DirectoryNodecwd () const
 Current working directory. More...
 
void cwd (DirectoryNode &dir)
 Change current directory. More...
 
std::string cwdPath () const
 Return pathname of current directory. More...
 
bool skipping () const
 true, if currently skipping a directory group More...
 
bool autocd () const
 Get current autocd status. More...
 
Executorautocd (bool v)
 Set autocd status. More...
 
bool autocomplete () const
 Get current autocomplete status. More...
 
Executorautocomplete (bool v)
 Set autocomplete status. More...
 
DirectoryNodechroot () const
 Get root node. More...
 
Executorchroot (DirectoryNode &node)
 chroot into given directory More...
 
Executorpolicy (SecurityPolicy policy=SecurityPolicy())
 Set security policy. More...
 
 Executor ()
 

Detailed Description

Execute config/console commands.

The Executor interprets parsed config/console commands and executes them. It manages the current execution context (current directory, directory stack and so on).

The executor is normally called directly by the parser callback for each command.

Executing the built-in 'exit' command will throw Executor::ExitException. This exception (which is not derived from std::exception since it's not a real exception) must be handled by the caller.

All directories are managed using weak pointers. If any of the directories expires (current directory, directory stack, last directory) it will be replaced with the root directory. Directories expire when they are destructed or when they are detached from the config tree root node.

Definition at line 48 of file Executor.hh.

Member Typedef Documentation

◆ result_type

Definition at line 66 of file Executor.hh.

◆ SecurityPolicy

typedef boost::function<void (DirectoryNode &,std::string const &)> senf::console::Executor::SecurityPolicy

Executor policy function.

Definition at line 61 of file Executor.hh.

Constructor & Destructor Documentation

◆ Executor()

senf::console::Executor::Executor ( )

Member Function Documentation

◆ autocd() [1/2]

bool senf::console::Executor::autocd ( ) const

Get current autocd status.

if autocd is enabled, specifying a directory name as command will cd to that directory. Disabled by default (but enabled automatically by the interactive console).

◆ autocd() [2/2]

Executor& senf::console::Executor::autocd ( bool  v)

Set autocd status.

See also
autocd()

◆ autocomplete() [1/2]

bool senf::console::Executor::autocomplete ( ) const

Get current autocomplete status.

if autocomplete is enabled, path components which can be uniquely completed will be completed automatically. Disabled by default (but enabled automatically by the interactive console).

◆ autocomplete() [2/2]

Executor& senf::console::Executor::autocomplete ( bool  v)

Set autocomplete status.

See also
autocomplete()

◆ chroot() [1/2]

DirectoryNode& senf::console::Executor::chroot ( ) const

Get root node.

The root node defaults to senf::console::root(). If changed, all path references are relative to this node and objects outside that tree cannot be accessed.

◆ chroot() [2/2]

Executor& senf::console::Executor::chroot ( DirectoryNode node)

chroot into given directory

After this call, all path's are interpreted relative to node and only nodes in the tree rooted at node are accessible via the executor. This value defaults to senf::console::root().

◆ cwd() [1/2]

senf::console::DirectoryNode & senf::console::Executor::cwd ( ) const

Current working directory.

Definition at line 49 of file Executor.cc.

◆ cwd() [2/2]

void senf::console::Executor::cwd ( DirectoryNode dir)

Change current directory.

◆ cwdPath()

std::string senf::console::Executor::cwdPath ( ) const

Return pathname of current directory.

Definition at line 58 of file Executor.cc.

◆ execute()

void senf::console::Executor::execute ( std::ostream &  output,
ParseCommandInfo const &  command 
)

Execute command.

Output will be written to output. Same as operator()().

Definition at line 71 of file Executor.cc.

◆ getNode()

senf::console::GenericNode & senf::console::Executor::getNode ( ParseCommandInfo const &  command)

Definition at line 169 of file Executor.cc.

◆ operator()()

void senf::console::Executor::operator() ( std::ostream &  output,
ParseCommandInfo const &  command 
)

Execute command.

Output will be written to output. Same as execute().

◆ policy()

Executor& senf::console::Executor::policy ( SecurityPolicy  policy = SecurityPolicy())

Set security policy.

The security policy is called before traversing a node to validate that access.

◆ skipping()

bool senf::console::Executor::skipping ( ) const

true, if currently skipping a directory group


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