source: libcfa/src/parseconfig.cfa @ ff3be413

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

Removed code specific to CS 343 assignment

  • Property mode set to 100644
File size: 1.3 KB
Line 
1#include <fstream.hfa>
2#include "parseconfig.hfa"
3
4bool comments( ifstream & in, char * name ) {
5        while () {
6                in | name;
7          if ( fail( in ) ) return true;
8          if ( name[0] != '#' ) break;
9                in | nl;        // ignore remainder of line
10        } // for
11        return false;
12} // comments
13
14// Process the configuration file to set the simulation parameters.
15void parseConfig( const char * configFile, ConfigParms & cparms ) {
16                ifstream in;
17        try {
18                open( in, configFile );                                                 // open the configuration file for input
19
20                while () {
21                  if ( comments( in, name ) ) break;                    // eof ?
22                        // Should we just overwrite duplicate config entries? Having a hash map would make this much easier
23                        in | value;
24                        if ( value < 0 ) {
25                                close( in );
26                                exit | "Error: file \"" | configFile | "\" parameter " | name
27                                         | " value " | value | " must be non-negative."; // *** DOES THIS PRINT TO STDERR??? IT MUST!!! *** //
28                        } // if
29                  if ( fail( in ) ) break;
30                        in | nl; // ignore remainder of line
31                } // for
32        } catch( Open_Failure * ex; ex->istream == &in ) {
33                exit | "Error: could not open input file \"" | configFile | "\""; // *** DOES THIS PRINT TO STDERR??? IT MUST!!! *** //
34        } // try
35        close( in );
36        // *** WE MUST ALLOW SOME SORT OF VALIDATION FUNCTIONALITY TOO!!! ***
37} // processConfigFile
38
39// Local Variables: //
40// tab-width: 4 //
41// compile-command: "cfa parseconfig.cfa" //
42// End: //
Note: See TracBrowser for help on using the repository browser.