本文整理汇总了C++中CFileHandler::Peek方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileHandler::Peek方法的具体用法?C++ CFileHandler::Peek怎么用?C++ CFileHandler::Peek使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileHandler
的用法示例。
在下文中一共展示了CFileHandler::Peek方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetWord
static void GetWord(CFileHandler& fh, std::string &s)
{
char a = fh.Peek();
while (a == ' ' || a == '\n' || a == '\r') {
fh.Read(&a, 1);
a = fh.Peek();
if (fh.Eof())
break;
}
s = "";
fh.Read(&a, 1);
while (a != ',' && a != ' ' && a != '\n' && a != '\r') {
s += a;
fh.Read(&a, 1);
if (fh.Eof())
break;
}
}
示例2:
string CUnit3DLoader::GetWord(CFileHandler& fh)
{
char a=fh.Peek();
while(a==' ' || a=='\xd' || a=='\xa'){
fh.Read(&a,1);
a=fh.Peek();
if(fh.Eof())
break;
}
string s="";
fh.Read(&a,1);
while(a!=',' && a!=' ' && a!='\xd' && a!='\xa'){
s+=a;
fh.Read(&a,1);
if(fh.Eof())
break;
}
return s;
}
示例3: GetLine
// returns next line (without newlines)
static string GetLine(CFileHandler& fh)
{
lineNumber++;
char a;
string s = "";
while (true) {
a = fh.Peek();
if (a == EOF) { break; }
fh.Read(&a, 1);
if (a == '\n') { break; }
if (a != '\r') { s += a; }
}
return s;
}
示例4: UnitModelGeometry
int CUnit3DLoader::ParseSub(CFileHandler& ifs, UnitModel &model,const string& filename,float3 offset,const string& treename)
{
string s;
bool inComment=false;
Animation* curAnim=0;
int curAnimFrame=0;
bool firstGeometryPass=false;
if(geometryModels.find(treename)==geometryModels.end()){
geometryModels[treename]=new UnitModelGeometry();
UnitModelGeometry& geometry=*geometryModels[treename];
firstGeometryPass=true;
geometry.normalBuffer=0;
geometry.indexBuffer=0;
geometry.numIndeces=0;
geometry.numVerteces=0;
}
model.geometry=geometryModels[treename];
UnitModelGeometry& geometry=*model.geometry;
geometry.radius=1;
geometry.height=1;
geometry.isAnimated=false;
model.texCoordBuffer=0;
while(ifs.Peek()!=EOF){
s=GetWord(ifs);
MakeLow(s);
if(s[0]=='/' && !inComment){
if(s[1]=='/'){
GetLine(ifs);
continue;
}
if(s[1]=='*')
inComment=true;
}
if(inComment){
for(int a=0;a<s.size()-1;++a)
if(s[a]=='*' && s[a+1]=='/')
inComment=false;
if(inComment)
continue;
}
if(ifs.Eof())
break;
while((s.c_str()[0]=='/') || (s.c_str()[0]=='\n')){
s=GetLine(ifs);
s=GetWord(ifs);
MakeLow(s);
if(ifs.Eof())
break;
}
if(s=="vertex"){
int num=atoi(GetWord(ifs).c_str());
float3 v;
v.x=atof(GetWord(ifs).c_str());
v.y=atof(GetWord(ifs).c_str());
v.z=atof(GetWord(ifs).c_str());
v-=offset;
if(firstGeometryPass){
if(curAnim==0){
while(geometry.vertex.size()<=num){
geometry.vertex.push_back(float3(0,0,0));
geometry.vertexNormal.push_back(float3(0,0,0));
}
geometry.vertex[num]=v;
} else {
AnimFrame* af=&curAnim->frames[curAnimFrame];
while(af->vertex.size()<=num){
af->vertex.push_back(float3());
// model.vertexNormal.push_back(float3(0,0,0));
}
af->vertex[num]=v;
}
}
} else if(s=="quad"){
Quad q;
QuadTex qt;
for(int a=0;a<4;++a)
q.verteces[a]=atoi(GetWord(ifs).c_str());
for(int a=0;a<8;++a)
qt.texPos[0][a]=atof(GetWord(ifs).c_str());
qt.texName=GetWord(ifs);
qt.teamTex=atoi(GetWord(ifs).c_str());
q.normalType=atoi(GetWord(ifs).c_str());
model.quadTex.push_back(qt);
if(firstGeometryPass)
geometry.quad.push_back(q);
} else if(s=="tri"){
Tri t;
TriTex tt;
for(int a=0;a<3;++a)
t.verteces[a]=atoi(GetWord(ifs).c_str());
for(int a=0;a<3;++a){
tt.texPos[0][a*2]=1-atof(GetWord(ifs).c_str());
//.........这里部分代码省略.........