summaryrefslogtreecommitdiffstats
path: root/iniFile
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--iniFile/iniFile.cpp60
-rw-r--r--iniFile/iniFile.h30
2 files changed, 50 insertions, 40 deletions
diff --git a/iniFile/iniFile.cpp b/iniFile/iniFile.cpp
index 23a1cfa92..adad8f515 100644
--- a/iniFile/iniFile.cpp
+++ b/iniFile/iniFile.cpp
@@ -388,33 +388,45 @@ double cIniFile::GetValueF(const string & keyname, const string & valuename, dou
-// 16 variables may be a bit of over kill, but hey, it's only code.
-unsigned cIniFile::GetValueV( const string & keyname, const string & valuename, char *format,
- void *v1, void *v2, void *v3, void *v4,
- void *v5, void *v6, void *v7, void *v8,
- void *v9, void *v10, void *v11, void *v12,
- void *v13, void *v14, void *v15, void *v16)
+AString cIniFile::GetValueSet(const AString & keyname, const AString & valuename, const AString & defValue)
{
- string value;
- // va_list args;
- unsigned nVals;
+ long keyID = FindKey( keyname);
+ if ( keyID == noID)
+ {
+ SetValue(keyname, valuename, defValue);
+ return defValue;
+ }
+ long valueID = FindValue( unsigned(keyID), valuename);
+ if ( valueID == noID)
+ {
+ SetValue(keyname, valuename, defValue);
+ return defValue;
+ }
- value = GetValue( keyname, valuename);
- if ( !value.length())
- return false;
- // Why is there not vsscanf() function. Linux man pages say that there is
- // but no compiler I've seen has it defined. Bummer!
- //
- // va_start( args, format);
- // nVals = vsscanf( value.c_str(), format, args);
- // va_end( args);
-
- nVals = sscanf_s( value.c_str(), format,
- v1, v2, v3, v4, v5, v6, v7, v8,
- v9, v10, v11, v12, v13, v14, v15, v16);
-
- return nVals;
+ return keys[keyID].values[valueID];
+}
+
+
+
+
+
+double cIniFile::GetValueSetF(const AString & keyname, const AString & valuename, const double defValue)
+{
+ AString Data;
+ Printf(Data, "%f", defValue);
+ return atof(GetValueSet(keyname, valuename, Data).c_str());
+}
+
+
+
+
+
+int cIniFile::GetValueSetI(const AString & keyname, const AString & valuename, const int defValue)
+{
+ AString Data;
+ Printf(Data, "%d", defValue);
+ return atoi(GetValueSet(keyname, valuename, Data).c_str());
}
diff --git a/iniFile/iniFile.h b/iniFile/iniFile.h
index b3e5c7f5c..13fa15e59 100644
--- a/iniFile/iniFile.h
+++ b/iniFile/iniFile.h
@@ -108,23 +108,21 @@ public:
// Gets value of [keyname] valuename =.
// Overloaded to return string, int, and double.
// Returns defValue if key/value not found.
- std::string GetValue( const std::string & keyname, const std::string & valuename, const std::string & defValue = "") const; //tolua_export
- std::string GetValue( const unsigned keyID, const unsigned valueID, const std::string & defValue = "") const; //tolua_export
- int GetValueI( const std::string & keyname, const std::string & valuename, const int defValue = 0) const; //tolua_export
- bool GetValueB( const std::string & keyname, const std::string & valuename, const bool defValue = false) const { //tolua_export
+ AString GetValue (const AString & keyname, const AString & valuename, const AString & defValue = "") const; // tolua_export
+ AString GetValue (const unsigned keyID, const unsigned valueID, const AString & defValue = "") const; // tolua_export
+ double GetValueF(const AString & keyname, const AString & valuename, const double defValue = 0) const; // tolua_export
+ int GetValueI(const AString & keyname, const AString & valuename, const int defValue = 0) const; // tolua_export
+ bool GetValueB(const AString & keyname, const AString & valuename, const bool defValue = false) const { // tolua_export
return ( GetValueI( keyname, valuename, int( defValue)) > 0);
- } //tolua_export
- double GetValueF( const std::string & keyname, const std::string & valuename, const double defValue = 0.0) const; //tolua_export
-
- // This is a variable length formatted GetValue routine. All these voids
- // are required because there is no vsscanf() like there is a vsprintf().
- // Only a maximum of 8 variable can be read.
- // NOTE: do not use this function, instead get the string value and parse it yourself
- OBSOLETE unsigned GetValueV( const std::string & keyname, const std::string & valuename, char *format,
- void *v1 = 0, void *v2 = 0, void *v3 = 0, void *v4 = 0,
- void *v5 = 0, void *v6 = 0, void *v7 = 0, void *v8 = 0,
- void *v9 = 0, void *v10 = 0, void *v11 = 0, void *v12 = 0,
- void *v13 = 0, void *v14 = 0, void *v15 = 0, void *v16 = 0);
+ } // tolua_export
+
+ // Gets the value; if not found, write the default to the INI file
+ AString GetValueSet (const AString & keyname, const AString & valuename, const AString & defValue = ""); // tolua_export
+ double GetValueSetF(const AString & keyname, const AString & valuename, const double defValue = 0.0); // tolua_export
+ int GetValueSetI(const AString & keyname, const AString & valuename, const int defValue = 0); // tolua_export
+ bool GetValueSetB(const AString & keyname, const AString & valuename, const bool defValue = false) { // tolua_export
+ return (GetValueSetI(keyname, valuename, defValue ? 1 : 0) > 0);
+ } // tolua_export
// Sets value of [keyname] valuename =.
// Specify the optional paramter as false (0) if you do not want it to create