Add property structs for transaction vs split properties

This commit is contained in:
Geert Janssens
2016-11-28 15:21:41 +01:00
committed by Geert Janssens
parent 91df5edaa5
commit ab6dc0f590
2 changed files with 31 additions and 3 deletions

View File

@@ -307,7 +307,8 @@ void GncTxImport::parse (bool guessColTypes)
orig_lines.clear();
for (auto tokenized_line : tokenizer->get_tokens())
{
orig_lines.push_back (std::make_tuple (tokenized_line, std::string()));
orig_lines.push_back (std::make_tuple (tokenized_line, std::string(),
std::make_shared<GncPreTrans>(), std::make_shared<GncPreSplit>()));
auto length = tokenized_line.size();
if (length > max_cols)
max_cols = length;

View File

@@ -39,6 +39,7 @@ extern "C" {
#include <vector>
#include <map>
#include <memory>
#include <boost/optional.hpp>
#include "gnc-tokenizer.hpp"
@@ -93,8 +94,34 @@ extern const gchar* currency_format_user[];
extern const int num_date_formats;
extern const gchar* date_format_user[];
/** Tuple to hold a tokenized line of input and an optional error string */
using parse_line_t = std::tuple<StrVec, std::string>;
struct GncPreTrans
{
boost::optional<time64> m_date;
boost::optional<std::string> m_num;
boost::optional<std::string> m_desc;
boost::optional<std::string> m_notes;
};
struct GncPreSplit
{
boost::optional<Account*> m_account;
boost::optional<gnc_numeric> m_deposit;
boost::optional<gnc_numeric> m_withdrawal;
boost::optional<gnc_numeric> m_balance;
boost::optional<std::string> m_memo;
boost::optional<Account*> m_oaccount;
boost::optional<std::string> m_omemo;
};
/** Tuple to hold
* - a tokenized line of input
* - an optional error string
* - a struct to hold user selected properties for a transaction
* - a struct to hold user selected properties for one or two splits in the above transaction */
using parse_line_t = std::tuple<StrVec,
std::string,
std::shared_ptr<GncPreTrans>,
std::shared_ptr<GncPreSplit>>;
/** The actual TxImport class
* It's intended to use in the following sequence of actions: