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

Classes

struct  Options
 The command-line options, after parsing. More...
 

Functions

std::vector< std::string > splitList (std::string_view text)
 Splits a comma-separated list.
 
Options parseOptions (int argc, char **argv)
 Parses the command line. Options take their value as --name=value or --name value.
 
int runScript (Session &session, std::istream &in)
 Runs a whole script and prints every result.
 
int runInteractive (Session &session)
 Reads statements at a tinysql> prompt until end of input (Ctrl+D).
 

Variables

constexpr std::string_view kUsage
 The text printed by --help and after a wrong option.
 

Function Documentation

◆ parseOptions()

Options anonymous_namespace{main.cpp}::parseOptions ( int  argc,
char **  argv 
)

Parses the command line. Options take their value as --name=value or --name value.

Parameters
argcNumber of arguments, as given to main().
argvThe arguments, as given to main().
Returns
The options.
Exceptions
std::invalid_argumentOn an unknown option, a missing or bad value, or --sqlfile together with --http.

Definition at line 75 of file main.cpp.

◆ runInteractive()

int anonymous_namespace{main.cpp}::runInteractive ( Session &  session)

Reads statements at a tinysql> prompt until end of input (Ctrl+D).

Parameters
sessionThe session to run them in.
Returns
The exit code, always 0.

Definition at line 148 of file main.cpp.

◆ runScript()

int anonymous_namespace{main.cpp}::runScript ( Session &  session,
std::istream &  in 
)

Runs a whole script and prints every result.

Parameters
sessionThe session to run it in.
inWhere to read the script from (a file or standard input).
Returns
The exit code: 0 if every statement succeeded, 1 otherwise.

Definition at line 131 of file main.cpp.

◆ splitList()

std::vector< std::string > anonymous_namespace{main.cpp}::splitList ( std::string_view  text)

Splits a comma-separated list.

Parameters
textE.g. "127.,192.168.".
Returns
The non-empty items.

Definition at line 57 of file main.cpp.

Variable Documentation

◆ kUsage

constexpr std::string_view anonymous_namespace{main.cpp}::kUsage
constexpr
Initial value:
= R"(Usage: myTinySql [options]
--sqlfile=FILE run the statements in FILE ('-' for standard input)
--http start the browser server (default port 8080)
--port=N listen on port N instead of 8080
--allow=LIST comma-separated client IP prefixes the server accepts,
e.g. 127.,192.168. (default: everyone)
--data=DIR directory with SYSTEM_TABLE and the *_DATA files (default: data)
--web=DIR directory with the browser page's files (default: web)
--help show this help
With no --sqlfile and no --http, statements are read from standard input.
)"

The text printed by --help and after a wrong option.

Definition at line 30 of file main.cpp.