|
myTinySQL v0.2.0-2-g5000098
A tiny SQL interpreter over fixed-width text files
|
Console text, and the JSON answers of the browser server's API. More...
Go to the source code of this file.
Functions | |
| 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. | |
| std::string | tinysql::anonymous_namespace{Output.cpp}::headerLine (const ResultSet &table) |
Builds the dashed header line of a console table, e.g. ID-------- NOME----. | |
| 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. | |
| std::string | tinysql::renderText (const StatementResult &result) |
| Formats one result for the console. | |
| std::string | tinysql::renderJson (const std::vector< StatementResult > &results) |
Builds the JSON answer of POST /api/sql: one object per statement that has something to show. | |
| std::string | tinysql::renderTablesJson (const std::vector< TableSchema > &tables) |
Builds the JSON answer of GET /api/tables: every table with its columns. | |
Console text, and the JSON answers of the browser server's API.
Definition in file Output.cpp.
| std::string tinysql::renderJson | ( | const std::vector< StatementResult > & | results | ) |
Builds the JSON answer of POST /api/sql: one object per statement that has something to show.
Example: {"results":[{"sql":"DELETE FROM EMPLOY WHERE ID = 3","ok":true,"message":"1 row deleted from EMPLOY", "table":"EMPLOY"}]}. A SELECT or DESCRIBE also has "columns" (name, width in the data file, and whether the browser may edit the cell), "rows" (arrays of strings) and "idColumn" (index of the ID, or null).
| results | The results of a script, in order; silent ones (COLUMN, comments) are left out. |
Definition at line 95 of file Output.cpp.
| std::string tinysql::renderTablesJson | ( | const std::vector< TableSchema > & | tables | ) |
Builds the JSON answer of GET /api/tables: every table with its columns.
Example: {"tables":[{"name":"EMPLOY","readOnly":false,"autoId":true,"columns":[{"name":"ID","width":10},...]}]}. readOnly is true for SYSTEM_TABLE, which the page must not change.
| tables | The tables, from Catalog::tables(). |
Definition at line 131 of file Output.cpp.
| std::string tinysql::renderText | ( | const StatementResult & | result | ) |
Formats one result for the console.
| result | The result of one statement. |
Definition at line 67 of file Output.cpp.