29 #ifndef GNC_TX_IMPORT_HPP 30 #define GNC_TX_IMPORT_HPP 45 #include "gnc-imp-props-tx.hpp" 50 extern const int num_currency_formats;
51 extern const gchar* currency_format_user[];
69 using StrVec = std::vector<std::string>;
76 std::shared_ptr<GncPreTrans>,
77 std::shared_ptr<GncPreSplit>,
87 GncCsvImpParseError(
const std::string& err, ErrMap err_vec) : std::runtime_error(err), m_errors{err_vec} {}
88 ErrMap errors()
const {
return m_errors;}
120 void currency_format (
int currency_format);
121 int currency_format ();
123 void date_format (
int date_format);
127 std::string encoding ();
129 void update_skipped_lines (std::optional<uint32_t> start, std::optional<uint32_t> end,
130 std::optional<bool> alt, std::optional<bool> errors);
131 uint32_t skip_start_lines ();
132 uint32_t skip_end_lines ();
133 bool skip_alt_lines ();
134 bool skip_err_lines ();
136 void separators (std::string separators);
137 std::string separators ();
140 bool save_settings ();
142 void settings_name (std::string name);
143 std::string settings_name ();
146 void load_file (
const std::string& filename);
150 std::string verify(
bool with_acct_errors);
156 bool check_for_column_type (GncTransPropType type);
157 void set_column_type (uint32_t position, GncTransPropType type,
bool force =
false);
158 std::vector<GncTransPropType> column_types ();
160 std::set<std::string> accounts ();
174 void create_transaction (std::vector<parse_line_t>::iterator& parsed_line);
176 void verify_column_selections (
ErrorList& error_msg);
179 void reset_formatted_column (std::vector<GncTransPropType>& col_types);
184 std::shared_ptr<DraftTransaction> trans_properties_to_trans (std::vector<parse_line_t>::iterator& parsed_line);
189 void update_pre_split_multi_col_prop (
parse_line_t& parsed_line, GncTransPropType col_type);
190 void update_pre_trans_props (
parse_line_t& parsed_line, uint32_t col, GncTransPropType old_type, GncTransPropType new_type);
191 void update_pre_split_props (
parse_line_t& parsed_line, uint32_t col, GncTransPropType old_type, GncTransPropType new_type);
196 bool m_multi_currency;
202 std::shared_ptr<GncPreTrans> m_parent =
nullptr;
203 std::shared_ptr<DraftTransaction> m_current_draft =
nullptr;
~GncTxImport()
Destructor for GncTxImport.
parse_line_cols
An enum describing the columns found in a parse_line_t.
std::tuple< StrVec, std::string, std::shared_ptr< GncImportPrice >, bool > parse_line_t
Tuple to hold.
void base_account(Account *base_account)
Sets a base account.
Exception that will be thrown whenever a parsing error is encountered.
void load_file(const std::string &filename)
Loads a file into a GncTxImport.
GncTxImport(GncImpFileFormat format=GncImpFileFormat::UNKNOWN)
Constructor for GncTxImport.
void multi_split(bool multi_split)
Toggles the multi-split state of the importer and will subsequently sanitize the column_types list...
Account handling public routines.
Class convert a file into vector of string vectors.
std::multimap< time64, std::shared_ptr< DraftTransaction > > m_transactions
map of transaction objects created from parsed_lines and column_types, ordered by date ...
void encoding(const std::string &encoding)
Converts raw file data using a new encoding.
GncImpFileFormat
Enumeration for file formats supported by this importer.
std::unique_ptr< GncTokenizer > m_tokenizer
Will handle file loading/encoding conversion/splitting into fields.
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 p...
void create_transactions()
This function will attempt to convert all tokenized lines into transactions using the column types th...
void tokenize(bool guessColTypes)
Splits a file into cells.
The actual TxImport class It's intended to use in the following sequence of actions: ...
std::vector< parse_line_t > m_parsed_lines
source file parsed into a two-dimensional array of strings.
API for Transactions and Splits (journal entries)