本文整理汇总了C++中istream::tellg方法的典型用法代码示例。如果您正苦于以下问题:C++ istream::tellg方法的具体用法?C++ istream::tellg怎么用?C++ istream::tellg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类istream
的用法示例。
在下文中一共展示了istream::tellg方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseStream
rspfErrorCode rspfRpfAttributeSectionSubheader::parseStream(istream& in,
rspfByteOrder byteOrder)
{
theAttributeSectionSubheaderStart = 0;
theAttributeSectionSubheaderEnd = 0;
if(in)
{
theAttributeSectionSubheaderStart = in.tellg();
in.read((char*)&theNumberOfAttributeOffsetRecords, 2);
in.read((char*)&theNumberOfExplicitArealCoverageRecords, 2);
in.read((char*)&theAttributeOffsetTableOffset, 4);
in.read((char*)&theAttribteOffsetRecordLength, 2);
rspfEndian anEndian;
if(anEndian.getSystemEndianType() != byteOrder)
{
anEndian.swap(theNumberOfAttributeOffsetRecords);
anEndian.swap(theNumberOfExplicitArealCoverageRecords);
anEndian.swap(theAttributeOffsetTableOffset);
anEndian.swap(theAttribteOffsetRecordLength);
}
theAttributeSectionSubheaderEnd = in.tellg();
}
else
{
return rspfErrorCodes::RSPF_ERROR;
}
return rspfErrorCodes::RSPF_OK;
}
示例2: ReadHeader
int FixedFieldBuffer::ReadHeader(istream & stream){
char *str = new char[headerStrSize+1];
int numFields, *fieldSize;
int result = FixedLengthBuffer::ReadHeader(stream);
if(!result) return -1;
//read header string.
stream.read(str, headerStrSize);
if(!stream.good()) return -1;
if(strncmp(str, headerStr, headerStrSize)!=0) return -1;
stream.read((char*)&numFields, sizeof(numFields));
if(!stream) return -1;
for(int i=0; i<numFields; i++)
stream.read((char*)&fieldSize[i], sizeof(fieldSize[i]));
if(Initialized){
if(numFields!=NumFields) return -1;
for(int j=0; j<numFields; j++)
if(fieldSize[j]!=FieldSize[j]) return -1;
return stream.tellg();
}
Init(numFields, fieldSize);
return stream.tellg();
}
示例3: getStreamSize
static size_t getStreamSize(istream& stream) {
auto startPosition = stream.tellg();
stream.seekg(0, ios_base::end);
auto fileSize = static_cast<size_t>(stream.tellg());
stream.seekg(startPosition);
return fileSize;
}
示例4: preprocess_input
string parser::preprocess_input(istream &stream)
{
streampos start = stream.tellg();
stream.seekg(0, ios::end);
streampos end = stream.tellg();
size_t file_size = end - start;
stream.seekg(start, ios::beg);
char bom_test[3];
static const char * BOM = "\xEF\xBB\xBF";
stream.read(bom_test, 3u);
if (strncmp(bom_test, BOM, 3u) == 0) {
// Matched BOM, keep stream position to prevent its reading
file_size -= 3u;
}
else {
// Seek stream back
stream.seekg(start, ios::beg);
}
char * buffer = new char[file_size + 1];
stream.read(buffer, file_size);
buffer[file_size] = '\0';
string s0(buffer);
delete[] buffer;
string s1 = fix_corrupted_data(s0);
return s1;
}
示例5: getChunkName
void
readsection(HeaderInfo &rwh, uint32 build, uint32 level, istream &rw)
{
for(uint32 i = 0; i < level; i++)
cout << " ";
string name = getChunkName(rwh.type);
cout << name << " (" << hex << rwh.length << " bytes @ 0x" <<
hex << rw.tellg()-(streampos)12 << "/0x" << hex << rw.tellg() <<
") - [0x" << hex << rwh.type << "] " << rwh.build << endl;
streampos end = rw.tellg() + (streampos)rwh.length;
while(rw.tellg() < end){
HeaderInfo newrwh;
newrwh.read(rw);
if(newrwh.build == build){
readsection(newrwh, build, level+1, rw);
/* Native Data PLG has the wrong length */
if(rwh.type == 0x510)
rw.seekg(end, ios::beg);
}else{
streampos sp = rw.tellg()+(streampos)rwh.length;
sp -= 12;
rw.seekg(sp, ios::beg);
break;
}
}
}
示例6: ParseException
ScriptDataTag::ScriptDataTag(istream& s):VideoTag(s)
{
unsigned int start=s.tellg();
tiny_string methodName;
//Specs talks about an arbitrary number of stuff, actually just a string and an array are expected
UI8 Type;
s >> Type;
if(Type!=2)
throw ParseException("Unexpected type in FLV");
ScriptDataString String(s);
methodName=String.getString();
//cout << methodName << endl;
s >> Type;
if(Type!=8)
throw ParseException("Unexpected type in FLV");
ScriptECMAArray ecmaArray(s);
frameRate=ecmaArray.frameRate;
//Compute totalLen
unsigned int end=s.tellg();
totalLen=(end-start)+11;
}
示例7: parseStream
rspfErrorCode rspfRpfImageDisplayParameterSubheader::parseStream(istream& in,
rspfByteOrder byteOrder)
{
clearFields();
if(in)
{
theStartOffset = in.tellg();
in.read((char*)&theNumberOfImageRows, 4);
in.read((char*)&theNumberOfImageCodesPerRow, 4);
in.read((char*)&theImageCodeBitLength, 1);
theEndOffset = in.tellg();
rspfEndian anEndian;
if(anEndian.getSystemEndianType() != byteOrder)
{
anEndian.swap(theNumberOfImageRows);
anEndian.swap(theNumberOfImageCodesPerRow);
}
}
else
{
return rspfErrorCodes::RSPF_ERROR;
}
return rspfErrorCodes::RSPF_OK;
}
示例8: get_fsize
size_t get_fsize(istream& is)
{
size_t fsize = is.tellg();
is.seekg(0, std::ios::end);
fsize = size_t(is.tellg()) - fsize;
is.seekg(0, std::ios::beg);
return fsize;
}
示例9: doCamera
bool SceneLoader::doCamera(istream &str, string &name)
{
if (!getName(str, "camera", name))
return false;
SceneGroup *n = new SceneGroup();
groups[name] = n;
n->_name = name;
n->_camera = new ParametricCamera();
do {
int state = findOpenOrClosedParen(str);
if (state == ERROR) {
SetCameraDefaults(n);
return false;
} else if (state == CLOSED) {
SetCameraDefaults(n);
return true;
}
else if (state == OPEN)
{
string cmd;
vector<ParametricValue*> values;
string sides = "lrbtnf";
int side = 0;
if (readCommand(str, cmd)) {
if (cmd == "perspective") {
if (getValues(str, values) < 1) {
*err << "Perspective with no parameters at ";
errLine(str.tellg());
} else {
cleanAfter(values, 1);
n->_camera->_perspective = values[0];
}
}
else if (cmd.size() == 1 && (side = (int)sides.find(cmd)) != string::npos) {
if (getValues(str, values) < 1) {
*err << "l with no parameters at ";
errLine(str.tellg());
} else {
cleanAfter(values, 1);
n->_camera->_frustum[side] = values[0];
}
}
else
{
*err << "Error: command " << cmd << " not recognized at ";
errLine(str.tellg());
}
findCloseParen(str);
}
}
} while (true);
}
示例10: _getStreamSize
std::streampos Data::_getStreamSize(istream &stream) {
auto current_pos = stream.tellg();
//Retrieve length
stream.seekg(0, stream.end);
auto endpos = stream.tellg();
//Restore old position
stream.seekg(current_pos, stream.beg);
return endpos - current_pos;
}
示例11: doSphere
bool SceneLoader::doSphere(istream &str, string &name)
{
if (!getName(str, "sphere", name))
return false;
SceneGroup *n = new SceneGroup();
groups[name] = n;
n->_name = name;
n->_sphere = new ParametricSphere();
do {
int state = findOpenOrClosedParen(str);
if (state == ERROR) {
SetSphereDefaults(n);
return false;
} else if (state == CLOSED) {
SetSphereDefaults(n);
return true;
} else if (state == OPEN)
{
string cmd;
vector<ParametricValue*> values;
if (readCommand(str, cmd)) {
if (cmd == "radius") {
if (getValues(str, values) < 1) {
*err << "Type with no parameters at ";
errLine(str.tellg());
} else {
cleanAfter(values, 1);
n->_sphere->_radius = values[0];
}
} else if (cmd == "material") {
string matName = getString(str);
if (matName.empty()) {
*err << "No material name after material command at ";
errLine(str.tellg());
} else if (materials[matName] == NULL) {
*err << "Unknown material " << matName << " referenced at ";
errLine(str.tellg());
} else {
n->_sphere->_material = materials[matName];
}
} else {
*err << "Error: command " << cmd << " not recognized at ";
errLine(str.tellg());
}
findCloseParen(str);
}
}
} while (true);
}
示例12: doInclude
// no obj includes in as5; they come back in as6
bool SceneLoader::doInclude(istream &str, string& name)
{
if (!getName(str, "include", name))
return false;
SceneGroup *n = new SceneGroup();
groups[name] = n;
n->_name = name;
string file = getQuoted(str);
n->_mesh = new OBJTriangleMesh(file);
do {
int state = findOpenOrClosedParen(str);
if (state == ERROR) {
if (n->_meshMaterial == NULL) {
n->_meshMaterial = new ParametricMaterial();
SetMaterialDefaults(n->_meshMaterial);
}
return false;
} else if (state == CLOSED) {
if (n->_meshMaterial == NULL) {
n->_meshMaterial = new ParametricMaterial();
SetMaterialDefaults(n->_meshMaterial);
}
return true;
} else if (state == OPEN) {
string cmd;
if (readCommand(str, cmd)) {
if (cmd == "material") {
string matName = getString(str);
if (matName.empty()) {
*err << "No material name after material command at ";
errLine(str.tellg());
} else if (materials[matName] == NULL) {
*err << "Unknown material " << matName << " referenced at ";
errLine(str.tellg());
} else {
n->_meshMaterial = materials[matName];
}
} else {
*err << "Error: command " << cmd << " not recognized at ";
errLine(str.tellg());
}
findCloseParen(str);
}
}
} while (true);
}
示例13: FromStream
void CL_TimeOfDay::FromStream (istream& s)
{
CL_String rep;
char c;
long count = 0;
char fill_char = s.fill ();
while (s.get (c) && c == fill_char);
if (!s.good() || s.eof()) {
_numSecs = 0;
return;
}
do {
if (isalnum (c) || c == ':') {
rep.Append (c);
count++;
}
else
break;
} while (s.get (c));
long n = ParseAndConvert (rep);
if (n > 0) {
if (!s.eof())
s.putback (c);
_numSecs = n;
}
else {
s.seekg (s.tellg() - count, istream::cur);
_numSecs = 0;
}
}
示例14: filesize
bool DSA1Intro::read(istream& strm) {
header_size = 20;
file_size = filesize(strm);
count = read16(strm);
// TODO: Was bedeutet der Rest des Headers?
strm.seekg(0x20);
while(strm.tellg() < file_size) {
DSA1Intro_Entry* entry = new DSA1Intro_Entry;
if (!entry->read(strm)) {
entry->name = "DUMMY";
entry->size = 0;
entry->volname = "DUMMY";
entry->offset = 0;
entries.push_back(entry);
//delete entry;
} else {
// Nach Duplikaten suchen und diese entfernen
/*for (u32 j=0; j<entries.size(); j++) {
if (entry->name == entries[j]->name) {
delete entry;
entry = 0;
break;
}
}*/
if (entry == 0) continue;
else entries.push_back(entry);
}
}
//assert(count == entries.size());
return true;
}
示例15: add
int
Patch::read_stream(istream &is, vector<string> &leftover)
{
leftover.clear();
// Number of faces in this patch
int num_faces;
is >> num_faces;
bool debug = Config::get_var_bool("DEBUG_PATCH_READ_STREAM",false);
if (debug)
err_msg("\n********\nPatch::read_stream: %d faces to read", num_faces);
if (num_faces > 0) {
if (debug)
err_msg("Patch::read_stream: reading %d faces from file", num_faces);
// for each face...
int face;
for (int f = 0; f < num_faces; f++) {
is >> face;
if (face < _mesh->nfaces()) {
add(_mesh->bf(face));
} else {
cerr << "Patch::read_stream - face " << face << " > "
<< _mesh->nfaces()
<< ", at byte " << is.tellg() << endl;
}
}
} else {
if (debug)