SmileeTiger
Programmer
I have a file that has it's fields seperated by ^A characters (0x01) and want to use the boost tokenizer to split the fields.
However, when I attempt to use 0x01 directly as the token I get a complaint about type mismatches. To get around that issue I created a char array to hold the token but man is it hacky:
//start of fugly code
char cSep[1];
str[0] = char(0x01);
//Tokenize the fields
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
boost::char_separator<char> sep(cSep);
tokenizer tokens(strDataLine, sep);
//End of fugly code
for(tokenizer::iterator itField = tokens.begin(); itField != tokens.end(); ++itField)
{
//Random field processing code here
}
Can anyone suggest a different way of setting the seperator in a less fugly way? That char array has got to go
However, when I attempt to use 0x01 directly as the token I get a complaint about type mismatches. To get around that issue I created a char array to hold the token but man is it hacky:
//start of fugly code
char cSep[1];
str[0] = char(0x01);
//Tokenize the fields
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
boost::char_separator<char> sep(cSep);
tokenizer tokens(strDataLine, sep);
//End of fugly code
for(tokenizer::iterator itField = tokens.begin(); itField != tokens.end(); ++itField)
{
//Random field processing code here
}
Can anyone suggest a different way of setting the seperator in a less fugly way? That char array has got to go