CLASS MANUAL
parser.h
1 #ifndef __PARSER__
2 #define __PARSER__
3 
4 #include "common.h"
5 
6 #define _LINE_LENGTH_MAX_ 1024
7 #define _ARGUMENT_LENGTH_MAX_ 1024
9 typedef char FileArg[_ARGUMENT_LENGTH_MAX_];
10 
11 /* after reading a given file, all relevant information stored in this structure, in view of being processed later*/
12 struct file_content {
13  char * filename;
14  int size;
15  FileArg * name;
16  FileArg * value;
17  short * read;
18 };
19 
20 /**************************************************************/
21 
22 /*
23  * Boilerplate for C++
24  */
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 int parser_read_file(
30  char * filename,
31  struct file_content * pfc,
32  ErrorMsg errmsg
33  );
34 
35 int parser_init(
36  struct file_content * pfc,
37  int size,
38  char * filename,
39  ErrorMsg errmsg
40  );
41 
42 int parser_free(
43  struct file_content * pfc
44  );
45 
46 int parser_read_line(
47  char * line,
48  int * is_data,
49  char * name,
50  char * value,
51  ErrorMsg errmsg
52  );
53 
54 int parser_read_int(
55  struct file_content * pfc,
56  char * name,
57  int * value,
58  int * found,
59  ErrorMsg errmsg
60  );
61 
62 int parser_read_double(
63  struct file_content * pfc,
64  char * name,
65  double * value,
66  int * found,
67  ErrorMsg errmsg
68  );
69 
70  int parser_read_double_and_position(
71  struct file_content * pfc,
72  char * name,
73  double * value,
74  int * position,
75  int * found,
76  ErrorMsg errmsg
77  );
78 
79 int parser_read_string(
80  struct file_content * pfc,
81  char * name,
82  FileArg * value,
83  int * found,
84  ErrorMsg errmsg
85  );
86 
87 int parser_read_list_of_doubles(
88  struct file_content * pfc,
89  char * name,
90  int * size,
91  double ** pointer_to_list,
92  int * found,
93  ErrorMsg errmsg
94  );
95 
96 int parser_read_list_of_integers(
97  struct file_content * pfc,
98  char * name,
99  int * size,
100  int ** pointer_to_list,
101  int * found,
102  ErrorMsg errmsg
103  );
104 
105 int parser_read_list_of_strings(
106  struct file_content * pfc,
107  char * name,
108  int * size,
109  char ** pointer_to_list,
110  int * found,
111  ErrorMsg errmsg
112  );
113 
114 int parser_cat(
115  struct file_content * pfc1,
116  struct file_content * pfc2,
117  struct file_content * pfc3,
118  ErrorMsg errmsg
119  );
120 
121 #ifdef __cplusplus
122 }
123 #endif
124 
125 #endif