I am working on a project management program and I am having trouble figuring out how to search the project file for the source file list. This is what the project file looks like:
1 2 3 4 5 6 7
$PROJECT_NAME = Project.pjt // The lines with the $ sign are the section headers.
$SOURCE_LIST:
#main.cpp // The lines with the # sign are the files.
$HEADER_LIST:
#test.h
$LIBRARIES:
%math // The lines with the % sign are the libraries to be included.
I need a way to have my program search for the lines with the # sign and take the strings after to use for opening the source files. Does anyone have any ideas?
You need a regular expression library for maximum flexibility. Doing it the 'raw' way of reading and comparing string is only for trivial matching but once there are more esoteric matching needed, you would turn to a library for help.
Personally, I think if he has the file divided into sections like $SOURCE_LIST: and $HEADER_LIST: then there isn't really any need to start the lines that contain the files with # or %.
So in my mind the file would look like this:
$PROJECT_NAME
Project.pjt
$SOURCE_LIST:
main.cpp that.cpp some_other.cpp
this.cpp
$HEADER_LIST:
test.h file2.h
file3.h another_headerfile.h
$LIBRARIES:
math
To find the sourcefiles just find the line that starts with $SOURCE_LIST:
Then any entries after that line up to the next section or end of file would be the source files list.