本文整理汇总了C++中trpgReadBuffer::Get方法的典型用法代码示例。如果您正苦于以下问题:C++ trpgReadBuffer::Get方法的具体用法?C++ trpgReadBuffer::Get怎么用?C++ trpgReadBuffer::Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trpgReadBuffer
的用法示例。
在下文中一共展示了trpgReadBuffer::Get方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Read
bool trpgMatTable::Read(trpgReadBuffer &buf)
{
trpgMaterial mat;
trpgToken matTok;
int32 len;
bool status;
int i,j;
int nMat,nTable;
try {
buf.Get(nTable);
buf.Get(nMat);
if (nTable <= 0 || nMat < 0) throw 1;
// Read the materials
for (i=0;i<nTable;i++)
for (j=0;j<nMat;j++) {
buf.GetToken(matTok,len);
if (matTok != TRPGMATERIAL) throw 1;
buf.PushLimit(len);
mat.Reset();
status = mat.Read(buf);
buf.PopLimit();
if (!status) throw 1;
AddMaterial(mat,false);
}
numTable += nTable;
numMat = materialMap.size();
}
catch (...) {
return false;
}
return isValid();
}
示例2: Read
bool trpgLabel::Read(trpgReadBuffer &buf)
{
int numSupport,i;
trpg3dPoint support;
int iVal;
try
{
buf.Get(iVal);
propertyId = iVal;
buf.Get(text);
buf.Get(iVal);
alignment = (AlignmentType)iVal;
buf.Get(tabSize);
buf.Get(scale);
buf.Get(thickness);
buf.Get(desc);
buf.Get(url);
buf.Get(location);
buf.Get(numSupport);
if (numSupport < 0) throw 1;
for (i=0;i<numSupport;i++) {
buf.Get(support);
supports.push_back(support);
}
}
catch (...)
{
return false;
}
return isValid();
}
示例3: Read
// Read in LOD
bool trpgLod::Read(trpgReadBuffer &buf)
{
try {
buf.Get(id);
buf.Get(numRange);
if (numRange < 0) throw 1;
buf.Get(center);
buf.Get(switchIn);
buf.Get(switchOut);
buf.Get(width);
if ( !buf.isEmpty() ) {
char nm[1024] = {0};
buf.Get(nm,1024);
if (*nm)
SetName(nm);
// Look for a range index
if (!buf.isEmpty())
buf.Get(rangeIndex);
}
}
catch (...) {
return false;
}
return isValid();
}
示例4: Read
bool trpgModel::Read(trpgReadBuffer &buf, bool hasHandle)
{
// MD: added complexity here - written multiple ways by
// mistake, unraveling the various cases.
char tmpName[1024];
try {
buf.Get(type);
// TerraPage 2.2 will store the unique handle after the type
// we use a different token, so this is backwards compatible.
if(hasHandle) {
int32 tempHandle;
if(buf.Get(tempHandle))
{
handle = tempHandle;
}
else
{
handle = -1;
}
}
else
handle = -1;
if (type == Local) {
// two possibilities:
// name, diskRef, useCount
// diskRef, useCount
// diskRef + useCount = 12 bytes...
if (buf.TestLimit(13))
{
buf.Get(tmpName,1023);
SetName(tmpName);
}
buf.Get(diskRef);
buf.Get(useCount);
}
else
{
// two possibilities:
// name, diskRef, useCount
// name, useCount
buf.Get(tmpName,1023);
SetName(tmpName);
// useCount = 4 bytes...
if (buf.TestLimit(5))
buf.Get(diskRef);
buf.Get(useCount);
}
}
catch(...) {
return false;
}
// going to make this fail if the buffer isn't empty.
if (buf.TestLimit(1)) return false;
return isValid();
}
示例5: Read
// Reads this class from a read buffer
bool trpgLight::Read(trpgReadBuffer &buf)
{
Reset();
int numVertices;
buf.Get(index);
buf.Get(numVertices);
for ( int i = 0; i < numVertices; i++ ) {
trpg3dPoint vx;
buf.Get(vx);
lightPoints.push_back(vx);
}
return isValid();
}
示例6: Read
bool trpgRangeTable::Read(trpgReadBuffer &buf)
{
int32 numRange;
trpgToken tok;
int32 len;
valid = false;
try {
buf.Get(numRange);
if (numRange < 0) throw 1;
for (int i=0;i<numRange;i++) {
// Read in the individual range
buf.GetToken(tok,len);
if (tok != TRPG_RANGE) throw 1;
buf.PushLimit(len);
trpgRange range;
bool status = range.Read(buf);
buf.PopLimit();
if (!status) throw 1;
AddRange(range);
}
valid = true;
}
catch (...) {
return false;
}
return isValid();
}
示例7: Read
bool trpgTileTable::Read(trpgReadBuffer &buf)
{
valid = false;
try {
int imode;
buf.Get(imode); mode = (TileMode)imode;
if (mode != External && mode != Local && mode != ExternalSaved) throw 1;
if (mode == Local || mode == ExternalSaved) {
int numLod;
buf.Get(numLod);
if (numLod <= 0) throw 1;
lodInfo.resize(numLod);
for (int i=0;i<numLod;i++) {
LodInfo &li = lodInfo[i];
if(localBlock) {
if(li.addr.size()==0) {
li.addr.resize(1);
li.elev_min.resize(1,0.0);
li.elev_max.resize(1,0.0);
}
int32 x,y;
buf.Get(x);
buf.Get(y);
int pos = (currentRow * li.numX) + currentCol;
int32 file,offset;
buf.Get(file);
buf.Get(offset);
trpgwAppAddress &ref = li.addr[pos];
ref.file = file;
ref.offset = offset;
ref.col = currentCol;
ref.row = currentRow;
float emin,emax;
buf.Get(emin);
buf.Get(emax);
li.elev_max[pos] = emax;
li.elev_min[pos] = emin;
}
else {
buf.Get(li.numX);
buf.Get(li.numY);
if (li.numX <= 0 || li.numY <= 0)
throw 1;
int numTile = li.numX*li.numY;
li.addr.resize(numTile);
li.elev_min.resize(numTile);
li.elev_max.resize(numTile);
int j;
for (j=0;j<numTile;j++) {
int32 file,offset;
buf.Get(file);
buf.Get(offset);
trpgwAppAddress &ref = li.addr[j];
ref.file = file;
ref.offset = offset;
}
for (j=0;j<numTile;j++) {
float emin,emax;
buf.Get(emin);
buf.Get(emax);
li.elev_max[j] = emax;
li.elev_min[j] = emin;
}
}
}
}
valid = true;
}
catch (...) {
printf("Caught an exception\n");
return false;
}
return isValid();
}
示例8: Parse
/* Parse Buffer
This runs through the given buffer parsing token sets until
it (1) runs out of buffer or (2) fails.
Note: Good place to return an exception, but keep it simple for now.
*/
bool trpgr_Parser::Parse(trpgReadBuffer &buf)
{
bool ret = true;
try
{
while (!buf.isEmpty())
{
/* We're expecting the following
Token (int32)
Length (int32)
Data (variable)
*/
trpgToken tok;
int32 len;
if (!buf.Get(tok)) throw 1;
// Push and Pop are special - no data
if (tok != TRPG_PUSH && tok != TRPG_POP)
{
if (!buf.Get(len)) throw 1;
if (!TokenIsValid(tok)) throw 1;
if (len < 0) throw 1;
// Limit what we're reading to the length of this
buf.PushLimit(len);
}
// Call our token handler for this one
try
{
const trpgr_Token *tcb = NULL;
tok_map::const_iterator p = tokenMap.find(tok);
if (p != tokenMap.end())
tcb = &(*p).second;
if (!tcb)
// No such token, call the default
tcb = &defCb;
// Run the callback
if (tcb->cb)
{
void *ret = tcb->cb->Parse(tok,buf);
// Note: Do something with the return value
lastObject = ret;
}
}
catch (...)
{
// Don't want to screw up the limit stack
}
// No limit to worry about with push and pop
if (tok != TRPG_PUSH && tok != TRPG_POP)
{
buf.SkipToLimit();
buf.PopLimit();
}
}
}
catch (...)
{
// Failed to parse.
ret = false;
}
return ret;
}