- 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:
- b532fcf
- Parents:
- 4df8fef5
- git-author:
- Jacob Prud'homme <jafprudhomme@…> (07/13/21 12:37:35)
- git-committer:
- Jacob Prud'homme <jafprudhomme@…> (08/31/21 01:49:09)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/parseconfig.cfa
r4df8fef5 r5e0e488 1 1 #include <fstream.hfa> 2 #include <heap.hfa> 2 3 #include "parseconfig.hfa" 4 5 struct KVPairs { 6 int size, max_size; 7 * [ char *, char * ] data; 8 }; 9 void ?{}( VLA & vla ) with ( vla ) { // default constructor 10 size = 0; max_size = 0; data = 0p; 11 } 12 void ?{}( VLA & vla, int size, char fill = ['\0', '\0'] ) { // initialization 13 vla.[ size, max_size, data ] = [ size, max_size, alloc( size, fill ) ]; 14 } 15 void ?{}( VLA & vla, VLA val ) with( val ) { // copy, deep 16 vla.[ size, max_size, data ] = [ size, max_size, alloc( size, data ) ]; 17 } 18 void ^?{}( VLA & vla ) with ( vla ) { // destructor 19 free( data ); 20 size = 0; max_size = 0; data = 0p; 21 } 22 23 void add_kv_pair( KVPairs kv_pairs, char * k, char * v ) with( kv_pairs ) { 24 if ( size == max_size ) { 25 max_size = max_size * 2; 26 data = resize( data, max_size ); 27 } 28 29 data[size] = [ k, v ]; 30 ++size; 31 } 3 32 4 33 bool comments( ifstream & in, char * name ) { … … 14 43 // Process the configuration file to set the simulation parameters. 15 44 void parse_config( const char * config_file, config_entry entries[], size_t num_entries ) { 45 KVPairs kv_pairs{ num_entries }; 46 16 47 ifstream in; 17 48 try {
Note: See TracChangeset
for help on using the changeset viewer.