本文整理汇总了C++中qof_instance_get_slots函数的典型用法代码示例。如果您正苦于以下问题:C++ qof_instance_get_slots函数的具体用法?C++ qof_instance_get_slots怎么用?C++ qof_instance_get_slots使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qof_instance_get_slots函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: write_book_parts
gboolean
write_book_parts(FILE *out, QofBook *book)
{
xmlNodePtr domnode;
domnode = guid_to_dom_tree(book_id_string, qof_book_get_guid(book));
xmlElemDump(out, NULL, domnode);
xmlFreeNode (domnode);
if (ferror(out) || fprintf(out, "\n") < 0)
return FALSE;
if (qof_instance_get_slots (QOF_INSTANCE (book)))
{
xmlNodePtr kvpnode = kvp_frame_to_dom_tree(book_slots_string,
qof_instance_get_slots (QOF_INSTANCE (book)));
if (kvpnode)
{
xmlElemDump(out, NULL, kvpnode);
xmlFreeNode(kvpnode);
if (ferror(out) || fprintf(out, "\n") < 0)
return FALSE;
}
}
return TRUE;
}
示例2: gnc_book_dom_tree_create
xmlNodePtr
gnc_book_dom_tree_create(QofBook *book)
{
xmlNodePtr ret;
G_GNUC_UNUSED gboolean allow_incompat = TRUE;
ret = xmlNewNode(NULL, BAD_CAST gnc_book_string);
xmlSetProp(ret, BAD_CAST "version", BAD_CAST gnc_v2_book_version_string);
xmlAddChild(ret, guid_to_dom_tree(book_id_string,
qof_book_get_guid(book)));
if (qof_instance_get_slots (QOF_INSTANCE (book)))
{
xmlNodePtr kvpnode = kvp_frame_to_dom_tree(book_slots_string,
qof_instance_get_slots (QOF_INSTANCE (book)));
if (kvpnode)
xmlAddChild(ret, kvpnode);
}
#ifdef IMPLEMENT_BOOK_DOM_TREES_LATER
/* theoretically, we should be adding all the below to the book
* but in fact, there's enough brain damage in the code already
* that we are only going to hand-edit the file at a higher layer.
* And that's OK, since its probably a performance boost anyway.
*/
xmlAddChild(ret, gnc_commodity_dom_tree_create(
gnc_commodity_table_get_table(book)));
xmlAddChild(ret, gnc_pricedb_dom_tree_create(gnc_pricedb_get_db(book)));
if (allow_incompat)
{
accnode = gnc_account_dom_tree_create(account, FALSE);
xmlAddChild (ret, rootAccNode);
}
append_account_tree (ret, gnc_book_get_root(book));
xaccAccountTreeForEachTransaction (gnc_book_get_root_account(book),
traverse_txns, ret);
/* xxx FIXME hack alert how are we going to handle
* gnc_book_get_template_group handled ??? */
xmlAddChild(ret, gnc_schedXaction_dom_tree_create(
gnc_book_get_schedxactions(book)));
#endif
return ret;
}
示例3: billterm_slots_handler
static gboolean
billterm_slots_handler (xmlNodePtr node, gpointer billterm_pdata)
{
struct billterm_pdata *pdata = billterm_pdata;
return dom_tree_to_kvp_frame_given (node,
qof_instance_get_slots (QOF_INSTANCE(pdata->term)));
}
示例4: customer_slots_handler
static gboolean
customer_slots_handler (xmlNodePtr node, gpointer cust_pdata)
{
struct customer_pdata *pdata = cust_pdata;
return dom_tree_to_kvp_frame_given (node,
qof_instance_get_slots (QOF_INSTANCE(pdata->customer)));
}
示例5: load_slot_for_list_item
static void
load_slot_for_list_item( GncSqlBackend* be, GncSqlRow* row, QofCollection* coll )
{
slot_info_t slot_info = { NULL, NULL, TRUE, NULL, 0, NULL, FRAME, NULL, NULL };
const GncGUID* guid;
QofInstance* inst;
g_return_if_fail( be != NULL );
g_return_if_fail( row != NULL );
g_return_if_fail( coll != NULL );
guid = load_obj_guid( be, row );
g_assert( guid != NULL );
inst = qof_collection_lookup_entity( coll, guid );
slot_info.be = be;
slot_info.pKvpFrame = qof_instance_get_slots( inst );
slot_info.context = NONE;
gnc_sql_load_object( be, row, TABLE_NAME, &slot_info, col_table );
if ( slot_info.path != NULL )
{
(void)g_string_free( slot_info.path, TRUE );
}
}
示例6: qof_book_get_default_gains_policy
/** Returns pointer to default gain/loss policy for book, if one exists in the
* KVP, or NULL; does not validate contents nor determine if there is a valid
* book-currency, both of which are required, for the 'book-currency'
* currency accounting method to apply. Use instead
* 'gnc_book_get_default_gains_policy' which does these validations. */
const gchar *
qof_book_get_default_gains_policy (QofBook *book)
{
KvpFrame *kvp;
KvpValue *value;
if (!book)
{
PWARN ("No book!!!");
return NULL;
}
/* Get the KVP from the current book */
kvp = qof_instance_get_slots (QOF_INSTANCE (book));
if (!kvp)
{
PWARN ("Book has no KVP_Frame");
return NULL;
}
/* See if there is a default gain/loss policy */
value = kvp->get_slot({KVP_OPTION_PATH, OPTION_SECTION_ACCOUNTS,
OPTION_NAME_DEFAULT_GAINS_POLICY});
if (!value)
/* No default gain/loss policy, therefore not valid book-currency
accounting method */
return nullptr;
return g_strdup(value->get<const char*>());
}
示例7: gnc_address_to_dom_tree
xmlNodePtr
gnc_address_to_dom_tree (const char *tag, GncAddress *addr)
{
xmlNodePtr ret;
KvpFrame *kf;
ret = xmlNewNode(NULL, BAD_CAST tag);
xmlSetProp(ret, BAD_CAST "version", BAD_CAST address_version_string);
maybe_add_string (ret, addr_name_string, gncAddressGetName (addr));
maybe_add_string (ret, addr_addr1_string, gncAddressGetAddr1 (addr));
maybe_add_string (ret, addr_addr2_string, gncAddressGetAddr2 (addr));
maybe_add_string (ret, addr_addr3_string, gncAddressGetAddr3 (addr));
maybe_add_string (ret, addr_addr4_string, gncAddressGetAddr4 (addr));
maybe_add_string (ret, addr_phone_string, gncAddressGetPhone (addr));
maybe_add_string (ret, addr_fax_string, gncAddressGetFax (addr));
maybe_add_string (ret, addr_email_string, gncAddressGetEmail (addr));
kf = qof_instance_get_slots (QOF_INSTANCE(addr));
if (kf)
{
xmlNodePtr kvpnode = kvp_frame_to_dom_tree(addr_slots_string, kf);
if (kvpnode)
{
xmlAddChild(ret, kvpnode);
}
}
return ret;
}
示例8: employee_slots_handler
static gboolean
employee_slots_handler (xmlNodePtr node, gpointer employee_pdata)
{
struct employee_pdata *pdata = employee_pdata;
return dom_tree_to_kvp_frame_given (
node, qof_instance_get_slots (QOF_INSTANCE(pdata->employee)));
}
示例9: qof_book_get_book_currency
/** Returns pointer to book-currency name for book, if one exists in the
* KVP, or NULL; does not validate contents nor determine if there is a valid
* default gain/loss policy, both of which are required, for the
* 'book-currency' currency accounting method to apply. Use instead
* 'gnc_book_get_book_currency' which does these validations. */
const gchar *
qof_book_get_book_currency (QofBook *book)
{
KvpFrame *kvp;
KvpValue *value;
if (!book)
{
PWARN ("No book!!!");
return NULL;
}
/* Get the KVP from the current book */
kvp = qof_instance_get_slots (QOF_INSTANCE (book));
if (!kvp)
{
PWARN ("Book has no KVP_Frame");
return NULL;
}
/* See if there is a book currency. */
value = kvp->get_slot({KVP_OPTION_PATH, OPTION_SECTION_ACCOUNTS,
OPTION_NAME_BOOK_CURRENCY});
if (!value) /* No book-currency */
return nullptr;
return value->get<const char*>();
}
示例10: TEST_F
TEST_F(ImapBayesTest, FindAccountBayes)
{
auto root = qof_instance_get_slots(QOF_INSTANCE(t_bank_account));
auto acct1_guid = guid_to_string (xaccAccountGetGUID(t_expense_account1));
auto acct2_guid = guid_to_string (xaccAccountGetGUID(t_expense_account2));
auto value = new KvpValue(INT64_C(42));
root->set_path({IMAP_FRAME_BAYES, foo, acct1_guid}, value);
root->set_path({IMAP_FRAME_BAYES, bar, acct1_guid}, value);
root->set_path({IMAP_FRAME_BAYES, baz, acct2_guid}, value);
root->set_path({IMAP_FRAME_BAYES, waldo, acct2_guid}, value);
root->set_path({IMAP_FRAME_BAYES, pepper, acct1_guid}, value);
root->set_path({IMAP_FRAME_BAYES, salt, acct2_guid}, value);
auto account = gnc_account_imap_find_account_bayes(t_imap, t_list1);
EXPECT_EQ(t_expense_account1, account);
account = gnc_account_imap_find_account_bayes(t_imap, t_list2);
EXPECT_EQ(t_expense_account2, account);
account = gnc_account_imap_find_account_bayes(t_imap, t_list3);
EXPECT_EQ(t_expense_account1, account);
account = gnc_account_imap_find_account_bayes(t_imap, t_list4);
EXPECT_EQ(t_expense_account2, account);
account = gnc_account_imap_find_account_bayes(t_imap, t_list5);
EXPECT_EQ(nullptr, account);
}
示例11: load_slot_for_book_object
static void
load_slot_for_book_object( GncSqlBackend* be, GncSqlRow* row, BookLookupFn lookup_fn )
{
slot_info_t slot_info = { NULL, NULL, TRUE, NULL, 0, NULL, FRAME, NULL, NULL };
const GncGUID* guid;
QofInstance* inst;
g_return_if_fail( be != NULL );
g_return_if_fail( row != NULL );
g_return_if_fail( lookup_fn != NULL );
guid = load_obj_guid( be, row );
g_return_if_fail( guid != NULL );
inst = lookup_fn( guid, be->book );
g_return_if_fail( inst != NULL );
slot_info.be = be;
slot_info.pKvpFrame = qof_instance_get_slots( inst );
slot_info.path = NULL;
gnc_sql_load_object( be, row, TABLE_NAME, &slot_info, col_table );
if ( slot_info.path != NULL )
{
(void)g_string_free( slot_info.path, TRUE );
}
}
示例12: address_slots_handler
static gboolean
address_slots_handler (xmlNodePtr node, gpointer addr_pdata)
{
struct address_pdata *pdata = addr_pdata;
return dom_tree_to_kvp_frame_given
(node, qof_instance_get_slots (QOF_INSTANCE (pdata->address)));
}
示例13: job_slots_handler
static gboolean
job_slots_handler (xmlNodePtr node, gpointer job_pdata)
{
struct job_pdata *pdata = job_pdata;
return dom_tree_to_kvp_frame_given
(node, qof_instance_get_slots (QOF_INSTANCE (pdata->job)));
}
示例14: qof_book_get_string_option
const char*
qof_book_get_string_option(const QofBook* book, const char* opt_name)
{
auto slot = qof_instance_get_slots(QOF_INSTANCE (book))->get_slot(opt_name);
if (slot == nullptr)
return nullptr;
return slot->get<const char*>();
}
示例15: create_session
static QofSession*
create_session(void)
{
QofSession* session = qof_session_new();
QofBook* book = qof_session_get_book( session );
Account* root = gnc_book_get_root_account( book );
Account* acct1;
Account* acct2;
KvpFrame* frame;
Transaction* tx;
Split* spl1;
Split* spl2;
Timespec ts;
struct timeval tv;
gnc_commodity_table* table;
gnc_commodity* currency;
table = gnc_commodity_table_get_table( book );
currency = gnc_commodity_table_lookup( table, GNC_COMMODITY_NS_CURRENCY, "CAD" );
acct1 = xaccMallocAccount( book );
xaccAccountSetType( acct1, ACCT_TYPE_BANK );
xaccAccountSetName( acct1, "Bank 1" );
xaccAccountSetCommodity( acct1, currency );
frame = qof_instance_get_slots( QOF_INSTANCE(acct1) );
kvp_frame_set_gint64( frame, "int64-val", 100 );
kvp_frame_set_double( frame, "double-val", 3.14159 );
kvp_frame_set_numeric( frame, "numeric-val", gnc_numeric_zero() );
time( &(tv.tv_sec) );
tv.tv_usec = 0;
ts.tv_sec = tv.tv_sec;
ts.tv_nsec = 1000 * tv.tv_usec;
kvp_frame_set_timespec( frame, "timespec-val", ts );
kvp_frame_set_string( frame, "string-val", "abcdefghijklmnop" );
kvp_frame_set_guid( frame, "guid-val", qof_instance_get_guid( QOF_INSTANCE(acct1) ) );
gnc_account_append_child( root, acct1 );
acct2 = xaccMallocAccount( book );
xaccAccountSetType( acct2, ACCT_TYPE_BANK );
xaccAccountSetName( acct2, "Bank 1" );
tx = xaccMallocTransaction( book );
xaccTransBeginEdit( tx );
xaccTransSetCurrency( tx, currency );
spl1 = xaccMallocSplit( book );
xaccTransAppendSplit( tx, spl1 );
spl2 = xaccMallocSplit( book );
xaccTransAppendSplit( tx, spl2 );
xaccTransCommitEdit( tx );
return session;
}