Changeset 4df8fef5
- Timestamp:
- Aug 31, 2021, 1:49:09 AM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, pthread-emulation, qualifiedEnum
- Children:
- 5e0e488
- Parents:
- 31337d8
- git-author:
- Jacob Prud'homme <jafprudhomme@…> (07/13/21 12:36:19)
- git-committer:
- Jacob Prud'homme <jafprudhomme@…> (08/31/21 01:49:09)
- Location:
- libcfa/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/parseconfig.cfa
r31337d8 r4df8fef5 13 13 14 14 // Process the configuration file to set the simulation parameters. 15 void parse Config( const char * configFile, ConfigParms & cparms ) {16 15 void parse_config( const char * config_file, config_entry entries[], size_t num_entries ) { 16 ifstream in; 17 17 try { 18 open( in, config File ); // open the configuration file for input18 open( in, config_file ); // open the configuration file for input 19 19 20 20 while () { 21 if ( comments( in, name ) ) break; // eof ? 21 char * key; 22 char * value; 23 if ( comments( in, key ) ) break; // eof ? 22 24 // Should we just overwrite duplicate config entries? Having a hash map would make this much easier 23 25 in | value; … … 31 33 } // for 32 34 } catch( Open_Failure * ex; ex->istream == &in ) { 33 exit | "Error: could not open input file \"" | config File | "\"";35 exit | "Error: could not open input file \"" | config_file | "\""; 34 36 } // try 35 37 close( in ); -
libcfa/src/parseconfig.hfa
r31337d8 r4df8fef5 15 15 }; // ConfigParms 16 16 17 void parseConfig( const char * configFile, ConfigParms & cparms ); 17 struct config_entry { 18 const char * key; 19 void * variable; 20 bool (*parse)(const char *, void *); 21 }; 22 23 static inline void ?{}( config_entry & this ) {} 24 25 forall(T & | { bool parse(const char *, T & ); }) 26 static inline void ?{}( config_entry & this, const char * key, T & variable ) { 27 this.key = key; 28 this.variable = (void *)&variable; 29 this.parse = (bool (*)(const char *, void *))parse; 30 } 31 32 forall(T &) 33 static inline void ?{}( config_entry & this, const char * key, T & variable, bool (*parse)(const char *, T &) ) { 34 this.key = key; 35 this.variable = (void *)&variable; 36 this.parse = (bool (*)(const char *, void *))parse; 37 } 38 39 void parse_config( const char * config_file, config_entry entries[], size_t num_entries ); 18 40 19 41 // Local Variables: //
Note: See TracChangeset
for help on using the changeset viewer.