internal override long GetParamValueBytes(SqliteValueHandle p, int nDataOffset, byte[] bDest, int nStart, int nLength) { int nCopied = nLength; int nlen = UnsafeNativeMethods.sqlite3_value_bytes(p); var ptr = UnsafeNativeMethods.sqlite3_value_blob(p); if (bDest == null) { return(nlen); } if (nCopied + nStart > bDest.Length) { nCopied = bDest.Length - nStart; } if (nCopied + nDataOffset > nlen) { nCopied = nlen - nDataOffset; } if (nCopied > 0) { Array.Copy(ptr, nStart + nDataOffset, bDest, 0, nCopied); } else { nCopied = 0; } return(nCopied); }
/// <summary> /// Converts an IntPtr array of context arguments to an object array containing the resolved parameters the pointers point to. /// </summary> /// <remarks> /// Parameters passed to functions have only an affinity for a certain data type, there is no underlying schema available /// to force them into a certain type. Therefore the only types you will ever see as parameters are /// DBNull.Value, Int64, Double, String or byte[] array. /// </remarks> /// <param name="nArgs">The number of arguments</param> /// <param name="argsptr">A pointer to the array of arguments</param> /// <returns>An object array of the arguments once they've been converted to .NET values</returns> internal object[] ConvertParams(int nArgs, SqliteValueHandle[] argsptr) { object[] parms = new object[nArgs]; SqliteValueHandle[] argint = new SqliteValueHandle[nArgs]; Array.Copy(argsptr, argint, nArgs); for (int n = 0; n < nArgs; n++) { switch (_base.GetParamValueType((SqliteValueHandle)argint[n])) { case TypeAffinity.Null: parms[n] = DBNull.Value; break; case TypeAffinity.Int64: parms[n] = _base.GetParamValueInt64((SqliteValueHandle)argint[n]); break; case TypeAffinity.Double: parms[n] = _base.GetParamValueDouble((SqliteValueHandle)argint[n]); break; case TypeAffinity.Text: parms[n] = _base.GetParamValueText((SqliteValueHandle)argint[n]); break; case TypeAffinity.Blob: { int x; byte[] blob; x = (int)_base.GetParamValueBytes((SqliteValueHandle)argint[n], 0, null, 0, 0); blob = new byte[x]; _base.GetParamValueBytes((SqliteValueHandle)argint[n], 0, blob, 0, x); parms[n] = blob; } break; case TypeAffinity.DateTime: // Never happens here but what the heck, maybe it will one day. parms[n] = _base.ToDateTime(_base.GetParamValueText((SqliteValueHandle)argint[n])); break; } } return(parms); }
/// <summary> /// An internal aggregate Final function callback, which wraps the context pointer and calls the virtual Final() method. /// </summary> /// <param name="context">A raw context pointer</param> internal void FinalCallback(SqliteContextHandle context) { SqliteValueHandle n = (SqliteValueHandle)_base.AggregateContext(context); object obj = null; if (_contextDataList.ContainsKey(n)) { obj = _contextDataList[n]._data; _contextDataList.Remove(n); } _context = context; SetReturnValue(context, Final(obj)); IDisposable disp = obj as IDisposable; if (disp != null) { disp.Dispose(); } }
internal abstract TypeAffinity GetParamValueType(SqliteValueHandle ptr);
internal abstract Int64 GetParamValueInt64(SqliteValueHandle ptr);
internal abstract double GetParamValueDouble(SqliteValueHandle ptr);
public static int sqlite3_value_type(SqliteValueHandle value) { throw new System.NotImplementedException(); }
public static long sqlite3_value_int64(SqliteValueHandle value) { throw new System.NotImplementedException(); }
internal override double GetParamValueDouble(SqliteValueHandle ptr) { return(UnsafeNativeMethods.sqlite3_value_double(ptr)); }
public static string sqlite3_value_text16(SqliteValueHandle value) { return sqlite3_value_text(value); }
public static int sqlite3_value_type(SqliteValueHandle value) { return Community.CsharpSqlite.Sqlite3.sqlite3_value_type(value.Handle); }
public static string sqlite3_value_text(SqliteValueHandle value) { return Community.CsharpSqlite.Sqlite3.sqlite3_value_text(value.Handle); }
public static long sqlite3_value_int64(SqliteValueHandle value) { return Community.CsharpSqlite.Sqlite3.sqlite3_value_int64(value.Handle); }
internal override long GetParamValueInt64(SqliteValueHandle ptr) { return(UnsafeNativeMethods.sqlite3_value_int64(ptr)); }
internal override string GetParamValueText(SqliteValueHandle ptr) { return(UTF8ToString(UnsafeNativeMethods.sqlite3_value_text(ptr), -1)); }
public static double sqlite3_value_double(SqliteValueHandle value) { return Community.CsharpSqlite.Sqlite3.sqlite3_value_double(value.Handle); }
internal override TypeAffinity GetParamValueType(SqliteValueHandle ptr) { return((TypeAffinity)UnsafeNativeMethods.sqlite3_value_type(ptr)); }
public static string sqlite3_value_text16(SqliteValueHandle value) { throw new System.NotImplementedException(); }
/// <summary> /// Converts an IntPtr array of context arguments to an object array containing the resolved parameters the pointers point to. /// </summary> /// <remarks> /// Parameters passed to functions have only an affinity for a certain data type, there is no underlying schema available /// to force them into a certain type. Therefore the only types you will ever see as parameters are /// DBNull.Value, Int64, Double, String or byte[] array. /// </remarks> /// <param name="nArgs">The number of arguments</param> /// <param name="argsptr">A pointer to the array of arguments</param> /// <returns>An object array of the arguments once they've been converted to .NET values</returns> internal object[] ConvertParams(int nArgs, SqliteValueHandle[] argsptr) { object[] parms = new object[nArgs]; SqliteValueHandle[] argint = new SqliteValueHandle[nArgs]; Array.Copy(argsptr, argint, nArgs); for (int n = 0; n < nArgs; n++) { switch (_base.GetParamValueType((SqliteValueHandle)argint[n])) { case TypeAffinity.Null: parms[n] = DBNull.Value; break; case TypeAffinity.Int64: parms[n] = _base.GetParamValueInt64((SqliteValueHandle)argint[n]); break; case TypeAffinity.Double: parms[n] = _base.GetParamValueDouble((SqliteValueHandle)argint[n]); break; case TypeAffinity.Text: parms[n] = _base.GetParamValueText((SqliteValueHandle)argint[n]); break; case TypeAffinity.Blob: { int x; byte[] blob; x = (int)_base.GetParamValueBytes((SqliteValueHandle)argint[n], 0, null, 0, 0); blob = new byte[x]; _base.GetParamValueBytes((SqliteValueHandle)argint[n], 0, blob, 0, x); parms[n] = blob; } break; case TypeAffinity.DateTime: // Never happens here but what the heck, maybe it will one day. parms[n] = _base.ToDateTime(_base.GetParamValueText((SqliteValueHandle)argint[n])); break; } } return parms; }
internal abstract long GetParamValueBytes(SqliteValueHandle ptr, int nDataOffset, byte[] bDest, int nStart, int nLength);
/// <summary> /// Internal scalar callback function, which wraps the raw context pointer and calls the virtual Invoke() method. /// </summary> /// <param name="context">A raw context pointer</param> /// <param name="nArgs">Number of arguments passed in</param> /// <param name="argsptr">A pointer to the array of arguments</param> internal void ScalarCallback(SqliteContextHandle context, int nArgs, SqliteValueHandle[] argsptr) { _context = context; SetReturnValue(context, Invoke(ConvertParams(nArgs, argsptr))); }
internal abstract int GetParamValueInt32(SqliteValueHandle ptr);
/// <summary> /// The internal aggregate Step function callback, which wraps the raw context pointer and calls the virtual Step() method. /// </summary> /// <remarks> /// This function takes care of doing the lookups and getting the important information put together to call the Step() function. /// That includes pulling out the user's contextData and updating it after the call is made. We use a sorted list for this so /// binary searches can be done to find the data. /// </remarks> /// <param name="context">A raw context pointer</param> /// <param name="nArgs">Number of arguments passed in</param> /// <param name="argsptr">A pointer to the array of arguments</param> internal void StepCallback(SqliteContextHandle context, int nArgs, SqliteValueHandle[] argsptr) { SqliteValueHandle nAux; AggregateData data; nAux = (SqliteValueHandle)_base.AggregateContext(context); if (_contextDataList.TryGetValue(nAux, out data) == false) { data = new AggregateData(); _contextDataList[nAux] = data; } try { _context = context; Step(ConvertParams(nArgs, argsptr), data._count, ref data._data); } finally { data._count++; } }
internal abstract string GetParamValueText(SqliteValueHandle ptr);
public static byte[] sqlite3_value_blob(SqliteValueHandle value) { return(Community.CsharpSqlite.Sqlite3.sqlite3_value_blob(value.Handle)); }
public static double sqlite3_value_double(SqliteValueHandle value) { return(Community.CsharpSqlite.Sqlite3.sqlite3_value_double(value.Handle)); }
public static long sqlite3_value_int64(SqliteValueHandle value) { return(Community.CsharpSqlite.Sqlite3.sqlite3_value_int64(value.Handle)); }
public static string sqlite3_value_text(SqliteValueHandle value) { return(Community.CsharpSqlite.Sqlite3.sqlite3_value_text(value.Handle)); }
public static byte[] sqlite3_value_blob(SqliteValueHandle value) { throw new System.NotImplementedException(); }
public static int sqlite3_value_type(SqliteValueHandle value) { return(Community.CsharpSqlite.Sqlite3.sqlite3_value_type(value.Handle)); }
public static string sqlite3_value_text16(SqliteValueHandle value) { return(sqlite3_value_text(value)); }
public static byte[] sqlite3_value_blob(SqliteValueHandle value) { return Community.CsharpSqlite.Sqlite3.sqlite3_value_blob(value.Handle); }