Changeset e54654e


Ignore:
Timestamp:
Aug 31, 2021, 1:49:09 AM (5 months ago)
Author:
Jacob Prud'homme <jafprudhomme@…>
Branches:
jacob/cs343-translation, master
Children:
80ae121
Parents:
4cc6c7d
git-author:
Jacob Prud'homme <jafprudhomme@…> (07/16/21 15:18:23)
git-committer:
Jacob Prud'homme <jafprudhomme@…> (08/31/21 01:49:09)
Message:

Added ability to specify optional validation function

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/parseconfig.hfa

    r4cc6c7d re54654e  
    55        void * variable;
    66        bool (*parse)( const char *, void * );
     7        bool (*validate)( void * );
    78};
    89
     
    1415        this.variable = (void *)&variable;
    1516        this.parse    = (bool (*)(const char *, void *))(bool (*)(const char *, T &))parse;
     17        this.validate = 0p;
     18}
     19
     20forall(T & | { bool parse( const char *, T & ); })
     21static inline void ?{}( config_entry & this, const char * key, T & variable, bool (*validate)(T &) ) {
     22        this.key      = key;
     23        this.variable = (void *)&variable;
     24        this.parse    = (bool (*)(const char *, void *))(bool (*)(const char *, T &))parse;
     25        this.validate = (bool (*)(void *))(bool (*)(T &))validate;
    1626}
    1727
     
    2131        this.variable = (void *)&variable;
    2232        this.parse    = (bool (*)(const char *, void *))(bool (*)(const char *, T &))parse;
     33        this.validate = 0p;
     34}
     35
     36forall(T &)
     37static inline void ?{}( config_entry & this, const char * key, T & variable, bool (*parse)(const char *, T &), bool (*validate)(T &) ) {
     38        this.key      = key;
     39        this.variable = (void *)&variable;
     40        this.parse    = (bool (*)(const char *, void *))(bool (*)(const char *, T &))parse;
     41        this.validate = (bool (*)(void *))(bool (*)(T &))validate;
    2342}
    2443
Note: See TracChangeset for help on using the changeset viewer.