本文整理汇总了C++中std::istream::unsetf方法的典型用法代码示例。如果您正苦于以下问题:C++ istream::unsetf方法的具体用法?C++ istream::unsetf怎么用?C++ istream::unsetf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::istream
的用法示例。
在下文中一共展示了istream::unsetf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readFromStream
std::string readFromStream(std::istream& in) {
in.unsetf(std::ios::skipws) ;
std::string return_info(std::istreambuf_iterator<char>(in.rdbuf()),
std::istreambuf_iterator<char>()) ;
return return_info ;
}
示例2: loadMtl
//Load materials from MTL source stream. Returns Model object with materials
//TODO: think about splitting this function.
ModelPtr loadMtl(std::istream& source, Manager& inManager){
if(!source.good())
throw std::runtime_error("OBJModelLoader: stream is in bad condition. Can't read data.");
//do not eat spaces (we will eat them manually)
source.unsetf(std::istream::skipws);
ModelPtr model(new Model());
MaterialPtr lastMaterial;
findNextToken(source);
while(source.good()){
std::string command = getNextToken(source);
eatSpaces(source);
if(!source.good()) break;
if(command == "newmtl"){ //new material command
std::string matName = getNextToken(source); //get next word(name)
//if already taken data for some material
if(lastMaterial){
//add new mesh
model->mMeshes.push_back(MeshPtr(new Mesh()));
//set current material to new mesh
model->mMeshes.back()->mMaterial = lastMaterial;
lastMaterial.reset();
}
lastMaterial = MaterialPtr(new Material());
lastMaterial->mName = matName;
}
else if(!lastMaterial){ //no newmtl directive before first commands
std::cerr << "OBJModelLoader: ERROR: newmtl directive should stand before any other directives" << std::endl;
}
else if(command[0] == 'K' && command.size() == 2){ //Ka, Kd or Ks
float r = 0.0f, g = -1.0, b;
source >> r;
eatSpaces(source);
if(isspace(source.peek())) g = b = r;
else{
source >> g;
eatSpaces(source);
source >> b;
}
Color newColor(r, g, b);
switch(command[1]){
case 'a': //Ka
lastMaterial->mAmbient = newColor;
break;
case 'd': //Kd
lastMaterial->mDiffuse = newColor;
break;
case 's': //Ks
lastMaterial->mSpecular = newColor;
break;
case 'e': //Ke
lastMaterial->mEmissive = newColor;
default:
//error
//throw std::runtime_error("OBJModelLoader: unknown directive in mtl file");
break;
}
}
//TODO: delete copy-paste code (textures must be handled in one common way)
else if(command.find("map_K") != std::string::npos){ //map_Kd, map_Ka, map_Ks