GnuCash
5.6-150-g038405b370+
|
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. More... | |
GncImpFileFormat | file_format () |
void | over_write (bool over) |
bool | over_write () |
void | from_commodity (gnc_commodity *from_commodity) |
Sets a from commodity. More... | |
gnc_commodity * | from_commodity () |
void | to_currency (gnc_commodity *to_currency) |
Sets a to currency. More... | |
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. More... | |
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 | 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. More... | |
void | tokenize (bool guessColTypes) |
Splits a file into cells. More... | |
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. More... | |
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. More... | |
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.
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 633 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 231 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.
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 144 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 348 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 175 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 375 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 142 of file gnc-import-price.hpp.