Contains useful set of functions to work with std::string and to convert various types in std::string. More...
#include <stdio.h>#include <sys/ioctl.h>#include <unistd.h>#include <vector>#include "ErrorHandler.hpp"#include "StrTools.hpp"Go to the source code of this file.
Functions | |
| template<typename... T> | |
| void | CppTools::Print (T... args) |
| Variadic print functions. | |
| int | CppTools::GetTerminalWidth () |
| Returns terminal width. | |
| void | CppTools::PrintInfo (const std::string &message) |
| Prints info prompt. | |
| void | CppTools::PrintSimpleSeparator (const std::string &leftEdge="|", const std::string &body="-", const std::string &rightEdge="|", int length=-1) |
| Prints vertical separator (with width of terminal by default). | |
| void | CppTools::PrintSeparator (const std::string &message, const std::string &color="", const std::string &leftEdge="//", const std::string &body="-", const std::string &rightEdge="//", int length=-1) |
| Prints vertical separator (with width of terminal by default) with message in the middle. | |
| void | CppTools::Print2EntrySeparator (const std::string &entry1, const std::string &entry2, const std::string &leftEdge="|", const std::string &rightEdge="|", int length=-1) |
| Prints vertical separator (with width of terminal by default) with one text entry on the left and the other on the left. | |
| void | CppTools::PrintMessageBox (const std::string &message, const std::string &ULCorner="╓", const std::string &URCorner="╖", const std::string &horizontalLine="─", const std::string &verticalLine="║", const std::string &BLCorner="╙", const std::string &BRCorner="╜", int length=-1) |
| Prints vertical separator (with width of terminal by default) constisting of 3 lines with message in the middle. | |
Contains useful set of functions to work with std::string and to convert various types in std::string.
In order to use functions from this file libStrTools.so must be loaded
This file is a part of a project CppTools (https://github.com/Sergeyir/CppTools).
| void CppTools::Print | ( | T... | args | ) |
Variadic print functions.
| [in] | args | parameter pack, every element of which will be printed |
| void CppTools::Print2EntrySeparator | ( | const std::string & | entry1, |
| const std::string & | entry2, | ||
| const std::string & | leftEdge = "|", | ||
| const std::string & | rightEdge = "|", | ||
| int | length = -1 ) |
Prints vertical separator (with width of terminal by default) with one text entry on the left and the other on the left.
| [in] | entry1 | - text to be printed on the left |
| [in] | entry2 | - text to be printed on the right |
| [in] | leftEdge | - left edge of a separator, only printed once |
| [in] | rightEdge | - right edge of a separator, only printed once |
| [in] | length | - length of a separator; negative values will result separator to be printed with a width of a terminal |
Example: Calling Print2EntrySeparator("left", "right", "|", "|", 20) will print without quotes
| left right |
| void CppTools::PrintInfo | ( | const std::string & | message | ) |
Prints info prompt.
| [in] | message | text to be printed in the info prompt |
| void CppTools::PrintMessageBox | ( | const std::string & | message, |
| const std::string & | ULCorner = "╓", | ||
| const std::string & | URCorner = "╖", | ||
| const std::string & | horizontalLine = "─", | ||
| const std::string & | verticalLine = "║", | ||
| const std::string & | BLCorner = "╙", | ||
| const std::string & | BRCorner = "╜", | ||
| int | length = -1 ) |
Prints vertical separator (with width of terminal by default) constisting of 3 lines with message in the middle.
| [in] | message | - text to be printed in the middle |
| [in] | ULCorner | - upper left corner of a separator |
| [in] | URCorner | - upper right corner of a separator |
| [in] | horizontalLine | - horizontal line of a separator |
| [in] | BLCorner | - bottom left corner of a separator |
| [in] | BRCorner | - bottom right corner of a separator |
| [in] | length | - length of a separator; negative values will result separator to be printed with a width of a terminal |
Example: Calling PrintBigSeparator("text", "UL", "UR", "-", "|", "BL", "BR", 20) will print (note the spaces on the left and on the right since they contribute to the length)
UL---------------UR | text | BL---------------BR
| void CppTools::PrintSeparator | ( | const std::string & | message, |
| const std::string & | color = "", | ||
| const std::string & | leftEdge = "//", | ||
| const std::string & | body = "-", | ||
| const std::string & | rightEdge = "//", | ||
| int | length = -1 ) |
Prints vertical separator (with width of terminal by default) with message in the middle.
| [in] | message | - text to be printed in the middle |
| [in] | color | - color of the message (see OutputColors.hpp file) |
| [in] | leftEdge | - left edge of a separator, only printed once |
| [in] | body | - body of a separator, can be printed multiple times to fill in the length. |
| [in] | rightEdge | - right edge of a separator, only printed once |
| [in] | length | - length of a separator; negative values will result separator to be printed with a width of a terminal |
Example: Calling PrintSeparator("text", "", "|", "*", "|", 12) will print (note the spaces on the left and on the right since they contribute to the length)
|***text***|
| void CppTools::PrintSimpleSeparator | ( | const std::string & | leftEdge = "|", |
| const std::string & | body = "-", | ||
| const std::string & | rightEdge = "|", | ||
| int | length = -1 ) |
Prints vertical separator (with width of terminal by default).
| [in] | leftEdge | - left edge of a separator, only printed once |
| [in] | body | - body of a separator, can be printed multiple times to fill in the length. |
| [in] | rightEdge | - right edge of a separator, only printed once |
| [in] | length | - length of a separator; negative values will result separator to be printed with a width of a terminal |
Example: Calling PrintSimpleSeparator("|", "*", "|", 7) will print
|*****|