Changeset a3f2a3e


Ignore:
Timestamp:
Aug 31, 2021, 1:49:10 AM (5 months ago)
Author:
Jacob Prud'homme <jafprudhomme@…>
Branches:
jacob/cs343-translation, master
Children:
c166f4e
Parents:
1764a63
git-author:
Jacob Prud'homme <jafprudhomme@…> (08/13/21 17:10:06)
git-committer:
Jacob Prud'homme <jafprudhomme@…> (08/31/21 01:49:10)
Message:

Simplified validation logic

Location:
libcfa/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/parseconfig.cfa

    r1764a63 ra3f2a3e  
    119119                for ( j; num_entries ) {
    120120                  if ( strcmp( src_key, entries[j].key ) != 0 ) continue;
     121                        // Parse the data
    121122                        if ( !entries[j].parse( src_value, entries[j].variable ) ) {
    122123                                delete( kv_pairs );
     
    124125                        }
    125126
    126                         // Validate the parsed data, if necessary
    127                         if ( entries[j].validate != (bool (*)(void *))0p
    128                                         && !entries[j].validate( entries[j].variable ) ) {
     127                        // Validate the data
     128                        if ( !entries[j].validate( entries[j].variable ) ) {
    129129                                delete( kv_pairs );
    130130                                throw (Validation_Failure){};
  • libcfa/src/parseconfig.hfa

    r1764a63 ra3f2a3e  
    1818};
    1919
     20bool null_validator( void * ) { return true; }
     21
    2022static inline void ?{}( config_entry & this ) {}
    2123
     
    2527        this.variable = (void *)&variable;
    2628        this.parse    = (bool (*)(const char *, void *))(bool (*)(const char *, T &))parse;
    27         this.validate = (bool (*)(void *))(bool (*)(T &))0p;
     29        this.validate = null_validation;
    2830}
    2931
     
    4143        this.variable = (void *)&variable;
    4244        this.parse    = (bool (*)(const char *, void *))(bool (*)(const char *, T &))parse;
    43         this.validate = (bool (*)(void *))(bool (*)(T &))0p;
     45        this.validate = null_validation;
    4446}
    4547
Note: See TracChangeset for help on using the changeset viewer.