GnuCash  4.8a-134-g214de30c7+
gmock-Account.cpp
1 #include <config.h>
2 
3 #include "gmock-Account.h"
4 
5 
7 {
8  QofInstanceClass parent_class;
9 };
10 typedef struct _MockAccountClass MockAccountClass;
11 
12 G_DEFINE_TYPE(MockAccount, gnc_mockaccount, QOF_TYPE_INSTANCE);
13 
14 static void
15 gnc_mockaccount_init (MockAccount *inst)
16 {
17  // function is unused, initialization is done in the MockAccount's C++ constructor
18 }
19 
20 static void
21 gnc_mockaccount_class_init(MockAccountClass *klass)
22 {
23  // function is unused, class functions are defined in C++ code
24 }
25 
26 
28 {
29  return gnc_mockaccount_get_type();
30 }
31 
32 void
34 {
35  ASSERT_TRUE(GNC_IS_MOCKACCOUNT(account));
36  gnc_mockaccount(account)->begin_edit();
37 }
38 
39 void
41 {
42  ASSERT_TRUE(GNC_IS_MOCKACCOUNT(account));
43  gnc_mockaccount(account)->commit_edit();
44 }
45 
46 QofBook *
47 gnc_account_get_book(const Account *account)
48 {
49  SCOPED_TRACE("");
50  auto mockaccount = gnc_mockaccount(account);
51  return mockaccount ? mockaccount->get_book() : nullptr;
52 }
53 
54 gint
55 xaccAccountForEachTransaction(const Account *acc, TransactionCallback proc,
56  void *data)
57 {
58  SCOPED_TRACE("");
59  auto mockaccount = gnc_mockaccount(acc);
60  return mockaccount ? mockaccount->for_each_transaction(proc, data) : 0;
61 }
62 
63 SplitList *
65 {
66  SCOPED_TRACE("");
67  auto mockaccount = gnc_mockaccount(account);
68  return mockaccount ? mockaccount->xaccAccountGetSplitList() : nullptr;
69 }
70 
71 
74 {
75  SCOPED_TRACE("");
76  auto mockaccount = gnc_mockaccount(acc);
77  return mockaccount ? mockaccount->create_imap() : nullptr;
78 }
79 
80 Account*
81 gnc_account_imap_find_account (
82  GncImportMatchMap *imap,
83  const char* category,
84  const char *key)
85 {
86  return ((GncMockImportMatchMap*)imap)->find_account(category, key);
87 }
88 
89 void
90 gnc_account_imap_add_account (
91  GncImportMatchMap *imap,
92  const char *category,
93  const char *key,
94  Account *acc)
95 {
96  ((GncMockImportMatchMap*)imap)->add_account(category, key, acc);
97 }
98 
99 Account*
101  GncImportMatchMap *imap,
102  GList *tokens)
103 {
104  std::vector<const char*> tokenVec;
105 
106  for (auto token = tokens; token; token = token->next)
107  {
108  tokenVec.push_back(static_cast <char const *> (token->data));
109  }
110 
111  return ((GncMockImportMatchMap*)imap)->find_account_bayes(tokenVec);
112 }
113 
114 void
116  GncImportMatchMap *imap,
117  GList *tokens,
118  Account *acc)
119 {
120  std::vector<const char*> tokenVec;
121 
122  for (auto token = tokens; token; token = token->next)
123  {
124  tokenVec.push_back(static_cast <char const *> (token->data));
125  }
126 
127  ((GncMockImportMatchMap*)imap)->add_account_bayes(tokenVec, acc);
128 }
129 
gint xaccAccountForEachTransaction(const Account *acc, TransactionCallback proc, void *data)
The xaccAccountForEachTransaction() routine will traverse all of the transactions in account and call...
SplitList * xaccAccountGetSplitList(const Account *account)
The xaccAccountGetSplitList() routine returns a pointer to a GList of the splits in the account...
Account * gnc_account_imap_find_account_bayes(GncImportMatchMap *imap, GList *tokens)
Look up an Account in the map using Baysian.
GList SplitList
GList of Split.
Definition: gnc-engine.h:211
void gnc_account_imap_add_account_bayes(GncImportMatchMap *imap, GList *tokens, Account *acc)
Updates the imap for a given account using a list of tokens.
GType gnc_account_get_type(void)
Returns the GType type system description of the Account class.
GncImportMatchMap * gnc_account_imap_create_imap(Account *acc)
Obtain an ImportMatchMap object from an Account or a Book.
void xaccAccountBeginEdit(Account *account)
The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account up...
void xaccAccountCommitEdit(Account *account)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...