A class... field has the following types of members :
I'm asking it to handle inputs of the following format:Code:int index; std::string name; std::string type; bool p_key; bool c_key;
[Int,String1,String2,Bool1,Bool2]
//The bools seem to be automatically stored and retrieved as o and 1
So..in the following code...
What do I put in /*Error*/ ?
Also, when an unexpected type of input goes through, is it sufficient to return the istream object in its fail state ?
Code:std::istream& operator>>(std::istream& is,field& f) { char c; is>>c;if(c!='['){/*Error*/}; is>>f.index; is>>c;if(c!=','){/*Error*/}; std::getline(is,f.name,','); // is>>c;if(c!=','){/*Error*/}else is.unget(); //Wrong std::getline(is,f.type,','); // is>>c;if(c!=','){/*Error*/}else is.unget(); //Wrong is>>f.p_key; is>>c;if(c!=','){/*Error*/}; is>>f.c_key; is>>c;if(c!=']'){/*Error*/}; return is; }



LinkBack URL
About LinkBacks




I used to be an adventurer like you... then I took an arrow to the knee.