blobtoxy.c File Reference

SQLite extension module for read-only BLOB to X/Y mapping using SQLite 3.3.x virtual table API plus some useful scalar and aggregate functions. More...

#include <sqlite3ext.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>

Go to the source code of this file.

Data Structures

struct  b2xy_table
 Structure to describe a virtual table. More...
 
struct  b2xy_cursor
 Structure to describe a cursor in the virtual table. More...
 
struct  strbuf
 Internal dynamic string buffer. More...
 
struct  path_aggctx
 Internal aggregate context for path/polyline function. More...
 
struct  rownumber_ctx
 SQLite context structure for "rownumber" function. More...
 

Macros

#define TYPE_CODE(num, type)
 
#define TYPE_SIZE(code)
 
#define TYPE_CHAR   TYPE_CODE( 0, char)
 
#define TYPE_UCHAR   TYPE_CODE( 1, char)
 
#define TYPE_SHORT_LE   TYPE_CODE( 2, short)
 
#define TYPE_USHORT_LE   TYPE_CODE( 3, short)
 
#define TYPE_SHORT_BE   TYPE_CODE( 4, short)
 
#define TYPE_USHORT_BE   TYPE_CODE( 5, short)
 
#define TYPE_INT_LE   TYPE_CODE( 6, int)
 
#define TYPE_UINT_LE   TYPE_CODE( 7, int)
 
#define TYPE_INT_BE   TYPE_CODE( 8, int)
 
#define TYPE_UINT_BE   TYPE_CODE( 9, int)
 
#define TYPE_BIGINT_LE   TYPE_CODE(10, sqlite_int64)
 
#define TYPE_BIGINT_BE   TYPE_CODE(11, sqlite_int64)
 
#define TYPE_FLOAT   TYPE_CODE(12, float)
 
#define TYPE_DOUBLE   TYPE_CODE(13, double)
 
#define PATH_MODE_TK   ((void *) 0)
 
#define PATH_MODE_SVG   ((void *) 1)
 
#define PATH_MODE_BLT_X   ((void *) 2)
 
#define PATH_MODE_BLT_Y   ((void *) 3)
 
#define PATH_MODE_BLT   ((void *) 4)
 
#define PATH_MODE_TK3D   ((void *) 5)
 

Typedefs

typedef struct b2xy_table b2xy_table
 
typedef struct b2xy_cursor b2xy_cursor
 

Functions

static int string_to_type (const char *str)
 Map type string to type code.
 
static int b2xy_destroy (sqlite3_vtab *vtab)
 Destroy virtual table.
 
static int b2xy_create (sqlite3 *db, void *userdata, int argc, const char *const *argv, sqlite3_vtab **vtabret, char **errp)
 Create virtual table.
 
static int b2xy_open (sqlite3_vtab *vtab, sqlite3_vtab_cursor **curret)
 Open virtual table and return cursor.
 
static int b2xy_close (sqlite3_vtab_cursor *cur)
 Close virtual table cursor.
 
static int b2xy_column (sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i)
 Return column data of virtual table.
 
static int b2xy_rowid (sqlite3_vtab_cursor *cur, sqlite_int64 *rowidp)
 Return current rowid of virtual table cursor.
 
static int b2xy_eof (sqlite3_vtab_cursor *cur)
 Return end of table state of virtual table cursor.
 
static int b2xy_next (sqlite3_vtab_cursor *cur)
 Retrieve next row from virtual table cursor.
 
static int b2xy_filter (sqlite3_vtab_cursor *cur, int idxNum, const char *idxStr, int argc, sqlite3_value **argv)
 Filter function for virtual table.
 
static int b2xy_bestindex (sqlite3_vtab *tab, sqlite3_index_info *info)
 Determines information for filter function according to constraints.
 
static int init_strbuf (strbuf *sb)
 Initialize dynamic string buffer with capacity 1024.
 
static int expand_strbuf (strbuf *sb)
 Expand or initialize dynamic string buffer.
 
