Line | |
---|
1 | /* |
---|
2 | * $Id$ |
---|
3 | * |
---|
4 | * [ Description ] |
---|
5 | * |
---|
6 | * Parse a Configuration's file and generate the Tree of configuration |
---|
7 | */ |
---|
8 | |
---|
9 | #include <stdio.h> |
---|
10 | #include <iostream> |
---|
11 | #include "message.h" |
---|
12 | #include "include/Configuration_files_parser.h" |
---|
13 | |
---|
14 | using namespace std; |
---|
15 | |
---|
16 | // Déclaration de variables globales |
---|
17 | extern FILE * yyin; |
---|
18 | extern int yyparse(void); |
---|
19 | |
---|
20 | namespace morpheo { |
---|
21 | namespace configuration { |
---|
22 | |
---|
23 | class Configuration |
---|
24 | { |
---|
25 | |
---|
26 | // -----[ fields ]---------------------------------------------------- |
---|
27 | private : FILE * file; |
---|
28 | |
---|
29 | // -----[ methods ]--------------------------------------------------- |
---|
30 | public : Configuration (string filename) |
---|
31 | { |
---|
32 | // Open the file in read only |
---|
33 | file = fopen(filename.c_str(), "r"); |
---|
34 | |
---|
35 | // Test if the file is open |
---|
36 | if (file == NULL) |
---|
37 | { |
---|
38 | cerr_msg << "The file \"" << filename << "\" can't be open" << endl; |
---|
39 | exit (EXIT_FAILURE); |
---|
40 | } |
---|
41 | |
---|
42 | // Parse the file |
---|
43 | yyin = file; |
---|
44 | yyparse(); |
---|
45 | } |
---|
46 | |
---|
47 | public : ~Configuration (void) |
---|
48 | { |
---|
49 | // Close the file |
---|
50 | fclose(file); |
---|
51 | } |
---|
52 | |
---|
53 | |
---|
54 | }; // end class Configuration |
---|
55 | |
---|
56 | }; // end namespace configuration |
---|
57 | }; // end namespace morpheo |
---|
Note: See
TracBrowser
for help on using the repository browser.