• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ trpgReadBuffer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中trpgReadBuffer的典型用法代码示例。如果您正苦于以下问题:C++ trpgReadBuffer类的具体用法?C++ trpgReadBuffer怎么用?C++ trpgReadBuffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了trpgReadBuffer类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: Read

bool trpgSupportStyleTable::Read(trpgReadBuffer &buf)
{
    trpgSupportStyle style;
    trpgToken styleTok;
    int32 len;
    bool status;
    int numStyle;
    int i;

    Reset();

    try
    {
        buf.Get(numStyle);
        if (numStyle < 0)
            throw 1;
        //styles.resize(numStyle);
        for (i=0;i<numStyle;i++) {
            buf.GetToken(styleTok,len);
            if (styleTok != TRPG_SUPPORT_STYLE) throw 1;
            buf.PushLimit(len);
            style.Reset();
            status = style.Read(buf);
            buf.PopLimit();
            if (!status) throw 1;
            AddStyle(style);
        }
    }
    catch (...)
    {
        return false;
    }

    return isValid();
}
开发者ID:yueying,项目名称:osg,代码行数:35,代码来源:trpage_label.cpp


示例2: 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();
}
开发者ID:BlitzMaxModules,项目名称:osg.mod,代码行数:34,代码来源:trpage_material.cpp


示例3: 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();
}
开发者ID:BlitzMaxModules,项目名称:osg.mod,代码行数:31,代码来源:trpage_range.cpp


示例4: Read

bool trpgModelTable::Read(trpgReadBuffer &buf)
{
    int32 numModel;
    trpgToken tok;
    int32 len;
    bool status;

    try {
        buf.Get(numModel);
        for (int i=0;i<numModel;i++) {
            trpgModel model;
            buf.GetToken(tok,len);
            bool readHandle;
            if (tok == TRPGMODELREF)
                readHandle = false;
            else if (tok == TRPGMODELREF2)
                readHandle = true;
            else
                throw 1;
            buf.PushLimit(len);
            status = model.Read(buf,readHandle);
            buf.PopLimit();
            if (!status)  throw 1;
            AddModel(model);
        }
    }
    catch (...) {
        return false;
    }

    return isValid();
}
开发者ID:BodyViz,项目名称:osg,代码行数:32,代码来源:trpage_model.cpp


示例5: 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();
}
开发者ID:BlitzMaxModules,项目名称:osg.mod,代码行数:27,代码来源:trpage_nodes.cpp


示例6: Read

bool trpgLightTable::Read(trpgReadBuffer &buf)
{
    int32        numLights;
    trpgToken    lightTok;
    int32        len;

    try {
        buf.Get(numLights);
        for (int i=0;i<numLights;i++) {
            buf.GetToken(lightTok,len);
            if (lightTok != TRPGLIGHTATTR) throw 1;
            buf.PushLimit(len);
            trpgLightAttr light;// = lightList[i];
            bool status = light.Read(buf);
            buf.PopLimit();
            if (!status) throw 1;
            AddLightAttr(light);
        }
    }
    catch (...) {
        return false;
    }

    return true;
}
开发者ID:yueying,项目名称:osg,代码行数:25,代码来源:trpage_light.cpp


示例7: it

/* 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;
}
开发者ID:yueying,项目名称:osg,代码行数:70,代码来源:trpage_parse.cpp


示例8: Read

// Read in the header
bool trpgHeader::Read(trpgReadBuffer &buf)
{
    uint8 i8;
    trpgToken tok;
    bool status;
    int32 len;

    try {
        buf.Get(verMajor);
        buf.Get(verMinor);
        buf.Get(dbVerMajor);
        buf.Get(dbVerMinor);
        buf.Get(origin);
        buf.Get(sw);
        buf.Get(ne);
        buf.Get(i8);  tileType = (trpgTileType)i8;
        buf.Get(numLods);
        if (numLods < 0) throw 1;

        // Read in the LOD range info
        buf.GetToken(tok,len);
        if (tok != TRPGHEAD_LODINFO)  throw 1;
        buf.PushLimit(len);
        status = ReadLodInfo(buf);
        buf.PopLimit();
        if (!status) throw 1;

        // Added after the first version (but still in 1.0)
        buf.Get(maxGroupID);
        if((verMajor >= TRPG_NOMERGE_VERSION_MAJOR) && (verMinor >=TRPG_NOMERGE_VERSION_MINOR)) {
            buf.Get(flags);
            buf.Get(rows);
            buf.Get(cols);
        }
    }

    catch (...) {
        return false;
    }

    return isValid();
}
开发者ID:151706061,项目名称:OpenSceneGraph,代码行数:43,代码来源:trpage_header.cpp


示例9: 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();
}
开发者ID:BlitzMaxModules,项目名称:osg.mod,代码行数:81,代码来源:trpage_tile.cpp



注:本文中的trpgReadBuffer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ trpgWriteBuffer类代码示例发布时间:2022-05-31
下一篇:
C++ trie_type类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap