mirror of
https://github.com/Gnucash/gnucash.git
synced 2026-11-02 09:49:06 -06:00
[gnc-features.cpp] convert to cpp
- don't need to create/destroy GHashTable for each feature query - plugs leak: g_hash_table_unref (features_used) not always called properly - to check 1 feature, don't need to traverse whole GHashTable
This commit is contained in:
1 parent
6f6d2fef48
commit
8192deff37
5 files changed
+90
-108
No files matched your search
@@ -61,6 +61,8 @@ extern "C"
|
||||
// For GNC_ID_ROOT_ACCOUNT:
|
||||
#include "AccountP.h"
|
||||
|
||||
#include "qofbook.hpp"
|
||||
|
||||
static QofLogModule log_module = QOF_MOD_ENGINE;
|
||||
#define AB_KEY "hbci"
|
||||
#define AB_TEMPLATES "template-list"
|
||||
@@ -1255,6 +1257,32 @@ qof_book_set_feature (QofBook *book, const gchar *key, const gchar *descr)
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string>
|
||||
qof_book_get_unknown_features (QofBook *book, const FeaturesTable& features)
|
||||
{
|
||||
std::vector<std::string> rv;
|
||||
auto test_feature = [&](const KvpFrameImpl::map_type::value_type& feature)
|
||||
{
|
||||
if (features.find (feature.first) == features.end ())
|
||||
rv.push_back (feature.second->get<const char*>());
|
||||
};
|
||||
auto frame = qof_instance_get_slots (QOF_INSTANCE (book));
|
||||
auto slot = frame->get_slot({GNC_FEATURES});
|
||||
if (slot != nullptr)
|
||||
{
|
||||
frame = slot->get<KvpFrame*>();
|
||||
std::for_each (frame->begin (), frame->end (), test_feature);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool
|
||||
qof_book_test_feature (QofBook *book, const char *feature)
|
||||
{
|
||||
auto frame = qof_instance_get_slots (QOF_INSTANCE (book));
|
||||
return (frame->get_slot({GNC_FEATURES, feature}) != nullptr);
|
||||
}
|
||||
|
||||
void
|
||||
qof_book_load_options (QofBook *book, GNCOptionLoad load_cb, GNCOptionDB *odb)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user