static void drop_strbuf (strbuf *sb)
 Free resources of dynamic string buffer.
 
static int print_strbuf (strbuf *sb, const char *fmt,...)
 Format printf-like into dynamic string buffer.
 
static void common_path_func (sqlite3_context *ctx, int nargs, sqlite3_value **args)
 Make path/polyline from blob.
 
static void common_path_step (sqlite3_context *ctx, int nargs, sqlite3_value **args)
 Path/polyline step callback for "tk_path", "svg_path", and "tk3d_path" aggregate functions.
 
static void common_path_finalize (sqlite3_context *ctx)
 Path/polyline finalizer.
 
static void blt_vec_step (sqlite3_context *ctx, int nargs, sqlite3_value **args)
 Path/polyline step callback for "blt_vec" aggregate functions.
 
static void subblob_func (sqlite3_context *ctx, int nargs, sqlite3_value **args)
 "subblob" function similar to "substr".
 
static void rownumber_func (sqlite3_context *ctx, int nargs, sqlite3_value **args)
 "rownumber" function.
 
static int b2xy_init (sqlite3 *db)
 Module initializer creating SQLite functions and modules.
 
int sqlite3_extension_init (sqlite3 *db, char **errmsg, const sqlite3_api_routines *api)
 Initializer for SQLite extension load mechanism.
 

Variables

static const sqlite3_module b2xy_module
 

Detailed Description

SQLite extension module for read-only BLOB to X/Y mapping using SQLite 3.3.x virtual table API plus some useful scalar and aggregate functions.

Id
blobtoxy.c,v 1.27 2020/06/13 11:04:17 chw Exp chw

Copyright (c) 2007-2020 Christian Werner chw@c.nosp@m.h-we.nosp@m.rner..nosp@m.de

See the file "license.terms" for information on usage and redistribution of this file and for a DISCLAIMER OF ALL WARRANTIES.

Usage:

Master (non-virtual) table:

CREATE TABLE t( key INTEGER PRIMARY KEY, data BLOB, scale DOUBLE, offset DOUBLE, foo TEXT, bar TEXT );

BLOB to X/Y mapping:

CREATE VIRTUAL TABLE t1 USING blobtoxy (t, key, data, short_le, x_scale, x_offset, y_scale, y_offset, "foo, bar");
CREATE VIRTUAL TABLE t2 USING blobtoxy (t, key, data, uchar, null, null, null, null, 'bar');
CREATE VIRTUAL TABLE t3 USING blobtoxy (t, key, data, int_be, 10.0, null, 10.0, null, "foo");
CREATE VIRTUAL TABLE t4 USING blobtoxy (t, key, data, float, null, -10, null, 10);

Arguments to "blobtoxy" module:

  1. master table name (required).
  2. key column in master table (required).
  3. blob column in master table (required).
  4. type code (optional), defaults to "char".
  5. X scale column in master table (optional), may be specified as integer or float constant, too, to explicitely omit scale, use an empty string ('') or null.
  6. X offset column in master table (optional), may be specified as integer or float constant, too, to explicitely omit offset, use an empty string ('') or null.
  7. Y scale column in master table (optional), see point 4.
  8. Y offset column in master table (optional), see point 5.
  9. other columns of the master table to appear in the result set (optional), must be specified as a single or double quoted string with comma separated column names as a sequence of named columns as it would be written in a SELECT statement.
  10. X start index (optional), specified as integer in type specific blob units, zero based.

X length (optional), specified as integer, number of blob units (= number of rows).

Supported data types:

"char" -> BLOB is a signed char array
"uchar" -> BLOB is an unsigned char array
"short_le" -> BLOB is a short array little endian
"short_be" -> BLOB is a short array big endian
"ushort_le" -> BLOB is an unsigned short array little endian
"ushort_be" -> BLOB is an unsigned short array big endian
"int_le" -> BLOB is a int array little endian
"int_be" -> BLOB is a int array big endian
"uint_le" -> BLOB is an unsigned int array little endian
"uint_be" -> BLOB is an unsigned int array big endian
"bigint_le" -> BLOB is an large integer array little endian
"bigint_be" -> BLOB is an large integer array big endian
"float" -> BLOB is a float array
"double" -> BLOB is a double array

Columns of "blobtoxy" mapped virtual table:

"key" Key column for JOINing with master table
"x" index within BLOB.
This value is optionally translated by the "x_scale" and "x_offset" columns i.e. x' = x * x_scale + x_offset, yielding a floating point result.
"y" BLOB's value at "x"-unscaled-index
This value is optionally translated by the "y_scale" and "y_offset" columns i.e. y' = y * y_scale + y_offset, yielding a floating point result.
... Other columns, see above

If the "key" field of the master table is an integer data type, it is used as the ROWID of the mapped virtual table. Otherwise the ROWID is a 0-based counter of the output rows.

Exported SQLite functions (svg|tk)_path[from_blob], blt_vec(x|y)

Scalar context:

svg_path_from_blob(data, type, x_scale, x_offset, y_scale, y_offset)
tk_path_from_blob(data, type, x_scale, x_offset, y_scale, y_offset)
blt_vec_(x|y)(data, type, x_scale, x_offset, y_scale, y_offset)
tk3d_path_from_blob(data, type, x_scale, x_offset, y_scale, y_offset, z_value, z_scale, z_offset)

Like BLOB to X/Y mapping but produces SVG or Tk Canvas path/polyline as a string, e.g.

SVG: "M 1 1 L 2 2 L 3 7 L 4 1<br> Tk Canvas: "1 1 2 2 3 7 4 1"<br> BLT Vector X: "1 2 3 4"<br> BLT Vector Y: "1 2 7 1"<br> Tk 3D Canvas: "1 1 0 2 2 0 3 7 0 4 1 0"<br> Arguments: 0. blob data (required); this parameter is always interpreted as blob. It must contain at least two elements, otherwise the function's result is NULL to indicate that nothing need be drawn<br> 1. type code (optional), defaults to "char"

  1. X scale (optional), see above
  2. X offset (optional), see above
  3. Y scale (optional), see above
  4. Y offset (optional), see above
  5. Z value (optional)
  6. Z scale (optional)
  7. Z offset (optional)

Aggregate context:

svg_path(xdata, ydata, x_scale, x_offset, y_scale, y_offset)
tk_path(xdata, ydata, x_scale, x_offset, y_scale, y_offset)
blt_vec(data, scale, offset)
tk3d_path(xdata, ydata, x_scale, x_offset, y_scale, y_offset, zdata, z_scale, z_offset)

Same behaviour except that xdata/ydata/data/zdata are interpreted directly as numeric values.

Exported SQLite function subblob

subblob(data, start, length, size, skip)

Works somewhat like substr, e.g.

select quote(subblob(X'0A0B0C0D0E0F0001',2,2,1,3))
-> X'0B0F'

Arguments:

  1. blob data (required); this parameter is always interpreted as blob.
  2. start offset (required) in bytes as in substr function (1-based, negative offsets count from end)
  3. length (required) in bytes to be copied
  4. size (optional) of items in bytes to be copied in combination with skip argument
  5. skip (optional) in bytes after one item of size argument has been copied

Exported SQLite function rownumber

rownumber(any)

Returns the row number counting from 0 in simple selects. An arbitrary dummy but constant argument must be provided to this function in order to satisfy some needs of the SQLite3 C API, e.g.

rownumber(0), rownumber('foo') right
rownumber(column_name) wrong, will yield always 0

Definition in file blobtoxy.c.

Macro Definition Documentation

◆ PATH_MODE_BLT

#define PATH_MODE_BLT   ((void *) 4)

Definition at line 1318 of file blobtoxy.c.

