本文整理汇总了C++中hkArray::setSize方法的典型用法代码示例。如果您正苦于以下问题:C++ hkArray::setSize方法的具体用法?C++ hkArray::setSize怎么用?C++ hkArray::setSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hkArray
的用法示例。
在下文中一共展示了hkArray::setSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: path
const char* HK_CALL hkDemoFileSystem::removeDemoBasePath( const char* pathIn, hkArray<char>& buffer )
{
hkString path( pathIn );
path.makeLowerCase();
// strip everything up to the demo root folder
hkString root("/demos/");
root.makeLowerCase();
const char* str = path.cString();
const char* start = hkString::strStr(str, root.cString());
if ( start != HK_NULL )
{
int pos = static_cast<int>(start - str) + root.getLength();
buffer.setSize( path.getLength() - pos + 1 );
// copy the part of the string that follows the demo prefix
hkString::memCpy( buffer.begin(), pathIn+pos, buffer.getSize()-1 );
buffer[ buffer.getSize()-1 ] = 0; // null terminate
return buffer.begin();
}
else
{
// nothing to do
return pathIn;
}
}
示例2: loadEntireFileIntoBuffer
void loadEntireFileIntoBuffer(const char* filepath, hkArray<char>& outBuf)
{
// Load the entire file
// Open a stream to read the file
hkIstream infile( filepath );
HK_ASSERT( 0x215d080c, infile.isOk() );
if( infile.getStreamReader()->seekTellSupported() )
{
infile.getStreamReader()->seek(0, hkStreamReader::STREAM_END);
outBuf.reserve( infile.getStreamReader()->tell() );
infile.getStreamReader()->seek(0, hkStreamReader::STREAM_SET);
}
// read entire file into local buffer
int nread = 1;
while( nread )
{
const int CSIZE = 8192;
char* b = outBuf.expandBy( CSIZE ); // outBuf.reserve( outBuf.getSize() + CSIZE ); b = outBuf.begin() + outBuf.getSize();
nread = infile.read( b, CSIZE );
outBuf.setSize( outBuf.getSize() + nread - CSIZE );
}
}