GnuCash  5.6-150-g038405b370+
gnc-imp-settings-csv.hpp
Go to the documentation of this file.
1 /*******************************************************************\
2  * gnc-imp-settings-csv.hpp -- Save and Load CSV Import Settings *
3  * *
4  * Copyright (C) 2014 Robert Fewell *
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 gnu@gnu.org *
22 \********************************************************************/
28 #ifndef GNC_CSV_IMPORT_SETTINGS_H
29 #define GNC_CSV_IMPORT_SETTINGS_H
30 
31 #include <config.h>
32 #include "Account.h"
33 #include "gnc-commodity.h"
34 
35 #include <string>
36 #include <vector>
37 #include <optional>
38 #include <cstdint>
39 #include <gnc-datetime.hpp>
40 #include "gnc-tokenizer.hpp"
41 
45 enum SEP_BUTTON_TYPES {SEP_SPACE, SEP_TAB, SEP_COMMA, SEP_COLON, SEP_SEMICOLON, SEP_HYPHEN,
46  SEP_NUM_OF_TYPES};
47 
49 enum SETTINGS_COL {SET_GROUP, SET_NAME};
50 
52 {
53  CsvImportSettings() : m_file_format (GncImpFileFormat::CSV), m_encoding {"UTF-8"},
54  m_date_format {0}, m_currency_format {0},
55  m_skip_start_lines{0}, m_skip_end_lines{0}, m_skip_alt_lines (false),
56  m_separators {","}, m_load_error {false} { }
57  virtual ~CsvImportSettings() = default;
58 
63 bool save (void);
64 
69 bool load (void);
70 
73 void remove (void);
74 
75 // Common Settings
76 std::string m_name; // Name given to this preset by the user
77 GncImpFileFormat m_file_format; // CSV import Format
78 std::string m_encoding; // File encoding
79 int m_date_format; // Date Active id
80 int m_currency_format; // Currency Active id
81 uint32_t m_skip_start_lines; // Number of header rows to skip
82 uint32_t m_skip_end_lines; // Number of footer rows to skip
83 bool m_skip_alt_lines; // Skip alternate rows
84 std::string m_separators; // Separators for csv format
85 bool m_load_error; // Was there an error while parsing the state file ?
86 std::vector<uint32_t> m_column_widths; // The Column widths
87 
88 protected:
89  virtual const char* get_group_prefix (void) = 0;
90 };
91 
92 std::string get_no_settings (void);
93 std::string get_gnc_exp (void);
94 std::string get_gnc_exp_4 (void);
95 
100 bool preset_is_reserved_name (const std::string& name);
101 
102 /**************************************************
103  * handle_load_error
104  *
105  * record possible errors in the log file
106  * ignore key-not-found errors though. We'll just
107  * use a default value and go on.
108  **************************************************/
109 bool
110 handle_load_error (GError **key_error, const std::string& group);
111 
112 #endif
Account handling public routines.
Class convert a file into vector of string vectors.
SETTINGS_COL
Enumeration for the settings combo&#39;s.
GncImpFileFormat
Enumeration for file formats supported by this importer.
bool load(void)
Load the widget properties from a key File.
bool save(void)
Save the gathered widget properties to a key File.
bool preset_is_reserved_name(const std::string &name)
Check whether name can be used as a preset name.
Commodity handling public routines.
SEP_BUTTON_TYPES
Enumeration for separator checkbutton types.