Representation of a command line, with parameters separated by spaces and an optional trailing space.
More...
#include <uuid/console.h>
|
| CommandLine ()=default |
| Create an empty command line. More...
|
|
| CommandLine (const std::string &line) |
| Parse a command line into separate parameters using built-in escaping rules. More...
|
|
| CommandLine (std::initializer_list< const std::vector< std::string >> arguments) |
| Create a command line from one or more vectors of parameters. More...
|
|
std::string | to_string (size_t reserve=Shell::MAX_COMMAND_LINE_LENGTH) const |
| Format a command line from separate parameters using built-in escaping rules. More...
|
|
size_t | total_size () const |
| Get the total size of the command line parameters, taking into account the trailing space. More...
|
|
void | reset () |
| Reset this command line's data. More...
|
|
void | escape_all_parameters () |
| Escape all parameters when formatting the command line for output. More...
|
|
void | escape_initial_parameters () |
| Only escape the number of parameters that currently exist when formatting the command line for output. More...
|
|
void | escape_initial_parameters (size_t count) |
| Escape the first count parameters when formatting the command line for output. More...
|
|
std::vector< std::string > & | operator* () |
| Obtain the parameters for this command line. More...
|
|
const std::vector< std::string > & | operator* () const |
| Obtain the parameters for this command line. More...
|
|
std::vector< std::string > * | operator-> () |
| Obtain the parameters for this command line. More...
|
|
const std::vector< std::string > * | operator-> () const |
| Obtain the parameters for this command line. More...
|
|
Representation of a command line, with parameters separated by spaces and an optional trailing space.
- Since
- 0.4.0
Definition at line 1642 of file console.h.
◆ CommandLine() [1/3]
uuid::console::CommandLine::CommandLine |
( |
| ) |
|
|
default |
Create an empty command line.
- Since
- 0.4.0
◆ CommandLine() [2/3]
uuid::console::CommandLine::CommandLine |
( |
const std::string & |
line | ) |
|
|
explicit |
Parse a command line into separate parameters using built-in escaping rules.
- Parameters
-
[in] | line | Command line to parse. |
- Since
- 0.4.0
Definition at line 28 of file command_line.cpp.
◆ CommandLine() [3/3]
uuid::console::CommandLine::CommandLine |
( |
std::initializer_list< const std::vector< std::string >> |
arguments | ) |
|
|
explicit |
Create a command line from one or more vectors of parameters.
- Parameters
-
[in] | arguments | Vectors of parameters to add to the command line. |
- Since
- 0.4.0
Definition at line 107 of file command_line.cpp.
◆ escape_all_parameters()
void uuid::console::CommandLine::escape_all_parameters |
( |
| ) |
|
|
inline |
Escape all parameters when formatting the command line for output.
This is the default.
- Since
- 0.5.0
Definition at line 1716 of file console.h.
◆ escape_initial_parameters() [1/2]
void uuid::console::CommandLine::escape_initial_parameters |
( |
| ) |
|
|
inline |
Only escape the number of parameters that currently exist when formatting the command line for output.
Use this before appending argument help that should not be escaped.
Empty parameters will always be escaped.
- Since
- 0.5.0
Definition at line 1728 of file console.h.
◆ escape_initial_parameters() [2/2]
void uuid::console::CommandLine::escape_initial_parameters |
( |
size_t |
count | ) |
|
|
inline |
Escape the first count parameters when formatting the command line for output.
Use this to prevent argument help from being escaped.
Empty parameters will always be escaped.
- Parameters
-
[in] | count | Number of parameters to escape. |
- Since
- 0.5.0
Definition at line 1740 of file console.h.
◆ operator*() [1/2]
std::vector<std::string>& uuid::console::CommandLine::operator* |
( |
| ) |
|
|
inline |
Obtain the parameters for this command line.
- Returns
- A reference to the parameters.
- Since
- 0.6.0
Definition at line 1748 of file console.h.
◆ operator*() [2/2]
const std::vector<std::string>& uuid::console::CommandLine::operator* |
( |
| ) |
const |
|
inline |
Obtain the parameters for this command line.
- Returns
- A reference to the parameters.
- Since
- 0.6.0
Definition at line 1755 of file console.h.
◆ operator->() [1/2]
std::vector<std::string>* uuid::console::CommandLine::operator-> |
( |
| ) |
|
|
inline |
Obtain the parameters for this command line.
- Returns
- A pointer to the parameters.
- Since
- 0.4.0
Definition at line 1762 of file console.h.
◆ operator->() [2/2]
const std::vector<std::string>* uuid::console::CommandLine::operator-> |
( |
| ) |
const |
|
inline |
Obtain the parameters for this command line.
- Returns
- A pointer to the parameters.
- Since
- 0.4.0
Definition at line 1769 of file console.h.
◆ reset()
void uuid::console::CommandLine::reset |
( |
| ) |
|
Reset this command line's data.
Clears the parameter list and removes any trailing space.
- Since
- 0.4.0
Definition at line 158 of file command_line.cpp.
◆ to_string()
Format a command line from separate parameters using built-in escaping rules.
- Parameters
-
[in] | reserve | String buffer size to preallocate. |
- Returns
- A command line, with escaping of characters sufficient to reproduce the same command line parameters when parsed.
- Since
- 0.4.0
Definition at line 113 of file command_line.cpp.
◆ total_size()
size_t uuid::console::CommandLine::total_size |
( |
| ) |
const |
|
inline |
Get the total size of the command line parameters, taking into account the trailing space.
- Returns
- The size of the command line parameters, plus 1 for a trailing space.
- Since
- 0.4.0
Definition at line 1698 of file console.h.
◆ operator!=
Compare this command line to another command line for inequality.
- Parameters
-
[in] | lhs | Left-hand side command line. |
[in] | rhs | Right-hand side command line. |
- Returns
- True if the command lines are not equal, otherwise false.
- Since
- 0.4.0
Definition at line 1790 of file console.h.
◆ operator==
Compare a command line to another command line for equality.
- Parameters
-
[in] | lhs | Left-hand side command line. |
[in] | rhs | Right-hand side command line. |
- Returns
- True if the command lines are equal, otherwise false.
- Since
- 0.4.0
Definition at line 1779 of file console.h.
◆ escape_parameters_
size_t uuid::console::CommandLine::escape_parameters_ = std::numeric_limits<size_t>::max() |
|
private |
Number of initial arguments to escape in output.
- Since
- 0.5.0
Definition at line 1798 of file console.h.
◆ parameters_
std::vector<std::string> uuid::console::CommandLine::parameters_ |
|
private |
Separate command line parameters.
- Since
- 0.4.0
Definition at line 1797 of file console.h.
◆ trailing_space
bool uuid::console::CommandLine::trailing_space = false |
Command line has a trailing space.
- Since
- 0.4.0
Definition at line 1794 of file console.h.
The documentation for this class was generated from the following files: