Commit 92e3a38c authored by gwenn's avatar gwenn

Add Context#Value.

parent 7453f923
......@@ -77,6 +77,7 @@ type Context struct {
argv **C.sqlite3_value
}
// Set the result of an SQL function
func (c *Context) ResultBool(b bool) {
if b {
c.ResultInt(1)
......@@ -205,6 +206,11 @@ func (c *Context) SetAuxData(n int, ad interface{}, d AuxDataDestructor) {
C.goSqlite3SetAuxdata(c.context, C.int(n), unsafe.Pointer(adp))
}
// The leftmost value is number 0.
func (c *Context) Bool(i int) bool {
return c.Int(i) == 1
}
// The leftmost value is number 0.
// Calls sqlite3_value_blob and sqlite3_value_bytes, http://sqlite.org/c3ref/value_blob.html
func (c *Context) Blob(i int) (value []byte) {
......@@ -259,6 +265,24 @@ func (c *Context) NumericType(i int) Type {
return Type(C.my_value_numeric_type(c.argv, C.int(i)))
}
func (c *Context) Value(i int) (value interface{}) {
switch c.Type(i) {
case Null:
value = nil
case Text:
value = c.Text(i)
case Integer:
value = c.Int64(i)
case Float:
value = c.Double(i)
case Blob:
value = c.Blob(i)
default:
panic("The value type is not one of SQLITE_INTEGER, SQLITE_FLOAT, SQLITE_TEXT, SQLITE_BLOB, or SQLITE_NULL")
}
return
}
type ScalarFunction func(ctx *Context, nArg int)
type DestroyFunctionData func(pApp interface{})
......
......@@ -315,7 +315,7 @@ func goXLog(udp unsafe.Pointer, err int, msg *C.char) {
var logger *sqliteLogger
// Configuring the logger of the SQLite library
// Configure the logger of the SQLite library
// Calls sqlite3_config(SQLITE_CONFIG_LOG,...)
func ConfigLog(f Logger, udp interface{}) error {
var rv C.int
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment