예제 #1
0
 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
0
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
0
파일: Mesh.cpp 프로젝트: Narcolapser/Delta
			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.