GnuCash  5.6-150-g038405b370+
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 gnc_commodity *
56 {
57  SCOPED_TRACE("");
58  auto mockaccount = gnc_mockaccount(account);
59  return mockaccount ? mockaccount->get_commodity() : nullptr;
60 }
61 
62 gint
63 xaccAccountForEachTransaction(const Account *acc, TransactionCallback proc,
64  void *data)
65 {
66  SCOPED_TRACE("");
67  auto mockaccount = gnc_mockaccount(acc);
68  return mockaccount ? mockaccount->for_each_transaction(proc, data) : 0;
69 }
70 
71 SplitList *
73 {
74  SCOPED_TRACE("");
75  auto mockaccount = gnc_mockaccount(account);
76  return mockaccount ? mockaccount->xaccAccountGetSplitList() : nullptr;
77 }
78 
79 const std::vector<Split*>&
80 xaccAccountGetSplits (const Account *account)
81 {
82  SCOPED_TRACE("");
83  auto mockaccount = gnc_mockaccount(account);
84  static const SplitsVec empty;
85  if (!mockaccount)
86  return empty;
87  return mockaccount->xaccAccountGetSplits();
88 }
89 
90 
91 Account*
92 gnc_account_imap_find_account (
93  Account *acc,
94  const char* category,
95  const char *key)
96 {
97  auto mockaccount = gnc_mockaccount(acc);
98  return mockaccount->find_account(category, key);
99 }
100 
101 void
102 gnc_account_imap_add_account (
103  Account *acc,
104  const char *category,
105  const char *key,
106  Account *dest_acc)
107 {
108  auto mockaccount = gnc_mockaccount(acc);
109  mockaccount->add_account(category, key, dest_acc);
110 }
111 
112 Account*
114  Account *acc,
115  GList *tokens)
116 {
117  std::vector<const char*> tokenVec;
118 
119  for (auto token = tokens; token; token = token->next)
120  {
121  tokenVec.push_back(static_cast <char const *> (token->data));
122  }
123 
124  auto mockaccount = gnc_mockaccount(acc);
125  return mockaccount->find_account_bayes(tokenVec);
126 }
127 
128 void
130  Account *acc,
131  GList *tokens,
132  Account *added_acc)
133 {
134  std::vector<const char*> tokenVec;
135 
136  for (auto token = tokens; token; token = token->next)
137  {
138  tokenVec.push_back(static_cast <char const *> (token->data));
139  }
140 
141  auto mockaccount = gnc_mockaccount(acc);
142  mockaccount->add_account_bayes(tokenVec, added_acc);
143 }
144 
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...
STRUCTS.
void gnc_account_imap_add_account_bayes(Account *acc, GList *tokens, Account *added_acc)
Updates the imap for a given account using a list of tokens.
GList SplitList
GList of Split.
Definition: gnc-engine.h:207
GType gnc_account_get_type(void)
Returns the GType type system description of the Account class.
void xaccAccountBeginEdit(Account *account)
The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account up...
gnc_commodity * xaccAccountGetCommodity(const Account *account)
Get the account&#39;s commodity.
void xaccAccountCommitEdit(Account *account)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
Account * gnc_account_imap_find_account_bayes(Account *acc, GList *tokens)
Look up an Account in the map using Baysian.