Pakman
Command Class Reference

#include <Command.h>

Public Member Functions

 Command ()
 
 Command (const std::string &raw_command)
 
 Command (const char raw_command[])
 
 Command (const Command &command)
 
 Command (Command &&command)
 
Commandoperator= (const Command &command)
 
Commandoperator= (Command &&command)
 
 ~Command ()
 
const std::string & str () const
 
char ** argv () const
 
bool isExecutable () const
 

Detailed Description

A class for representing shell commands.

Commands take a raw command string and convert it to an array of command tokens using the function parse_command_tokens().

The array of command tokens, to be used in system functions such as exec(), can be accessed with the function argv().

Definition at line 16 of file Command.h.

Constructor & Destructor Documentation

◆ Command() [1/5]

Command::Command ( )

Default constructor.

Definition at line 13 of file Command.cc.

◆ Command() [2/5]

Command::Command ( const std::string &  raw_command)

Construct from raw command string.

Parameters
raw_commandC++-style string containing raw command.

Definition at line 18 of file Command.cc.

◆ Command() [3/5]

Command::Command ( const char  raw_command[])

Construct from raw command string.

Parameters
raw_commandC-style string containing raw command.

Definition at line 32 of file Command.cc.

◆ Command() [4/5]

Command::Command ( const Command command)

Copy constructor.

Parameters
commandsource Command object.

Definition at line 38 of file Command.cc.

◆ Command() [5/5]

Command::Command ( Command &&  command)

Move constructor.

Parameters
commandsource Command object.

Definition at line 49 of file Command.cc.

◆ ~Command()

Command::~Command ( )

Destructor.

Definition at line 103 of file Command.cc.

Member Function Documentation

◆ argv()

char ** Command::argv ( ) const
Returns
argv.
Warning
Do NOT call free on the returned pointer or any of the pointers it points to. Else, there WILL be pain.

Definition at line 117 of file Command.cc.

◆ isExecutable()

bool Command::isExecutable ( ) const
Returns
whether argv[0] is a valid executable.

Definition at line 153 of file Command.cc.

◆ operator=() [1/2]

Command & Command::operator= ( const Command command)

Copy-assignment constructor.

Parameters
commandsource Command object.
Returns
reference to copy-assigned Command object.

Definition at line 59 of file Command.cc.

◆ operator=() [2/2]

Command & Command::operator= ( Command &&  command)

Move-assignment constructor.

Parameters
commandsource Command object.
Returns
reference to move-assigned Command object.

Definition at line 81 of file Command.cc.

◆ str()

const std::string & Command::str ( ) const
Returns
raw command string.

Definition at line 111 of file Command.cc.


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