Author: ianmacarthur
Date: 2010-03-25 09:29:13 -0700 (Thu, 25 Mar 2010)
New Revision: 7338
Log:
Remove a spurious #warning I'd left in the win32 builds...
Modified:
branches/branch-1.3/src/Fl_Preferences.cxx
Modified: branches/branch-1.3/src/Fl_Preferences.cxx
===================================================================
--- branches/branch-1.3/src/Fl_Preferences.cxx 2010-03-25 16:05:00 UTC (rev
7337)
+++ branches/branch-1.3/src/Fl_Preferences.cxx 2010-03-25 16:29:13 UTC (rev
7338)
@@ -77,7 +77,7 @@
/**
* Returns a UUID as generated by the system.
*
- * A UUID is a "universally unique identifier" which is commonly used in
+ * A UUID is a "universally unique identifier" which is commonly used in
* configuration files to create identities. A UUID in ASCII looks like this:
* <tt>937C4900-51AA-4C11-8DD3-7AB59944F03E</tt>. It has always 36 bytes plus
* a trailing zero.
@@ -85,7 +85,7 @@
* \return a pointer to a static buffer containing the new UUID in ASCII
format.
* The buffer is overwritten during every call to this function!
*/
-const char *Fl_Preferences::newUUID()
+const char *Fl_Preferences::newUUID()
{
#ifdef __APPLE__
CFUUIDRef theUUID = CFUUIDCreate(NULL);
@@ -95,9 +95,6 @@
b.byte8, b.byte9, b.byte10, b.byte11, b.byte12, b.byte13, b.byte14,
b.byte15);
CFRelease(theUUID);
#elif defined (WIN32)
-#if defined (__GNUC__)
-# warning MSWindows implementation incomplete!
-#endif // (__GNUC__)
// First try and use the win API function UuidCreate(), but if that is not
// available, fall back to making something up from scratch.
// We do not want to link against the Rpcrt4.dll, as we will rarely use it,
@@ -182,7 +179,7 @@
gethostname(name, 79);
memcpy(b+12, name, 4);
sprintf(uuidBuffer,
"%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",
- b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7],
+ b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7],
b[8], b[9], b[10], b[11], b[12], b[13], b[14], b[15]);
#endif
@@ -195,7 +192,7 @@
child groups. Groups are ready for reading and writing at any time.
The root argument is either Fl_Preferences::USER
or Fl_Preferences::SYSTEM.
-
+
This constructor creates the <i>base</i> instance for all
following entries and reads existing databases into memory. The
vendor argument is a unique text string identifying the
@@ -206,11 +203,11 @@
name of your application. Both vendor and
application must be valid relative UNIX pathnames and
may contain '/'s to create deeper file structures.
-
+
A set of Preferences marked "run-time" exists exactly one per application
and
- only as long as the application runs. It can be used as a database for
+ only as long as the application runs. It can be used as a database for
volatile information. FLTK uses it to register plugins at run-time.
-
+
\param[in] root can be \c USER or \c SYSTEM for user specific or system wide
preferences
\param[in] vendor unique text describing the company or author of this file
@@ -226,12 +223,12 @@
/**
\brief Use this constructor to create or read a preferences file at an
- arbitrary position in the file system.
+ arbitrary position in the file system.
The file name is generated in the form
<tt><i>path</i>/<i>application</i>.prefs</tt>. If \p application
is \c NULL, \p path must contain the full file name.
-
+
\param[in] path path to the directory that contains the preferences file
\param[in] vendor unique text describing the company or author of this file
\param[in] application unique text describing the application
@@ -245,11 +242,11 @@
/**
- \brief Generate or read a new group of entries within another group.
+ \brief Generate or read a new group of entries within another group.
Use the \p group argument to name the group that you would like to access.
\p Group can also contain a path to a group further down the hierarchy by
- separating group names with a forward slash '/'.
+ separating group names with a forward slash '/'.
\param[in] parent reference object for the new group
\param[in] group name of the group to access (may contain '/'s)
@@ -263,7 +260,7 @@
/**
\brief Create or access a group of preferences using a name.
- \param[in] parent the parameter parent is a pointer to the parent group.
+ \param[in] parent the parameter parent is a pointer to the parent group.
\p Parent may be \p NULL. It then refers to an application
internal
database which exists only once, and remains in RAM only until
the
application quits. This databse is used to manage plugins and
other
@@ -288,15 +285,15 @@
/**
- \brief Open a child group using a given index.
-
+ \brief Open a child group using a given index.
+
Use the \p groupIndex argument to find the group that you would like to
access.
If the given index is invalid (negative or too high), a new group is created
with a UUID as a name.
-
+
The index needs to be fixed. It is currently backward. Index 0 points
to the last member in the 'list' of preferences.
-
+
\param[in] parent reference object for the new group
\param[in] groupIndex zero based index into child groups
*/
@@ -327,13 +324,13 @@
/**
Create a new dataset access point using a dataset ID.
-
+
ID's are a great way to remember shortcuts to database entries that are deeply
nested in a preferences database, as long as the databse root is not deleted.
An ID can be retrieved from any Fl_Preferences dataset, and can then be used
to create multiple new references to the same dataset.
-
- ID's can be put very helpful when put into the <tt>user_data()</tt> field of
+
+ ID's can be put very helpful when put into the <tt>user_data()</tt> field of
widget callbacks.
*/
Fl_Preferences::Fl_Preferences( Fl_Preferences::ID id )
@@ -345,18 +342,18 @@
/**
Create another reference to a Preferences group.
*/
-Fl_Preferences::Fl_Preferences(const Fl_Preferences &rhs)
-: node(rhs.node),
- rootNode(rhs.rootNode)
+Fl_Preferences::Fl_Preferences(const Fl_Preferences &rhs)
+: node(rhs.node),
+ rootNode(rhs.rootNode)
{ }
/**
Assign another reference to a Preference group.
*/
Fl_Preferences &Fl_Preferences::operator=(const Fl_Preferences &rhs) {
- if (&rhs != this) {
- node = rhs.node;
- rootNode = rhs.rootNode;
+ if (&rhs != this) {
+ node = rhs.node;
+ rootNode = rhs.rootNode;
}
return *this;
}
@@ -395,7 +392,7 @@
/**
Returns the number of groups that are contained within a group.
-
+
\return 0 for no groups at all
*/
int Fl_Preferences::groups()
@@ -408,7 +405,7 @@
Returns the name of the Nth (\p num_group) group.
There is no guaranteed order of group names. The index must
be within the range given by groups().
-
+
\param[in] num_group number indexing the requested group
\return 'C' string pointer to the group name
*/
@@ -423,7 +420,7 @@
Group names are relative to the Preferences node and can contain a path.
"." describes the current node, "./" describes the topmost node.
By preceding a groupname with a "./", its path becomes relative to the
topmost node.
-
+
\param[in] key name of group that is searched for
\return 0 if no group by that name was found
*/
@@ -438,7 +435,7 @@
Removes a group and all keys and groups within that group
from the database.
-
+
\param[in] group name of the group to delete
\return 0 if call failed
*/
@@ -460,7 +457,7 @@
/**
Returns the number of entries (name/value pairs) in a group.
-
+
\return number of entries
*/
int Fl_Preferences::entries()
@@ -473,7 +470,7 @@
Returns the name of an entry. There is no guaranteed order of
entry names. The index must be within the range given by
entries().
-
+
\param[in] index number indexing the requested entry
\return pointer to value cstring
*/
@@ -485,7 +482,7 @@
/**
Returns non-zero if an entry with this name exists.
-
+
\param[in] key name of entry that is searched for
\return 0 if entry was not found
*/
@@ -497,9 +494,9 @@
/**
Deletes a single name/value pair.
-
+
This function removes the entry \p key from the database.
-
+
\param[in] key name of entry to delete
\return 0 if deleting the entry failed
*/
@@ -520,7 +517,7 @@
/**
Delete all groups and all entries.
*/
-char Fl_Preferences::clear()
+char Fl_Preferences::clear()
{
char ret1 = deleteAllGroups();
char ret2 = deleteAllEntries();
@@ -531,11 +528,11 @@
Reads an entry from the group. A default value must be
supplied. The return value indicates if the value was available
(non-zero) or the default was used (0).
-
+
\param[in] key name of entry
\param[out] value returned from preferences or default value if none was set
\param[in] defaultValue default value to be used if no preference was set
- \return 0 if the default value was used
+ \return 0 if the default value was used
*/
char Fl_Preferences::get( const char *key, int &value, int defaultValue )
{
@@ -545,12 +542,12 @@
}
-/**
+/**
Sets an entry (name/value pair). The return value indicates if there
was a problem storing the data in memory. However it does not
reflect if the value was actually stored in the preferences
file.
-
+
\param[in] key name of entry
\param[in] value set this entry to \p value
\return 0 if setting the value failed
@@ -566,12 +563,12 @@
/**
Reads an entry from the group. A default value must be
supplied. The return value indicates if the value was available
- (non-zero) or the default was used (0).
-
+ (non-zero) or the default was used (0).
+
\param[in] key name of entry
\param[out] value returned from preferences or default value if none was set
\param[in] defaultValue default value to be used if no preference was set
- \return 0 if the default value was used
+ \return 0 if the default value was used
*/
char Fl_Preferences::get( const char *key, float &value, float defaultValue )
{
@@ -581,12 +578,12 @@
}
-/**
+/**
Sets an entry (name/value pair). The return value indicates if there
was a problem storing the data in memory. However it does not
reflect if the value was actually stored in the preferences
file.
-
+
\param[in] key name of entry
\param[in] value set this entry to \p value
\return 0 if setting the value failed
@@ -599,12 +596,12 @@
}
-/**
+/**
Sets an entry (name/value pair). The return value indicates if there
was a problem storing the data in memory. However it does not
reflect if the value was actually stored in the preferences
file.
-
+
\param[in] key name of entry
\param[in] value set this entry to \p value
\param[in] precision number of decimal digits to represent value
@@ -621,12 +618,12 @@
/**
Reads an entry from the group. A default value must be
supplied. The return value indicates if the value was available
- (non-zero) or the default was used (0).
-
+ (non-zero) or the default was used (0).
+
\param[in] key name of entry
\param[out] value returned from preferences or default value if none was set
\param[in] defaultValue default value to be used if no preference was set
- \return 0 if the default value was used
+ \return 0 if the default value was used
*/
char Fl_Preferences::get( const char *key, double &value, double defaultValue )
{
@@ -636,12 +633,12 @@
}
-/**
+/**
Sets an entry (name/value pair). The return value indicates if there
was a problem storing the data in memory. However it does not
reflect if the value was actually stored in the preferences
file.
-
+
\param[in] key name of entry
\param[in] value set this entry to \p value
\return 0 if setting the value failed
@@ -654,12 +651,12 @@
}
-/**
+/**
Sets an entry (name/value pair). The return value indicates if there
was a problem storing the data in memory. However it does not
reflect if the value was actually stored in the preferences
file.
-
+
\param[in] key name of entry
\param[in] value set this entry to \p value
\param[in] precision number of decimal digits to represent value
@@ -706,15 +703,15 @@
/**
Reads an entry from the group. A default value must be
supplied. The return value indicates if the value was available
- (non-zero) or the default was used (0).
- 'maxSize' is the maximum length of text that will be read.
+ (non-zero) or the default was used (0).
+ 'maxSize' is the maximum length of text that will be read.
The text buffer must allow for one additional byte for a trailling zero.
-
+
\param[in] key name of entry
\param[out] text returned from preferences or default value if none was set
\param[in] defaultValue default value to be used if no preference was set
\param[in] maxSize maximum length of value plus one byte for a trailing zero
- \return 0 if the default value was used
+ \return 0 if the default value was used
*/
char Fl_Preferences::get( const char *key, char *text, const char
*defaultValue, int maxSize )
{
@@ -736,13 +733,13 @@
Reads an entry from the group. A default value must be
supplied. The return value indicates if the value was available
(non-zero) or the default was used (0). get() allocates memory of
- sufficient size to hold the value. The buffer must be free'd by
- the developer using 'free(value)'.
-
+ sufficient size to hold the value. The buffer must be free'd by
+ the developer using 'free(value)'.
+
\param[in] key name of entry
\param[out] text returned from preferences or default value if none was set
\param[in] defaultValue default value to be used if no preference was set
- \return 0 if the default value was used
+ \return 0 if the default value was used
*/
char Fl_Preferences::get( const char *key, char *&text, const char
*defaultValue )
{
@@ -751,7 +748,7 @@
{
text = decodeText( v );
return 1;
- }
+ }
if ( !v ) v = defaultValue;
if ( v )
text = strdup( v );
@@ -762,12 +759,12 @@
-/**
+/**
Sets an entry (name/value pair). The return value indicates if there
was a problem storing the data in memory. However it does not
reflect if the value was actually stored in the preferences
file.
-
+
\param[in] key name of entry
\param[in] text set this entry to \p value
\return 0 if setting the value failed
@@ -780,13 +777,13 @@
if ( ns )
{
char *buffer = (char*)malloc( n+ns+1 ), *d = buffer;
- for ( s=text; *s; )
- {
+ for ( s=text; *s; )
+ {
char c = *s;
if ( c=='\\' ) { *d++ = '\\'; *d++ = '\\'; s++; }
else if ( c=='\n' ) { *d++ = '\\'; *d++ = 'n'; s++; }
else if ( c=='\r' ) { *d++ = '\\'; *d++ = 'r'; s++; }
- else if ( c<32 || c==0x7f )
+ else if ( c<32 || c==0x7f )
{ *d++ = '\\'; *d++ = '0'+((c>>6)&3); *d++ = '0'+((c>>3)&7); *d++ =
'0'+(c&7); s++; }
else *d++ = *s++;
}
@@ -826,16 +823,16 @@
/**
Reads an entry from the group. A default value must be
supplied. The return value indicates if the value was available
- (non-zero) or the default was used (0).
- 'maxSize' is the maximum length of text that will be read.
-
+ (non-zero) or the default was used (0).
+ 'maxSize' is the maximum length of text that will be read.
+
\param[in] key name of entry
\param[out] data value returned from preferences or default value if none was
set
\param[in] defaultValue default value to be used if no preference was set
\param[in] defaultSize size of default value array
\param[in] maxSize maximum length of value
- \return 0 if the default value was used
-
+ \return 0 if the default value was used
+
\todo maxSize should receive the number of bytes that were read.
*/
char Fl_Preferences::get( const char *key, void *data, const void
*defaultValue, int defaultSize, int maxSize )
@@ -848,7 +845,7 @@
memmove( data, w, dsize>maxSize?maxSize:dsize );
free( w );
return 1;
- }
+ }
if ( defaultValue )
memmove( data, defaultValue, defaultSize>maxSize?maxSize:defaultSize );
return 0;
@@ -859,14 +856,14 @@
Reads an entry from the group. A default value must be
supplied. The return value indicates if the value was available
(non-zero) or the default was used (0). get() allocates memory of
- sufficient size to hold the value. The buffer must be free'd by
- the developer using 'free(value)'.
-
+ sufficient size to hold the value. The buffer must be free'd by
+ the developer using 'free(value)'.
+
\param[in] key name of entry
\param[out] data returned from preferences or default value if none was set
\param[in] defaultValue default value to be used if no preference was set
\param[in] defaultSize size of default value array
- \return 0 if the default value was used
+ \return 0 if the default value was used
*/
char Fl_Preferences::get( const char *key, void *&data, const void
*defaultValue, int defaultSize )
{
@@ -876,7 +873,7 @@
int dsize;
data = decodeHex( v, dsize );
return 1;
- }
+ }
if ( defaultValue )
{
data = (void*)malloc( defaultSize );
@@ -888,12 +885,12 @@
}
-/**
+/**
Sets an entry (name/value pair). The return value indicates if there
was a problem storing the data in memory. However it does not
reflect if the value was actually stored in the preferences
file.
-
+
\param[in] key name of entry
\param[in] data set this entry to \p value
\param[in] dsize size of data array
@@ -919,7 +916,7 @@
/**
Returns the size of the value part of an entry.
-
+
\param[in] key name of entry
\return size of value
*/
@@ -933,11 +930,11 @@
/**
\brief Creates a path that is related to the preferences file and
that is usable for additional application data.
-
+
This function creates a directory that is named after the preferences
database without the \c .prefs extension and located in the same directory.
It then fills the given buffer with the complete path name.
-
+
Exmaple:
\code
Fl_Preferences prefs( USER, "matthiasm.com", "test" );
@@ -952,7 +949,7 @@
\code
c:/Documents and Settings/matt/Application Data/matthiasm.com/test/
\endcode
-
+
\param[out] path buffer for user data path
\param[in] pathlen size of path buffer (should be at least \c FL_PATH_MAX)
\return 0 if path was not created or pathname can't fit into buffer
@@ -981,9 +978,9 @@
/**
Creates a group name or entry name on the fly.
-
+
This version creates a simple unsigned integer as an entry name.
-
+
\code
int n, i;
Fl_Preferences prev( appPrefs, "PreviousFiles" );
@@ -1000,9 +997,9 @@
/**
Creates a group name or entry name on the fly.
-
+
This version creates entry names as in 'printf'.
-
+
\code
int n, i;
Fl_Preferences prefs( USER, "matthiasm.com", "test" );
@@ -1243,7 +1240,7 @@
{
if ( prefs_->node->dirty() )
write();
- if ( filename_ ) {
+ if ( filename_ ) {
free( filename_ );
filename_ = 0L;
}
@@ -1264,12 +1261,12 @@
{
if (!filename_) // RUNTIME preferences
return -1;
-
+
char buf[1024];
FILE *f = fl_fopen( filename_, "rb" );
- if ( !f )
+ if ( !f )
return -1;
-
+
fgets( buf, 1024, f );
fgets( buf, 1024, f );
fgets( buf, 1024, f );
@@ -1283,7 +1280,7 @@
buf[ end+1 ] = 0;
nd = prefs_->node->find( buf+1 );
}
- else if ( buf[0]=='+' ) //
+ else if ( buf[0]=='+' ) //
{ // value of previous name/value pair spans multiple lines
int end = strcspn( buf+1, "\n\r" );
if ( end != 0 ) // if entry is not empty
@@ -1311,12 +1308,12 @@
{
if (!filename_) // RUNTIME preferences
return -1;
-
+
fl_make_path_for_file(filename_);
FILE *f = fl_fopen( filename_, "wb" );
- if ( !f )
+ if ( !f )
return -1;
-
+
fprintf( f, "; FLTK preferences file format 1.0\n" );
fprintf( f, "; vendor: %s\n", vendor_ );
fprintf( f, "; application: %s\n", application_ );
@@ -1330,7 +1327,7 @@
{
if (!filename_) // RUNTIME preferences
return -1;
-
+
strlcpy( path, filename_, pathlen);
char *s;
@@ -1358,7 +1355,7 @@
nIndex_ = NIndex_ = 0;
}
-void Fl_Preferences::Node::deleteAllChildren()
+void Fl_Preferences::Node::deleteAllChildren()
{
Node *nx;
for ( Node *nd = child_; nd; nd = nx )
@@ -1371,7 +1368,7 @@
updateIndex();
}
-void Fl_Preferences::Node::deleteAllEntries()
+void Fl_Preferences::Node::deleteAllEntries()
{
if ( entry_ )
{
@@ -1473,7 +1470,7 @@
if (n->top_)
return n->root_;
n = n->parent();
-
+
} while (n);
return 0L;
}
@@ -1599,7 +1596,7 @@
int len = strlen( path_ );
if ( strncmp( path, path_, len ) == 0 )
{
- if ( path[ len ] == 0 )
+ if ( path[ len ] == 0 )
return this;
if ( path[ len ] == '/' )
{
@@ -1651,7 +1648,7 @@
}
offset = strlen( path_ ) + 1;
}
-
+
int len = strlen( path_ );
if ( len < offset-1 ) return 0;
len -= offset;
@@ -1739,9 +1736,9 @@
{
if ( nd == this )
{
- if ( np )
- np->next_ = nd->next_;
- else
+ if ( np )
+ np->next_ = nd->next_;
+ else
parent()->child_ = nd->next_;
break;
}
@@ -1780,7 +1777,7 @@
indexed_ = 0;
}
-char Fl_Preferences::Node::copyTo(Fl_Tree *tree, Fl_Tree_Item *ti)
+char Fl_Preferences::Node::copyTo(Fl_Tree *tree, Fl_Tree_Item *ti)
{
ti->label(name());
ti->user_data(this);
@@ -1887,7 +1884,7 @@
/**
* \brief Return the address of a plugin by index.
*/
-Fl_Plugin *Fl_Plugin_Manager::plugin(int index)
+Fl_Plugin *Fl_Plugin_Manager::plugin(int index)
{
char buf[34];
Fl_Plugin *ret = 0;
@@ -1903,7 +1900,7 @@
/**
* \brief Return the address of a plugin by name.
*/
-Fl_Plugin *Fl_Plugin_Manager::plugin(const char *name)
+Fl_Plugin *Fl_Plugin_Manager::plugin(const char *name)
{
char buf[34];
Fl_Plugin *ret = 0;
@@ -1957,7 +1954,7 @@
*
* A module must be a dynamically linkable file for the given operating system.
* When loading a module, its +init function will be called which in turn calls
- * the constructor of all statically initialized Fl_Plugin classes and adds
+ * the constructor of all statically initialized Fl_Plugin classes and adds
* them to the database.
*/
int Fl_Plugin_Manager::load(const char *filename)
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit