当前位置: 首页>>代码示例>>C#>>正文


C# Expr.Copy方法代码示例

本文整理汇总了C#中Expr.Copy方法的典型用法代码示例。如果您正苦于以下问题:C# Expr.Copy方法的具体用法?C# Expr.Copy怎么用?C# Expr.Copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Expr的用法示例。


在下文中一共展示了Expr.Copy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: exprDup

    /*
    ** This function is similar to sqlite3ExprDup(), except that if pzBuffer
    ** is not NULL then *pzBuffer is assumed to point to a buffer large enough
    ** to store the copy of expression p, the copies of p->u.zToken
    ** (if applicable), and the copies of the p->pLeft and p->pRight expressions,
    ** if any. Before returning, *pzBuffer is set to the first byte passed the
    ** portion of the buffer copied into by this function.
    */
    static Expr exprDup( sqlite3 db, Expr p, int flags, ref Expr pzBuffer )
    {
      Expr pNew = null;                      /* Value to return */
      if ( p != null )
      {
        bool isReduced = ( flags & EXPRDUP_REDUCE ) != 0;
        Expr zAlloc = new Expr();
        u32 staticFlag = 0;

        Debug.Assert( pzBuffer == null || isReduced );

        /* Figure out where to write the new Expr structure. */
        //if ( pzBuffer !=null)
        //{
        //  zAlloc = pzBuffer;
        //  staticFlag = EP_Static;
        //}
        //else
        //{
        ///Expr  zAlloc = new Expr();//sqlite3DbMallocRaw( db, dupedExprSize( p, flags ) );
        //}
        // (Expr)zAlloc;

        //if ( pNew != null )
        {
          /* Set nNewSize to the size allocated for the structure pointed to
          ** by pNew. This is either EXPR_FULLSIZE, EXPR_REDUCEDSIZE or
          ** EXPR_TOKENONLYSIZE. nToken is set to the number of bytes consumed
          ** by the copy of the p->u.zToken string (if any).
          */
          int nStructSize = dupedExprStructSize( p, flags );
          int nNewSize = nStructSize & 0xfff;
          int nToken;
          if ( !ExprHasProperty( p, EP_IntValue ) && !String.IsNullOrEmpty( p.u.zToken ) )
          {
            nToken = sqlite3Strlen30( p.u.zToken );
          }
          else
          {
            nToken = 0;
          }
          if ( isReduced )
          {
            Debug.Assert( !ExprHasProperty( p, EP_Reduced ) );
            pNew = p.Copy( EXPR_TOKENONLYSIZE );//memcpy( zAlloc, p, nNewSize );
          }
          else
          {
            int nSize = exprStructSize( p );
            //memcpy( zAlloc, p, nSize );
            pNew = p.Copy();
            //memset( &zAlloc[nSize], 0, EXPR_FULLSIZE - nSize );
          }

          /* Set the EP_Reduced, EP_TokenOnly, and EP_Static flags appropriately. */
          unchecked
          {
            pNew.flags &= (ushort)( ~( EP_Reduced | EP_TokenOnly | EP_Static ) );
          }
          pNew.flags |= (ushort)( nStructSize & ( EP_Reduced | EP_TokenOnly ) );
          pNew.flags |= (ushort)staticFlag;

          /* Copy the p->u.zToken string, if any. */
          if ( nToken != 0 )
          {
            string zToken;// = pNew.u.zToken = (char)&zAlloc[nNewSize];
            zToken = p.u.zToken.Substring( 0, nToken );// memcpy( zToken, p.u.zToken, nToken );
          }

          if ( 0 == ( ( p.flags | pNew.flags ) & EP_TokenOnly ) )
          {
            /* Fill in the pNew.x.pSelect or pNew.x.pList member. */
            if ( ExprHasProperty( p, EP_xIsSelect ) )
            {
              pNew.x.pSelect = sqlite3SelectDup( db, p.x.pSelect, isReduced ? 1 : 0 );
            }
            else
            {
              pNew.x.pList = sqlite3ExprListDup( db, p.x.pList, isReduced ? 1 : 0 );
            }
          }

          /* Fill in pNew.pLeft and pNew.pRight. */
          if ( ExprHasAnyProperty( pNew, EP_Reduced | EP_TokenOnly ) )
          {
            //zAlloc += dupedExprNodeSize( p, flags );
            if ( ExprHasProperty( pNew, EP_Reduced ) )
            {
              pNew.pLeft = exprDup( db, p.pLeft, EXPRDUP_REDUCE, ref pzBuffer );
              pNew.pRight = exprDup( db, p.pRight, EXPRDUP_REDUCE, ref pzBuffer );
            }
            //if ( pzBuffer != null )
//.........这里部分代码省略.........
开发者ID:laboratoryyingong,项目名称:BARLESS,代码行数:101,代码来源:expr_c.cs

示例2: exprDup

		/*
		** This function is similar to sqlite3ExprDup(), except that if pzBuffer
		** is not NULL then *pzBuffer is assumed to point to a buffer large enough
		** to store the copy of expression p, the copies of p->u.zToken
		** (if applicable), and the copies of the p->pLeft and p->pRight expressions,
		** if any. Before returning, *pzBuffer is set to the first byte passed the
		** portion of the buffer copied into by this function.
		*/
		static Expr exprDup(sqlite3 db, Expr p, int flags, ref Expr pzBuffer)
		{
			Expr pNew = null;                      /* Value to return */
			if (p != null)
			{
				bool isReduced = (flags & EXPRDUP_REDUCE) != 0;
				u32 staticFlag = 0;

				Debug.Assert(pzBuffer == null || isReduced);

				/* Figure out where to write the new Expr structure. */
				{
					/* Set nNewSize to the size allocated for the structure pointed to
					** by pNew. This is either EXPR_FULLSIZE, EXPR_REDUCEDSIZE or
					** EXPR_TOKENONLYSIZE. nToken is set to the number of bytes consumed
					** by the copy of the p->u.zToken string (if any).
					*/
					int nStructSize = dupedExprStructSize(p, flags);
					if (isReduced)
					{
						Debug.Assert(!ExprHasProperty(p, EP_Reduced));
						pNew = p.Copy(EXPR_TOKENONLYSIZE);//memcpy( zAlloc, p, nNewSize );
					}
					else
					{
						pNew = p.Copy();
					}

					/* Set the EP_Reduced, EP_TokenOnly, and EP_Static flags appropriately. */
					unchecked
					{
						pNew.flags &= (ushort)(~(EP_Reduced | EP_TokenOnly | EP_Static));
					}
					pNew.flags |= (ushort)(nStructSize & (EP_Reduced | EP_TokenOnly));
					pNew.flags |= (ushort)staticFlag;
					if (0 == ((p.flags | pNew.flags) & EP_TokenOnly))
					{
						/* Fill in the pNew.x.pSelect or pNew.x.pList member. */
						if (ExprHasProperty(p, EP_xIsSelect))
						{
							pNew.x.pSelect = sqlite3SelectDup(db, p.x.pSelect, isReduced ? 1 : 0);
						}
						else
						{
							pNew.x.pList = sqlite3ExprListDup(db, p.x.pList, isReduced ? 1 : 0);
						}
					}

					/* Fill in pNew.pLeft and pNew.pRight. */
					if (ExprHasAnyProperty(pNew, EP_Reduced | EP_TokenOnly))
					{
						if (ExprHasProperty(pNew, EP_Reduced))
						{
							pNew.pLeft = exprDup(db, p.pLeft, EXPRDUP_REDUCE, ref pzBuffer);
							pNew.pRight = exprDup(db, p.pRight, EXPRDUP_REDUCE, ref pzBuffer);
						}
					}
					else
					{
						pNew.flags2 = 0;
						if (!ExprHasAnyProperty(p, EP_TokenOnly))
						{
							pNew.pLeft = sqlite3ExprDup(db, p.pLeft, 0);
							pNew.pRight = sqlite3ExprDup(db, p.pRight, 0);
						}
					}
				}
			}
			return pNew;
		}
开发者ID:jcwmoore,项目名称:athena,代码行数:78,代码来源:expr_c.cs


注:本文中的Expr.Copy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。