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

Functions

bool matches (std::string_view fieldValue, const Condition &condition)
 Applies a WHERE test to one value.
 
ResultSet fitted (std::vector< std::string > headers, std::vector< std::vector< std::string > > rows)
 Builds a result whose column widths fit the headers and the values (used by DESCRIBE).
 
std::string plural (std::size_t n, std::string_view word)
 Writes a count with a noun in singular or plural.
 
void checkName (std::string_view name, std::string_view what)
 Checks a new table or column name.
 

Variables

constexpr std::size_t kMaxNameLength = 20
 Longest table or column name: the width of the TABLE and FIELD columns of SYSTEM_TABLE.
 
constexpr std::size_t kMaxRecordLength = 99999
 Longest row: SYSTEM_TABLE keeps column positions in 5 characters.
 

Function Documentation

◆ checkName()

void tinysql::anonymous_namespace{Session.cpp}::checkName ( std::string_view  name,
std::string_view  what 
)

Checks a new table or column name.

Parameters
nameThe name.
what"table" or "column", for the error message.
Exceptions
SqlErrorUnless the name starts with a letter, has only letters, digits, _ and -, and is at most kMaxNameLength characters long.

Definition at line 91 of file Session.cpp.

◆ fitted()

ResultSet tinysql::anonymous_namespace{Session.cpp}::fitted ( std::vector< std::string >  headers,
std::vector< std::vector< std::string > >  rows 
)

Builds a result whose column widths fit the headers and the values (used by DESCRIBE).

Parameters
headersThe column titles.
rowsThe values, one inner vector per row.
Returns
The result set.

Definition at line 54 of file Session.cpp.

◆ matches()

bool tinysql::anonymous_namespace{Session.cpp}::matches ( std::string_view  fieldValue,
const Condition &  condition 
)

Applies a WHERE test to one value.

Parameters
fieldValueThe row's value in the tested column.
conditionThe test.
Returns
True if the value passes. LIKE matches a pattern, ignoring case (see matchesLike()). The other operators compare numbers as numbers when both sides are integers, otherwise as case-sensitive text.

Definition at line 26 of file Session.cpp.

◆ plural()

std::string tinysql::anonymous_namespace{Session.cpp}::plural ( std::size_t  n,
std::string_view  word 
)

Writes a count with a noun in singular or plural.

Parameters
nThe count.
wordThe noun in singular, e.g. "row".
Returns
E.g. "1 row" or "3 rows".

Definition at line 75 of file Session.cpp.

Variable Documentation

◆ kMaxNameLength

constexpr std::size_t tinysql::anonymous_namespace{Session.cpp}::kMaxNameLength = 20
constexpr

Longest table or column name: the width of the TABLE and FIELD columns of SYSTEM_TABLE.

Definition at line 81 of file Session.cpp.

◆ kMaxRecordLength

constexpr std::size_t tinysql::anonymous_namespace{Session.cpp}::kMaxRecordLength = 99999
constexpr

Longest row: SYSTEM_TABLE keeps column positions in 5 characters.

Definition at line 84 of file Session.cpp.