Пример #1
0
// Text obtains a SQL function parameter value.
// The leftmost value is number 0.
// (See sqlite3_value_text, http://sqlite.org/c3ref/value_blob.html)
func (c *FunctionContext) Text(i int) string {
	p := C.my_value_text(c.argv, C.int(i))
	if p == nil {
		return ""
	}
	n := C.my_value_bytes(c.argv, C.int(i))
	return C.GoStringN((*C.char)(unsafe.Pointer(p)), n)
}
Пример #2
0
// Blob obtains a SQL function parameter value.
// The leftmost value is number 0.
// (See sqlite3_value_blob and sqlite3_value_bytes, http://sqlite.org/c3ref/value_blob.html)
func (c *FunctionContext) Blob(i int) (value []byte) {
	p := C.my_value_blob(c.argv, C.int(i))
	if p != nil {
		n := C.my_value_bytes(c.argv, C.int(i))
		// value = (*[1 << 30]byte)(unsafe.Pointer(p))[:n]
		value = C.GoBytes(p, n) // The memory space used to hold strings and BLOBs is freed automatically.
	}
	return
}