source: libcfa/src/parseconfig.hfa @ 4df8fef5

ADTast-experimentalenumforall-pointer-decayjacob/cs343-translationpthread-emulationqualifiedEnum
Last change on this file since 4df8fef5 was 4df8fef5, checked in by Jacob Prud'homme <jafprudhomme@…>, 3 years ago

Restructured parseconfig to work like parseargs

  • Property mode set to 100644
File size: 1.7 KB
Line 
1#pragma once
2
3struct ConfigParms {
4        unsigned int stopCost;                                                          // amount to charge per train stop
5        unsigned int numStudents;                                                       // number of students to create
6        unsigned int numStops;                                                          // number of train stops; minimum of 2
7        unsigned int maxNumStudents;                                            // maximum students each train can carry
8        unsigned int timerDelay;                                                        // length of time between each tick of the timer
9        unsigned int maxStudentDelay;                                           // maximum random student delay between trips
10        unsigned int maxStudentTrips;                                           // maximum number of train trips each student takes
11        unsigned int groupoffDelay;                                                     // length of time between initializing gift cards
12        unsigned int conductorDelay;                                            // length of time between checking on passenger POPs
13        unsigned int parentalDelay;                                                     // length of time between cash deposits
14        unsigned int numCouriers;                                                       // number of WATCard office couriers in the pool
15}; // ConfigParms
16
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 );
40
41// Local Variables: //
42// mode: c //
43// tab-width: 4 //
44// End: //
Note: See TracBrowser for help on using the repository browser.