BashSpark
Loading...
Searching...
No Matches
bs::command_seq Class Reference

Prints a sequence on stdout. Supports negative numbers and decreasing sequences. More...

#include <command_seq.h>

Inheritance diagram for bs::command_seq:
Collaboration diagram for bs::command_seq:

Public Member Functions

 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).
 

Detailed Description

Prints a sequence on stdout. Supports negative numbers and decreasing sequences.

Syntax: seq begin end
Syntax: seq begin step end

Member Function Documentation

◆ 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
oStdErrStream to print error message.
sIntNon 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
oStdErrStream to print error message.
sIntNon 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
oStdErrStream to print error message.
nMinStarting value of the sequence
nStepStepping value of the sequence
nMaxFinal 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
oStdErrStream to print error message.
nArgsNumber of provided arguments.

◆ run()

shell_status bs::command_seq::run ( const std::span< const std::string > &  vArgs,
shell_session oSession 
) const
overridevirtual

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
vArgsArguments for the command.
oSessionThe shell session context.
Returns
Status of command execution.

Implements bs::command.


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