ma740988 wrote in message
<11**********************@z34g2000cwc.googlegroups .com>...
What is 'iss'?
Bob, my aplogies. I'm not sure where I went wrong with my post, might
have changed something while posting. In any event here goes:
while( std::getline( InOut, line ) ){
std::istringstream iss( line );
if( iss == "header" ){
// error: ambiguous overload for 'operator==' in 'iss == "header"'
iss.ignore( sz );
int value ( 0 );
iss >> value;
values.push_back(value);
}
}
[...]
Did that compile for you?
How did you overload 'operator==' for 'stringstream'?
I think what you want is more like:
// InOut << "header" + dt + "0x2100\n";
std::string line("header ....... 0x2100\n"); // simulated input
if( line.find("header") != line.npos ){
int value( 0 );
std::cout<<" line="<<line<<std::endl;
for(size_t i(0); i < line.size(); ++i){
if( std::isdigit( line.at( i ) ) ){
std::cout<<" line.substr(i)="
<<line.substr( i )<<std::endl;
std::istringstream sStream( line.substr( i ) );
sStream >>std::hex>> value;
// values.push_back(value);
break;
} // if(isdigit)
} // for(i)
std::cout<<" header found. value="<<value<<std::endl;
} // if(find)
// --- output ---
// line=header ....... 0x2100
// line.substr(i)=0x2100
// header found. value=8448
Use 'std::string' for what it's good for and 'std::stringstream' for what
it's good for.
Don't try to make one do the others job.
KISS, refactor later (if needed)! <G>
--
Bob R
POVrookie