GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
qif-import-p.h
1 /* qif-import-p.h -- a QIF Importer module (private headers)
2  *
3  * Written By: Derek Atkins <[email protected]>
4  * Copyright (c) 2003 Derek Atkins <[email protected]>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, contact:
18  *
19  * Free Software Foundation Voice: +1-617-542-5942
20  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
21  * Boston, MA 02110-1301, USA [email protected]
22  */
23 
24 #ifndef QIF_IMPORT_P_H
25 #define QIF_IMPORT_P_H
26 
27 #include "qif-import.h"
28 #include "qif-objects.h"
29 #include "qif-parse.h"
30 #include "qif-file.h"
31 
32 #include <stdio.h>
33 
35 {
36  void (*init)(QifContext ctx);
37  QifError (*parse_record)(QifContext ctx, GList *record);
38  QifError (*end)(QifContext ctx);
39 };
40 
42 {
43  /* The parent context */
44  QifContext parent;
45 
46  /* file information */
47  char * filename;
48  FILE * fp;
49  gint lineno;
50 
51  /* This describes what we are parsing right now */
52  QifType parse_type;
53  QifHandler handler;
54  gpointer parse_state;
55 
56  /* A bunch of flags for the current handler */
57  gint parse_flags;
58  gboolean parsed;
59 
60  /* The current and "opening balance" account */
61  QifAccount current_acct;
62  QifAccount opening_bal_acct;
63 
64  /* HashTable of Maps of data objects */
65  GHashTable * object_maps;
66 
67  /* HashTable of Lists of data objects */
68  GHashTable * object_lists;
69 
70  /* List of files */
71  GList *files;
72 };
73 
74 /* Object Maps */
75 gint qif_object_map_count(QifContext ctx, const char *type);
76 void qif_object_map_foreach(QifContext ctx, const char *type,
77  GHFunc func, gpointer arg);
78 void qif_object_map_insert(QifContext ctx, const char *key, QifObject obj);
79 void qif_object_map_remove(QifContext ctx, const char *type, const char *key);
80 QifObject qif_object_map_lookup(QifContext ctx, const char *type, const char *key);
81 void qif_object_map_destroy(QifContext ctx);
82 /* GList _SHOULD_ be freed by the caller */
83 GList * qif_object_map_get(QifContext ctx, const char *type);
84 
85 /* Object Lists */
86 void qif_object_list_reverse(QifContext ctx, const char *type);
87 gint qif_object_list_count(QifContext ctx, const char *type);
88 void qif_object_list_foreach(QifContext ctx, const char *type,
89  GFunc func, gpointer arg);
90 void qif_object_list_insert(QifContext ctx, QifObject obj);
91 void qif_object_list_remove(QifContext ctx, QifObject obj);
92 void qif_object_list_destroy(QifContext ctx);
93 /* GList should NOT be freed by the caller */
94 GList *qif_object_list_get(QifContext ctx, const char *type);
95 
96 /* Set and clear flags in bit-flags */
97 #define qif_set_flag(i,f) (i |= f)
98 #define qif_clear_flag(i,f) (i &= ~f)
99 
100 #endif /* QIF_IMPORT_P_H */