View Single Post
Old 07-22-2006, 01:34 PM   #7 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 598
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
Wow, that's a fun format to deal with, and by fun I mean difficult.
I'm going to go ahead and guess further that there are fixed field lengths for each category so instead of needing to aply the full power of a regular expression library you just need to read in a fixed number of characters at a time for each field. I would imagine the people who sent you the text format would have the field lengths, but worst case you can just measure yourself from the text file.
It looks like you need to be able to process info for a couple of records at a time since they share line space. Some psuedo code for your data collection might look like
Code:
std::string readNameField (int offset, std::string inputLine) {
    return subseq(offset, NAMEFIELD_LENGTH, inputLine);
}
//etc... for all your data fields
int main() {
  //read in a line
  //allocate 4 new structs to hold the address data
  //update counter that tells us what type of line we're dealing with (names, addresses, cities, etc
   //switch cases depending on the counter above
     //run the appropriate "parsing" routines and store data in the proper structs
   //when the counter gets to the last line, print out the contents of the structs in the new format, and clear the values of the structs for new input
}
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote