Simple config file class with added support for floats

Fork of ConfigFile by peter brier

Revision:
2:ba316099c799
Parent:
1:a802df951169
Child:
3:31c936f3b9df
--- a/ConfigFile.cpp	Thu Jan 27 21:23:19 2011 +0000
+++ b/ConfigFile.cpp	Thu Jan 27 21:36:01 2011 +0000
@@ -1,4 +1,4 @@
-/*
+/**
  * ConfigFile.cpp
  * Simple Config file reader class
  *
@@ -22,21 +22,14 @@
  */
 #include "ConfigFile.h"
 
-/// 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.
-  */ 
+// Make new config file object
 ConfigFile::ConfigFile(char *file) 
 {
  // printf("ConfigFile(%s)\n\r", file);
   fp = fopen(file,"rb");
 }
 
- /**
-   * Destroy a config file (closes the file handle)
-   */
+// Destroy a config file (closes the file handle)
 ConfigFile::~ConfigFile() 
 {
  // printf("~ConfigFile()\n\r");
@@ -44,7 +37,7 @@
     fclose(fp);
 }
 
-
+// Read value
 bool ConfigFile::Value(char *key, char *value,  size_t maxlen, char *def)
 {
   int m=0,n=0,c,s=0;
@@ -122,17 +115,11 @@
   } 
 }
 
-
-/** 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)
-  */ 
+// Read int value
 bool ConfigFile::Value(char *key, int *value, int def)
 {
   char val[16];
-  bool b = Value(key, val, 15, "");
+  bool b = Value(key, val, 12, "");
   if ( b )
     *value = atoi(val);
   else