![]() |
mksqlite
2.5
A MATLAB interface to SQLite
|
Main routine class. More...
Public Types | |
enum | command_e { OPEN, CLOSE, QUERY, DONE, FAILED } |
Return values of cmdAnalyseCommand() | |
Public Member Functions | |
Mksqlite (int nlhs, mxArray **plhs, int nrhs, const mxArray **prhs) | |
Standard ctor. | |
void | Release () |
Release object. | |
~Mksqlite () | |
Dtor. | |
bool | errPending () |
Returns true, if any error is pending. | |
void | errClear () |
Clear recent error. | |
void | returnWithError () |
Terminate function. More... | |
bool | ensureDbIsOpen () |
Ensuring current database is open. More... | |
bool | warnOnDefDbid () |
Omits a warning if database is given but superfluous. More... | |
bool | assureSQLinterface () |
Creates a SQL interface if not already happen. | |
bool | argGetNextInteger (int &refValue, bool asBoolInt=false) |
Get next integer from argument list. More... | |
bool | argGetNextFcnHandle (const mxArray *&refValue) |
Get next value as function handle from argument list. More... | |
bool | argGetNextLiteral (const mxArray *&refValue) |
Get next value as literal argument from argument list. More... | |
bool | argTryReadValidDbid () |
Get database ID from argument list. More... | |
bool | argReadCommand () |
Get command from argument list. More... | |
bool | cmdTryHandleFlag (const char *strMatchFlagName, int &refFlag) |
Handle flag from command. More... | |
bool | cmdTryHandleVersion (const char *strCmdMatchVerMex, const char *strCmdMatchVerSql) |
Handle version commands. More... | |
bool | cmdTryHandleTypedBlob (const char *strCmdMatchName) |
Handle typed BLOB settings command. More... | |
bool | cmdTryHandleEnableExtension (const char *strCmdMatchName) |
Handle command to (en-/dis-)able loading extensions. More... | |
bool | cmdTryHandleCreateFunction (const char *strCmdMatchName) |
Handle command to create or delete a SQL user function. More... | |
bool | cmdTryHandleCreateAggregation (const char *strCmdMatchName) |
Handle command to create or delete a SQL user aggregate function. More... | |
bool | cmdTryHandleCompression (const char *strCmdMatchName) |
Handle compression setting command. More... | |
bool | cmdTryHandleStatus (const char *strCmdMatchName) |
Handle status command. More... | |
bool | cmdTryHandleLanguage (const char *strCmdMatchName) |
Handle language command. More... | |
bool | cmdTryHandleFilename (const char *strCmdMatchName) |
Get the filename of current database. More... | |
bool | cmdTryHandleStreaming (const char *strCmdMatchName) |
Handle streaming setting command. More... | |
bool | cmdTryHandleResultType (const char *strCmdMatchName) |
Handle result type command. More... | |
bool | cmdTryHandleSetBusyTimeout (const char *strCmdMatchName) |
Handle set busy timeout command. More... | |
bool | cmdTryHandleNonSqlStatement () |
Interpret current argument as command or switch. More... | |
command_e | cmdAnalyseCommand () |
Analyse command string and process if its neither open, close nor a sql command. More... | |
bool | cmdHandleOpen () |
Handle open command. More... | |
bool | cmdHandleClose () |
Handle close command. More... | |
ValueMex | createItemFromValueSQL (const ValueSQL &value) |
Transfer fetched SQL value into a MATLAB array. More... | |
mxArray * | createResultColNameMatrix (const ValueSQLCols &cols) |
Create a MATLAB cell array of column names. More... | |
mxArray * | createResultAsArrayOfStructs (ValueSQLCols &cols) |
Transform SQL fetch to MATLAB array of structs. More... | |
mxArray * | createResultAsStructOfArrays (ValueSQLCols &cols) |
Transform SQL fetch to MATLAB struct of arrays. More... | |
mxArray * | createResultAsMatrix (ValueSQLCols &cols) |
Transform SQL fetch to MATLAB (cell) array. More... | |
bool | cmdHandleSQLStatement () |
Handle common SQL statement. More... | |
bool | switchDBSlot (command_e command) |
Selects the desired slot from SQLStack for the operation. More... | |
void | cmdExecute () |
Execute the command string passed to mksqlite. | |
Private Member Functions | |
Inhibit assignment, default and copy ctors | |
Mksqlite () | |
Mksqlite (const Mksqlite &) | |
Mksqlite & | operator= (const Mksqlite &) |
Private Attributes | |
int | m_nlhs |
count of left hand side arguments | |
int | m_narg |
count of right hand side arguments | |
mxArray ** | m_plhs |
pointer to current left hand side argument | |
const mxArray ** | m_parg |
pointer to current right hand side argument | |
char * | m_command |
SQL command. Allocated and freed by this class. | |
const char * | m_query |
m_command , or a translation from m_command | |
int | m_dbid_req |
requested database id (user input) -1="arg missing", 0="next free slot" or 1..COUNT_DB | |
int | m_dbid |
selected database slot (1..COUNT_DB) | |
SQLerror | m_err |
recent error | |
SQLiface * | m_interface |
interface (holding current SQLite statement) to current database | |
Main routine class.
Definition at line 478 of file mksqlite.cpp.
|
inline |
Get next value as function handle from argument list.
[out] | refValue | Result will be returned in |
Read next parameter at current argument read position, and write to refValue
Definition at line 665 of file mksqlite.cpp.
References Err::set().
|
inline |
Get next integer from argument list.
[out] | refValue | Result will be returned in |
[in] | asBoolInt | If true, refValue will be true (1) or false (0) only |
Read an integer parameter at current argument read position, and write to refValue
(as 0 or 1 if asBoolInt
is set to true)
Definition at line 629 of file mksqlite.cpp.
References Err::set().
|
inline |
Get next value as literal argument from argument list.
[out] | refValue | Result will be returned in |
Read next parameter at current argument read position, and write to refValue
Definition at line 697 of file mksqlite.cpp.
References Err::set().
|
inline |
Get command from argument list.
Read the command from current argument position, always a string and thus asserted.
Definition at line 774 of file mksqlite.cpp.
References getLocaleMsg(), and PRINTF.
|
inline |
Get database ID from argument list.
Reads the next argument if it is numeric and a valid dbid. dbid must be in range 0..CONFIG_MAX_NUM_OF_DBS
, where 0 has the special meaning that the first free slot will later be used.
If the parameter is missing, m_dbid_req
will be set to -1. m_dbid
will be set to either -1 (argument missing) or a valid dbid 1..CONFIG_MAX_NUM_OF_DBS
Definition at line 729 of file mksqlite.cpp.
References SQLstack::isValidId(), and Err::set().
|
inline |
Analyse command string and process if its neither open, close nor a sql command.
Reads the command from the current argument position and test for switches or other commands. Switches were dispatched, other commands remain unhandled here.
Definition at line 1745 of file mksqlite.cpp.
References STRMATCH.
|
inline |
Handle close command.
Closes a database. If a dbid of 0 is given, all open dbs will be closed.
Definition at line 1897 of file mksqlite.cpp.
References Err::set().
|
inline |
Handle open command.
Handle the open command. If the read dbid is -1 a new slot (dbid) will be used, otherwise the given dbid or, if no dbid was given, the recent dbid is used.
Definition at line 1763 of file mksqlite.cpp.
References Err::set().
|
inline |
Handle common SQL statement.
The mksqlite command string will be delegated to the SQLite engine.
Definition at line 2222 of file mksqlite.cpp.
References MEM_ALLOC, Err::set(), and utils_latin2utf().
|
inline |
Handle compression setting command.
[in] | strCmdMatchName | Command name |
Try to interpret current command as compression setting. strCmdMatchName
holds the mksqlite command name. m_plhs[0] will be set to the old setting.
Definition at line 1197 of file mksqlite.cpp.
References STRMATCH.
|
inline |
Handle command to create or delete a SQL user aggregate function.
[in] | strCmdMatchName | Command name |
Try to interpret current command as to create a SQL user aggregate function strCmdMatchName
holds the mksqlite command name.
Definition at line 1116 of file mksqlite.cpp.
References Err::set(), and STRMATCH.
|
inline |
Handle command to create or delete a SQL user function.
[in] | strCmdMatchName | Command name |
Try to interpret current command as to create a SQL user function strCmdMatchName
holds the mksqlite command name.
Definition at line 1044 of file mksqlite.cpp.
References Err::set(), and STRMATCH.
|
inline |
Handle command to (en-/dis-)able loading extensions.
[in] | strCmdMatchName | Command name |
Try to interpret current command as setting for sqlite extension enable strCmdMatchName
holds the mksqlite command name.
Definition at line 993 of file mksqlite.cpp.
References Err::set(), and STRMATCH.
|
inline |
Get the filename of current database.
strCmdMatchName | Command name |
filename will be given in m_plhs[0]
Definition at line 1407 of file mksqlite.cpp.
References Err::set(), STRMATCH, and SQLstack::switchTo().
|
inline |
Handle flag from command.
[in] | strMatchFlagName | Name of flag to test |
[out] | refFlag | Flag value if name matched |
Test current command as flag parameter with it's new value. strMatchFlagName
holds the name of the flag to test.
Definition at line 815 of file mksqlite.cpp.
References Err::set(), and STRMATCH.
|
inline |
Handle language command.
[in] | strCmdMatchName | Command name |
Try to interpret current command as status command. strCmdMatchName
holds the mksqlite command name.
Definition at line 1357 of file mksqlite.cpp.
References Err::set(), and STRMATCH.
|
inline |
Interpret current argument as command or switch.
Checking following commands:
Definition at line 1695 of file mksqlite.cpp.
References g_check4uniquefields, g_convertUTF8, and g_NULLasNaN.
|
inline |
Handle result type command.
[in] | strCmdMatchName | Command name |
Try to interpret current command as result type. strCmdMatchName
holds the mksqlite command name. m_plhs[0] will be set to the old setting.
Definition at line 1538 of file mksqlite.cpp.
References g_result_type, Err::set(), and STRMATCH.
|
inline |
Handle set busy timeout command.
[in] | strCmdMatchName | Command name |
Try to interpret current command as busy timeout switch. strCmdMatchName
holds the mksqlite command name. m_plhs[0] will be set to the old setting.
Definition at line 1611 of file mksqlite.cpp.
References Err::set(), and STRMATCH.
|
inline |
Handle status command.
[in] | strCmdMatchName | Command name |
Try to interpret current command as status command. strCmdMatchName
holds the mksqlite command name.
Definition at line 1299 of file mksqlite.cpp.
References Err::set(), and STRMATCH.
|
inline |
Handle streaming setting command.
[in] | strCmdMatchName | Command name |
Try to interpret current command as streaming switch. strCmdMatchName
holds the mksqlite command name. m_plhs[0] will be set to the old setting.
Definition at line 1475 of file mksqlite.cpp.
References Err::set(), and STRMATCH.
|
inline |
Handle typed BLOB settings command.
[in] | strCmdMatchName | Command name |
Try to interpret current command as blob mode setting strCmdMatchName
hold the mksqlite command name. m_plhs[0] will be set to the old setting.
Definition at line 922 of file mksqlite.cpp.
References g_streaming, Err::set(), STRMATCH, and typed_blobs_mode_on().
|
inline |
Handle version commands.
[in] | strCmdMatchVerMex | Command name to get mex version |
[in] | strCmdMatchVerSql | Command name to get SQLite version |
Test current command as version query to sqlite or mksqlite version numbers. strCmdMatchVerMex
and strCmdMatchVerSql
hold the mksqlite command names. m_plhs[0] will be set to the corresponding version string.
Definition at line 857 of file mksqlite.cpp.
References Err::set(), and STRMATCH.
Transfer fetched SQL value into a MATLAB array.
[in] | value | encapsulated SQL field value |
Definition at line 1939 of file mksqlite.cpp.
|
inline |
Transform SQL fetch to MATLAB array of structs.
[in] | cols | container for SQLite fetched table |
Definition at line 2007 of file mksqlite.cpp.
References Err::set().
|
inline |
Transform SQL fetch to MATLAB (cell) array.
[in] | cols | SQLite fetched table |
Definition at line 2149 of file mksqlite.cpp.
References Err::set().
|
inline |
Transform SQL fetch to MATLAB struct of arrays.
[in] | cols | container for SQLite fetched table |
Definition at line 2067 of file mksqlite.cpp.
References Err::set().
|
inline |
Create a MATLAB cell array of column names.
[in] | cols | container for SQLite fetched table |
Definition at line 1963 of file mksqlite.cpp.
References Err::set(), and utils_destroy_array().
|
inline |
Ensuring current database is open.
Sets m_err
to MSG_DBNOTOPEN, if not.
Definition at line 576 of file mksqlite.cpp.
References SQLiface::isOpen(), and Err::set().
|
inline |
Terminate function.
Aborts the running function with an error message. Allocated memory (by MATLAB allocation functions) is freed automatically
Definition at line 558 of file mksqlite.cpp.
References Err::get().
Referenced by mexFunction().
|
inline |
Selects the desired slot from SQLStack for the operation.
command | User operation (or query) on database |
Definition at line 2595 of file mksqlite.cpp.
References Err::set().
|
inline |
Omits a warning if database is given but superfluous.
Definition at line 594 of file mksqlite.cpp.
References getLocaleMsg().