Changeset 930609e2 for libcfa


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:
716e4e6
Parents:
6604ea1
git-author:
Jacob Prud'homme <jafprudhomme@…> (07/16/21 15:36:51)
git-committer:
Jacob Prud'homme <jafprudhomme@…> (08/31/21 01:49:09)
Message:

Added some basic examples of validation functions

And rearranged the ordering of some declarations to avoid errors

Location:
libcfa/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/parseconfig.cfa

    r6604ea1 r930609e2  
    115115
    116116
     117// *********************************** validation ***********************************
     118
     119
     120forall(T | arithmetic( T ))
     121bool is_nonnegative( T & value ) {
     122        T zero_val = 0;
     123        return value >= zero_val;
     124}
     125
     126forall(T | arithmetic( T ))
     127bool is_positive( T & value ) {
     128        T zero_val = 0;
     129        return value > zero_val;
     130}
     131
     132forall(T | arithmetic( T ))
     133bool is_nonpositive( T & value ) {
     134        T zero_val = 0;
     135        return value <= zero_val;
     136}
     137
     138forall(T | arithmetic( T ))
     139bool is_negative( T & value ) {
     140        T zero_val = 0;
     141        return value < zero_val;
     142}
     143
     144
    117145// Local Variables: //
    118146// tab-width: 4 //
  • libcfa/src/parseconfig.hfa

    r6604ea1 r930609e2  
    11#pragma once
    22
    3 
    4 // *********************************** exceptions ***********************************
     3#include <rational.hfa>
    54
    65
    7 EHM_EXCEPTION(Validation_Failure)(
    8         const char * key;
    9         void * variable;
    10 );
    11 
    12 void ?{}( Validation_Failure & this, config_entry & entry );
    13 
    14 
    15 // *********************************** main code ***********************************
     6// *********************************** initial declarations ***********************************
    167
    178
     
    5748}
    5849
     50
     51// *********************************** exceptions ***********************************
     52
     53
     54EHM_EXCEPTION(Validation_Failure)(
     55        const char * key;
     56        void * variable;
     57);
     58
     59void ?{}( Validation_Failure & this, config_entry & entry );
     60
     61
     62// *********************************** main code ***********************************
     63
     64
    5965void parse_config( const char * config_file, config_entry entries[], size_t num_entries );
    6066
     
    6773bool parse( const char *, double & );
    6874
     75
     76// *********************************** validation ***********************************
     77
     78
     79forall(T | arithmetic( T ))
     80bool is_nonnegative( T & );
     81
     82forall(T | arithmetic( T ))
     83bool is_positive( T & );
     84
     85forall(T | arithmetic( T ))
     86bool is_nonpositive( T & );
     87
     88forall(T | arithmetic( T ))
     89bool is_negative( T & );
     90
     91
    6992// Local Variables: //
    7093// mode: c //
Note: See TracChangeset for help on using the changeset viewer.