Referenced by b2xy_init(), blt_vec_step(), and common_path_finalize().

◆ PATH_MODE_BLT_X

#define PATH_MODE_BLT_X   ((void *) 2)

Definition at line 1316 of file blobtoxy.c.

Referenced by b2xy_init(), and common_path_func().

◆ PATH_MODE_BLT_Y

#define PATH_MODE_BLT_Y   ((void *) 3)

Definition at line 1317 of file blobtoxy.c.

Referenced by b2xy_init(), and common_path_func().

◆ PATH_MODE_SVG

#define PATH_MODE_SVG   ((void *) 1)

Definition at line 1315 of file blobtoxy.c.

Referenced by b2xy_init(), common_path_func(), and common_path_step().

◆ PATH_MODE_TK

#define PATH_MODE_TK   ((void *) 0)

Definition at line 1314 of file blobtoxy.c.

Referenced by b2xy_init().

◆ PATH_MODE_TK3D

#define PATH_MODE_TK3D   ((void *) 5)

Definition at line 1319 of file blobtoxy.c.

Referenced by b2xy_init(), common_path_func(), and common_path_step().

◆ TYPE_BIGINT_BE

#define TYPE_BIGINT_BE   TYPE_CODE(11, sqlite_int64)

Definition at line 218 of file blobtoxy.c.

Referenced by b2xy_column(), and string_to_type().

◆ TYPE_BIGINT_LE

#define TYPE_BIGINT_LE   TYPE_CODE(10, sqlite_int64)

Definition at line 217 of file blobtoxy.c.

Referenced by b2xy_column(), and string_to_type().

◆ TYPE_CHAR

#define TYPE_CHAR   TYPE_CODE( 0, char)

Definition at line 207 of file blobtoxy.c.

Referenced by b2xy_column(), b2xy_create(), common_path_func(), and string_to_type().

◆ TYPE_CODE

#define TYPE_CODE ( num,
type )
Value:
(((num) << 8) | (sizeof (type)))

Definition at line 204 of file blobtoxy.c.

◆ TYPE_DOUBLE

#define TYPE_DOUBLE   TYPE_CODE(13, double)

Definition at line 220 of file blobtoxy.c.

Referenced by b2xy_column(), b2xy_create(), common_path_func(), and string_to_type().

◆ TYPE_FLOAT

#define TYPE_FLOAT   TYPE_CODE(12, float)

Definition at line 219 of file blobtoxy.c.

Referenced by b2xy_column(), b2xy_create(), common_path_func(), and string_to_type().

◆ TYPE_INT_BE

#define TYPE_INT_BE   TYPE_CODE( 8, int)

Definition at line 215 of file blobtoxy.c.

Referenced by b2xy_column(), common_path_func(), and string_to_type().

◆ TYPE_INT_LE

#define TYPE_INT_LE   TYPE_CODE( 6, int)

Definition at line 213 of file blobtoxy.c.

Referenced by b2xy_column(), common_path_func(), and string_to_type().

◆ TYPE_SHORT_BE

#define TYPE_SHORT_BE   TYPE_CODE( 4, short)

Definition at line 211 of file blobtoxy.c.

Referenced by b2xy_column(), common_path_func(), and string_to_type().

◆ TYPE_SHORT_LE

#define TYPE_SHORT_LE   TYPE_CODE( 2, short)

Definition at line 209 of file blobtoxy.c.

Referenced by b2xy_column(), common_path_func(), and string_to_type().

◆ TYPE_SIZE

#define TYPE_SIZE ( code)
Value:
((code) & 0xFF)

Definition at line 205 of file blobtoxy.c.

Referenced by b2xy_column(), b2xy_next(), and common_path_func().

◆ TYPE_UCHAR

#define TYPE_UCHAR   TYPE_CODE( 1, char)

Definition at line 208 of file blobtoxy.c.

Referenced by b2xy_column(), common_path_func(), and string_to_type().

◆ TYPE_UINT_BE

