summaryrefslogtreecommitdiff
path: root/src/c_fl_preferences.cpp
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2024-10-24 21:50:46 +1300
committerJedidiah Barber <contact@jedbarber.id.au>2024-10-24 22:02:44 +1300
commit1b1904f3e1578ffd60e09edfded113d4c8f50c41 (patch)
treea5c5c98672eb50bfb15c20a09e0d550da06919f1 /src/c_fl_preferences.cpp
parent18a37bf29456be7dc7c5531d336b414c1c70c2c3 (diff)
Completed Fl_Preferences API binding
Diffstat (limited to 'src/c_fl_preferences.cpp')
-rw-r--r--src/c_fl_preferences.cpp188
1 files changed, 156 insertions, 32 deletions
diff --git a/src/c_fl_preferences.cpp b/src/c_fl_preferences.cpp
index 56f95ff..6f2e1ad 100644
--- a/src/c_fl_preferences.cpp
+++ b/src/c_fl_preferences.cpp
@@ -5,23 +5,121 @@
#include <FL/Fl_Preferences.H>
+#include <FL/filename.H>
+#include <cstdlib>
#include "c_fl_preferences.h"
-PREFS new_fl_preferences(char * p, char * v, char * a) {
- Fl_Preferences *e = new Fl_Preferences(p,v,a);
+const int root_fl_prefs_system = Fl_Preferences::SYSTEM;
+const int root_fl_prefs_user = Fl_Preferences::USER;
+
+const int const_fl_path_max = FL_PATH_MAX;
+
+
+
+
+const char * fl_preferences_new_uuid() {
+ return Fl_Preferences::newUUID();
+}
+
+
+
+
+class My_Preferences : public Fl_Preferences {
+ public:
+ using Fl_Preferences::Fl_Preferences;
+ int reference_count = 0;
+};
+
+
+
+
+PREFS new_fl_pref_database_path(char * p, char * v, char * a) {
+ My_Preferences *e = new My_Preferences(p, v, a);
+ return e;
+}
+
+PREFS new_fl_pref_database_scope(int s, char * v, char * a) {
+ My_Preferences *e = new My_Preferences((Fl_Preferences::Root)s, v, a);
return e;
}
-void free_fl_preferences(PREFS e) {
+void upref_fl_pref_database(PREFS e) {
+ reinterpret_cast<My_Preferences*>(e)->reference_count += 1;
+}
+
+void free_fl_pref_database(PREFS e) {
+ if (reinterpret_cast<My_Preferences*>(e)->reference_count <= 0) {
+ delete reinterpret_cast<My_Preferences*>(e);
+ } else {
+ reinterpret_cast<My_Preferences*>(e)->reference_count -= 1;
+ }
+}
+
+
+PREFS new_fl_pref_group_copy(PREFS e) {
+ Fl_Preferences *g = new Fl_Preferences(reinterpret_cast<Fl_Preferences*>(e));
+ return g;
+}
+
+PREFS new_fl_pref_group_memory(char * n) {
+ Fl_Preferences *g = new Fl_Preferences(NULL, n);
+ return g;
+}
+
+PREFS new_fl_pref_group_name(PREFS e, char * n) {
+ Fl_Preferences *g = new Fl_Preferences(reinterpret_cast<Fl_Preferences*>(e), n);
+ return g;
+}
+
+PREFS new_fl_pref_group_index(PREFS e, int i) {
+ Fl_Preferences *g = new Fl_Preferences(reinterpret_cast<Fl_Preferences*>(e), i);
+ return g;
+}
+
+void free_fl_pref_group(PREFS e) {
delete reinterpret_cast<Fl_Preferences*>(e);
}
+void fl_preferences_flush(PREFS e) {
+ reinterpret_cast<Fl_Preferences*>(e)->flush();
+}
+
+int fl_preferences_getuserdatapath(PREFS e, char * p, int len) {
+ return (int)reinterpret_cast<Fl_Preferences*>(e)->getUserdataPath(p, len);
+}
+
+
+
+
+int fl_preferences_deleteentry(PREFS e, const char * k) {
+ return (int)reinterpret_cast<Fl_Preferences*>(e)->deleteEntry(k);
+}
+
+int fl_preferences_deleteallentries(PREFS e) {
+ return (int)reinterpret_cast<Fl_Preferences*>(e)->deleteAllEntries();
+}
+
+int fl_preferences_deletegroup(PREFS e, const char * g) {
+ return (int)reinterpret_cast<Fl_Preferences*>(e)->deleteGroup(g);
+}
+
+int fl_preferences_deleteallgroups(PREFS e) {
+ return (int)reinterpret_cast<Fl_Preferences*>(e)->deleteAllGroups();
+}
+
+int fl_preferences_clear(PREFS e) {
+ return (int)reinterpret_cast<Fl_Preferences*>(e)->clear();
+}
+
+
+
+
int fl_preferences_entries(PREFS e) {
return reinterpret_cast<Fl_Preferences*>(e)->entries();
}
@@ -31,7 +129,7 @@ const char * fl_preferences_entry(PREFS e, int i) {
}
int fl_preferences_entryexists(PREFS e, const char * k) {
- return reinterpret_cast<Fl_Preferences*>(e)->entryExists(k);
+ return (int)reinterpret_cast<Fl_Preferences*>(e)->entryExists(k);
}
int fl_preferences_size(PREFS e, const char * k) {
@@ -41,69 +139,95 @@ int fl_preferences_size(PREFS e, const char * k) {
-int fl_preferences_get_int(PREFS e, const char * k, int& v, int d) {
- return reinterpret_cast<Fl_Preferences*>(e)->get(k,v,d);
+int fl_preferences_groups(PREFS e) {
+ return reinterpret_cast<Fl_Preferences*>(e)->groups();
}
-int fl_preferences_get_float(PREFS e, const char * k, float& v, float d) {
- return reinterpret_cast<Fl_Preferences*>(e)->get(k,v,d);
+const char * fl_preferences_group(PREFS e, int i) {
+ return reinterpret_cast<Fl_Preferences*>(e)->group(i);
}
-int fl_preferences_get_double(PREFS e, const char * k, double& v, double d) {
- return reinterpret_cast<Fl_Preferences*>(e)->get(k,v,d);
+int fl_preferences_groupexists(PREFS e, const char * g) {
+ return (int)reinterpret_cast<Fl_Preferences*>(e)->groupExists(g);
}
-int fl_preferences_get_str(PREFS e, const char * k, char *& v, const char * d) {
- return reinterpret_cast<Fl_Preferences*>(e)->get(k,v,d);
+
+
+
+const char * fl_preferences_name(PREFS e) {
+ return reinterpret_cast<Fl_Preferences*>(e)->name();
}
+const char * fl_preferences_path(PREFS e) {
+ return reinterpret_cast<Fl_Preferences*>(e)->path();
+}
-int fl_preferences_set_int(PREFS e, const char * k, int v) {
- return reinterpret_cast<Fl_Preferences*>(e)->set(k,v);
+
+int fl_preferences_get_int(PREFS e, const char * k, int& v, int d) {
+ return (int)reinterpret_cast<Fl_Preferences*>(e)->get(k,v,d);
}
-int fl_preferences_set_float(PREFS e, const char * k, float v) {
- return reinterpret_cast<Fl_Preferences*>(e)->set(k,v);
+int fl_preferences_get_float(PREFS e, const char * k, float& v, float d) {
+ return (int)reinterpret_cast<Fl_Preferences*>(e)->get(k,v,d);
}
-int fl_preferences_set_float_prec(PREFS e, const char * k, float v, int p) {
- return reinterpret_cast<Fl_Preferences*>(e)->set(k,v,p);
+int fl_preferences_get_double(PREFS e, const char * k, double& v, double d) {
+ return (int)reinterpret_cast<Fl_Preferences*>(e)->get(k,v,d);
}
-int fl_preferences_set_double(PREFS e, const char * k, double v) {
- return reinterpret_cast<Fl_Preferences*>(e)->set(k,v);
+// must deallocate result afterwards
+int fl_preferences_get_str(PREFS e, const char * k, char *& v, const char * d) {
+ return (int)reinterpret_cast<Fl_Preferences*>(e)->get(k,v,d);
}
-int fl_preferences_set_double_prec(PREFS e, const char * k, double v, int p) {
- return reinterpret_cast<Fl_Preferences*>(e)->set(k,v,p);
+int fl_preferences_get_str_limit (PREFS e, const char * k, char * v, const char * d, int m) {
+ return (int)reinterpret_cast<Fl_Preferences*>(e)->get(k, v, d, m);
}
-int fl_preferences_set_str(PREFS e, const char * k, const char * v) {
- return reinterpret_cast<Fl_Preferences*>(e)->set(k,v);
+// must deallocate result afterwards
+int fl_preferences_get_void (PREFS e, const char * k, void *& v, const void * d, int ds) {
+ return (int)reinterpret_cast<Fl_Preferences*>(e)->get(k, v, d, ds);
+}
+
+int fl_preferences_get_void_limit (PREFS e, const char * k, void * v, const void * d, int ds, int ms) {
+ return (int)reinterpret_cast<Fl_Preferences*>(e)->get(k, v, d, ds, ms);
}
+void free_fl_preferences_void_data(void * v) {
+ free(v);
+}
-int fl_preferences_deleteentry(PREFS e, const char * k) {
- return reinterpret_cast<Fl_Preferences*>(e)->deleteEntry(k);
+
+int fl_preferences_set_int(PREFS e, const char * k, int v) {
+ return (int)reinterpret_cast<Fl_Preferences*>(e)->set(k,v);
}
-int fl_preferences_deleteallentries(PREFS e) {
- return reinterpret_cast<Fl_Preferences*>(e)->deleteAllEntries();
+int fl_preferences_set_float(PREFS e, const char * k, float v) {
+ return (int)reinterpret_cast<Fl_Preferences*>(e)->set(k,v);
}
-int fl_preferences_clear(PREFS e) {
- return reinterpret_cast<Fl_Preferences*>(e)->clear();
+int fl_preferences_set_float_prec(PREFS e, const char * k, float v, int p) {
+ return (int)reinterpret_cast<Fl_Preferences*>(e)->set(k,v,p);
}
+int fl_preferences_set_double(PREFS e, const char * k, double v) {
+ return (int)reinterpret_cast<Fl_Preferences*>(e)->set(k,v);
+}
+int fl_preferences_set_double_prec(PREFS e, const char * k, double v, int p) {
+ return (int)reinterpret_cast<Fl_Preferences*>(e)->set(k,v,p);
+}
+int fl_preferences_set_str(PREFS e, const char * k, const char * v) {
+ return (int)reinterpret_cast<Fl_Preferences*>(e)->set(k,v);
+}
-void fl_preferences_flush(PREFS e) {
- reinterpret_cast<Fl_Preferences*>(e)->flush();
+int fl_preferences_set_void(PREFS e, const char * k, const void * d, int ds) {
+ return (int)reinterpret_cast<Fl_Preferences*>(e)->set(k, d, ds);
}