本文整理汇总了C++中KvpFrame类的典型用法代码示例。如果您正苦于以下问题:C++ KvpFrame类的具体用法?C++ KvpFrame怎么用?C++ KvpFrame使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KvpFrame类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: equals_node_val_vs_kvp_frame
gboolean
equals_node_val_vs_kvp_frame(xmlNodePtr node, const KvpFrame *frm)
{
KvpFrame *cmpfrm;
g_return_val_if_fail(node, FALSE);
g_return_val_if_fail(frm, FALSE);
cmpfrm = dom_tree_to_kvp_frame(node);
g_return_val_if_fail(cmpfrm, FALSE);
if (compare(frm, cmpfrm) == 0)
{
delete cmpfrm;
return TRUE;
}
else
{
auto frm1str = g_strdup(frm->to_string().c_str());
auto frm2str = g_strdup(cmpfrm->to_string().c_str());
printf("%s vs %s\n", frm1str, frm2str);
g_free(frm1str);
g_free(frm2str);
delete cmpfrm;
return FALSE;
}
}
示例2: 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*>());
}
示例3: 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*>();
}
示例4: qof_book_get_option
KvpValue*
qof_book_get_option (QofBook *book, GSList *path)
{
KvpFrame *root = qof_instance_get_slots(QOF_INSTANCE (book));
Path path_v {KVP_OPTION_PATH};
for (auto item = path; item != nullptr; item = g_slist_next(item))
path_v.push_back(static_cast<const char*>(item->data));
return root->get_slot(path_v);
}
示例5: qof_book_set_feature
void
qof_book_set_feature (QofBook *book, const gchar *key, const gchar *descr)
{
KvpFrame *frame = qof_instance_get_slots (QOF_INSTANCE (book));
qof_book_begin_edit (book);
delete frame->set_path({GNC_FEATURES, key}, new KvpValue(descr));
qof_instance_set_dirty (QOF_INSTANCE (book));
qof_book_commit_edit (book);
}
示例6: qof_book_get_counter_format
const gchar *
qof_book_get_counter_format(const QofBook *book, const char *counter_name)
{
KvpFrame *kvp;
const char *format;
KvpValue *value;
gchar *error;
if (!book)
{
PWARN ("No book!!!");
return NULL;
}
if (!counter_name || *counter_name == '\0')
{
PWARN ("Invalid counter name.");
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;
}
format = NULL;
/* Get the format string */
value = kvp->get_slot({"counter_formats", counter_name});
if (value)
{
format = value->get<const char*>();
error = qof_book_validate_counter_format(format);
if (error != NULL)
{
PWARN("Invalid counter format string. Format string: '%s' Counter: '%s' Error: '%s')", format, counter_name, error);
/* Invalid format string */
format = NULL;
g_free(error);
}
}
/* If no (valid) format string was found, use the default format
* string */
if (!format)
{
/* Use the default format */
format = "%.6" G_GINT64_FORMAT;
}
return format;
}
示例7: qof_book_set_option
void
qof_book_set_option (QofBook *book, KvpValue *value, GSList *path)
{
KvpFrame *root = qof_instance_get_slots (QOF_INSTANCE (book));
Path path_v {KVP_OPTION_PATH};
for (auto item = path; item != nullptr; item = g_slist_next(item))
path_v.push_back(static_cast<const char*>(item->data));
qof_book_begin_edit (book);
delete root->set_path(path_v, value);
qof_instance_set_dirty (QOF_INSTANCE (book));
qof_book_commit_edit (book);
}
示例8: qof_instance_slots_to_dom_tree
xmlNodePtr
qof_instance_slots_to_dom_tree(const char *tag, const QofInstance* inst)
{
xmlNodePtr ret;
const char ** keys;
unsigned int i;
KvpFrame *frame = qof_instance_get_slots(inst);
if (!frame)
return nullptr;
ret = xmlNewNode(nullptr, BAD_CAST tag);
frame->for_each_slot(add_kvp_slot, static_cast<void*>(ret));
return ret;
}
示例9: qof_book_get_features
GHashTable *
qof_book_get_features (QofBook *book)
{
KvpFrame *frame = qof_instance_get_slots (QOF_INSTANCE (book));
GHashTable *features = g_hash_table_new_full (g_str_hash, g_str_equal,
NULL, g_free);
auto slot = frame->get_slot(GNC_FEATURES);
if (slot != nullptr)
{
frame = slot->get<KvpFrame*>();
frame->for_each_slot(&add_feature_to_hash, &features);
}
return features;
}
示例10: qof_book_get_counter
gint64
qof_book_get_counter (QofBook *book, const char *counter_name)
{
KvpFrame *kvp;
KvpValue *value;
if (!book)
{
PWARN ("No book!!!");
return -1;
}
if (!counter_name || *counter_name == '\0')
{
PWARN ("Invalid counter name.");
return -1;
}
/* Use the KVP in the book */
kvp = qof_instance_get_slots (QOF_INSTANCE (book));
if (!kvp)
{
PWARN ("Book has no KVP_Frame");
return -1;
}
value = kvp->get_slot({"counters", counter_name});
if (value)
{
/* found it */
return value->get<int64_t>();
}
else
{
/* New counter */
return 0;
}
}
示例11: gnc_sql_slots_save
gboolean
gnc_sql_slots_save( GncSqlBackend* be, const GncGUID* guid, gboolean is_infant,
QofInstance *inst)
{
slot_info_t slot_info = { NULL, NULL, TRUE, NULL, KvpValue::Type::INVALID, NULL, FRAME, NULL, g_string_new(NULL) };
KvpFrame *pFrame = qof_instance_get_slots (inst);
g_return_val_if_fail( be != NULL, FALSE );
g_return_val_if_fail( guid != NULL, FALSE );
g_return_val_if_fail( pFrame != NULL, FALSE );
// If this is not saving into a new db, clear out the old saved slots first
if ( !be->is_pristine_db && !is_infant )
{
(void)gnc_sql_slots_delete( be, guid );
}
slot_info.be = be;
slot_info.guid = guid;
pFrame->for_each_slot(save_slot, &slot_info);
(void)g_string_free( slot_info.path, TRUE );
return slot_info.is_ok;
}
示例12: qof_book_options_delete
void
qof_book_options_delete (QofBook *book)
{
KvpFrame *root = qof_instance_get_slots(QOF_INSTANCE (book));
delete root->set_path(KVP_OPTION_PATH, nullptr);
}