GnuCash c935c2f+
Loading...
Searching...
No Matches
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
45enum SEP_BUTTON_TYPES {SEP_SPACE, SEP_TAB, SEP_COMMA, SEP_COLON, SEP_SEMICOLON, SEP_HYPHEN,
46 SEP_NUM_OF_TYPES};
47
49enum 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_enable_escape {true}, m_load_error {false} { }
57 virtual ~CsvImportSettings() = default;
58
63bool save (void);
64
69bool load (void);
70
73void remove (void);
74
75// Common Settings
76std::string m_name; // Name given to this preset by the user
77GncImpFileFormat m_file_format; // CSV import Format
78std::string m_encoding; // File encoding
79int m_date_format; // Date Active id
80int m_currency_format; // Currency Active id
81uint32_t m_skip_start_lines; // Number of header rows to skip
82uint32_t m_skip_end_lines; // Number of footer rows to skip
83bool m_skip_alt_lines; // Skip alternate rows
84std::string m_separators; // Separators for csv format
85bool m_enable_escape; // Process escapes in quoted csv entries
86bool m_load_error; // Was there an error while parsing the state file ?
87std::vector<uint32_t> m_column_widths; // The Column widths
88
89protected:
90 virtual const char* get_group_prefix (void) = 0;
91};
92
93std::string get_no_settings (void);
94std::string get_gnc_exp (void);
95std::string get_gnc_exp_4 (void);
96
101bool preset_is_reserved_name (const std::string& name);
102
103/**************************************************
104 * handle_load_error
105 *
106 * record possible errors in the log file
107 * ignore key-not-found errors though. We'll just
108 * use a default value and go on.
109 **************************************************/
110bool
111handle_load_error (GError **key_error, const std::string& group);
112
113#endif
Account handling public routines.
Commodity handling public routines.
SETTINGS_COL
Enumeration for the settings combo's.
SEP_BUTTON_TYPES
Enumeration for separator checkbutton types.
bool preset_is_reserved_name(const std::string &name)
Check whether name can be used as a preset name.
Class convert a file into vector of string vectors.
GncImpFileFormat
Enumeration for file formats supported by this importer.
bool save(void)
Save the gathered widget properties to a key File.
bool load(void)
Load the widget properties from a key File.
void remove(void)
Remove the preset from the state file.