+ added VECTOR and MAP mode to ParaParser in order to handle entries with same
[qpalma.git] / ParaParser / ParaParser.h
1 #ifndef __PARAPARSER_H__
2 #define __PARAPARSER_H__
3
4 #include <Python.h>
5 #include <map>
6 #include <vector>
7 using namespace std;
8
9 struct KeyCmp {
10 //bool operator()( unsigned long s1, unsigned long s2 ) const {
11 bool operator()( int s1, int s2 ) const {
12 return ( s1 < s2 );
13 }
14 };
15
16 enum storage_mode { IN_VECTOR=0, IN_MAP=1 };
17
18 typedef unsigned long map_key_t;
19
20 typedef map<map_key_t,char**,KeyCmp> MAP;
21
22 typedef vector<char**> VECTOR;
23
24
25 class ParaParser{
26
27 private:
28 char* format_string;
29 char** field_names;
30 size_t num_columns;
31 char** types_list;
32
33 storage_mode current_mode;
34
35 MAP *entries;
36 VECTOR *v_entries;
37
38 public:
39 ParaParser(const char* fmt, char** _fields, int num_entries, storage_mode mode);
40 int parseFile(char* reads_filename);
41 void create_entry_from_line(const char* current_line, char* format_string);
42 PyObject* fetchEntry(map_key_t id);
43
44 ~ParaParser(){}
45 };
46
47 #endif // __PARAPARSER_H__
48