Simple config file class with added support for floats

Fork of ConfigFile by peter brier

Files at this revision

API Documentation at this revision

Comitter:
pbrier
Date:
Thu Jan 27 21:23:19 2011 +0000
Parent:
0:57f3e167586f
Child:
2:ba316099c799
Commit message:
version 1.0

Changed in this revision

ConfigFile.cpp Show annotated file Show diff for this revision Revisions of this file
ConfigFile.h Show annotated file Show diff for this revision Revisions of this file
--- a/ConfigFile.cpp	Thu Jan 27 21:08:51 2011 +0000
+++ b/ConfigFile.cpp	Thu Jan 27 21:23:19 2011 +0000
@@ -44,13 +44,7 @@
     fclose(fp);
 }
 
-/** Read value. If file is not open, or key does not exist: copy default value (return false)
-  * @param key name of the key in the file
-  * @param value pointer to buffer that receives the value
-  * @param maxlen the maximum length of the value. If the actual value is longer, it is truncated
-  * @param def Default value. If the key is not found in the file, this value is copied. 
-  * @return "true" if the key is found "false" is key is not found (default value is returned)
-  */ 
+
 bool ConfigFile::Value(char *key, char *value,  size_t maxlen, char *def)
 {
   int m=0,n=0,c,s=0;
@@ -135,7 +129,6 @@
   * @param def Default value. If the key is not found in the file, this value is copied. 
   * @return "true" if the key is found "false" is key is not found (default value is returned)
   */ 
-// Return int value
 bool ConfigFile::Value(char *key, int *value, int def)
 {
   char val[16];
--- a/ConfigFile.h	Thu Jan 27 21:08:51 2011 +0000
+++ b/ConfigFile.h	Thu Jan 27 21:23:19 2011 +0000
@@ -31,20 +31,53 @@
  *
  * note: NULL key does nothing
  */
- 
+
 #include "mbed.h"
 
 #ifndef _CONFIG_FILE_H_
 #define _CONFIG_FILE_H_
 
+    /** Simple config file object
+      * Note: the file handle is kept open during the lifetime of this object.
+      * To close the file: destroy this ConfigFile object! A simple way is to enclose the creation
+      * of this object inside a code block
+      * Example:
+      * @code 
+      *  bla
+      * @endcode
+      */
 class ConfigFile {
-  public:
+public:
+    /// Make new config file object
+    /** Open config file.
+      * Note: the file handle is kept open during the lifetime of this object.
+      * To close the file: destroy this ConfigFile object!
+      * @param file Filename of the configuration file.
+      */
     ConfigFile(char *name);
+
     ~ConfigFile();
+
+/** Read value. If file is not open, or key does not exist: copy default value (return false)
+  * @param key name of the key in the file
+  * @param value pointer to buffer that receives the value
+  * @param maxlen the maximum length of the value. If the actual value is longer, it is truncated
+  * @param def Default value. If the key is not found in the file, this value is copied. 
+  * @return "true" if the key is found "false" is key is not found (default value is returned)
+  */ 
     bool Value(char *key, char *value,  size_t maxlen, char *def);
+
+/** Read Integer value. If file is not open, or key does not exist: copy default value (return false)
+  * @param key name of the key in the file
+  * @param value pointer to integer that receives the value
+  * @param def Default value. If the key is not found in the file, this value is copied. 
+  * @return "true" if the key is found "false" is key is not found (default value is returned)
+  */ 
     bool Value(char *key, int *value, int def);
-  private:    
+    
+private:
     FILE *fp;
+
 };
 
 #endif