MemoryAccessor 1
A command-line front-end for exploring virtual memory of a linux process by accessing /proc/PID/mem file.
|
A class to perform CLI. More...
#include <console.h>
Public Member Functions | |
Console (MemoryAccessor &memory_accessor, HexViewer &hex_viewer, Tools &tools) noexcept(false) | |
Constructor. | |
Console (const Console &origin)=delete | |
Copy constructor (deleted). | |
Console (Console &&origin)=delete | |
Move constructor (deleted). | |
Console & | operator= (const Console &origin)=delete |
Copy-assignment operator (deleted). | |
Console & | operator= (Console &&origin)=delete |
Move-assignment operator (deleted). | |
~Console () noexcept | |
Destructor. | |
void | SetBufferSize (const size_t &buffer_size) |
Set buffer size of an instance. | |
void | PrintNameVer () const noexcept |
Print project name and version. | |
void | Start () noexcept |
Start the console. | |
void | ReadStdin () noexcept |
Read and process input from stdin. | |
void | HandleCommand (const std::string &line) noexcept |
Handle line with command. | |
Public Attributes | |
const std::string | kProjectName {"MemoryAccessor"} |
Name of the project. | |
const std::string | kProjectVersion {"v1.0"} |
Project version. | |
const std::string | kProjectDescription |
Project description. | |
const std::string | kConsolePrefix |
Prefix shown in console input. | |
MemoryAccessor & | memory_accessor_ |
A reference to a MemoryAccessor class instance. | |
HexViewer & | hex_viewer_ |
A reference to a HexViewer class instance. | |
Tools & | tools_ |
A reference to a Tools class instance. | |
const Command | kCommands [kCommandsNumber] |
Definitions of commands. | |
Static Public Attributes | |
static constexpr int | kCommandsNumber |
Number of the commands available. | |
A class to perform CLI.
The class provides commandline interface to interract with MemoryAccessor effectively. It can handle various commands with arguments. The class can either execute a command as a std::string or read a command from stdin. Moving, copying and creating more than 1 instance of the class is prohibited.
|
explicit |
Constructor.
[in,out] | memory_accessor | A reference to an instance of MemoryAccessor class. |
[in,out] | hex_viewer | A reference to an instance of HexViewer class. |
[in,out] | tools | A reference to an instance of Tools struct. |
std::logic_error | If an instance of the class have already been created and it is a second instance. |
Initializes MemoryAccessor class, HexViewer class and Tools struct references by values got as parameters. Throws an exception if an instance of the class have already been created. Sets one_instance_created_ to true.
|
delete |
Copy constructor (deleted).
[in] | origin | Console instance to copy from. |
Create a new object by copying an old one. Prohibited.
|
delete |
Move constructor (deleted).
[in] | origin | Moved Console object. |
Create a new object by moving an old one. Prohibited.
|
noexcept |
Destructor.
Deletes SIGINT handler attach if it is set to memoryaccessor_console_src::CtrlC, sets variables current_console_p to nullptr, rl_attempted_completion_function to nullptr and one_instance_created_ to false.
|
noexcept |
Handle line with command.
[in] | line | Line containing the command.f |
Parse and execute the given line containing the command.
Move-assignment operator (deleted).
[in] | origin | Moved Console object. |
Assign an object by moving other object. Prohibited.
Copy-assignment operator (deleted).
[in] | origin | Console instance to copy from. |
Assign an object by copying other object. Prohibited.
|
noexcept |
Print project name and version.
Print project name and version to stdout.
|
noexcept |
Read and process input from stdin.
Print prefix of a console, read input and process it (add line to history and handle command). If Ctrl-D is pressed, print "Quit" and exit the program with the code 0.
|
inline |
Set buffer size of an instance.
[in] | buffer_size | Desired buffer size in bytes. |
Set buffer size, a number of bytes that are allocated when needed.
|
noexcept |
Start the console.
Try to set handler for SIGINT, set memoryaccessor_console_src::current_console_p, rl_attempted_completion_function and print greeting message to stdout.
|
staticconstexpr |
Number of the commands available.
const std::string Console::kConsolePrefix |
Prefix shown in console input.
const std::string Console::kProjectDescription |
Project description.