#define TYPE_UINT_BE   TYPE_CODE( 9, int)

Definition at line 216 of file blobtoxy.c.

Referenced by b2xy_column(), common_path_func(), and string_to_type().

◆ TYPE_UINT_LE

#define TYPE_UINT_LE   TYPE_CODE( 7, int)

Definition at line 214 of file blobtoxy.c.

Referenced by b2xy_column(), common_path_func(), and string_to_type().

◆ TYPE_USHORT_BE

#define TYPE_USHORT_BE   TYPE_CODE( 5, short)

Definition at line 212 of file blobtoxy.c.

Referenced by b2xy_column(), common_path_func(), and string_to_type().

◆ TYPE_USHORT_LE

#define TYPE_USHORT_LE   TYPE_CODE( 3, short)

Definition at line 210 of file blobtoxy.c.

Referenced by b2xy_column(), common_path_func(), and string_to_type().

Typedef Documentation

◆ b2xy_cursor

typedef struct b2xy_cursor b2xy_cursor

◆ b2xy_table

typedef struct b2xy_table b2xy_table

Function Documentation

◆ b2xy_bestindex()

static int b2xy_bestindex ( sqlite3_vtab * tab,
sqlite3_index_info * info )
static

Determines information for filter function according to constraints.

Parameters
tabvirtual table
infoindex/constraint iinformation
Returns
SQLite error code

Definition at line 1100 of file blobtoxy.c.

References b2xy_table::key_column.

◆ b2xy_close()

static int b2xy_close ( sqlite3_vtab_cursor * cur)
static

Close virtual table cursor.

Parameters
curcursor pointer
Returns
SQLite error code

Definition at line 641 of file blobtoxy.c.

References b2xy_cursor::select.

◆ b2xy_column()

static int b2xy_column ( sqlite3_vtab_cursor * cur,
sqlite3_context * ctx,
int i )
static

◆ b2xy_create()

static int b2xy_create ( sqlite3 * db,
void * userdata,
int argc,
const char *const * argv,
sqlite3_vtab ** vtabret,
char ** errp )
static

Create virtual table.

Parameters
dbSQLite database pointer
userdatauser specific pointer (unused)
argcargument count
argvargument vector
vtabretpointer receiving virtual table pointer
errppointer receiving error messag
Returns
SQLite error code

Argument vector contains:

argv[0] - module name
argv[1] - database name
argv[2] - table name (virtual table)
argv[3] - master table name (required)
argv[4] - key column (required)
argv[5] - blob column (required)
argv[6] - type code (optional)
argv[7] - X scale column (optional)
argv[8] - X offset column (optional)
argv[9] - Y scale column (optional)
argv[10] - Y offset column (optional)
argv[11] - other columns (optional)
argv[12] - X start (optional)
argv[13] - X length (optional)

Definition at line 376 of file blobtoxy.c.

References b2xy_table::argc, b2xy_table::argv, b2xy_destroy(), b2xy_table::blob_column, b2xy_table::db, b2xy_table::do_x_sl, b2xy_table::fq_master_table, b2xy_table::key_column, b2xy_table::master_table, b2xy_table::other_columns, string_to_type(), b2xy_table::type, TYPE_CHAR, TYPE_DOUBLE, TYPE_FLOAT, b2xy_table::x_length, b2xy_table::x_offset_column, b2xy_table::x_scale_column, b2xy_table::x_start, b2xy_table::y_offset_column, and b2xy_table::y_scale_column.

◆ b2xy_destroy()

static int b2xy_destroy ( sqlite3_vtab * vtab)
static

Destroy virtual table.

Parameters
vtabvirtual table pointer
Returns
always SQLITE_OK

Definition at line 339 of file blobtoxy.c.

Referenced by b2xy_create().

◆ b2xy_eof()

static int b2xy_eof ( sqlite3_vtab_cursor * cur)
static

Return end of table state of virtual table cursor.

