Simple config file class with added support for floats
Fork of ConfigFile by
Diff: ConfigFile.cpp
- Revision:
- 6:78404e968c3e
- Parent:
- 3:31c936f3b9df
- Child:
- 7:0a8c1d05611b
diff -r 8c8cf4615b32 -r 78404e968c3e ConfigFile.cpp --- a/ConfigFile.cpp Thu Jan 27 21:46:18 2011 +0000 +++ b/ConfigFile.cpp Mon Dec 29 10:01:31 2014 +0000 @@ -128,3 +128,17 @@ } return b; } + +// Read float value +bool ConfigFile::Value(char *key, float *value, float def) +{ + char val[16]; + bool b = Value(key, val, 12, ""); + if ( b ) + *value = atof(val); + else + { + *value = def; + } + return b; +}