GnuCash c935c2f+
Loading...
Searching...
No Matches
Macros | Functions | Variables
gnc-imp-settings-csv-tx.cpp File Reference

CSV Import Settings. More...

#include "gnc-imp-settings-csv.hpp"
#include "gnc-imp-settings-csv-tx.hpp"
#include <algorithm>
#include <memory>
#include <sstream>
#include <string>
#include <vector>
#include <cstdint>
#include <config.h>
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include "Account.h"
#include "gnc-state.h"
#include "gnc-ui-util.h"

Go to the source code of this file.

Macros

#define CSV_COL_TYPES   "ColumnTypes"
 
#define CSV_ACCOUNT   "BaseAccount"
 
#define CSV_ACCOUNT_GUID   "BaseAccountGuid"
 
#define CSV_MULTI_SPLIT   "MultiSplit"
 

Functions

const preset_vec_trans & get_import_presets_trans (void)
 Creates a vector of CsvTransImpSettings which combines.
 

Variables

constexpr auto group_prefix = "Import csv,transaction - "
 
preset_vec_trans presets_trans
 

Detailed Description

CSV Import Settings.

Author
Copyright (c) 2014 Robert Fewell
Copyright (c) 2016 Geert Janssens

Definition in file gnc-imp-settings-csv-tx.cpp.

Macro Definition Documentation

◆ CSV_ACCOUNT

#define CSV_ACCOUNT   "BaseAccount"

Definition at line 51 of file gnc-imp-settings-csv-tx.cpp.

◆ CSV_ACCOUNT_GUID

#define CSV_ACCOUNT_GUID   "BaseAccountGuid"

Definition at line 52 of file gnc-imp-settings-csv-tx.cpp.

◆ CSV_COL_TYPES

#define CSV_COL_TYPES   "ColumnTypes"

Definition at line 49 of file gnc-imp-settings-csv-tx.cpp.

◆ CSV_MULTI_SPLIT

#define CSV_MULTI_SPLIT   "MultiSplit"

Definition at line 53 of file gnc-imp-settings-csv-tx.cpp.

Function Documentation

◆ get_import_presets_trans()

const preset_vec_trans & get_import_presets_trans ( void  )

Creates a vector of CsvTransImpSettings which combines.

  • one or more internally defined presets
  • all preset found in the state key file.
Returns
a reference to the populated vector.

Definition at line 143 of file gnc-imp-settings-csv-tx.cpp.

144{
145 // Search all Groups in the state key file for ones starting with prefix
146 auto preset_names = std::vector<std::string>();
147 auto keyfile = gnc_state_get_current ();
148 gsize grouplength;
149 gchar **groups = g_key_file_get_groups (keyfile, &grouplength);
150
151 /* Start by building a sorted list of candidate presets as found in the state file */
152 for (gsize i=0; i < grouplength; i++)
153 {
154 auto group = std::string(groups[i]);
155 auto gp = std::string {group_prefix};
156 auto pos = group.find(gp);
157 if (pos == std::string::npos)
158 continue;
159
160 preset_names.push_back(group.substr(gp.size()));
161 }
162 // string array from the state file is no longer needed now.
163 g_strfreev (groups);
164
165 /* We want our settings to appear sorted alphabetically to the user */
166 std::sort(preset_names.begin(), preset_names.end());
167
168 /* Now add each preset to our global list */
169 presets_trans.clear();
170
171 /* Start with the internally generated ones */
172 presets_trans.push_back(create_int_no_preset());
173 presets_trans.push_back(create_int_gnc_exp_preset());
174 presets_trans.push_back(create_int_gnc_exp_4_preset());
175
176 /* Then add all the ones we found in the state file */
177 for (auto preset_name : preset_names)
178 {
179 auto preset = std::make_shared<CsvTransImpSettings>();
180 preset->m_name = preset_name;
181 preset->load();
182 presets_trans.push_back(preset);
183 }
184 return presets_trans;
185}
GKeyFile * gnc_state_get_current(void)
Returns a pointer to the most recently loaded state.
Definition gnc-state.c:248

Variable Documentation

◆ group_prefix

constexpr auto group_prefix = "Import csv,transaction - "
constexpr

Definition at line 47 of file gnc-imp-settings-csv-tx.cpp.

◆ presets_trans

preset_vec_trans presets_trans

Definition at line 57 of file gnc-imp-settings-csv-tx.cpp.