Ignore:
Timestamp:
Aug 31, 2021, 1:49:09 AM (3 years ago)
Author:
Jacob Prud'homme <jafprudhomme@…>
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)
Message:

Restructured parseconfig to work like parseargs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/parseconfig.hfa

    r31337d8 r4df8fef5  
    1515}; // ConfigParms
    1616
    17 void parseConfig( const char * configFile, ConfigParms & cparms );
     17struct config_entry {
     18        const char * key;
     19        void * variable;
     20        bool (*parse)(const char *, void *);
     21};
     22
     23static inline void ?{}( config_entry & this ) {}
     24
     25forall(T & | { bool parse(const char *, T & ); })
     26static 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
     32forall(T &)
     33static 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
     39void parse_config( const char * config_file, config_entry entries[], size_t num_entries );
    1840
    1941// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.