本文整理汇总了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;
}
示例2: length
void vec_GF2::SetMaxLength(long n)
{
long oldlen = length();
if (n > oldlen) {
SetLength(n);
SetLength(oldlen);
}
}
示例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 );
}
}
示例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);
}
示例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;
}
示例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;
}
}
}
}
示例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);
}
示例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 );
}
示例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 );
}
}
示例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 );
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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 );
}