Prints a sequence on stdout. Supports negative numbers and decreasing sequences.
More...
#include <command_seq.h>
|
|
| command_seq () |
| | Constructs command.
|
| |
| shell_status | run (const std::span< const std::string > &vArgs, shell_session &oSession) const override |
| | Prints a sequence on stdout.
|
| |
| virtual void | msg_error_param_number (std::ostream &oStdErr, std::size_t nArgs) const |
| | Print an error if the wrong number of arguments is provided.
|
| |
| virtual void | msg_error_int_format (std::ostream &oStdErr, const std::string &sInt) const |
| | Print an error if a parameter is non integer.
|
| |
| virtual void | msg_error_int_bounds (std::ostream &oStdErr, const std::string &sInt) const |
| | Print an error if an integer values is outside the bounds of c2 64 bit binary.
|
| |
| virtual void | msg_error_logics (std::ostream &oStdErr, std::int64_t nMin, std::int64_t nStep, std::int64_t nMax) const |
| | Print an error if the parameters are incoherent, meaning the sequence can not be completed.
|
| |
Public Member Functions inherited from bs::command |
| | command (std::string sName) |
| | Construct a command with a given name.
|
| |
|
virtual | ~command ()=default |
| | Virtual destructor.
|
| |
| std::string | get_name () const |
| | Get the command name (copy).
|
| |
| const std::string & | get_name_ref () const noexcept |
| | Get the command name (reference).
|
| |
Prints a sequence on stdout. Supports negative numbers and decreasing sequences.
Syntax: seq begin end
Syntax: seq begin step end
◆ msg_error_int_bounds()
| void bs::command_seq::msg_error_int_bounds |
( |
std::ostream & |
oStdErr, |
|
|
const std::string & |
sInt |
|
) |
| const |
|
virtual |
Print an error if an integer values is outside the bounds of c2 64 bit binary.
- Parameters
-
| oStdErr | Stream to print error message. |
| sInt | Non integer parameter. |
◆ msg_error_int_format()
| void bs::command_seq::msg_error_int_format |
( |
std::ostream & |
oStdErr, |
|
|
const std::string & |
sInt |
|
) |
| const |
|
virtual |
Print an error if a parameter is non integer.
- Parameters
-
| oStdErr | Stream to print error message. |
| sInt | Non integer parameter. |
◆ msg_error_logics()
| void bs::command_seq::msg_error_logics |
( |
std::ostream & |
oStdErr, |
|
|
std::int64_t |
nMin, |
|
|
std::int64_t |
nStep, |
|
|
std::int64_t |
nMax |
|
) |
| const |
|
virtual |
Print an error if the parameters are incoherent, meaning the sequence can not be completed.
- Parameters
-
| oStdErr | Stream to print error message. |
| nMin | Starting value of the sequence |
| nStep | Stepping value of the sequence |
| nMax | Final value of the sequence |
◆ msg_error_param_number()
| void bs::command_seq::msg_error_param_number |
( |
std::ostream & |
oStdErr, |
|
|
std::size_t |
nArgs |
|
) |
| const |
|
virtual |
Print an error if the wrong number of arguments is provided.
- Parameters
-
| oStdErr | Stream to print error message. |
| nArgs | Number of provided arguments. |
◆ run()
Prints a sequence on stdout.
Integers are defined by regex: R"(^[+-]?\d+$)"
If the parameter count does not match 2 or 3 then msg_error_param_number method is called. If any of the parameters is not a number then msg_error_int_format method is called. If any of the parameters is not within the bounds of c2 64 bit binary then msg_error_int_bounds method is called. If the parameters are incoherent, meaning the sequence can not be completed, then msg_error_logics method is called.
- Parameters
-
| vArgs | Arguments for the command. |
| oSession | The shell session context. |
- Returns
- Status of command execution.
Implements bs::command.
The documentation for this class was generated from the following files:
- /home/runner/work/bashspark/bashspark/include/BashSpark/command/command_seq.h
- /home/runner/work/bashspark/bashspark/src/BashSpark/command/command_seq.cpp