20#ifndef Fl_Preferences_H
21# define Fl_Preferences_H
24# include "Fl_Export.H"
164 static const unsigned int NONE = 0x0000;
194 static Root filename(
char *buffer,
size_t buffer_size,
Root root,
const char *vendor,
const char *application );
206 FL_DEPRECATED(
"since 1.4.0 - use Fl_Preferences(path, vendor, application, flags) instead",
221 const char *
name() {
return node->name(); }
225 const char *
path() {
return node->path(); }
228 const char *group(
int num_group );
229 char group_exists(
const char *key );
230 char delete_group(
const char *group );
231 char delete_all_groups();
234 const char *entry(
int index );
235 char entry_exists(
const char *key );
236 char delete_entry(
const char *entry );
237 char delete_all_entries();
241 char set(
const char *entry,
int value );
242 char set(
const char *entry,
float value );
243 char set(
const char *entry,
float value,
int precision );
244 char set(
const char *entry,
double value );
245 char set(
const char *entry,
double value,
int precision );
246 char set(
const char *entry,
const char *value );
247 char set(
const char *entry,
const void *value,
int size );
249 char get(
const char *entry,
int &value,
int defaultValue );
250 char get(
const char *entry,
float &value,
float defaultValue );
251 char get(
const char *entry,
double &value,
double defaultValue );
252 char get(
const char *entry,
char *&value,
const char *defaultValue );
253 char get(
const char *entry,
char *value,
const char *defaultValue,
int maxSize );
254 char get(
const char *entry,
void *&value,
const void *defaultValue,
int defaultSize );
255 char get(
const char *entry,
void *value,
const void *defaultValue,
int defaultSize,
int maxSize );
256 char get(
const char *entry,
void *value,
const void *defaultValue,
int defaultSize,
int *size );
262 char set(
const char *entry,
const std::string &value );
263 char get(
const char *entry, std::string &value,
const std::string &defaultValue );
266 int size(
const char *entry );
268 char get_userdata_path(
char *path,
int pathlen );
275 static const char *newUUID() {
return new_UUID(); }
276 char groupExists(
const char *key ) {
return group_exists(key); }
277 char deleteGroup(
const char *group ) {
return delete_group(group); }
278 char deleteAllGroups() {
return delete_all_groups(); }
279 char entryExists(
const char *key ) {
return entry_exists(key); }
280 char deleteEntry(
const char *entry ) {
return delete_entry(entry); }
281 char deleteAllEntries() {
return delete_all_entries(); }
282 char getUserdataPath(
char *path,
int pathlen ) {
return get_userdata_path(path, pathlen); }
302 Name(
unsigned int n );
303 Name(
const char *format, ... );
309 operator const char *() {
return data_; }
322 static char nameBuffer[128];
323 static char uuidBuffer[40];
325 static unsigned int fileAccess_;
330 class FL_EXPORT Node {
332 Node *first_child_, *next_;
339 int nEntry_, NEntry_;
340 unsigned char dirty_:1;
341 unsigned char top_:1;
342 unsigned char indexed_:1;
345 int nIndex_, NIndex_;
350 static int lastEntrySet;
352 Node(
const char *path );
355 int write( FILE *f );
357 const char *path() {
return path_; }
358 Node *find(
const char *path );
359 Node *search(
const char *path,
int offset=0 );
360 Node *childNode(
int ix );
361 Node *addChild(
const char *path );
362 void setParent( Node *parent );
363 Node *parent() {
return top_?0L:parent_; }
364 void setRoot(
RootNode *r) { root_node_ = r; top_ = 1; }
368 void clearDirtyFlags();
369 void deleteAllChildren();
372 const char *child(
int ix );
373 void set(
const char *name,
const char *value );
374 void set(
const char *line );
375 void add(
const char *line );
376 const char *get(
const char *name );
377 int getEntry(
const char *name );
378 char deleteEntry(
const char *name );
379 void deleteAllEntries();
380 int nEntry() {
return nEntry_; }
381 Entry &entry(
int i) {
return entry_[i]; }
385 class FL_EXPORT RootNode {
388 char *vendor_, *application_;
397 char getPath(
char *
path,
int pathlen );
398 char *filename() {
return filename_; }
399 Root root() {
return root_type_; }
'Name' provides a simple method to create numerical or more complex procedural names for entries and ...
Definition Fl_Preferences.H:297
Name(unsigned int n)
Creates a group name or entry name on the fly.
Definition Fl_Preferences.cxx:1298
Definition Fl_Preferences.H:330
Definition Fl_Preferences.H:385
Fl_Preferences store user settings between application starts.
Definition Fl_Preferences.H:125
Root
Define the scope of the preferences.
Definition Fl_Preferences.H:131
@ SYSTEM
Preferences are used system-wide. Deprecated, see SYSTEM_L.
Definition Fl_Preferences.H:133
@ UNKNOWN_ROOT_TYPE
Returned if storage could not be determined.
Definition Fl_Preferences.H:132
@ C_LOCALE
This flag should always be set to ensure that floating point values are written and read correctly in...
Definition Fl_Preferences.H:138
@ USER_L
Preferences apply only to the current user, locale independent.
Definition Fl_Preferences.H:142
@ CORE_USER
Deprecated, same as CORE | USER. Use CORE_USER_L instead.
Definition Fl_Preferences.H:146
@ CORE_SYSTEM_L
Same as CORE | SYSTEM | C_LOCALE.
Definition Fl_Preferences.H:143
@ ROOT_MASK
Mask for the values above.
Definition Fl_Preferences.H:136
@ CLEAR
Don't read a possibly existing database. Instead, start with an empty set of preferences.
Definition Fl_Preferences.H:140
@ CORE_USER_L
Same as CORE | USER | C_LOCALE.
Definition Fl_Preferences.H:144
@ CORE
OR'd by FLTK to read and write core library preferences and options.
Definition Fl_Preferences.H:137
@ SYSTEM_L
Preferences are used system-wide, locale independent.
Definition Fl_Preferences.H:141
@ USER
Preferences apply only to the current user. Deprecated, see USER_L.
Definition Fl_Preferences.H:134
@ MEMORY
Returned if querying memory mapped preferences.
Definition Fl_Preferences.H:135
@ CORE_SYSTEM
Deprecated, same as CORE | SYSTEM. Use CORE_SYSTEM_L instead.
Definition Fl_Preferences.H:145
static const unsigned int ALL_WRITE_OK
Set this to allow FLTK and applications to create and write preference files.
Definition Fl_Preferences.H:188
ID id()
Return an ID that can later be reused to open more references to this dataset.
Definition Fl_Preferences.H:213
static const unsigned int NONE
Set this if no call to Fl_Preferences shall access the file system.
Definition Fl_Preferences.H:164
static const unsigned int CORE_READ_OK
Set this if it is OK for FLTK to read preference files.
Definition Fl_Preferences.H:180
static Root filename(char *buffer, size_t buffer_size, Root root, const char *vendor, const char *application)
Determine the file name and path to preferences that would be opened with these parameters.
Definition Fl_Preferences.cxx:263
static const unsigned int SYSTEM_OK
Set this if it is OK for applications to read, create, and write system wide preference files.
Definition Fl_Preferences.H:176
static const unsigned int USER_READ_OK
Set this if it is OK for applications to read user preference files.
Definition Fl_Preferences.H:166
const char * path()
Return the full path to this entry.
Definition Fl_Preferences.H:225
static const unsigned int APP_OK
Set this if it is OK for applications to read, create, and write any kind of preference files.
Definition Fl_Preferences.H:178
static const char * new_UUID()
Returns a UUID as generated by the system.
Definition Fl_Preferences.cxx:188
void * ID
Every Fl_Preferences-Group has a unique ID.
Definition Fl_Preferences.H:156
const char * name()
Return the name of this entry.
Definition Fl_Preferences.H:221
static char remove(ID id_)
Remove the group with this ID from a database.
Definition Fl_Preferences.H:217
static const unsigned int SYSTEM_READ_OK
Set this if it is OK for applications to read system wide preference files.
Definition Fl_Preferences.H:172
const char * group(int num_group)
Returns the name of the Nth (num_group) group.
Definition Fl_Preferences.cxx:630
static const unsigned int SYSTEM_WRITE_OK
Set this if it is OK for applications to create and write system wide preference files.
Definition Fl_Preferences.H:174
static const unsigned int ALL
Set this to give FLTK and applications permission to read, write, and create preference files.
Definition Fl_Preferences.H:190
static void file_access(unsigned int flags)
Tell the FLTK preferences system which files in the file system it may read, create,...
Definition Fl_Preferences.cxx:228
static const unsigned int ALL_READ_OK
Set this to allow FLTK and applications to read preference files.
Definition Fl_Preferences.H:186
static const unsigned int USER_WRITE_OK
Set this if it is OK for applications to create and write user preference files.
Definition Fl_Preferences.H:168
static const unsigned int CORE_OK
Set this if it is OK for FLTK to read, create, or write preference files.
Definition Fl_Preferences.H:184
static const unsigned int USER_OK
Set this if it is OK for applications to read, create, and write user preference files.
Definition Fl_Preferences.H:170
static const unsigned int CORE_WRITE_OK
Set this if it is OK for FLTK to create or write preference files.
Definition Fl_Preferences.H:182
Fl_Preferences(Root root, const char *vendor, const char *application)
The constructor creates a group that manages key/value pairs and child groups.
Definition Fl_Preferences.cxx:365
This file defines compiler-specific macros.
#define FL_DEPRECATED(msg, func)
Enclosing a function or method in FL_DEPRECATED marks it as no longer recommended.
Definition fl_attr.h:57
Definition Fl_Preferences.H:314