internal void call_step(IntPtr context, IntPtr agg_context, int num_args, IntPtr argsptr) { sqlite3_context ctx = get_context(context, agg_context); sqlite3_value[] a = new sqlite3_value[num_args]; // TODO warning on the following line. SizeOf(Type) replaced in .NET 4.5.1 with SizeOf<T>() int ptr_size = Marshal.SizeOf(typeof(IntPtr)); for (int i = 0; i < num_args; i++) { IntPtr vp = Marshal.ReadIntPtr(argsptr, i * ptr_size); a[i] = new sqlite3_value(vp); } _func_step(ctx, _user_data, a); }
static public int sqlite3_value_type(sqlite3_value val) { return _imp.sqlite3_value_type(val.ptr); }
static public long sqlite3_value_int64(sqlite3_value val) { return _imp.sqlite3_value_int64(val.ptr); }
static public double sqlite3_value_double(sqlite3_value val) { return _imp.sqlite3_value_double(val.ptr); }
private static void cube(sqlite3_context ctx, object user_data, sqlite3_value[] args) { Assert.AreEqual(args.Length, 1); long x = args[0].value_int64(); Assert.AreEqual(x, val); ctx.result_int64(x * x * x); }
static public string sqlite3_value_text(sqlite3_value val) { return(_imp.sqlite3_value_text(val.ptr)); }
static public long sqlite3_value_int64(sqlite3_value val) { return(_imp.sqlite3_value_int64(val.ptr)); }
static public int sqlite3_value_bytes(sqlite3_value val) { return(_imp.sqlite3_value_bytes(val.ptr)); }
private static void concat(sqlite3_context ctx, object user_data, sqlite3_value[] args) { string r = ""; foreach (sqlite3_value v in args) { r += v.value_text(); } ctx.result_text(r); }
private static void len_as_blobs(sqlite3_context ctx, object user_data, sqlite3_value[] args) { int r = 0; foreach (sqlite3_value v in args) { if (v.value_type() != raw.SQLITE_NULL) { Assert.AreEqual(v.value_blob().Length, v.value_bytes()); r += v.value_blob().Length; } } ctx.result_int(r); }
private static void count_nulls(sqlite3_context ctx, object user_data, sqlite3_value[] args) { int r = 0; foreach (sqlite3_value v in args) { if (v.value_type() == raw.SQLITE_NULL) { r++; } } ctx.result_int(r); }
private static void count_args(sqlite3_context ctx, object user_data, sqlite3_value[] args) { ctx.result_int(args.Length); }
private static void mean(sqlite3_context ctx, object user_data, sqlite3_value[] args) { double d = 0; foreach (sqlite3_value v in args) { d += v.value_double(); } ctx.result_double(d / args.Length); }
private static void makeblob(sqlite3_context ctx, object user_data, sqlite3_value[] args) { byte[] b = new byte[args[0].value_int()]; for (int i=0; i<b.Length; i++) { b[i] = (byte) (i % 256); } ctx.result_blob(b); }
static public string sqlite3_value_text(sqlite3_value val) { return _imp.sqlite3_value_text(val.ptr); }
static public byte[] sqlite3_value_blob(sqlite3_value val) { return(_imp.sqlite3_value_blob(val.ptr)); }
private static void sum_plus_count_step(sqlite3_context ctx, object user_data, sqlite3_value[] args) { Assert.AreEqual(args.Length, 1); if (ctx.state == null) { ctx.state = new my_state(); } my_state st = ctx.state as my_state; st.sum += args[0].value_int64(); st.count++; }
static public double sqlite3_value_double(sqlite3_value val) { return(_imp.sqlite3_value_double(val.ptr)); }
internal void call_step(IntPtr context, IntPtr agg_context, int num_args, IntPtr argsptr) { sqlite3_context ctx = get_context(context, agg_context); sqlite3_value[] a = new sqlite3_value[num_args]; // TODO warning on the following line. SizeOf(Type) replaced in .NET 4.5.1 with SizeOf<T>() int ptr_size = Marshal.SizeOf(typeof(IntPtr)); for (int i=0; i<num_args; i++) { IntPtr vp = Marshal.ReadIntPtr(argsptr, i * ptr_size); a[i] = new sqlite3_value(vp); } _func_step(ctx, _user_data, a); }
static public int sqlite3_value_type(sqlite3_value val) { return(_imp.sqlite3_value_type(val.ptr)); }
static public byte[] sqlite3_value_blob(sqlite3_value val) { return _imp.sqlite3_value_blob(val.ptr); }
static public int sqlite3_value_bytes(sqlite3_value val) { return _imp.sqlite3_value_bytes(val.ptr); }
static public ReadOnlySpan <byte> sqlite3_value_blob(sqlite3_value val) { return(_imp.sqlite3_value_blob(val.ptr)); }