|
GnuCash c935c2f+
|
The actual PriceImport class It's intended to use in the following sequence of actions: More...
#include <gnc-import-price.hpp>
Public Member Functions | |
| GncPriceImport (GncImpFileFormat format=GncImpFileFormat::UNKNOWN) | |
| Constructor for GncPriceImport. | |
| ~GncPriceImport () | |
| Destructor for GncPriceImport. | |
| void | file_format (GncImpFileFormat format) |
| Sets the file format for the file to import, which may cause the file to be reloaded as well if the previously set file format was different and a filename was already set. | |
| GncImpFileFormat | file_format () |
| void | over_write (bool over) |
| bool | over_write () |
| void | from_commodity (gnc_commodity *from_commodity) |
| Sets a from commodity. | |
| gnc_commodity * | from_commodity () |
| void | to_currency (gnc_commodity *to_currency) |
| Sets a to currency. | |
| gnc_commodity * | to_currency () |
| void | currency_format (int currency_format) |
| int | currency_format () |
| void | date_format (int date_format) |
| int | date_format () |
| void | encoding (const std::string &encoding) |
| Converts raw file data using a new encoding. | |
| std::string | encoding () |
| void | update_skipped_lines (std::optional< uint32_t > start, std::optional< uint32_t > end, std::optional< bool > alt, std::optional< bool > errors) |
| uint32_t | skip_start_lines () |
| uint32_t | skip_end_lines () |
| bool | skip_alt_lines () |
| bool | skip_err_lines () |
| void | separators (std::string separators) |
| std::string | separators () |
| void | enable_escape (bool enable) |
| bool | enable_escape () |
| void | settings (const CsvPriceImpSettings &settings) |
| bool | save_settings () |
| void | settings_name (std::string name) |
| std::string | settings_name () |
| void | load_file (const std::string &filename) |
| Loads a file into a GncPriceImport. | |
| void | tokenize (bool guessColTypes) |
| Splits a file into cells. | |
| std::string | verify () |
| void | create_prices () |
| This function will attempt to convert all tokenized lines into prices using the column types the user has set. | |
| bool | check_for_column_type (GncPricePropType type) |
| void | set_column_type_price (uint32_t position, GncPricePropType type, bool force=false) |
| std::vector< GncPricePropType > | column_types_price () |
Data Fields | |
| std::unique_ptr< GncTokenizer > | m_tokenizer |
| Will handle file loading/encoding conversion/splitting into fields. | |
| std::vector< parse_line_t > | m_parsed_lines |
| source file parsed into a two-dimensional array of strings. | |
| int | m_prices_added |
| int | m_prices_duplicated |
| int | m_prices_replaced |
The actual PriceImport class It's intended to use in the following sequence of actions:
Definition at line 82 of file gnc-import-price.hpp.
| GncPriceImport::GncPriceImport | ( | GncImpFileFormat | format = GncImpFileFormat::UNKNOWN | ) |
Constructor for GncPriceImport.
Definition at line 65 of file gnc-import-price.cpp.
| GncPriceImport::~GncPriceImport | ( | ) |
| bool GncPriceImport::check_for_column_type | ( | GncPricePropType | type | ) |
Definition at line 674 of file gnc-import-price.cpp.
| std::vector< GncPricePropType > GncPriceImport::column_types_price | ( | ) |
Definition at line 794 of file gnc-import-price.cpp.
| void GncPriceImport::create_prices | ( | ) |
This function will attempt to convert all tokenized lines into prices using the column types the user has set.
Creates a list of prices from parsed data.
The parsed data will first be validated. If any errors are found in lines that are marked for processing (ie not marked to skip) this function will throw an error.
| skip_errors | true skip over lines with errors |
| throws | std::invalid_argument if data validation or processing fails. |
Definition at line 646 of file gnc-import-price.cpp.
| int GncPriceImport::currency_format | ( | ) |
Definition at line 217 of file gnc-import-price.cpp.
| void GncPriceImport::currency_format | ( | int | currency_format | ) |
Definition at line 209 of file gnc-import-price.cpp.
| int GncPriceImport::date_format | ( | ) |
Definition at line 227 of file gnc-import-price.cpp.
| void GncPriceImport::date_format | ( | int | date_format | ) |
Definition at line 219 of file gnc-import-price.cpp.
| bool GncPriceImport::enable_escape | ( | ) |
Definition at line 301 of file gnc-import-price.cpp.
| void GncPriceImport::enable_escape | ( | bool | enable | ) |
Definition at line 293 of file gnc-import-price.cpp.
| std::string GncPriceImport::encoding | ( | ) |
Definition at line 251 of file gnc-import-price.cpp.
| void GncPriceImport::encoding | ( | const std::string & | encoding | ) |
Converts raw file data using a new encoding.
This function must be called after load_file only if load_file guessed the wrong encoding.
| encoding | Encoding that data should be translated using |
Definition at line 234 of file gnc-import-price.cpp.
| GncImpFileFormat GncPriceImport::file_format | ( | ) |
Definition at line 131 of file gnc-import-price.cpp.
| void GncPriceImport::file_format | ( | GncImpFileFormat | format | ) |
Sets the file format for the file to import, which may cause the file to be reloaded as well if the previously set file format was different and a filename was already set.
| format | the new format to set |
| std::ifstream::failure | if file reloading fails |
Definition at line 87 of file gnc-import-price.cpp.
| gnc_commodity * GncPriceImport::from_commodity | ( | ) |
Definition at line 171 of file gnc-import-price.cpp.
| void GncPriceImport::from_commodity | ( | gnc_commodity * | from_commodity | ) |
Sets a from commodity.
This is the commodity all import data relates to. When a from commodity is set, there can't be any from columns selected in the import data.
| from_commodity | pointer to a commodity or NULL. |
Definition at line 147 of file gnc-import-price.cpp.
| void GncPriceImport::load_file | ( | const std::string & | filename | ) |
Loads a file into a GncPriceImport.
This is the first function that must be called after creating a new GncPriceImport. As long as this function didn't run successfully, the importer can't proceed.
| filename | Name of the file that should be opened |
| may | throw std::ifstream::failure on any io error |
Definition at line 361 of file gnc-import-price.cpp.
| bool GncPriceImport::over_write | ( | ) |
Definition at line 140 of file gnc-import-price.cpp.
| void GncPriceImport::over_write | ( | bool | over | ) |
Definition at line 136 of file gnc-import-price.cpp.
| bool GncPriceImport::save_settings | ( | ) |
Definition at line 335 of file gnc-import-price.cpp.
| std::string GncPriceImport::separators | ( | ) |
Definition at line 291 of file gnc-import-price.cpp.
| void GncPriceImport::separators | ( | std::string | separators | ) |
Definition at line 281 of file gnc-import-price.cpp.
| void GncPriceImport::set_column_type_price | ( | uint32_t | position, |
| GncPricePropType | type, | ||
| bool | force = false |
||
| ) |
Definition at line 731 of file gnc-import-price.cpp.
| void GncPriceImport::settings | ( | const CsvPriceImpSettings & | settings | ) |
Definition at line 303 of file gnc-import-price.cpp.
| std::string GncPriceImport::settings_name | ( | ) |
Definition at line 353 of file gnc-import-price.cpp.
| void GncPriceImport::settings_name | ( | std::string | name | ) |
Definition at line 352 of file gnc-import-price.cpp.
| bool GncPriceImport::skip_alt_lines | ( | ) |
Definition at line 278 of file gnc-import-price.cpp.
| uint32_t GncPriceImport::skip_end_lines | ( | ) |
Definition at line 277 of file gnc-import-price.cpp.
| bool GncPriceImport::skip_err_lines | ( | ) |
Definition at line 279 of file gnc-import-price.cpp.
| uint32_t GncPriceImport::skip_start_lines | ( | ) |
Definition at line 276 of file gnc-import-price.cpp.
| gnc_commodity * GncPriceImport::to_currency | ( | ) |
Definition at line 196 of file gnc-import-price.cpp.
| void GncPriceImport::to_currency | ( | gnc_commodity * | to_currency | ) |
Sets a to currency.
This is the to currency all import data relates to. When a to currency is set, there can't be any to currency columns selected in the import data.
| to_currency | pointer to a commodity or NULL. |
Definition at line 178 of file gnc-import-price.cpp.
| void GncPriceImport::tokenize | ( | bool | guessColTypes | ) |
Splits a file into cells.
This requires having an encoding that works (see GncPriceImport::convert_encoding). Tokenizing related options should be set to the user's selections before calling this function. Notes: - this function must be called with guessColTypes set to true once before calling it with guessColTypes set to false.
| guessColTypes | true to guess what the types of columns are based on the cell contents |
| std::range_error | if tokenizing failed |
Definition at line 388 of file gnc-import-price.cpp.
| void GncPriceImport::update_skipped_lines | ( | std::optional< uint32_t > | start, |
| std::optional< uint32_t > | end, | ||
| std::optional< bool > | alt, | ||
| std::optional< bool > | errors | ||
| ) |
Definition at line 253 of file gnc-import-price.cpp.
| std::string GncPriceImport::verify | ( | ) |
Definition at line 505 of file gnc-import-price.cpp.
| std::vector<parse_line_t> GncPriceImport::m_parsed_lines |
source file parsed into a two-dimensional array of strings.
Per line also holds possible error messages and objects with extracted price properties.
Definition at line 145 of file gnc-import-price.hpp.
| int GncPriceImport::m_prices_added |
Definition at line 148 of file gnc-import-price.hpp.
| int GncPriceImport::m_prices_duplicated |
Definition at line 149 of file gnc-import-price.hpp.
| int GncPriceImport::m_prices_replaced |
Definition at line 150 of file gnc-import-price.hpp.
| std::unique_ptr<GncTokenizer> GncPriceImport::m_tokenizer |
Will handle file loading/encoding conversion/splitting into fields.
Definition at line 144 of file gnc-import-price.hpp.