本文整理汇总了C++中std::iostream::read方法的典型用法代码示例。如果您正苦于以下问题:C++ iostream::read方法的具体用法?C++ iostream::read怎么用?C++ iostream::read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::iostream
的用法示例。
在下文中一共展示了iostream::read方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Event
SkillLevelEvent::SkillLevelEvent( std::iostream& ios )
: Event(ios)
{
// Read bonus
ios.read( (char*) &bonus, sizeof( bonus ) );
// Read skill
ios.read( (char*) &skill, sizeof( skill ) );
}
示例2: Item
Ammo::Ammo( std::iostream& inFile, TargetValue* TVP )
// Read Item base information:
: Item (inFile, TVP)
{
// Read char form
inFile.read( (char*) &form, sizeof(form) );
// Read bool fired
inFile.read( (char*) &fired, sizeof(fired) );
}
示例3: sizeof
Event::Event( std::iostream& ios )
{
ios.read( (char*) &time, sizeof(time) );
Timeline::add( this );
}
示例4: test_seekable_in_chunks
bool test_seekable_in_chunks(std::iostream& io)
{
int i; // old 'for' scope workaround.
// Test seeking with ios::cur
for (i = 0; i < data_reps; ++i) {
io.write(narrow_data(), chunk_size);
io.seekp(-chunk_size, BOOST_IOS::cur);
char buf[chunk_size];
io.read(buf, chunk_size);
if (strncmp(buf, narrow_data(), chunk_size) != 0)
return false;
io.seekp(-chunk_size, BOOST_IOS::cur);
io.write(narrow_data(), chunk_size);
}
// Test seeking with ios::beg
std::streamoff off = 0;
io.seekp(0, BOOST_IOS::beg);
for (i = 0; i < data_reps; ++i, off += chunk_size) {
io.write(narrow_data(), chunk_size);
io.seekp(off, BOOST_IOS::beg);
char buf[chunk_size];
io.read(buf, chunk_size);
if (strncmp(buf, narrow_data(), chunk_size) != 0)
return false;
io.seekp(off, BOOST_IOS::beg);
io.write(narrow_data(), chunk_size);
}
// Test seeking with ios::end
io.seekp(0, BOOST_IOS::end);
off = io.tellp();
io.seekp(-off, BOOST_IOS::end);
for (i = 0; i < data_reps; ++i, off -= chunk_size) {
io.write(narrow_data(), chunk_size);
io.seekp(-off, BOOST_IOS::end);
char buf[chunk_size];
io.read(buf, chunk_size);
if (strncmp(buf, narrow_data(), chunk_size) != 0)
return false;
io.seekp(-off, BOOST_IOS::end);
io.write(narrow_data(), chunk_size);
}
return true;
}
示例5: Item
Fluid::Fluid( std::iostream& inFile, TargetValue* TVP )
// Read Item base information:
: Item (inFile, TVP)
{
// Read materialClass f_material
inFile.read( (char*) &f_material, sizeof(f_material) );
}
示例6: saveFile
bool ResourceManager::saveFile(const std::string& fileName, std::iostream& in)
{
std::streampos oldPos = in.tellg();
in.seekg(0, std::ios::end);
std::streampos size = in.tellg();
in.seekg(0, std::ios::beg);
std::vector<char> buffer(size);
in.read(&buffer[0], size);
bool ret = saveFile(fileName, (const uchar*)&buffer[0], size);
in.seekg(oldPos, std::ios::beg);
return ret;
}
示例7: FillStream
void FillStream(std::iostream& strm, RawData& expression)
{
static const std::string s_smallExpression("0123456789abcdefghijklmnopqrstuvwxyz");
static const int iterationsCount = 10;
for (int i = 0; i < iterationsCount; ++i)
{
strm << s_smallExpression;
}
size_t expressionSize = iterationsCount * s_smallExpression.size();
expression.resize(expressionSize);
strm.read(reinterpret_cast<char*>(&expression[0]), expressionSize);
strm.seekg(0);
}