source: libcfa/src/parseconfig.hfa@ c1dafea

ADT ast-experimental enum forall-pointer-decay jacob/cs343-translation pthread-emulation qualifiedEnum
Last change on this file since c1dafea was ad8072c, checked in by Jacob Prud'homme <jafprudhomme@…>, 4 years ago

Fixed type warning

  • Property mode set to 100644
File size: 2.7 KB
RevLine 
[16f9aca]1#pragma once
2
[c58c65a]3#include <math.trait.hfa>
[80ae121]4
5
[930609e2]6// *********************************** initial declarations ***********************************
[80ae121]7
8
[4df8fef5]9struct config_entry {
10 const char * key;
11 void * variable;
[58ebd786]12 bool (*parse)( const char *, void * );
[e54654e]13 bool (*validate)( void * );
[4df8fef5]14};
15
16static inline void ?{}( config_entry & this ) {}
17
[58ebd786]18forall(T & | { bool parse( const char *, T & ); })
[4df8fef5]19static inline void ?{}( config_entry & this, const char * key, T & variable ) {
20 this.key = key;
21 this.variable = (void *)&variable;
[4cc6c7d]22 this.parse = (bool (*)(const char *, void *))(bool (*)(const char *, T &))parse;
[ad8072c]23 this.validate = (bool (*)(void *))(bool (*)(T &))0p;
[e54654e]24}
25
26forall(T & | { bool parse( const char *, T & ); })
27static inline void ?{}( config_entry & this, const char * key, T & variable, bool (*validate)(T &) ) {
28 this.key = key;
29 this.variable = (void *)&variable;
30 this.parse = (bool (*)(const char *, void *))(bool (*)(const char *, T &))parse;
31 this.validate = (bool (*)(void *))(bool (*)(T &))validate;
[4df8fef5]32}
33
34forall(T &)
35static inline void ?{}( config_entry & this, const char * key, T & variable, bool (*parse)(const char *, T &) ) {
36 this.key = key;
37 this.variable = (void *)&variable;
[4cc6c7d]38 this.parse = (bool (*)(const char *, void *))(bool (*)(const char *, T &))parse;
[ad8072c]39 this.validate = (bool (*)(void *))(bool (*)(T &))0p;
[e54654e]40}
41
42forall(T &)
43static inline void ?{}( config_entry & this, const char * key, T & variable, bool (*parse)(const char *, T &), bool (*validate)(T &) ) {
44 this.key = key;
45 this.variable = (void *)&variable;
46 this.parse = (bool (*)(const char *, void *))(bool (*)(const char *, T &))parse;
47 this.validate = (bool (*)(void *))(bool (*)(T &))validate;
[4df8fef5]48}
49
[930609e2]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
[4df8fef5]65void parse_config( const char * config_file, config_entry entries[], size_t num_entries );
[16f9aca]66
[b1eeb3aa]67bool parse( const char *, const char * & );
68bool parse( const char *, int & );
69bool parse( const char *, unsigned & );
70bool parse( const char *, unsigned long & );
71bool parse( const char *, unsigned long long & );
72bool parse( const char *, float & );
73bool parse( const char *, double & );
74
[930609e2]75
76// *********************************** validation ***********************************
77
78
[c58c65a]79forall(T | Relational( T ))
[930609e2]80bool is_nonnegative( T & );
81
[c58c65a]82forall(T | Relational( T ))
[930609e2]83bool is_positive( T & );
84
[c58c65a]85forall(T | Relational( T ))
[930609e2]86bool is_nonpositive( T & );
87
[c58c65a]88forall(T | Relational( T ))
[930609e2]89bool is_negative( T & );
90
91
[16f9aca]92// Local Variables: //
93// mode: c //
94// tab-width: 4 //
95// End: //
Note: See TracBrowser for help on using the repository browser.