Changeset d8db0af for libcfa/src
- Timestamp:
- Aug 31, 2021, 1:49:10 AM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, pthread-emulation, qualifiedEnum
- Children:
- a434e92
- Parents:
- ad78e08
- git-author:
- Jacob Prud'homme <jafprudhomme@…> (08/05/21 23:25:24)
- git-committer:
- Jacob Prud'homme <jafprudhomme@…> (08/31/21 01:49:10)
- Location:
- libcfa/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/parseconfig.cfa
rad78e08 rd8db0af 66 66 67 67 // Parse configuration from a file formatted in shell style 68 KVPairs &parse_tabular_config_format( const char * config_file, size_t num_entries ) {68 KVPairs * parse_tabular_config_format( const char * config_file, size_t num_entries ) { 69 69 * KVPairs kv_pairs = new( num_entries ); 70 70 … … 93 93 close( in ); 94 94 95 return *kv_pairs;95 return kv_pairs; 96 96 } 97 97 98 98 // Parse configuration values from intermediate format 99 void parse_config( const char * config_file, config_entry entries[], size_t num_entries ) { 100 KVPairs & kv_pairs = parse_tabular_config_format( config_file, num_entries ); 99 void parse_config( const char * config_file, config_entry entries[], size_t num_entries, config_format format ) { 100 KVPairs * kv_pairs; 101 choose ( format ) { 102 case TABULAR_CONFIG: 103 kv_pairs = parse_tabular_config_format( config_file, num_entries ); 104 default: 105 exit | "Error: config file format " | format | " is not supported"; 106 } 101 107 102 108 int entries_so_far = 0; 103 for ( i; kv_pairs .size ) {109 for ( i; kv_pairs->size ) { 104 110 if ( entries_so_far == num_entries ) break; 105 111 106 112 char * src_key, * src_value; 107 [ src_key, src_value ] = kv_pairs .data[i];113 [ src_key, src_value ] = kv_pairs->data[i]; 108 114 109 115 for ( j; num_entries ) { … … 123 129 } 124 130 } 131 132 ^(*kv_pairs){}; 125 133 } // processConfigFile 126 134 -
libcfa/src/parseconfig.hfa
rad78e08 rd8db0af 6 6 // *********************************** initial declarations *********************************** 7 7 8 9 enum config_format { 10 TABULAR_CONFIG 11 }; 8 12 9 13 struct config_entry { … … 63 67 64 68 65 void parse_config( const char * config_file, config_entry entries[], size_t num_entries );69 void parse_config( const char * config_file, config_entry entries[], size_t num_entries, config_format format ); 66 70 67 71 bool parse( const char *, const char * & );
Note: See TracChangeset
for help on using the changeset viewer.