command¶
-
struct
mikrotik::api::command¶ A command to send and to execute on the MikroTik device.
A command is a word that can be executed by the MikroTik device it’s sent to. This is always the first word to be sent to the device and may be followed by attribute or query words that either provide required information for the command’s execution, or filter the output provided by it respectively.
A DSL is provided by the library to allow easy creation of commands by utilizing the
_cmduser defined literal on strings, which invokes the first constructor.- Since
v1.0.0
Public Functions
-
command(std::string_view cmd)¶ Creates a command from a string.
Takes a string and prepends a forward slash to it to create a command. This is then sent to the MikroTik device so the given string with the prepended slash must be a valid MikroTik API command word.
- Since
v1.0.0
- Parameters
cmd: The string to turn into a command
-
command
operator/(std::string_view nxt) &&¶ Appends a string to a command.
Takes a command and adds a new part to it by concatenating a forward slash and the provided string.
For example:
auto cmd = "system"_cmd; // -> /system cmd = cmd / "resource" / "print"; // -> /system/resource/print
- Return
The new command
- Since
v1.0.0
- Parameters
nxt: The string to append
-
command
operator/(std::string_view nxt) const &¶ Appends a string to a command.
Takes a command and adds a new part to it by concatenating a forward slash and the provided string.
For example:
auto cmd = "system"_cmd; // -> /system cmd = cmd / "resource" / "print"; // -> /system/resource/print
- Return
The new command
- Since
v1.0.0
- Parameters
nxt: The string to append
-
sentence
operator[](const attribute &attr) const¶ Creates a sentence from the command with an attribute.
Takes the command and promotes it to a sentence by taking the command and adding an attribute word.
-
sentence
operator()(const query &query) const¶ Creates a sentence from the command with a query.
Takes the command and promotes it to a sentence by taking the command and adding a query word.
-
operator sentence() const¶ Implicit conversion operator to a sentence.
Promotes the command to a sentence with one word: this command.
- Return
The new sentence
- Since
v1.0.0
Public Members
-
std::string
cmd¶ The command as a string ready to be sent.