GnuCash c935c2f+
Loading...
Searching...
No Matches
Data Structures | Typedefs | Functions
gnc-imp-settings-csv-price.hpp File Reference

CSV Import Settings. More...

#include <config.h>
#include "Account.h"
#include "gnc-commodity.h"
#include <string>
#include <vector>
#include "gnc-imp-props-price.hpp"
#include "gnc-tokenizer.hpp"
#include "gnc-imp-settings-csv.hpp"

Go to the source code of this file.

Data Structures

struct  CsvPriceImpSettings
 

Typedefs

using preset_vec_price = std::vector< std::shared_ptr< CsvPriceImpSettings > >
 

Functions

const preset_vec_price & get_import_presets_price (void)
 Creates a vector of CsvPriceImpSettings which combines.
 

Detailed Description

CSV Import Settings.

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

Definition in file gnc-imp-settings-csv-price.hpp.

Typedef Documentation

◆ preset_vec_price

using preset_vec_price = std::vector<std::shared_ptr<CsvPriceImpSettings> >

Definition at line 70 of file gnc-imp-settings-csv-price.hpp.

Function Documentation

◆ get_import_presets_price()

const preset_vec_price & get_import_presets_price ( void  )

Creates a vector of CsvPriceImpSettings 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 72 of file gnc-imp-settings-csv-price.cpp.

73{
74 // Search all Groups in the state key file for ones starting with prefix
75 auto preset_names = std::vector<std::string>();
76 auto keyfile = gnc_state_get_current ();
77 gsize grouplength;
78 gchar **groups = g_key_file_get_groups (keyfile, &grouplength);
79
80 /* Start by building a sorted list of candidate presets as found in the state file */
81 for (gsize i=0; i < grouplength; i++)
82 {
83 auto group = std::string(groups[i]);
84 auto gp = std::string {group_prefix};
85 auto pos = group.find(gp);
86 if (pos == std::string::npos)
87 continue;
88
89 preset_names.push_back(group.substr(gp.size()));
90 }
91 // string array from the state file is no longer needed now.
92 g_strfreev (groups);
93
94 /* We want our settings to appear sorted alphabetically to the user */
95 std::sort(preset_names.begin(), preset_names.end());
96
97 /* Now add each preset to our global list */
98 presets_price.clear();
99
100 /* Start with the internally generated ones */
101 presets_price.push_back(create_int_no_preset());
102 //presets_price.push_back(create_int_gnc_exp_preset()); // Not Required
103
104 /* Then add all the ones we found in the state file */
105 for (auto preset_name : preset_names)
106 {
107 auto preset = std::make_shared<CsvPriceImpSettings>();
108 preset->m_name = preset_name;
109 preset->load();
110 presets_price.push_back(preset);
111 }
112 return presets_price;
113}
GKeyFile * gnc_state_get_current(void)
Returns a pointer to the most recently loaded state.
Definition gnc-state.c:248