Hi all,
Once again I would like to seek your help.
I got one file (test.hrh) with a number of flags. Some falgs are defined (#define), some not (#undef).
I got another file which a flag list which should be added to the file if not there, and if exists then need to check the status and change if needed.
#test.hrh file content:
#ifndef __BLDSERVICESSOFTWARE_HRH
#define __BLDSERVICESSOFTWARE_HRH
/** #FF_TOPCONTACTSWIDGET_COMPONENT */
#undef FF_TOPCONTACTSWIDGET_COMPONENT
/** #FF_VISUAL_RADIO_COMPONENT */
#undef FF_VISUAL_RADIO_COMPONENT
/** #FF_WEB_SEARCH_COMPONENT */
#undef FF_WEB_SEARCH_COMPONENT
/** #__MOBILESEARCH_CLASSIC_IDLE */
#define __MOBILESEARCH_CLASSIC_IDLE
#endif // __BLDSERVICESSOFTWARE_HRH
List of flags:
===============
1. FF_HERE_AND_NOW_COMPONENT
2. FF_WEB_SEARCH_COMPONENT
Note:
1 should be added to the file as #define FF_HERE_AND_NOW_COMPONENT
2 already exists but as #undef, should be changed to #define FF_WEB_SEARCH_COMPONENT
I implemented it as:
Create a new file (test.new) and parsed all the test.hrh contents there. While parsin I checked whether the flag exists, if not then added the whole string like "#define FLAG". If it was defined and everthing is right then doing nothing. Else change the status from "undef FLAG" to "#define FLAG".
Finally deleted the "test.hrh" file and renamed "test.new" to tet.hrh.
Can it be done other way? Without creating a new file?