mirror of https://github.com/fltk/fltk
Fl_Preferences now have an API to delete all nodes or entries at once.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6995 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
2e87701192
commit
68219958d0
|
@ -57,7 +57,7 @@
|
|||
yet exist.
|
||||
|
||||
Entries can be of any length. However, the size of each
|
||||
preferences file should be kept under 100k for performance
|
||||
preferences file should be kept small for performance
|
||||
reasons. One application can have multiple preferences files.
|
||||
Extensive binary data however should be stored in separate
|
||||
files: see getUserdataPath().
|
||||
|
@ -116,11 +116,15 @@ public:
|
|||
const char *group( int num_group );
|
||||
char groupExists( const char *key );
|
||||
char deleteGroup( const char *group );
|
||||
char deleteAllGroups();
|
||||
|
||||
int entries();
|
||||
const char *entry( int index );
|
||||
char entryExists( const char *key );
|
||||
char deleteEntry( const char *entry );
|
||||
char deleteAllEntries();
|
||||
|
||||
char clear();
|
||||
|
||||
char set( const char *entry, int value );
|
||||
char set( const char *entry, float value );
|
||||
|
@ -223,6 +227,7 @@ private:
|
|||
RootNode *findRoot();
|
||||
char remove();
|
||||
char dirty();
|
||||
void deleteAllChildren();
|
||||
// entry methods
|
||||
int nChildren();
|
||||
const char *child( int ix );
|
||||
|
@ -232,6 +237,7 @@ private:
|
|||
const char *get( const char *name );
|
||||
int getEntry( const char *name );
|
||||
char deleteEntry( const char *name );
|
||||
void deleteAllEntries();
|
||||
// public values
|
||||
Entry *entry;
|
||||
int nEntry, NEntry;
|
||||
|
|
|
@ -401,6 +401,14 @@ char Fl_Preferences::deleteGroup( const char *group )
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
Delete all groups.
|
||||
*/
|
||||
char Fl_Preferences::deleteAllGroups()
|
||||
{
|
||||
node->deleteAllChildren();
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
Returns the number of entries (name/value pairs) in a group.
|
||||
|
@ -452,6 +460,24 @@ char Fl_Preferences::deleteEntry( const char *key )
|
|||
return node->deleteEntry( key );
|
||||
}
|
||||
|
||||
/**
|
||||
Delete all entries.
|
||||
*/
|
||||
char Fl_Preferences::deleteAllEntries()
|
||||
{
|
||||
node->deleteAllEntries();
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
Delete all groups and all entries.
|
||||
*/
|
||||
char Fl_Preferences::clear()
|
||||
{
|
||||
char ret1 = deleteAllGroups();
|
||||
char ret2 = deleteAllEntries();
|
||||
return ret1 & ret2;
|
||||
}
|
||||
|
||||
/**
|
||||
Reads an entry from the group. A default value must be
|
||||
|
@ -1248,8 +1274,7 @@ Fl_Preferences::Node::Node( const char *path )
|
|||
top_ = 0;
|
||||
}
|
||||
|
||||
// delete this and all depending nodes
|
||||
Fl_Preferences::Node::~Node()
|
||||
void Fl_Preferences::Node::deleteAllChildren()
|
||||
{
|
||||
Node *nx;
|
||||
for ( Node *nd = child_; nd; nd = nx )
|
||||
|
@ -1258,6 +1283,10 @@ Fl_Preferences::Node::~Node()
|
|||
delete nd;
|
||||
}
|
||||
child_ = 0L;
|
||||
}
|
||||
|
||||
void Fl_Preferences::Node::deleteAllEntries()
|
||||
{
|
||||
if ( entry )
|
||||
{
|
||||
for ( int i = 0; i < nEntry; i++ )
|
||||
|
@ -1275,6 +1304,13 @@ Fl_Preferences::Node::~Node()
|
|||
entry = 0L;
|
||||
nEntry = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// delete this and all depending nodes
|
||||
Fl_Preferences::Node::~Node()
|
||||
{
|
||||
deleteAllChildren();
|
||||
deleteAllEntries();
|
||||
if ( path_ ) {
|
||||
free( path_ );
|
||||
path_ = 0L;
|
||||
|
|
Loading…
Reference in New Issue