GnuCash  4.12-74-g36b33262ad+
Files | Functions

Files

file  gnc-features.h
 Utility functions for file access.
 

Functions

gchar * gnc_features_test_unknown (QofBook *book)
 Test if the current book relies on features only introduced in a more recent version of GnuCash. More...
 
void gnc_features_set_unused (QofBook *book, const gchar *feature)
 Indicate that the current book does not use the given feature. More...
 
void gnc_features_set_used (QofBook *book, const gchar *feature)
 Indicate that the current book uses the given feature. More...
 
gboolean gnc_features_check_used (QofBook *, char const *feature)
 

Defined features

#define GNC_FEATURE_CREDIT_NOTES   "Credit Notes"
 
#define GNC_FEATURE_NUM_FIELD_SOURCE   "Number Field Source"
 
#define GNC_FEATURE_KVP_EXTRA_DATA   "Extra data in addresses, jobs or invoice entries"
 
#define GNC_FEATURE_BOOK_CURRENCY   "Use a Book-Currency"
 
#define GNC_FEATURE_GUID_BAYESIAN   "Account GUID based Bayesian data"
 
#define GNC_FEATURE_GUID_FLAT_BAYESIAN   "Account GUID based bayesian with flat KVP"
 
#define GNC_FEATURE_SQLITE3_ISO_DATES   "ISO-8601 formatted date strings in SQLite3 databases."
 
#define GNC_FEATURE_REG_SORT_FILTER   "Register sort and filter settings stored in .gcm file"
 
#define GNC_FEATURE_BUDGET_UNREVERSED   "Use natural signs in budget amounts"
 
#define GNC_FEATURE_BUDGET_SHOW_EXTRA_ACCOUNT_COLS   "Show extra account columns in the Budget View"
 
#define GNC_FEATURE_EQUITY_TYPE_OPENING_BALANCE   "Use a dedicated opening balance account identified by an 'equity-type' slot"
 

Detailed Description

Function Documentation

◆ gnc_features_set_unused()

void gnc_features_set_unused ( QofBook *  book,
const gchar *  feature 
)

Indicate that the current book does not use the given feature.

This will allow older versions of GnuCash that don't support this feature to load this book.

Definition at line 95 of file gnc-features.cpp.

96 {
97  g_return_if_fail (book);
98  g_return_if_fail (feature);
99 
100  /* Can't set an unknown feature */
101  auto iter = features_table.find (feature);
102  if (iter == features_table.end ())
103  {
104  PWARN("Tried to set unknown feature as unused.");
105  return;
106  }
107 
108  qof_book_unset_feature (book, feature);
109 }
#define PWARN(format, args...)
Log a warning.
Definition: qoflog.h:250

◆ gnc_features_set_used()

void gnc_features_set_used ( QofBook *  book,
const gchar *  feature 
)

Indicate that the current book uses the given feature.

This will prevent older versions of GnuCash that don't support this feature to refuse to load this book.

Definition at line 78 of file gnc-features.cpp.

79 {
80  g_return_if_fail (book);
81  g_return_if_fail (feature);
82 
83  /* Can't set an unknown feature */
84  auto iter = features_table.find (feature);
85  if (iter == features_table.end ())
86  {
87  PWARN("Tried to set unknown feature as used.");
88  return;
89  }
90 
91  qof_book_set_feature (book, feature, iter->second.c_str());
92 }
#define PWARN(format, args...)
Log a warning.
Definition: qoflog.h:250

◆ gnc_features_test_unknown()

gchar* gnc_features_test_unknown ( QofBook *  book)

Test if the current book relies on features only introduced in a more recent version of GnuCash.

Returns a message to display if we found unknown features, NULL if we're okay.

Definition at line 69 of file gnc-features.cpp.

70 {
71  auto unknowns {qof_book_get_unknown_features (book, features_table)};
72  auto accum = [](const auto& a, const auto& b){ return a + "\n* " + b; };
73  return unknowns.empty() ? nullptr :
74  g_strdup (std::accumulate (unknowns.begin(), unknowns.end(),
75  std::string (_(header)), accum).c_str());
76 }