Parameters
curvirtual table cursor
Returns
true/false

Definition at line 856 of file blobtoxy.c.

References b2xy_cursor::select.

◆ b2xy_filter()

static int b2xy_filter ( sqlite3_vtab_cursor * cur,
int idxNum,
const char * idxStr,
int argc,
sqlite3_value ** argv )
static

Filter function for virtual table.

Parameters
curvirtual table cursor
idxNumused for expression (<, =, >, etc.)
idxStroptional order by clause
argcnumber arguments (0 or 1)
argvargument (nothing or RHS of filter expression)
Returns
SQLite error code

Definition at line 966 of file blobtoxy.c.

References b2xy_next(), b2xy_table::blob_column, b2xy_table::db, b2xy_cursor::fix_cols, b2xy_table::fq_master_table, b2xy_table::key_column, b2xy_cursor::num_cols, b2xy_table::other_columns, b2xy_cursor::rowid, b2xy_cursor::rowid_from_key, b2xy_cursor::select, b2xy_cursor::table, b2xy_cursor::x_offset_col, b2xy_table::x_offset_column, b2xy_cursor::x_scale_col, b2xy_table::x_scale_column, b2xy_cursor::y_offset_col, b2xy_table::y_offset_column, b2xy_cursor::y_scale_col, and b2xy_table::y_scale_column.

◆ b2xy_init()

static int b2xy_init ( sqlite3 * db)
static

Module initializer creating SQLite functions and modules.

Parameters
dbSQLite database pointer
Returns
SQLite error code

Definition at line 1857 of file blobtoxy.c.

References b2xy_module, blt_vec_step(), common_path_finalize(), common_path_func(), common_path_step(), PATH_MODE_BLT, PATH_MODE_BLT_X, PATH_MODE_BLT_Y, PATH_MODE_SVG, PATH_MODE_TK, PATH_MODE_TK3D, rownumber_func(), and subblob_func().

Referenced by sqlite3_extension_init().

◆ b2xy_next()

◆ b2xy_open()

static int b2xy_open ( sqlite3_vtab * vtab,
sqlite3_vtab_cursor ** curret )
static

Open virtual table and return cursor.

Parameters
vtabvirtual table pointer
curretpointer receiving cursor pointer
Returns
SQLite error code

Definition at line 614 of file blobtoxy.c.

References b2xy_cursor::do_x_sl, b2xy_table::do_x_sl, b2xy_cursor::table, b2xy_cursor::type, b2xy_table::type, b2xy_cursor::x_length, b2xy_table::x_length, b2xy_cursor::x_start, and b2xy_table::x_start.

◆ b2xy_rowid()

static int b2xy_rowid ( sqlite3_vtab_cursor * cur,
sqlite_int64 * rowidp )
static

Return current rowid of virtual table cursor.

Parameters
curvirtual table cursor
rowidpvalue buffer to receive current rowid
Returns
SQLite error code

Definition at line 841 of file blobtoxy.c.

References b2xy_cursor::rowid.

◆ blt_vec_step()

static void blt_vec_step ( sqlite3_context * ctx,
int nargs,
sqlite3_value ** args )
static

Path/polyline step callback for "blt_vec" aggregate functions.

Parameters
ctxSQLite function context
nargsnumber arguments
argsarguments

Arguments:

args[0] - value (required)
args[1] - scale (optional)
args[2] - offset (optional)

Definition at line 1678 of file blobtoxy.c.

References path_aggctx::count, drop_strbuf(), path_aggctx::init, init_strbuf(), path_aggctx::mode, PATH_MODE_BLT, print_strbuf(), and path_aggctx::sb.

Referenced by b2xy_init().

◆ common_path_finalize()

static void common_path_finalize ( sqlite3_context * ctx)
static

Path/polyline finalizer.

Parameters
ctxSQLite function context

Definition at line 1644 of file blobtoxy.c.

