本文整理汇总了C++中istringstream::peek方法的典型用法代码示例。如果您正苦于以下问题:C++ istringstream::peek方法的具体用法?C++ istringstream::peek怎么用?C++ istringstream::peek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类istringstream
的用法示例。
在下文中一共展示了istringstream::peek方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deserialize
NestedInteger deserialize(istringstream &in) {
int number;
if(in>>number) return NestedInteger(number); //如果开头是数字,那么一定是单个数的
in.clear();
in.get();
NestedInteger list;
while(in.peek() != ']')
{
list.add(deserialize(in));
if(in.peek()==',')
in.get();
}
in.get();
return list;
}
示例2: parseQuotes
static void parseQuotes(istringstream& result, forward_list<pair<string,quote_>>& quotes)
{
string row;
string date;
float price[4];
result.ignore(256, '\n');
while(result.peek() != EOF)
{
getline(result, date, ',');
result>> row;
result.ignore();
sscanf(row.c_str(), "%f,%f,%f,%f", &price[0], &price[1], &price[2], &price[3]);
quotes.push_front(pair<string,quote_>(date, {price[0], price[1], price[2], price[3]}));
}
}
示例3: if
verts.push_back(y);
verts.push_back(z);
vertc++;//increment the number of vertices.
}
else if (line.substr(0,2) == "f ") //if it starts with "f " it is a face.
{
istringstream s(line.substr(2));//stream in again for simplicity.
GLushort a,b,c,d;//temp variables to hold face info as it comes in.
s >> a; s >> b; s >> c;//read in the face info.
a--; b--; c--;// each one needs to be decrememnted because .obj is 1
//indexed where as vbos are 0 indexed.
els.push_back(a);//push info onto the vector
els.push_back(b);
els.push_back(c);
elc++;//incrememnt the number of faces.
char temp = s.peek();
if ((int)temp != -1)
{
s >> d;
d--;
els.push_back(a);
els.push_back(c);
els.push_back(d);
elc++;
}
}
else if (line[0] == '#') { /* ignoring this line */ }
else { /* ignoring this line */ }
}
//these two loops convert the vectors into arrays so they can be sent to opengl.