本文整理汇总了C++中CStr::Resize方法的典型用法代码示例。如果您正苦于以下问题:C++ CStr::Resize方法的具体用法?C++ CStr::Resize怎么用?C++ CStr::Resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStr
的用法示例。
在下文中一共展示了CStr::Resize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadShaderData
//A utility function to load shaders from resource
bool LoadShaderData(CStr& outData, int iShaderID, HINSTANCE hInst, const MSTR& strTypeName)
{
bool bResult = false;
// Load from resource
HRSRC hResourceInfo;
HGLOBAL hResource;
DWORD dwSize;
// find the resource info
hResourceInfo = FindResourceW(hInst, MAKEINTRESOURCEW(iShaderID), strTypeName);
if (hResourceInfo != NULL)
{
// handle to the resource
hResource = LoadResource(hInst, hResourceInfo);
if (hResource != NULL)
{
byte* pStr = (byte*)LockResource(hResource);
dwSize = SizeofResource(hInst, hResourceInfo);
if (pStr != NULL && dwSize != 0)
{
outData.Resize(dwSize + 1); //Reserve '\0' at the end of string
ZeroMemory(outData.dataForWrite(), outData.length());
memcpy(outData.dataForWrite(), pStr, dwSize);
outData.dataForWrite()[dwSize] = '\0';
UnlockResource(hResource);
bResult = true;
}
}
}
return bResult;
}
示例2: Substr
// Substring operator
CStr CStr::Substr(int start, int nchars) const
{
CStr tmp;
int len = Length();
int n = min(start+nchars, len) - start;
tmp.Resize(n);
StringCbCopyA(tmp.buf, n, buf+start);
return tmp;
}
示例3: if
//.........这里部分代码省略.........
c24=(Color_24 *)data;
WRTERR(c24,3);
break;
case MAT_MAP_ANG:
{
MapParams *mp = (MapParams *)data;
float ang,dang;
ang = (float)atan2(mp->ang_sin,mp->ang_cos);
dang = RadToDeg(ang);
#if 0
printf("Saving MAT_MAP_ANG sin = %.4f , cos = %.4f, ang = %.4f \n",
mp->ang_sin, mp->ang_cos, ang);
#endif
WRTERR(&dang,4);
}
break;
case COLOR_F:
cf=(Color_f *)data;
WRTERR(cf,12);
break;
case COLOR_24:
c24=(Color_24 *)data;
WRTERR(c24,3);
break;
case LIN_COLOR_24:
c24 = (Color_24 *)data;
WRTERR(c24,3);
break;
case MAT_NAME: /* Simple strings */
tName = (TCHAR *)data;
cName = tName.ToCP(codePage).data();
if(cName.Length()>16)
cName.Resize(16);
WRTERR(cName.data(),(size_t)( cName.Length()+1));
break;
case MAT_MAPNAME:
tName = (TCHAR *)data;
// convert to 8.3 filename format
EightDotThreeName( tName, false );
cName = tName.ToCP(codePage).data();
if(cName.Length()>12)
cName.Resize(12);
WRTERR( cName.data(),(size_t)( cName.Length()+1));
break;
case MAT_BUMP_PERCENT:
case INT_PERCENTAGE:
WRTERR(data,2);
break;
case MAT_WIRESIZE:
WRTERR(data,4);
break;
case MAT_TWO_SIDE:
case MAT_SUPERSMP:
case MAT_ADDITIVE:
case MAT_WIRE:
case MAT_FACEMAP:
case MAT_XPFALLIN:
case MAT_USE_XPFALL:
case MAT_USE_REFBLUR:
case MAT_PHONGSOFT:
case MAT_WIREABS:
case DUMMY:
break;
case MAT_ACUBIC: {