References path_aggctx::count, drop_strbuf(), strbuf::idx, path_aggctx::init, path_aggctx::mode, PATH_MODE_BLT, path_aggctx::sb, and strbuf::str.

Referenced by b2xy_init().

◆ common_path_func()

static void common_path_func ( sqlite3_context * ctx,
int nargs,
sqlite3_value ** args )
static

Make path/polyline from blob.

Parameters
ctxSQLite function context
nargsnumber arguments
argsarguments

Arguments:

args[0] - blob data (required)
args[1] - type (optional, default "char")
args[2] - X scale (optional)
args[3] - X offset (optional)
args[4] - Y scale (optional)
args[5] - Y offset (optional)
args[6] - Z value (optional)
args[7] - Z scale (optional)
args[8] - Z offset (optional)

Definition at line 1341 of file blobtoxy.c.

References drop_strbuf(), strbuf::idx, init_strbuf(), PATH_MODE_BLT_X, PATH_MODE_BLT_Y, PATH_MODE_SVG, PATH_MODE_TK3D, print_strbuf(), strbuf::str, string_to_type(), TYPE_CHAR, TYPE_DOUBLE, TYPE_FLOAT, TYPE_INT_BE, TYPE_INT_LE, TYPE_SHORT_BE, TYPE_SHORT_LE, TYPE_SIZE, TYPE_UCHAR, TYPE_UINT_BE, TYPE_UINT_LE, TYPE_USHORT_BE, and TYPE_USHORT_LE.

Referenced by b2xy_init().

◆ common_path_step()

static void common_path_step ( sqlite3_context * ctx,
int nargs,
sqlite3_value ** args )
static

Path/polyline step callback for "tk_path", "svg_path", and "tk3d_path" aggregate functions.

Parameters
ctxSQLite function context
nargsnumber arguments
argsarguments

Arguments:

args[0] - X value (required)
args[1] - Y value (required)
args[2] - X scale (optional)
args[3] - X offset (optional)
args[4] - Y scale (optional)
args[5] - Y offset (optional)
args[6] - Z value (optional)
args[7] - Z scale (optional)
args[8] - Z offset (optional)

Definition at line 1538 of file blobtoxy.c.

References path_aggctx::count, drop_strbuf(), strbuf::idx, path_aggctx::init, init_strbuf(), path_aggctx::linebreak, path_aggctx::mode, PATH_MODE_SVG, PATH_MODE_TK3D, print_strbuf(), and path_aggctx::sb.

Referenced by b2xy_init().

◆ drop_strbuf()

static void drop_strbuf ( strbuf * sb)
static

Free resources of dynamic string buffer.

Parameters
sbpointer to string buffer

Definition at line 1271 of file blobtoxy.c.

References strbuf::max, and strbuf::str.

Referenced by blt_vec_step(), common_path_finalize(), common_path_func(), and common_path_step().

◆ expand_strbuf()

static int expand_strbuf ( strbuf * sb)
static

Expand or initialize dynamic string buffer.

Parameters
sbpointer to string buffer
Returns
SQLite error code

Definition at line 1247 of file blobtoxy.c.

References init_strbuf(), strbuf::max, and strbuf::str.

Referenced by print_strbuf().

◆ init_strbuf()

static int init_strbuf ( strbuf * sb)
static

Initialize dynamic string buffer with capacity 1024.

Parameters
sbpointer to string buffer
Returns
SQLite error code

Definition at line 1225 of file blobtoxy.c.

References strbuf::idx, strbuf::max, and strbuf::str.

Referenced by blt_vec_step(), common_path_func(), common_path_step(), and expand_strbuf().

◆ print_strbuf()

static int print_strbuf ( strbuf * sb,
const char * fmt,
... )
static

Format printf-like into dynamic string buffer.

Parameters
sbpointer to string buffer
fmtprintf-like format string
Returns
SQLite error code

Definition at line 1288 of file blobtoxy.c.

References expand_strbuf(), strbuf::idx, strbuf::max, and strbuf::str.

