I have a file and I need to loop through it assigning an int foo, string type, 64/128 bit long. How would I use a stream to parse these lines into the following variables – I want to stick with the stream syntax ( ifs >> foo >> type ) but in this case type would end up being the rest of the line after the 0/52 … and at that point I’d just get a char* and use strtoull and such so why use the stream in the first place… I’m hoping for readable code without horrid performance over char strings / strtok / strtoull
//input file:
0ULL'04001C0180000000000000000EE317BC'
52L'04001C0180000000'
//ouput:
//0 ULL 0x04001C0180000000 0x000000000EE317BC
//52 L 0x04001C0180000000
ifstream ifs("input.data");
int foo;
string type;
unsigned long long ull[2];
This is a rather trivial task for a more sophisticated parser such as boost.spirit.
To solve this using just the standard C++ streams you would need to
'as whitespace andBorrowing Jerry Coffin’s sample facet code,
test: https://ideone.com/lRBTq