GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
gnc-csv-model.h
Go to the documentation of this file.
1 /********************************************************************\
2  * This program is free software; you can redistribute it and/or *
3  * modify it under the terms of the GNU General Public License as *
4  * published by the Free Software Foundation; either version 2 of *
5  * the License, or (at your option) any later version. *
6  * *
7  * This program is distributed in the hope that it will be useful, *
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
10  * GNU General Public License for more details. *
11  * *
12  * You should have received a copy of the GNU General Public License*
13  * along with this program; if not, contact: *
14  * *
15  * Free Software Foundation Voice: +1-617-542-5942 *
16  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
17  * Boston, MA 02110-1301, USA [email protected] *
18 \********************************************************************/
19 
27 #ifndef GNC_CSV_MODEL_H
28 #define GNC_CSV_MODEL_H
29 
30 #include "config.h"
31 
32 #include "Account.h"
33 #include "Transaction.h"
34 
35 #include "stf/stf-parse.h"
36 
41 enum GncCsvColumnType {GNC_CSV_NONE,
42  GNC_CSV_DATE,
43  GNC_CSV_NUM,
44  GNC_CSV_DESCRIPTION,
45  GNC_CSV_NOTES,
46  GNC_CSV_ACCOUNT,
47  GNC_CSV_DEPOSIT,
48  GNC_CSV_WITHDRAWAL,
49  GNC_CSV_BALANCE,
50  GNC_CSV_NUM_COL_TYPES
51  };
52 
56 enum GncCsvErrorType {GNC_CSV_FILE_OPEN_ERR,
57  GNC_CSV_ENCODING_ERR
58  };
59 
63 typedef struct
64 {
65  char* begin;
66  char* end;
67 } GncCsvStr;
68 
69 /* TODO We now sort transactions by date, not line number, so we
70  * should probably get rid of this struct and uses of it. */
71 
79 typedef struct
80 {
81  int line_no;
82  Transaction* trans;
84  gboolean balance_set;
85  gchar *num;
87 
88 /* A set of currency formats that the user sees. */
89 extern const int num_currency_formats;
90 extern const gchar* currency_format_user[];
91 
92 /* A set of date formats that the user sees. */
93 extern const int num_date_formats;
94 extern const gchar* date_format_user[];
95 
96 /* This array contains all of the different strings for different column types. */
97 extern gchar* gnc_csv_column_type_strs[];
98 
100 typedef struct
101 {
102  gchar* encoding;
103  GMappedFile* raw_mapping;
106  GPtrArray* orig_lines;
110  GStringChunk* chunk;
111  StfParseOptions_t* options;
112  GArray* column_types;
113  GList* error_lines;
114  GList* transactions;
116  int start_row;
117  int end_row;
118  gboolean skip_rows;
121 
123 
124 void gnc_csv_parse_data_free (GncCsvParseData* parse_data);
125 
126 int gnc_csv_load_file (GncCsvParseData* parse_data, const char* filename,
127  GError** error);
128 
129 int gnc_csv_convert_encoding (GncCsvParseData* parse_data, const char* encoding, GError** error);
130 
131 int gnc_csv_parse (GncCsvParseData* parse_data, gboolean guessColTypes, GError** error);
132 
133 int gnc_csv_parse_to_trans (GncCsvParseData* parse_data, Account* account, gboolean redo_errors);
134 
135 time64 parse_date (const char* date_str, int format);
136 
137 #endif
gnc_numeric balance
Definition: gnc-csv-model.h:83
GMappedFile * raw_mapping
GncCsvErrorType
Definition: gnc-csv-model.h:56
GPtrArray * orig_lines
int gnc_csv_convert_encoding(GncCsvParseData *parse_data, const char *encoding, GError **error)
int gnc_csv_parse_to_trans(GncCsvParseData *parse_data, Account *account, gboolean redo_errors)
GArray * orig_row_lengths
time64 parse_date(const char *date_str, int format)
gboolean balance_set
Definition: gnc-csv-model.h:84
void gnc_csv_parse_data_free(GncCsvParseData *parse_data)
Account handling public routines.
GncCsvStr file_str
StfParseOptions_t * options
GncCsvParseData * gnc_csv_new_parse_data(void)
int gnc_csv_parse(GncCsvParseData *parse_data, gboolean guessColTypes, GError **error)
GList * transactions
GStringChunk * chunk
GncCsvColumnType
Definition: gnc-csv-model.h:41
gint64 time64
Definition: gnc-date.h:83
GArray * column_types
gboolean skip_rows
API for Transactions and Splits (journal entries)
GncCsvStr raw_str
int gnc_csv_load_file(GncCsvParseData *parse_data, const char *filename, GError **error)