GnuCash  4.8a-134-g214de30c7+
gmock-gnc-prefs.cpp
1 #include <config.h>
2 
3 #include "gmock-gnc-prefs.h"
4 
5 static MockPrefsBackend* prefsbackend = nullptr;
6 
7 void
8 gmock_gnc_prefs_set_backend(MockPrefsBackend *backend)
9 {
10  prefsbackend = backend;
11 }
12 
13 extern "C"
14 {
15 gboolean
16 gnc_prefs_get_bool (const gchar *group, const gchar *pref_name)
17 {
18  EXPECT_NE(prefsbackend, nullptr);
19  return prefsbackend ? prefsbackend->get_bool(group, pref_name) : FALSE;
20 }
21 
22 gint
23 gnc_prefs_get_int (const gchar *group, const gchar *pref_name)
24 {
25  EXPECT_NE(prefsbackend, nullptr);
26  return prefsbackend ? prefsbackend->get_int(group, pref_name) : 0;
27 }
28 
29 gint64
30 gnc_prefs_get_int64 (const gchar *group, const gchar *pref_name)
31 {
32  EXPECT_NE(prefsbackend, nullptr);
33  return prefsbackend ? prefsbackend->get_int64(group, pref_name) : 0;
34 }
35 
36 gdouble
37 gnc_prefs_get_float (const gchar *group, const gchar *pref_name)
38 {
39  EXPECT_NE(prefsbackend, nullptr);
40  return prefsbackend ? prefsbackend->get_float(group, pref_name) : 0.0;
41 }
42 
43 gchar *
44 gnc_prefs_get_string (const gchar *group, const gchar *pref_name)
45 {
46  EXPECT_NE(prefsbackend, nullptr);
47  return prefsbackend ? prefsbackend->get_string(group, pref_name) : NULL;
48 }
49 
50 gint
51 gnc_prefs_get_enum (const gchar *group, const gchar *pref_name)
52 {
53  EXPECT_NE(prefsbackend, nullptr);
54  return prefsbackend ? prefsbackend->get_enum(group, pref_name) : 0;
55 }
56 
57 void
58 gnc_prefs_get_coords (const gchar *group, const gchar *pref_name, gdouble *x, gdouble *y)
59 {
60  EXPECT_NE(prefsbackend, nullptr);
61 
62  *x = 0.0;
63  *y = 0.0;
64 
65  if (prefsbackend != nullptr)
66  prefsbackend->get_coords(group, pref_name, x, y);
67 }
68 
69 } // extern "C"
gchar * gnc_prefs_get_string(const gchar *group, const gchar *pref_name)
Get a string value from the preferences backend.
gint64 gnc_prefs_get_int64(const gchar *group, const gchar *pref_name)
Get an 64 bit integer value from the preferences backend.
gint gnc_prefs_get_int(const gchar *group, const gchar *pref_name)
Get an integer value from the preferences backend.
gint gnc_prefs_get_enum(const gchar *group, const gchar *pref_name)
Get an enum value from the preferences backend.
void gnc_prefs_get_coords(const gchar *group, const gchar *pref_name, gdouble *x, gdouble *y)
Get a pair of coordinates from the preferences backend.
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Get a boolean value from the preferences backend.
gdouble gnc_prefs_get_float(const gchar *group, const gchar *pref_name)
Get an float value from the preferences backend.