2013 March 15
The author disclaims copyright to this source code. In place of a legal notice, here is a blessing:
May you do good and not evil. May you find forgiveness for yourself and forgive others. May you share freely, never taking more than you give.
Definition in file xpath.c.#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <libxml/xpath.h>
#include <sqlite3ext.h>
Go to the source code of this file.
Data Structures | |
struct | XCSR |
Structure to describe virtual table cursor. More... | |
struct | XDOC |
Structure to cache XML document. More... | |
struct | XEXP |
Structure to describe XPath expression. More... | |
struct | XMOD |
Structure holding per module/database data. More... | |
struct | XTAB |
Structure to describe virtual table. More... | |
Typedefs | |
typedef XDOC | XDOC |
typedef XMOD | XMOD |
typedef XTAB | XTAB |
typedef XEXP | XEXP |
typedef XCSR | XCSR |
Functions | |
int | xpath_connect (sqlite3 *db, void *aux, int argc, const char *const *argv, sqlite3_vtab **vtabp, char **errp) |
Connect to virtual table. | |
int | xpath_create (sqlite3 *db, void *aux, int argc, const char *const *argv, sqlite3_vtab **vtabp, char **errp) |
Create virtual table. | |
int | xpath_disconnect (sqlite3_vtab *vtab) |
Disconnect virtual table. | |
int | xpath_destroy (sqlite3_vtab *vtab) |
Destroy virtual table. | |
int | xpath_bestindex (sqlite3_vtab *vtab, sqlite3_index_info *info) |
Determines information for filter function according to constraints. | |
int | xpath_open (sqlite3_vtab *vtab, sqlite3_vtab_cursor **cursorp) |
Open virtual table and return cursor. | |
int | xpath_close (sqlite3_vtab_cursor *cursor) |
Close virtual table cursor. | |
int | xpath_next (sqlite3_vtab_cursor *cursor) |
Retrieve next row from virtual table cursor. | |
int | xpath_filter (sqlite3_vtab_cursor *cursor, int idxNum, const char *idxStr, int argc, sqlite3_value **argv) |
Filter function for virtual table. | |
int | xpath_eof (sqlite3_vtab_cursor *cursor) |
Return end of table state of virtual table cursor. | |
int | xpath_column (sqlite3_vtab_cursor *cursor, sqlite3_context *ctx, int n) |
Return column data of virtual table. | |
int | xpath_rowid (sqlite3_vtab_cursor *cursor, sqlite3_int64 *rowidp) |
Return current rowid of virtual table cursor. | |
int | xpath_update (sqlite3_vtab *vtab, int argc, sqlite3_value **argv, sqlite3_int64 *rowidp) |
Insert/delete row into/from virtual table. | |
void | xpath_vfunc_common (sqlite3_context *ctx, int conv, int argc, sqlite3_value **argv) |
Common XPath select function for virtual table. | |
void | xpath_vfunc_string (sqlite3_context *ctx, int argc, sqlite3_value **argv) |
XPath select function returning string value from virtual table. | |
void | xpath_vfunc_boolean (sqlite3_context *ctx, int argc, sqlite3_value **argv) |
XPath select function returning boolean value from virtual table. | |
void | xpath_vfunc_number (sqlite3_context *ctx, int argc, sqlite3_value **argv) |
XPath select function returning number from virtual table. | |
void | xpath_vfunc_xml (sqlite3_context *ctx, int argc, sqlite3_value **argv) |
XPath select function returning XML from virtual table. | |
int | xpath_findfunc (sqlite3_vtab *vtab, int nargs, const char *name, void(**pfunc)(sqlite3_context *, int, sqlite3_value **), void **parg) |
Find overloaded function on virtual table. | |
void | xpath_func_common (sqlite3_context *ctx, int conv, int argc, sqlite3_value **argv) |
Common XPath select function. | |
void | xpath_func_string (sqlite3_context *ctx, int argc, sqlite3_value **argv) |
XPath select function returning string value. | |
void | xpath_func_boolean (sqlite3_context *ctx, int argc, sqlite3_value **argv) |
XPath select function returning boolean value. | |
void | xpath_func_number (sqlite3_context *ctx, int argc, sqlite3_value **argv) |
XPath select function returning number. | |
void | xpath_func_xml (sqlite3_context *ctx, int argc, sqlite3_value **argv) |
XPath select function returning XML. | |
void | xpath_func_dump (sqlite3_context *ctx, int argc, sqlite3_value **argv) |
Function to dump XML document. | |
void | xpath_fini (void *aux) |
Module finalizer. | |
int | xpath_init (sqlite3 *db) |
Module initializer creating SQLite module and functions. | |
int | sqlite3_extension_init (sqlite3 *db, char **errmsg, const sqlite3_api_routines *api) |
Initializer for SQLite extension load mechanism. | |
Variables | |
int | initialized = 0 |
XMOD * | xmod = 0 |
sqlite3_module | xpath_mod |
SQLite module descriptor. |
|
|
|
|
|
|
|
|
|
|
|
Initializer for SQLite extension load mechanism.
Definition at line 1658 of file xpath.c. References xpath_init(). Referenced by impexp_init(). |
|
Determines information for filter function according to constraints.
|
|
Close virtual table cursor.
Definition at line 290 of file xpath.c. References XCSR::cursor, XCSR::first, XEXP::next, XEXP::pctx, XEXP::pobj, and XTAB::xc. |
|
Return column data of virtual table.
Definition at line 461 of file xpath.c. References XCSR::cursor, XDOC::doc, XMOD::docs, XTAB::idocs, XTAB::ndoc, XCSR::pos, and XTAB::xm. |
|
Connect to virtual table.
argv[0] - module name Definition at line 135 of file xpath.c. References XTAB::db, XTAB::idocs, XTAB::ndoc, XTAB::sdoc, XTAB::vtab, XTAB::xc, and XTAB::xm. Referenced by xpath_create(). |
|
Create virtual table.
Definition at line 191 of file xpath.c. References xpath_connect(). |
|
Destroy virtual table.
Definition at line 242 of file xpath.c. References xpath_disconnect(). |
|
Disconnect virtual table.
Definition at line 205 of file xpath.c. References XDOC::doc, XMOD::docs, XTAB::idocs, XMOD::mutex, XMOD::ndoc, XTAB::ndoc, XDOC::refcnt, XMOD::sdoc, and XTAB::xm. Referenced by xpath_destroy(). |
|
Return end of table state of virtual table cursor.
Definition at line 444 of file xpath.c. References XCSR::cursor, XTAB::ndoc, and XCSR::pos. |
|
Filter function for virtual table.
Definition at line 426 of file xpath.c. References XCSR::cursor, XCSR::pos, XTAB::xc, and xpath_next(). |
|
Find overloaded function on virtual table.
Definition at line 1008 of file xpath.c. References xpath_vfunc_boolean(), xpath_vfunc_number(), xpath_vfunc_string(), and xpath_vfunc_xml(). |
|
Module finalizer.
Definition at line 1518 of file xpath.c. References XDOC::doc, XMOD::docs, initialized, XMOD::mutex, XMOD::ndoc, XDOC::refcnt, XMOD::refcnt, and XMOD::sdoc. Referenced by xpath_init(). |
|
XPath select function returning boolean value.
Definition at line 1259 of file xpath.c. References xpath_func_common(). Referenced by xpath_init(). |
|
Common XPath select function.
SELECT xpath_string(<docid>, '//book/title');
The <docid> argument is the DOCID value of a row in a virtual table. Otherwise a string containing an XML document is expected. The optional arguments are Definition at line 1106 of file xpath.c. References XDOC::doc, XMOD::docs, XMOD::mutex, XDOC::refcnt, and XMOD::sdoc. Referenced by xpath_func_boolean(), xpath_func_number(), xpath_func_string(), and xpath_func_xml(). |
|
Function to dump XML document.
SELECT xml_dump(<docid>, <encoding> <fmt>) The <docid> argument is the DOCID value of a row in a virtual table. The <encoding> argument is the optional encoding (default UTF-8). The <fmt> argument is the optional formatting flag for the xmlDocDumpFormatMemoryEnc() libxml2 function. Definition at line 1308 of file xpath.c. References XDOC::doc, XMOD::docs, XMOD::mutex, and XMOD::sdoc. Referenced by xpath_init(). |
|
XPath select function returning number.
Definition at line 1272 of file xpath.c. References xpath_func_common(). Referenced by xpath_init(). |
|
XPath select function returning string value.
Definition at line 1246 of file xpath.c. References xpath_func_common(). Referenced by xpath_init(). |
|
XPath select function returning XML.
Definition at line 1285 of file xpath.c. References xpath_func_common(). Referenced by xpath_init(). |
|
Module initializer creating SQLite module and functions.
Definition at line 1571 of file xpath.c. References XMOD::docs, initialized, XMOD::mutex, XMOD::ndoc, XMOD::refcnt, XMOD::sdoc, xpath_fini(), xpath_func_boolean(), xpath_func_dump(), xpath_func_number(), xpath_func_string(), xpath_func_xml(), and xpath_mod. Referenced by sqlite3_extension_init(). |
|
Retrieve next row from virtual table cursor.
Definition at line 321 of file xpath.c. References XCSR::cursor, XCSR::first, XTAB::ndoc, XCSR::nexpr, XEXP::next, XEXP::parent, XEXP::pobj, XEXP::pos, and XCSR::pos. Referenced by xpath_filter(). |
|
Open virtual table and return cursor.
Definition at line 268 of file xpath.c. References XCSR::cursor, XCSR::first, XCSR::last, XCSR::nexpr, and XCSR::pos. |
|
Return current rowid of virtual table cursor.
Definition at line 505 of file xpath.c. References XCSR::cursor, XDOC::doc, XMOD::docs, XTAB::idocs, XCSR::pos, and XTAB::xm. |
|
Insert/delete row into/from virtual table.
CREATE VIRTUAL TABLE X USING xpath(); Virtual table columns:
DOCID - document identifier and ROWID All columns except DOCID are hidden. UPDATE on the virtual table is not supported. Default parser options are XML_PARSE_NOERROR, XML_PARSE_NOWARNING, and XML_PARSE_NONET. Definition at line 550 of file xpath.c. References XDOC::doc, XMOD::docs, XTAB::idocs, XMOD::mutex, XMOD::ndoc, XTAB::ndoc, XDOC::refcnt, XTAB::sdoc, XMOD::sdoc, and XTAB::xm. |
|
XPath select function returning boolean value from virtual table.
Definition at line 966 of file xpath.c. References xpath_vfunc_common(). Referenced by xpath_findfunc(). |
|
Common XPath select function for virtual table.
CREATE VIRTUAL TABLE X USING xpath(); The RHS of the xpath_* functions should be a constant string. Definition at line 757 of file xpath.c. References XEXP::conv, XEXP::doc, XDOC::doc, XMOD::docs, XEXP::expr, XCSR::first, XTAB::idocs, XCSR::last, XTAB::ndoc, XCSR::nexpr, XEXP::next, XEXP::parent, XEXP::pctx, XEXP::pobj, XEXP::pos, XCSR::pos, XEXP::prev, XTAB::xc, and XTAB::xm. Referenced by xpath_vfunc_boolean(), xpath_vfunc_number(), xpath_vfunc_string(), and xpath_vfunc_xml(). |
|
XPath select function returning number from virtual table.
Definition at line 979 of file xpath.c. References xpath_vfunc_common(). Referenced by xpath_findfunc(). |
|
XPath select function returning string value from virtual table.
Definition at line 953 of file xpath.c. References xpath_vfunc_common(). Referenced by xpath_findfunc(). |
|
XPath select function returning XML from virtual table.
Definition at line 992 of file xpath.c. References xpath_vfunc_common(). Referenced by xpath_findfunc(). |
|
Definition at line 66 of file xpath.c. Referenced by xpath_fini(), and xpath_init(). |
|
|
|
Initial value: { 1, xpath_create, xpath_connect, xpath_bestindex, xpath_disconnect, xpath_destroy, xpath_open, xpath_close, xpath_filter, xpath_next, xpath_eof, xpath_column, xpath_rowid, xpath_update, 0, 0, 0, 0, xpath_findfunc, }
Definition at line 1058 of file xpath.c. Referenced by xpath_init(). |