本文整理汇总了C++中std::fstream::read方法的典型用法代码示例。如果您正苦于以下问题:C++ fstream::read方法的具体用法?C++ fstream::read怎么用?C++ fstream::read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::fstream
的用法示例。
在下文中一共展示了fstream::read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeof
bool Organism::State::Load (std::fstream &File) {
int Count;
File.read ((char *) &Count, sizeof (int));
char *cname = new char [Count];
File.read ((char *) cname, sizeof (char) * Count);
Name = cname;
delete [] cname;
if (!File.good ())
return false;
return true;
}
示例2: ReadSector
void ReadSector(char* buffer, size_t sec) {
sec += partitionOffset;
if (sec > partitionLength)
return;
f.seekg(sec * 512, std::ios::beg);
f.read(buffer, 512);
}
示例3: readBlob
inline bool PBFParser::readBlob(std::fstream &stream, ParserThreadData *thread_data)
{
if (stream.eof())
{
return false;
}
const int size = thread_data->PBFBlobHeader.datasize();
if (size < 0 || size > MAX_BLOB_SIZE)
{
std::cerr << "[error] invalid Blob size:" << size << std::endl;
return false;
}
char *data = new char[size];
stream.read(data, sizeof(data[0]) * size);
if (!thread_data->PBFBlob.ParseFromArray(data, size))
{
std::cerr << "[error] failed to parse blob" << std::endl;
delete[] data;
return false;
}
if (thread_data->PBFBlob.has_raw())
{
const std::string &data = thread_data->PBFBlob.raw();
thread_data->charBuffer.clear();
thread_data->charBuffer.resize(data.size());
std::copy(data.begin(), data.end(), thread_data->charBuffer.begin());
}
else if (thread_data->PBFBlob.has_zlib_data())
{
if (!unpackZLIB(thread_data))
{
std::cerr << "[error] zlib data encountered that could not be unpacked" << std::endl;
delete[] data;
return false;
}
}
else if (thread_data->PBFBlob.has_lzma_data())
{
if (!unpackLZMA(thread_data))
{
std::cerr << "[error] lzma data encountered that could not be unpacked" << std::endl;
}
delete[] data;
return false;
}
else
{
std::cerr << "[error] Blob contains no data" << std::endl;
delete[] data;
return false;
}
delete[] data;
return true;
}
示例4: sizeof
void
CBOLoader::_readIndexData (std::shared_ptr<nau::geometry::IndexData>& anIndexData, std::fstream &f) {
unsigned int siz;
unsigned int countFilledArrays;
f.read(reinterpret_cast<char *> (&countFilledArrays), sizeof (countFilledArrays));
f.read (reinterpret_cast<char *> (&siz), sizeof (siz));
if (siz > 0) {
std::shared_ptr<std::vector<unsigned int>> aNewVector =
std::shared_ptr<std::vector<unsigned int>>(new std::vector<unsigned int>(siz));
f.read (reinterpret_cast<char *> (&(*aNewVector)[0]), siz * sizeof (unsigned int));
anIndexData->setIndexData (aNewVector);
}
}
示例5:
bool
StandardFileProvider::read( void* buffer, Size size, Size& nin, Size maxChunkSize )
{
_fstream.read( (char*)buffer, size );
if( _fstream.fail() )
return true;
nin = _fstream.gcount();
return false;
}
示例6: readString
unsigned readString(char* _str,unsigned _count) {
if(size==0 || _str==0 || _count==0)
return 0;
char ch[1];
unsigned i=0;
for(i=0; i<_count && file.read(ch,sizeof(ch)); ++i) //读取文件中的内容
sprintf(_str+2*i,"%02x",int(ch[0])+128);
return i;
}
示例7: patchdef
void stex::Tri::restore(std::fstream & cp_file)
{
uint nspecs = patchdef()->countSpecs();
cp_file.read((char*)pPoolCount, sizeof(uint) * nspecs);
cp_file.read((char*)pPoolFlags, sizeof(uint) * nspecs);
KProcPVecCI e = pKProcs.end();
for (KProcPVecCI i = pKProcs.begin(); i != e; ++i) (*i)->restore(cp_file);
}
示例8: ByteToInt
int Camera::ByteToInt(std::fstream& _file)
{
char b[4];
int temp = 0;
_file.read( b, sizeof(int) );
memcpy( &temp, b, sizeof(int) );
return temp;
}
示例9: Read
bool OsFileImpl::Read( void* Data, size_t Size )
{
if( !IsValid() )
{
return false;
}
mFile.read( ( char* )Data, Size );
mPosition = mFile.tellg();
return IsValid();
}
示例10: read
void Camera::read(std::fstream& stream, int versionNumber)
{
stream.read((char*)&fogColor, sizeof(fogColor));
setFogColor(fogColor);
stream.read((char*)&fogStrength, sizeof(fogStrength));
setFogStrength(fogStrength);
if (versionNumber >= 6)
{
stream.read((char*)&fogColor, sizeof(fogColor));
setFogColor(fogColor);
stream.read((char*)&zoom ,sizeof(zoom));
}
if (versionNumber >= 11)
stream.read((char*)&sunStrength, sizeof(sunStrength));
}
示例11: ByteToCamPath
camPath Camera::ByteToCamPath(std::fstream& _file)
{
char b[sizeof(camPath)];
camPath cp;
_file.read(b, sizeof(camPath));
memcpy(&cp, b, sizeof(camPath));
return cp;
}
示例12: ReadOffsetString
//ReadOffsetString
// Reads in the next 4 bytes as an offset to a zero-terminated string value, then
// allocates and fills in the provided string with that value.
void ReadOffsetString(std::fstream& f, char*& sz)
{
int32_t i;
char szBuffer[4];
f.read(szBuffer, 4);
if (*(int32_t*)szBuffer == 0)
sz = NULL;
else
{
f.seekg(*(int32_t*)szBuffer - 4, ios::cur);
for (i = 0; f.get() != '\0'; ++i);
f.seekg(-(i + 1), ios::cur);
sz = new char[i + 1];
f.read(sz, i);
sz[i] = '\0';
}
f.seekg(4 - *(int32_t*)szBuffer - i, ios::cur);
}
示例13: Material
/* Creates the material from a scene file. */
FrostedGlass::FrostedGlass(std::fstream& file, std::vector<Distribution*>* distributions) : Material(file)
{
/* Read the material definition from the scene file. */
FrostedGlassDefinition definition;
file.read((char*)&definition, sizeof(FrostedGlassDefinition));
/* Get the appropriate distribution from the distribution vector. */
this->refractiveIndex = distributions->at(definition.refractiveIndex);
this->roughness = definition.roughness;
}
示例14: floats
void G3D::readVertices(std::fstream & fs, std::vector<float*> & vertexAttributes, const GeometryInfo & info)
{
for (uint32_t i=0; i<info.attributeSemantics.size(); ++i)
{
vertexAttributes.push_back(NULL);
uint32_t attributeFloats = floats(info.attributeSemantics.at(i));
vertexAttributes.at(i) = new float[info.numberVertices * attributeFloats];
fs.read((char*)vertexAttributes.at(i), info.numberVertices * attributeFloats * sizeof(float));
}
}
示例15: readUNPW
int User::readUNPW(std::fstream &fin){
auto fpos = fin.cur;
fin.seekg(0, fin.beg);
fin.read(username, sizeof(str));
fin.read(password, sizeof(str));
decode(username);
decode(password);
fin.seekg(fpos);
return 0;
}