myTinySQL v0.2.0-2-g5000098
A tiny SQL interpreter over fixed-width text files
Loading...
Searching...
No Matches
Functions
tinysql::anonymous_namespace{Output.cpp} Namespace Reference

Functions

std::string fit (std::string_view text, std::size_t width, char filler)
 Cuts or pads text to an exact width.
 
std::string headerLine (const ResultSet &table)
 Builds the dashed header line of a console table, e.g. ID-------- NOME----.
 
std::string jsonString (std::string_view text)
 Writes text as a JSON string: in double quotes, with quotes, backslashes and control characters escaped.
 

Function Documentation

◆ fit()

std::string tinysql::anonymous_namespace{Output.cpp}::fit ( std::string_view  text,
std::size_t  width,
char  filler 
)

Cuts or pads text to an exact width.

Parameters
textThe text.
widthThe width wanted.
fillerThe character used for padding (space for values, dash for headers).
Returns
Exactly width characters.

Definition at line 19 of file Output.cpp.

◆ headerLine()

std::string tinysql::anonymous_namespace{Output.cpp}::headerLine ( const ResultSet &  table)

Builds the dashed header line of a console table, e.g. ID-------- NOME----.

Parameters
tableThe result set.
Returns
The header line, columns separated by one space.

Definition at line 29 of file Output.cpp.

◆ jsonString()

std::string tinysql::anonymous_namespace{Output.cpp}::jsonString ( std::string_view  text)

Writes text as a JSON string: in double quotes, with quotes, backslashes and control characters escaped.

Parameters
textAny text (UTF-8 is passed through unchanged).
Returns
The JSON string; for example, the text say "hi" becomes "say \"hi\"".

Definition at line 44 of file Output.cpp.