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


C++ SetLength函数代码示例

本文整理汇总了C++中SetLength函数的典型用法代码示例。如果您正苦于以下问题:C++ SetLength函数的具体用法?C++ SetLength怎么用?C++ SetLength使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: EncodeDSA_Signature

word32 EncodeDSA_Signature(const Integer& r, const Integer& s, byte* output)
{
    word32 rSz = r.ByteCount();
    word32 sSz = s.ByteCount();

    byte rLen[MAX_LENGTH_SZ + 1];
    byte sLen[MAX_LENGTH_SZ + 1];

    rLen[0] = INTEGER;
    sLen[0] = INTEGER;

    word32 rLenSz = SetLength(rSz, &rLen[1]) + 1;
    word32 sLenSz = SetLength(sSz, &sLen[1]) + 1;

    byte seqArray[MAX_SEQ_SZ];

    word32 seqSz = SetSequence(rLenSz + rSz + sLenSz + sSz, seqArray);
    
    // seq
    memcpy(output, seqArray, seqSz);
    // r
    memcpy(output + seqSz, rLen, rLenSz);
    r.Encode(output + seqSz + rLenSz, rSz);
    // s
    memcpy(output + seqSz + rLenSz + rSz, sLen, sLenSz);
    s.Encode(output + seqSz + rLenSz + rSz + sLenSz, sSz);

    return seqSz + rLenSz + rSz + sLenSz + sSz;
}
开发者ID:zhongliangkang,项目名称:mysql-5.6.6-labs-april-2012-sky,代码行数:29,代码来源:asn.cpp

示例2: length

void vec_GF2::SetMaxLength(long n)
{
   long oldlen = length();
   if (n > oldlen) {
      SetLength(n);
      SetLength(oldlen);
   }
}
开发者ID:Brainloop-Security,项目名称:secret-sharing,代码行数:8,代码来源:vec_GF2.cpp

示例3: D3DXVec3Normalize

//	AI MOVE
void	cMobKnight::AI_StatusMove	( D3DXVECTOR3 Pos )
{
	D3DXVec3Normalize( &m_vMonster_dir, &m_vMonster_dir );
	m_vMonster_dir *= m_Velocity;
	if( SetLength( Pos ) < 200.0f && SetLength( Pos ) > 23.0f && m_Status.ActionCansle == true )
	{
		MOVE();
		m_vPos.x += ( m_vMonster_dir.x );
		m_vPos.z += ( m_vMonster_dir.z );
	}
}
开发者ID:Portfolio870920,项目名称:PF,代码行数:12,代码来源:cMobKnight.cpp

示例4: GetBeginAtom

  void OBBond::SetLength(double length)
  {
    OBAtom *atom1 = GetBeginAtom();
    OBAtom *atom2 = GetEndAtom();

    //split the length difference in half, and modify the bond twice
    double firstLength = length + ((GetLength() - length) / 2);

    SetLength(atom1, firstLength);
    SetLength(atom2, length);
  }
开发者ID:AlbertDeFusco,项目名称:openbabel,代码行数:11,代码来源:bond.cpp

示例5: SetLength

bool TextDocument::Load(char *File)
{
	bool Status = FALSE;

	if (Open(File, O_READ))
	{
		int FileSize = F.GetSize();
		if (SetLength(FileSize))
		{
			F.Read(Data, FileSize);
			
			CrLf = FALSE;

			char *In = Data, *Out = Data;
			int Size = 0;
			for (int i=0; i<FileSize; i++, In++)
			{
				if (*In != '\r')
				{
					*Out++ = *In;
					Size++;
				}
				else
				{
					if (In[1] != '\n')
					{
						// Macintrash file
						*Out++ = '\n';
						Size++;
					}
					else
					{
						CrLf = TRUE;
					}
				}
			}

			Status = SetLength(Size);
			Data[Length] = 0;
			Lines = max(CountLines(Data), 1);
		}

		F.Close();
		Dirty = FALSE;
	}

	return Status;
}
开发者ID:FEI17N,项目名称:Lgi,代码行数:48,代码来源:GText.cpp

示例6: SetValue

void customOptionList::SetValue(int i, const char *format, ...)
{
	if(i >= length) SetLength(i+1);

	if(i >= 0 && i < length)
	{
		char *tmp=0;
		va_list va;
		va_start(va, format);
		vasprintf(&tmp, format, va);
		va_end(va);

		if(tmp)
		{
			if(value[i] && !strcmp(tmp, value[i]))
				free(tmp);
			else
			{
				free(value[i]);
				value[i] = tmp;
				changed = true;
			}
		}
	}
}
开发者ID:smurk-too,项目名称:wodebrew,代码行数:25,代码来源:gui_customoptionbrowser.cpp

示例7: GetMarker

// writes ae desc data out to the stream
void CNewHandleStream::WriteAEDescData(
	const AEDesc	&inDesc)
{
	Size			byteCount=::AEGetDescDataSize(&inDesc);
	
	ExceptionCode	err = noErr;
	SInt32			endOfWrite = GetMarker() + byteCount;

	if (endOfWrite > GetLength()) {		// Need to grow Handle

		try {
			SetLength(endOfWrite);
		}

		catch (ExceptionCode inErr) {	// Grow failed. Write only what fits.
			byteCount = GetLength() - GetMarker();
			err = inErr;
		}

		catch (const LException& inException) {
			byteCount = GetLength() - GetMarker();
			err = inException.GetErrorCode();
		}
	}
										// Copy bytes into Handle
	if (byteCount > 0) {				//   Byte count will be zero if
										//   mDataH is nil
//		::BlockMoveData(inBuffer, *mDataH + GetMarker(), ioByteCount);
		UHandleLocker		locked(mDataH);
		err=::AEGetDescData(&inDesc,*mDataH + GetMarker(), byteCount);
		SetMarker(byteCount, streamFrom_Marker);
	}

	ThrowIfOSErr_(err);
}
开发者ID:MaddTheSane,项目名称:tntbasic,代码行数:36,代码来源:TNewHandleStream.cpp

示例8: ReadZ

int CGString::ReadZ( CFile * pFile, int iLenMax )
{
	//@------------------------------------------------------------------------
	// PURPOSE:
	//  Read in a new string from an open MMSYSTEM file.
	// ARGS:
	//  hmmio = the open file.
	//  iLen = The length of the string to read. NOT THE NULL !
	// RETURN:
	//  <= 0 = error or no valid string.
	//  length of the string.
	//@------------------------------------------------------------------------

	if ( ! SetLength( iLenMax ))
		return( -1 );

	if ( pFile->Read( m_pchData, iLenMax ) != (DWORD) iLenMax )
		return( -1 );

	//
	// Make sure it is null terminated.
	//
	m_pchData[ iLenMax ] = '\0';
	return( iLenMax );
}
开发者ID:GenerationOfWorlds,项目名称:Sphere,代码行数:25,代码来源:CFile.cpp

示例9: Length

void CUtlString::TrimRight( const char *szTargets )
{
	const int nLastCharIndex = Length() - 1;
	int i;

	for( i = nLastCharIndex; i > 0; i-- )
	{
		bool bWhitespace = false;

		for( int j = 0; szTargets[j] != 0; j++ )
		{
			if ( m_pString[i] == szTargets[j] )
			{
				bWhitespace = true;
				break;
			}
		}

		if ( !bWhitespace )
		{
			break;
		}
	}

	// We have some whitespace to remove
	if ( i < nLastCharIndex )
	{
		m_pString[i + 1] = 0;
		SetLength( i + 2 );
	}
}
开发者ID:Adidasman1,项目名称:source-sdk-2013,代码行数:31,代码来源:utlstring.cpp

示例10: memcpy

void CUtlString::TrimLeft( const char *szTargets )
{
	int i;

	if ( IsEmpty() )
	{
		return;
	}

	for( i = 0; m_pString[i] != 0; i++ )
	{
		bool bWhitespace = false;

		for( int j = 0; szTargets[j] != 0; j++ )
		{
			if ( m_pString[i] == szTargets[j] )
			{
				bWhitespace = true;
				break;
			}
		}

		if ( !bWhitespace )
		{
			break;
		}
	}

	// We have some whitespace to remove
	if ( i > 0 )
	{
		memcpy( m_pString, &m_pString[i], Length() - i );
		SetLength( Length() - i );
	}
}
开发者ID:Adidasman1,项目名称:source-sdk-2013,代码行数:35,代码来源:utlstring.cpp

示例11: SetLength

void CHttpString::SetData(CString strData){
	int nLeft = str.Find("\r\n\r\n");
	str.Delete(nLeft + 4,str.GetLength() - nLeft - 4);
	str = str + strData;
	SetLength(strData.GetLength());
	return;
}
开发者ID:xylsxyls,项目名称:xueyelingshuang,代码行数:7,代码来源:CHttpString.cpp

示例12: SetLength

/**
*  @brief
*    Calculates a normalized projection vector
*/
Vector4 &Vector4::GetProjection(const Vector4 &vX, const Vector4 &vN)
{
	*this = vX + vN*(-vN.DotProduct(vX)/vN.DotProduct(vN));
	SetLength(1.0f);

	return *this;
}
开发者ID:ByeDream,项目名称:pixellight,代码行数:11,代码来源:Vector4.cpp

示例13: CopyArray

bool ON_wString::UrlDecode()
{
  CopyArray();

  bool rc = true;
  wchar_t c;
  wchar_t* s0 = Array();
  if ( !s0 )
    return true;
  wchar_t* s1 = s0;
  //const wchar_t* debg = s1;
  int i;
  for (i = Length(); i > 0; i-- )
  {
    c = *s0++;
    if (0==c)
      break;
    if (i >= 3 && '%' == c && UrlDecodeHelper(s0) )
    {
      s0++;
      *s1++ = *s0++;
      i -= 2;
    }
    else
    {
      *s1++ = c;
      if (rc)
        rc = IsValidUrlChar(c);
    }
  }
  *s1 = 0;
  SetLength(s1 - Array());
  return rc;
}
开发者ID:ckvk,项目名称:opennurbs,代码行数:34,代码来源:opennurbs_wstring.cpp

示例14: copy

void
nsACString::StripChars(const char *aSet)
{
  nsCString copy(*this);

  const char_type *source, *sourceEnd;
  copy.BeginReading(&source, &sourceEnd);

  char_type *dest;
  BeginWriting(&dest);
  if (!dest)
    return;

  char_type *curDest = dest;

  for (; source < sourceEnd; ++source) {
    const char *test;
    for (test = aSet; *test; ++test) {
      if (*source == char_type(*test))
        break;
    }

    if (!*test) {
      // not stripped, copy this char
      *curDest = *source;
      ++curDest;
    }
  }

  SetLength(curDest - dest);
}
开发者ID:mikeaich,项目名称:releases-mozilla-central,代码行数:31,代码来源:nsStringAPI.cpp

示例15: Length

int TString::cat_vprintf( const char* format, va_list args )
{
    int currentlen = Length();
    int len = vsnprintf( NULL, 0, format, args );
    SetLength( len + currentlen );
    return vsprintf( c_str() + currentlen, format, args );
}
开发者ID:Sustak,项目名称:final.utils,代码行数:7,代码来源:str.cpp


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