It is definitely possible. How you do this depends on what contribution you expect. For example, if you know you are going to read a flag line, then create a operator>>()flag for the class.
std::istream& operator>>(std::istream& in, CheckBox& cb)
{
std::string input_str;
in >> input_str;
if( str == "CheckBox::unchecked" ) cb.set_value(false);
else if( str == "CheckBox::checked" ) cb.set_value(true);
else in.setstate(ios::badbit);
return in;
}
CheckBox b;
if( !( cin >> b) )
If you do not know what you are going to read, then you are in the field of grammar and parsing. To do this, you must define your grammar (when is the "checkbox" line allowed?). Once you have written the grammar, you write the lexer and parser. There are tools for this.
source
share