Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

retaining comments...

Status
Not open for further replies.

tryfekid

Programmer
Aug 16, 2001
9
US
Hi,

I'm reading in a configuration file that can support comments. Currently, I'm parsing the file so that if a ! character (comment indicator) is reached then I just skip the line, or skip what comes after it, sort of like a C/C++ compiler. Here's an example of the config file:

#SECTION1
! comment
data1 ! comment
! comment

#SECTION2
!comment
data2
! comment

Well, that's how the configuration file is designed and # means a section header. The user has an option of reading in this file, and through a GUI, save this file, with the changes, to another file. However, I've only gotten to the point where the output of this file only shows the changes to the data, but the comments are lost.

So my question is: Is there a way to retain the comments so that the comments show if the configuration file is saved somewhere else?

Thanks, any help is appreciated.
 
make 2 queue, one for comments and one for info

each time you read in a line, put the info into the info queue and the comments into the comment queue. If no comment exists then put an empty string in the queue. When you are done... loop through the two queues outputing from each in order of info.dequeue comment.dequeue. the end result will be all the data and the comments in tact.

matt

P.S. Follow the same schema for putting in an empty string into the info queue when required.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top