本文整理汇总了C#中Mem类的典型用法代码示例。如果您正苦于以下问题:C# Mem类的具体用法?C# Mem怎么用?C# Mem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Mem类属于命名空间,在下文中一共展示了Mem类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: sqlite3VdbeChangeEncoding
} // TODO -- Convert to inline for speed
/*
** If pMem is an object with a valid string representation, this routine
** ensures the internal encoding for the string representation is
** 'desiredEnc', one of SQLITE_UTF8, SQLITE_UTF16LE or SQLITE_UTF16BE.
**
** If pMem is not a string object, or the encoding of the string
** representation is already stored using the requested encoding, then this
** routine is a no-op.
**
** SQLITE_OK is returned if the conversion is successful (or not required).
** SQLITE_NOMEM may be returned if a malloc() fails during conversion
** between formats.
*/
private static int sqlite3VdbeChangeEncoding(Mem pMem, int desiredEnc)
{
int rc;
Debug.Assert((pMem.flags & MEM_RowSet) == 0);
Debug.Assert(desiredEnc == SQLITE_UTF8 || desiredEnc == SQLITE_UTF16LE
|| desiredEnc == SQLITE_UTF16BE);
if ((pMem.flags & MEM_Str) == 0 || pMem.enc == desiredEnc)
{
if (String.IsNullOrEmpty(pMem.z) && pMem.zBLOB != null)
pMem.z = Encoding.UTF8.GetString(pMem.zBLOB, 0, pMem.zBLOB.Length);
return SQLITE_OK;
}
Debug.Assert(pMem.db == null || sqlite3_mutex_held(pMem.db.mutex));
#if SQLITE_OMIT_UTF16
return SQLITE_ERROR;
#else
/* MemTranslate() may return SQLITE_OK or SQLITE_NOMEM. If NOMEM is returned,
** then the encoding of the value may not have changed.
*/
rc = sqlite3VdbeMemTranslate(pMem, (u8)desiredEnc);
Debug.Assert(rc==SQLITE_OK || rc==SQLITE_NOMEM);
Debug.Assert(rc==SQLITE_OK || pMem.enc!=desiredEnc);
Debug.Assert(rc==SQLITE_NOMEM || pMem.enc==desiredEnc);
return rc;
#endif
}
开发者ID:broettge,项目名称:MatterControl,代码行数:43,代码来源:vdbemem_c.cs
示例2: MemStoreType
//: static void Deephemeralize(Mem P) { }
#endregion
#region Name2
public static void MemStoreType(Mem mem)
{
MEM flags = mem.Flags;
if ((flags & MEM.Null) != 0) { mem.Type = TYPE.NULL; mem.Z = null; }
else if ((flags & MEM.Int) != 0) mem.Type = TYPE.INTEGER;
else if ((flags & MEM.Real) != 0) mem.Type = TYPE.FLOAT;
else if ((flags & MEM.Str) != 0) mem.Type = TYPE.TEXT;
else mem.Type = TYPE.BLOB;
}
开发者ID:BclEx,项目名称:GpuStructs,代码行数:15,代码来源:Vdbe.cs
示例3: SetValue
public void SetValue(Mem buffer)
{
if (buffer == null)
throw new ArgumentNullException("buffer");
unsafe
{
IntPtr handle = buffer.Handle.DangerousGetHandle();
SetValue((UIntPtr)IntPtr.Size, (IntPtr)(&handle));
}
}
开发者ID:JamesLinus,项目名称:NOpenCL,代码行数:11,代码来源:KernelArgument.cs
示例4: CreateCLImageFromGLTexture
/// <summary>
/// Creates the CL image from GL texture. This can be a platfor specific operation.
/// On some platforms, some of the parameters may be ignored.
/// </summary>
/// <returns>The CL image from GL texture.</returns>
/// <param name="context">Context.</param>
/// <param name="memFlags">Mem flags.</param>
/// <param name="target">Target.</param>
/// <param name="mipLevel">Mip level.</param>
/// <param name="texturePointer">Texture pointer.</param>
/// <param name="error">Error.</param>
public static IMem CreateCLImageFromGLTexture(Context context, MemFlags memFlags, TextureTarget target, int mipLevel, IntPtr texturePointer, out ErrorCode error){
#if UNITY_STANDALONE_OSX || UNITY_IPHONE
//here, we use a function from apple (gcl) headers
var ret = new Mem(gcl_gl_create_image_from_texture(target,new IntPtr(mipLevel),texturePointer));
error = ErrorCode.Success;
return ret;
#endif
#if UNITY_STANDALONE_WIN || UNITY_STANDALONE_LINUX || UNITY_ANDROID
//here we use the GL sharing extensions.
return new Mem(clCreateFromGLTexture2D((context as IHandleData).Handle,memFlags,target,new IntPtr(mipLevel),texturePointer,out error));
#endif
}
开发者ID:RokkiGH,项目名称:openclnet_unity,代码行数:23,代码来源:Unity.CL.API.cs
示例5: GetMemObjectInfo
public static InfoBuffer GetMemObjectInfo(Mem mem, MemInfo paramName, out ErrorCode error)
{
if (paramName == MemInfo.HostPtr) // Handle special case
{
IntPtr size = GetInfo(Cl.GetMemObjectInfo, mem, Cl.MemInfo.Size, out error).CastTo<IntPtr>();
var buffer = new InfoBuffer(size);
error = GetMemObjectInfo(mem, paramName, size, buffer, out size);
if (error != ErrorCode.Success)
return InfoBuffer.Empty;
return buffer;
}
return GetInfo(GetMemObjectInfo, mem, paramName, out error);
}
开发者ID:cephdon,项目名称:gpudotnet,代码行数:15,代码来源:Cl.Overloads.cs
示例6: RenameParentFunc
static void RenameParentFunc(FuncContext fctx, int notUsed, Mem[] argv)
{
Context ctx = Vdbe.Context_Ctx(fctx);
string input = Vdbe.Value_Text(argv[0]);
string oldName = Vdbe.Value_Text(argv[1]);
string newName = Vdbe.Value_Text(argv[2]);
int zIdx; // Pointer to token
int zLeft = 0; // Pointer to remainder of String
TK token = 0; // Type of token
string output = string.Empty;
int n; // Length of token z
for (int z = 0; z < input.Length; z += n)
{
n = Parse.GetToken(input, z, ref token);
if (token == TK.REFERENCES)
{
string parent;
do
{
z += n;
n = Parse.GetToken(input, z, ref token);
} while (token == TK.SPACE);
parent = (z + n < input.Length ? input.Substring(z, n) : string.Empty);
if (string.IsNullOrEmpty(parent)) break;
Parse.Dequote(ref parent);
if (oldName.Equals(parent, StringComparison.OrdinalIgnoreCase))
{
string out_ = C._mtagprintf(ctx, "%s%.*s\"%w\"", output, z - zLeft, input.Substring(zLeft), newName);
C._tagfree(ctx, ref output);
output = out_;
z += n;
zLeft = z;
}
C._tagfree(ctx, ref parent);
}
}
string r = C._mtagprintf(ctx, "%s%s", output, input.Substring(zLeft));
Vdbe.Result_Text(fctx, r, -1, DESTRUCTOR.DYNAMIC);
C._tagfree(ctx, ref output);
}
开发者ID:BclEx,项目名称:GpuStructs,代码行数:45,代码来源:Alter.cs
示例7: MemMakeWriteable
public static RC MemMakeWriteable(Mem mem)
{
Debug.Assert(mem.Ctx == null || MutexEx.Held(mem.Ctx.Mutex));
Debug.Assert((mem.Flags & MEM.RowSet) == 0);
E.ExpandBlob(mem);
MEM f = mem.Flags;
if ((f & (MEM.Str | MEM.Blob)) != 0) //: mem->Z != mem->Malloc)
{
if (MemGrow(mem, mem.N + 2, true) != 0)
return RC.NOMEM;
//: mem.Z[mem.N] = 0;
//: mem.Z[mem.N + 1] = 0;
mem.Flags |= MEM.Term;
#if DEBUG
mem.ScopyFrom = null;
#endif
}
return RC.OK;
}
开发者ID:BclEx,项目名称:GpuStructs,代码行数:19,代码来源:Vdbe+Mem.cs
示例8: MemGrow
public static RC MemGrow(Mem mem, int newSize, bool preserve)
{
//Debug.Assert((mem.Malloc != null && mem.Malloc == mem.Z ? 1 : 0) +
// ((mem.Flags & MEM.Dyn) && mem.Del ? 1 : 0) +
// ((mem.Flags & MEM.Ephem) ? 1 : 0) +
// ((mem.Flags & MEM.Static) ? 1 : 0) <= 1);
Debug.Assert((mem.Flags & MEM.RowSet) == 0);
// If the preserve flag is set to true, then the memory cell must already contain a valid string or blob value.
Debug.Assert(!preserve || (mem.Flags & (MEM.Blob | MEM.Str)) != 0);
if (newSize < 32) newSize = 32;
//: if (_tagallocsize(mem->Ctx, mem->Malloc) < newSize)
if (preserve) //: && mem->Z == mem->Malloc)
{
if (mem.Z == null)
mem.Z = null;
else
if (newSize < mem.Z.Length)
mem.Z = mem.Z.Substring(0, newSize);
preserve = false;
}
else
{
//: _tagfree(mem->Ctx, mem->Malloc);
mem.Z = null; //: mem->Malloc = (char*)_tagalloc(mem->Ctx, newSize);
}
//: if (mem.Z && preserve && mem.Malloc && mem.Z != mem->Malloc)
//: _memcpy(mem.Malloc, mem.Z, mem.N);
if ((mem.Flags & MEM.Dyn) != 0 && mem.Del != null)
{
Debug.Assert(mem.Del != C.DESTRUCTOR_DYNAMIC);
mem.Del(mem.Z);
}
//: mem.Z = mem->Malloc;
mem.Flags = (MEM)(mem.Z == null ? MEM.Null : mem.Flags & ~(MEM.Ephem | MEM.Static));
mem.Del = null;
return (mem.Z != null ? RC.OK : RC.NOMEM);
}
开发者ID:BclEx,项目名称:GpuStructs,代码行数:41,代码来源:Vdbe+Mem.cs
示例9: ChangeEncoding
public static RC ChangeEncoding(Mem mem, TEXTENCODE newEncode)
{
Debug.Assert((mem.Flags & MEM.RowSet) == 0);
Debug.Assert(newEncode == TEXTENCODE.UTF8 || newEncode == TEXTENCODE.UTF16LE || newEncode == TEXTENCODE.UTF16BE);
if ((mem.Flags & MEM.Str) == 0 || mem.Encode == newEncode)
{
if (mem.Z == null && mem.Z_ != null)
mem.Z = Encoding.UTF8.GetString(mem.Z_, 0, mem.Z_.Length);
return RC.OK;
}
Debug.Assert(mem.Ctx == null || MutexEx.Held(mem.Ctx.Mutex));
#if OMIT_UTF16
return RC.ERROR;
#else
// MemTranslate() may return SQLITE_OK or SQLITE_NOMEM. If NOMEM is returned, then the encoding of the value may not have changed.
RC rc = MemTranslate(mem, newEncode);
Debug.Assert(rc == RC.OK || rc == RC.NOMEM);
Debug.Assert(rc == RC.OK || mem.Encode != newEncode);
Debug.Assert(rc == RC.NOMEM || mem.Encode == newEncode);
return rc;
#endif
}
开发者ID:BclEx,项目名称:GpuStructs,代码行数:22,代码来源:Vdbe+Mem.cs
示例10: RenameTableFunc
static void RenameTableFunc(FuncContext fctx, int notUsed, Mem[] argv)
{
Context ctx = Vdbe.Context_Ctx(fctx);
string sql = Vdbe.Value_Text(argv[0]);
string tableName = Vdbe.Value_Text(argv[1]);
if (string.IsNullOrEmpty(sql))
return;
int length = 0;
TK token = 0;
Token tname = new Token();
int z = 0, zLoc = 0;
// The principle used to locate the table name in the CREATE TABLE statement is that the table name is the first non-space token that
// is immediately followed by a TK_LP or TK_USING token.
do
{
if (z == sql.Length)
return; // Ran out of input before finding an opening bracket. Return NULL.
// Store the token that zCsr points to in tname.
zLoc = z;
tname.data = sql.Substring(z);
tname.length = (uint)length;
// Advance zCsr to the next token. Store that token type in 'token', and its length in 'len' (to be used next iteration of this loop).
do
{
z += length;
length = (z == sql.Length ? 1 : Parse.GetToken(sql, z, ref token));
} while (token == TK.SPACE);
Debug.Assert(length > 0);
} while (token != TK.LP && token != TK.USING);
string r = C._mtagprintf(ctx, "%.*s\"%w\"%s", zLoc, sql.Substring(0, zLoc), tableName, sql.Substring(zLoc + (int)tname.length));
Vdbe.Result_Text(fctx, r, -1, DESTRUCTOR_DYNAMIC);
}
开发者ID:BclEx,项目名称:GpuStructs,代码行数:36,代码来源:Alter.cs
示例11: sqlite3VdbeMemSetBlob
} // Call w/o offset
private static int sqlite3VdbeMemSetBlob(
Mem pMem, /* Memory cell to set to string value */
byte[] zBlob, /* Blob pointer */
int offset, /* offset into string */
int n, /* Bytes in string, or negative */
u8 enc, /* Encoding of z. 0 for BLOBs */
dxDel xDel//)(void*)/* Destructor function */
)
{
int nByte = n; /* New value for pMem->n */
int iLimit; /* Maximum allowed string or blob size */
Debug.Assert(pMem.db == null || sqlite3_mutex_held(pMem.db.mutex));
Debug.Assert((pMem.flags & MEM_RowSet) == 0);
/* If zBlob is a NULL pointer, set pMem to contain an SQL NULL. */
if (zBlob == null || zBlob.Length < offset)
{
sqlite3VdbeMemSetNull(pMem);
return SQLITE_OK;
}
if (pMem.db != null)
{
iLimit = pMem.db.aLimit[SQLITE_LIMIT_LENGTH];
}
else
{
iLimit = SQLITE_MAX_LENGTH;
}
if (nByte < 0)
{
Debug.Assert(enc != 0);
if (enc == SQLITE_UTF8)
{
for (nByte = 0; nByte <= iLimit && nByte < zBlob.Length - offset && zBlob[offset + nByte] != 0; nByte++)
{
}
}
else
{
for (nByte = 0; nByte <= iLimit && zBlob[nByte + offset] != 0 || zBlob[offset + nByte + 1] != 0; nByte += 2)
{
}
}
}
/* The following block sets the new values of Mem.z and Mem.xDel. It
** also sets a flag in local variable "flags" to indicate the memory
** management (one of MEM_Dyn or MEM_Static).
*/
Debug.Assert(enc == 0);
{
pMem.z = null;
pMem.zBLOB = sqlite3Malloc(n);
Buffer.BlockCopy(zBlob, offset, pMem.zBLOB, 0, n);
}
pMem.n = nByte;
pMem.flags = MEM_Blob | MEM_Term;
pMem.enc = (enc == 0 ? SQLITE_UTF8 : enc);
pMem.type = (enc == 0 ? SQLITE_BLOB : SQLITE_TEXT);
if (nByte > iLimit)
{
return SQLITE_TOOBIG;
}
return SQLITE_OK;
}
开发者ID:broettge,项目名称:MatterControl,代码行数:71,代码来源:vdbemem_c.cs
示例12: sqlite3VdbeMemSetStr
private static int sqlite3VdbeMemSetStr(
Mem pMem, /* Memory cell to set to string value */
string z, /* String pointer */
int n, /* Bytes in string, or negative */
u8 enc, /* Encoding of z. 0 for BLOBs */
dxDel xDel /* Destructor function */
)
{
return sqlite3VdbeMemSetStr(pMem, z, 0, n, enc, xDel);
} // Call w/o offset
开发者ID:broettge,项目名称:MatterControl,代码行数:10,代码来源:vdbemem_c.cs
示例13: sqlite3VdbeMemMove
/*
** Transfer the contents of pFrom to pTo. Any existing value in pTo is
** freed. If pFrom contains ephemeral data, a copy is made.
**
** pFrom contains an SQL NULL when this routine returns.
*/
private static void sqlite3VdbeMemMove(Mem pTo, Mem pFrom)
{
Debug.Assert(pFrom.db == null || sqlite3_mutex_held(pFrom.db.mutex));
Debug.Assert(pTo.db == null || sqlite3_mutex_held(pTo.db.mutex));
Debug.Assert(pFrom.db == null || pTo.db == null || pFrom.db == pTo.db);
sqlite3VdbeMemRelease(pTo);
pFrom.CopyTo(ref pTo);// memcpy(pTo, pFrom, Mem).Length;
pFrom.flags = MEM_Null;
pFrom.xDel = null;
pFrom.z = null;
sqlite3_free(ref pFrom.zBLOB); //pFrom.zMalloc=0;
}
开发者ID:broettge,项目名称:MatterControl,代码行数:19,代码来源:vdbemem_c.cs
示例14: sqlite3VdbeMemShallowCopy
/*
** Size of struct Mem not including the Mem.zMalloc member.
*/
//#define MEMCELLSIZE (size_t)(&(((Mem *)0).zMalloc))
/*
** Make an shallow copy of pFrom into pTo. Prior contents of
** pTo are freed. The pFrom.z field is not duplicated. If
** pFrom.z is used, then pTo.z points to the same thing as pFrom.z
** and flags gets srcType (either MEM_Ephem or MEM_Static).
*/
private static void sqlite3VdbeMemShallowCopy(Mem pTo, Mem pFrom, int srcType)
{
Debug.Assert((pFrom.flags & MEM_RowSet) == 0);
sqlite3VdbeMemReleaseExternal(pTo);
pFrom.CopyTo(ref pTo);// memcpy(pTo, pFrom, MEMCELLSIZE);
pTo.xDel = null;
if ((pFrom.flags & MEM_Static) != 0)
{
pTo.flags = (u16)(pFrom.flags & ~(MEM_Dyn | MEM_Static | MEM_Ephem));
Debug.Assert(srcType == MEM_Ephem || srcType == MEM_Static);
pTo.flags |= (u16)srcType;
}
}
开发者ID:broettge,项目名称:MatterControl,代码行数:25,代码来源:vdbemem_c.cs
示例15: sqlite3VdbeMemCopy
/*
** Make a full copy of pFrom into pTo. Prior contents of pTo are
** freed before the copy is made.
*/
private static int sqlite3VdbeMemCopy(Mem pTo, Mem pFrom)
{
int rc = SQLITE_OK;
Debug.Assert((pFrom.flags & MEM_RowSet) == 0);
sqlite3VdbeMemReleaseExternal(pTo);
pFrom.CopyTo(ref pTo);// memcpy(pTo, pFrom, MEMCELLSIZE);
pTo.flags = (u16)(pTo.flags & ~MEM_Dyn);
if ((pTo.flags & (MEM_Str | MEM_Blob)) != 0)
{
if (0 == (pFrom.flags & MEM_Static))
{
pTo.flags |= MEM_Ephem;
rc = sqlite3VdbeMemMakeWriteable(pTo);
}
}
return rc;
}
开发者ID:broettge,项目名称:MatterControl,代码行数:25,代码来源:vdbemem_c.cs
示例16: sqlite3VdbeMemTooBig
/*
** Return true if the Mem object contains a TEXT or BLOB that is
** too large - whose size exceeds p.db.aLimit[SQLITE_LIMIT_LENGTH].
*/
private static bool sqlite3VdbeMemTooBig(Mem p)
{
//Debug.Assert( p.db != null );
if ((p.flags & (MEM_Str | MEM_Blob)) != 0)
{
int n = p.n;
if ((p.flags & MEM_Zero) != 0)
{
n += p.u.nZero;
}
return n > p.db.aLimit[SQLITE_LIMIT_LENGTH];
}
return false;
}
开发者ID:broettge,项目名称:MatterControl,代码行数:19,代码来源:vdbemem_c.cs
示例17: sqlite3VdbeMemPrepareToChange
/*
** This routine prepares a memory cell for modication by breaking
** its link to a shallow copy and by marking any current shallow
** copies of this cell as invalid.
**
** This is used for testing and debugging only - to make sure shallow
** copies are not misused.
*/
private static void sqlite3VdbeMemPrepareToChange(Vdbe pVdbe, Mem pMem)
{
int i;
Mem pX;
for (i = 1; i <= pVdbe.nMem; i++)
{
pX = pVdbe.aMem[i];
if (pX.pScopyFrom == pMem)
{
pX.flags |= MEM_Invalid;
pX.pScopyFrom = null;
}
}
pMem.pScopyFrom = null;
}
开发者ID:broettge,项目名称:MatterControl,代码行数:24,代码来源:vdbemem_c.cs
示例18: sqlite3VdbeMemSetDouble
/*
** Delete any previous value and set the value stored in pMem to val,
** manifest type REAL.
*/
private static void sqlite3VdbeMemSetDouble(Mem pMem, double val)
{
if (sqlite3IsNaN(val))
{
sqlite3VdbeMemSetNull(pMem);
}
else
{
sqlite3VdbeMemRelease(pMem);
pMem.r = val;
pMem.flags = MEM_Real;
pMem.type = SQLITE_FLOAT;
}
}
开发者ID:broettge,项目名称:MatterControl,代码行数:19,代码来源:vdbemem_c.cs
示例19: sqlite3VdbeMemSetRowSet
/*
** Delete any previous value and set the value of pMem to be an
** empty boolean index.
*/
private static void sqlite3VdbeMemSetRowSet(Mem pMem)
{
sqlite3 db = pMem.db;
Debug.Assert(db != null);
Debug.Assert((pMem.flags & MEM_RowSet) == 0);
sqlite3VdbeMemRelease(pMem);
//pMem.zMalloc = sqlite3DbMallocRaw( db, 64 );
//if ( db.mallocFailed != 0 )
//{
// pMem.flags = MEM_Null;
//}
//else
{
//Debug.Assert( pMem.zMalloc );
pMem.u.pRowSet = new RowSet(db, 5);// sqlite3RowSetInit( db, pMem.zMalloc,
// sqlite3DbMallocSize( db, pMem.zMalloc ) );
Debug.Assert(pMem.u.pRowSet != null);
pMem.flags = MEM_RowSet;
}
}
开发者ID:broettge,项目名称:MatterControl,代码行数:25,代码来源:vdbemem_c.cs
示例20: sqlite3VdbeMemRealify
/*
** Convert pMem so that it is of type MEM_Real.
** Invalidate any prior representations.
*/
private static int sqlite3VdbeMemRealify(Mem pMem)
{
Debug.Assert(pMem.db == null || sqlite3_mutex_held(pMem.db.mutex));
//assert( EIGHT_BYTE_ALIGNMENT(pMem) );
pMem.r = sqlite3VdbeRealValue(pMem);
MemSetTypeFlag(pMem, MEM_Real);
return SQLITE_OK;
}
开发者ID:broettge,项目名称:MatterControl,代码行数:14,代码来源:vdbemem_c.cs
注:本文中的Mem类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论