A simple .ini file interface.
Dependents: Smart-WiFly-WebServer SignalGenerator WattEye X10Svr
Revision 12:6cf929bde139, committed 2016-04-11
- Comitter:
- WiredHome
- Date:
- Mon Apr 11 02:16:18 2016 +0000
- Parent:
- 11:738604f18088
- Child:
- 13:d5957065d066
- Child:
- 16:82e0f8747b95
- Commit message:
- Added a ReadLongInt method for convenience.
Changed in this revision
IniManager.cpp | Show annotated file Show diff for this revision Revisions of this file |
IniManager.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/IniManager.cpp Tue Jan 26 11:51:08 2016 +0000 +++ b/IniManager.cpp Mon Apr 11 02:16:18 2016 +0000 @@ -133,6 +133,17 @@ return found; } +long int INI::ReadLongInt(const char * section, const char * key, long int defaultValue) +{ + char localBuf[16]; + + if (ReadString(section, key, localBuf, sizeof(localBuf))) { + return atol(localBuf); + } else { + return defaultValue; + } +} + bool INI::CleanUp() { char * newFile = (char *)swMalloc(strlen(iniFile)+1); @@ -419,3 +430,5 @@ return 0; } #endif + +
--- a/IniManager.h Tue Jan 26 11:51:08 2016 +0000 +++ b/IniManager.h Mon Apr 11 02:16:18 2016 +0000 @@ -83,6 +83,19 @@ */ bool ReadString(const char * section, const char * key, char * buffer, size_t bufferSize, const char * defaultString = NULL); + /** Read a long integer from the ini file - if it exists. + * + * This searches the ini file for the named section and key and if found it will + * return the long integer value from that entry. + * + * @param[in] section is the name of the section to search. + * @param[in] key is the name of the key to search. + * @param[in] defaultValue is the default value to return if the entry is not found. + * + * @return the value read, or the defaultVaule. + */ + long int ReadLongInt(const char * section, const char * key, long int defaultValue); + /** Writes a string into the ini file * * This writes a given string into an ini file in the named section and key.