Referenced by blt_vec_step(), common_path_func(), and common_path_step().

◆ rownumber_func()

static void rownumber_func ( sqlite3_context * ctx,
int nargs,
sqlite3_value ** args )
static

"rownumber" function.

Parameters
ctxSQLite function context
nargsnumber arguments
argsarguments

Definition at line 1828 of file blobtoxy.c.

References rownumber_ctx::count, rownumber_ctx::ctx, and rownumber_ctx::value.

Referenced by b2xy_init().

◆ sqlite3_extension_init()

int sqlite3_extension_init ( sqlite3 * db,
char ** errmsg,
const sqlite3_api_routines * api )

Initializer for SQLite extension load mechanism.

Parameters
dbSQLite database pointer
errmsgpointer receiving error message
apiSQLite API routines
Returns
SQLite error code

Definition at line 1895 of file blobtoxy.c.

References b2xy_init().

◆ string_to_type()

static int string_to_type ( const char * str)
static

Map type string to type code.

Parameters
strtype string, e.g. "char"
Returns
type code, e.g. TYPE_CHAR

Definition at line 285 of file blobtoxy.c.

References TYPE_BIGINT_BE, TYPE_BIGINT_LE, TYPE_CHAR, TYPE_DOUBLE, TYPE_FLOAT, TYPE_INT_BE, TYPE_INT_LE, TYPE_SHORT_BE, TYPE_SHORT_LE, TYPE_UCHAR, TYPE_UINT_BE, TYPE_UINT_LE, TYPE_USHORT_BE, and TYPE_USHORT_LE.

Referenced by b2xy_create(), and common_path_func().

◆ subblob_func()

static void subblob_func ( sqlite3_context * ctx,
int nargs,
sqlite3_value ** args )
static

"subblob" function similar to "substr".

Parameters
ctxSQLite function context
nargsnumber arguments
argsarguments

Definition at line 1733 of file blobtoxy.c.

Referenced by b2xy_init().

Variable Documentation

◆ b2xy_module

const sqlite3_module b2xy_module
static
Initial value:
= {
1,
0,
0,
0,
0,
0,
0,
}
static int b2xy_close(sqlite3_vtab_cursor *cur)
Close virtual table cursor.
Definition blobtoxy.c:641
static int b2xy_bestindex(sqlite3_vtab *tab, sqlite3_index_info *info)
Determines information for filter function according to constraints.
Definition blobtoxy.c:1100
static int b2xy_next(sqlite3_vtab_cursor *cur)
Retrieve next row from virtual table cursor.
Definition blobtoxy.c:870
static int b2xy_column(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i)
Return column data of virtual table.
Definition blobtoxy.c:659
static int b2xy_destroy(sqlite3_vtab *vtab)
Destroy virtual table.
Definition blobtoxy.c:339
static int b2xy_rowid(sqlite3_vtab_cursor *cur, sqlite_int64 *rowidp)
Return current rowid of virtual table cursor.
Definition blobtoxy.c:841
static int b2xy_open(sqlite3_vtab *vtab, sqlite3_vtab_cursor **curret)
Open virtual table and return cursor.
Definition blobtoxy.c:614
static int b2xy_create(sqlite3 *db, void *userdata, int argc, const char *const *argv, sqlite3_vtab **vtabret, char **errp)
Create virtual table.
Definition blobtoxy.c:376
static int b2xy_eof(sqlite3_vtab_cursor *cur)
Return end of table state of virtual table cursor.
Definition blobtoxy.c:856
static int b2xy_filter(sqlite3_vtab_cursor *cur, int idxNum, const char *idxStr, int argc, sqlite3_value **argv)
Filter function for virtual table.
Definition blobtoxy.c:966

Definition at line 1181 of file blobtoxy.c.

Referenced by b2xy_init().


Generated on Sun Nov 26 2023 by doxygen.
Contact: chw@ch-werner.de