insert code for reading double numbers from ini-file

Fork of IniFileLib by rinosh 2

Revision:
3:1f40bfa093d0
Parent:
1:3601c7feb547
--- a/IniFile.h	Thu Nov 18 17:39:02 2010 +0000
+++ b/IniFile.h	Wed Jan 07 21:52:20 2015 +0000
@@ -1,5 +1,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 // IniFile: .ini file parser   by rinos 2010
+// 07.01.2015: DS: inserted code for double format
 ///////////////////////////////////////////////////////////////////////////////
 
 // Ini file value (int/bool/string)
@@ -17,76 +18,83 @@
 
 #include "mbed.h"
 
-class IniFile{
-	// defines /////////////////////////////////////////////////////////////////
+class IniFile
+{
+    // defines /////////////////////////////////////////////////////////////////
 public:
-	// data type
-	typedef enum {
-		DTYPE_INT	= -1,
-		DTYPE_BOOL	= -2,
-		// other string
-	} DataType;
+    // data type
+    typedef enum {
+        DTYPE_INT	= -1,
+        DTYPE_BOOL	= -2,
+        DTYPE_DOUBLE = -3,
+        // other string
+    } DataType;
 
-	// For the multiple read
-	struct IniList{
-		const char* key;	// key name  (set NULL for list end)
-		int   typelen;		// >0: buffer length, <0: DataType
-		void* buf;			// return buffer
-	};
+    // For the multiple read
+    struct IniList {
+        const char* key;	// key name  (set NULL for list end)
+        int   typelen;		// >0: buffer length, <0: DataType
+        void* buf;			// return buffer
+    };
 
-	// error code
-	typedef enum {
-		S_SUCCESS,
-		S_OPEN_ERROR,
-		S_NOT_OPENED,
-		S_NO_KEY,
-		S_BUFFER_TOO_SHORT,
-		S_FORMAT_ERROR,
-	} Status;
-	
-	// internal member/method //////////////////////////////////////////////////
+    // error code
+    typedef enum {
+        S_SUCCESS,
+        S_OPEN_ERROR,
+        S_NOT_OPENED,
+        S_NO_KEY,
+        S_BUFFER_TOO_SHORT,
+        S_FORMAT_ERROR,
+    } Status;
+
+    // internal member/method //////////////////////////////////////////////////
 private:
-	FILE* m_fp;
+    FILE* m_fp;
 
-	// Invalid method
+    // Invalid method
 protected:
-	IniFile(const IniFile& v);
-	const IniFile& operator =(const IniFile& v);
+    IniFile(const IniFile& v);
+    const IniFile& operator =(const IniFile& v);
 
 public:
-	IniFile(const char* file = 0);
-	~IniFile();
+    IniFile(const char* file = 0);
+    ~IniFile();
+
+    // Access methods
+    Status open(const char* file);
+    Status close();
+
+    Status get(const char* key, char* ret, int ret_size);
+    Status get(const char* key, int&  ret);
+    Status get(const char* key, double&  ret);
+    Status get(const char* key, bool& ret);
+    Status get(const IniList* inilist);
 
-	// Access methods
-	Status open(const char* file);
-	Status close();
-	
-	Status get(const char* key, char* ret, int ret_size);
-	Status get(const char* key, int&  ret);
-	Status get(const char* key, bool& ret);
-	Status get(const IniList* inilist);
-	
-	// For easy acccess
-	static Status getval(const char* inifile, const char* key, char* ret, int ret_size){
-		return IniFile(inifile).get(key, ret, ret_size);
-	}
-	static Status getval(const char* inifile, const char* key, int& ret){
-		return IniFile(inifile).get(key, ret);
-	}
-	static Status getval(const char* inifile, const char* key, bool& ret){
-		return IniFile(inifile).get(key, ret);
-	}
-	static Status getval(const char* inifile, const IniList* inilist){
-		return IniFile(inifile).get(inilist);
-	}
+    // For easy acccess
+    static Status getval(const char* inifile, const char* key, char* ret, int ret_size) {
+        return IniFile(inifile).get(key, ret, ret_size);
+    }
+    static Status getval(const char* inifile, const char* key, int& ret) {
+        return IniFile(inifile).get(key, ret);
+    }
+    static Status getval(const char* inifile, const char* key, bool& ret) {
+        return IniFile(inifile).get(key, ret);
+    }
+    static Status getval(const char* inifile, const char* key, double& ret) {
+        return IniFile(inifile).get(key, ret);
+    }
+    static Status getval(const char* inifile, const IniList* inilist) {
+        return IniFile(inifile).get(inilist);
+    }
 
-	// for string triming
-	static Status strtrim(char* dst, const char* src, int dst_size); // move to public
+    // for string triming
+    static Status strtrim(char* dst, const char* src, int dst_size); // move to public
 };
 
 // for the table
 #define INIFILE_INT(key,  val)		{key,	IniFile::DTYPE_INT,		&val}
 #define INIFILE_BOOL(key, val)		{key,	IniFile::DTYPE_BOOL,	&val}
+#define INIFILE_DOUBLE(key, val)	{key,	IniFile::DTYPE_DOUBLE,	&val}
 #define INIFILE_STR(key, buf, size)	{key,	size,					buf}
 #define INIFILE_END					0