From 156c9851b8a099656fa86ea52d989e35e5b7ebf1 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 5 Jun 2014 17:58:29 +0100 Subject: Suggestions --- lib/inifile/iniFile.cpp | 20 ++++++++++++++++++++ lib/inifile/iniFile.h | 2 ++ 2 files changed, 22 insertions(+) (limited to 'lib') diff --git a/lib/inifile/iniFile.cpp b/lib/inifile/iniFile.cpp index ea03f5d35..7515483df 100644 --- a/lib/inifile/iniFile.cpp +++ b/lib/inifile/iniFile.cpp @@ -447,6 +447,15 @@ bool cIniFile::SetValueI(const AString & a_KeyName, const AString & a_ValueName, +bool cIniFile::SetValueI(const AString & a_Keyname, const AString & a_ValueName, const Int64 a_Value, const bool a_CreateIfNotExists) +{ + return SetValue(a_Keyname, a_ValueName, Printf("lld", a_Value), a_CreateIfNotExists); +} + + + + + bool cIniFile::SetValueF(const AString & a_KeyName, const AString & a_ValueName, double const a_Value, const bool a_CreateIfNotExists) { return SetValue(a_KeyName, a_ValueName, Printf("%f", a_Value), a_CreateIfNotExists); @@ -571,6 +580,17 @@ int cIniFile::GetValueSetI(const AString & keyname, const AString & valuename, c +Int64 cIniFile::GetValueSetI(const AString & keyname, const AString & valuename, const Int64 defValue) +{ + AString Data; + Printf(Data, "%lld", defValue); + return std::stoll(GetValueSet(keyname, valuename, Data)); +} + + + + + bool cIniFile::DeleteValueByID(const int keyID, const int valueID) { if ((keyID < (int)keys.size()) && (valueID < (int)keys[keyID].names.size())) diff --git a/lib/inifile/iniFile.h b/lib/inifile/iniFile.h index 0bf1d917e..58fecd0cf 100644 --- a/lib/inifile/iniFile.h +++ b/lib/inifile/iniFile.h @@ -119,6 +119,7 @@ public: AString GetValueSet (const AString & keyname, const AString & valuename, const AString & defValue = ""); double GetValueSetF(const AString & keyname, const AString & valuename, const double defValue = 0.0); int GetValueSetI(const AString & keyname, const AString & valuename, const int defValue = 0); + Int64 GetValueSetI(const AString & keyname, const AString & valuename, const Int64 defValue = 0); bool GetValueSetB(const AString & keyname, const AString & valuename, const bool defValue = false) { return (GetValueSetI(keyname, valuename, defValue ? 1 : 0) != 0); @@ -141,6 +142,7 @@ public: bool SetValue (const int keyID, const int valueID, const AString & value); bool SetValue (const AString & a_KeyName, const AString & a_ValueName, const AString & a_Value, const bool a_CreateIfNotExists = true); bool SetValueI(const AString & a_KeyName, const AString & a_ValueName, const int a_Value, const bool a_CreateIfNotExists = true); + bool SetValueI(const AString & a_Keyname, const AString & a_ValueName, const Int64 a_Value, const bool a_CreateIfNotExists = true); bool SetValueB(const AString & a_KeyName, const AString & a_ValueName, const bool a_Value, const bool a_CreateIfNotExists = true) { return SetValueI(a_KeyName, a_ValueName, int(a_Value), a_CreateIfNotExists); -- cgit v1.2.3 From 3275bbf01b79eefb77861cca1fa4fd79c6ae1403 Mon Sep 17 00:00:00 2001 From: worktycho Date: Sat, 7 Jun 2014 00:10:58 +0100 Subject: Fix reading 64 bit values --- lib/inifile/iniFile.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/inifile/iniFile.cpp b/lib/inifile/iniFile.cpp index 7515483df..0c208b953 100644 --- a/lib/inifile/iniFile.cpp +++ b/lib/inifile/iniFile.cpp @@ -449,7 +449,7 @@ bool cIniFile::SetValueI(const AString & a_KeyName, const AString & a_ValueName, bool cIniFile::SetValueI(const AString & a_Keyname, const AString & a_ValueName, const Int64 a_Value, const bool a_CreateIfNotExists) { - return SetValue(a_Keyname, a_ValueName, Printf("lld", a_Value), a_CreateIfNotExists); + return SetValue(a_Keyname, a_ValueName, Printf("%lld", a_Value), a_CreateIfNotExists); } @@ -584,7 +584,10 @@ Int64 cIniFile::GetValueSetI(const AString & keyname, const AString & valuename, { AString Data; Printf(Data, "%lld", defValue); - return std::stoll(GetValueSet(keyname, valuename, Data)); + Astring resultstring = GetValueSet(keyname, valuename, Data); + Int64 result; + sscanf(resultstring.c_str(), "%lld", &result); + return result; } -- cgit v1.2.3 From b925eb4ad4fb02141915aa5392d8a0852f291355 Mon Sep 17 00:00:00 2001 From: worktycho Date: Sat, 7 Jun 2014 00:18:58 +0100 Subject: Capitalising --- lib/inifile/iniFile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/inifile/iniFile.cpp b/lib/inifile/iniFile.cpp index 0c208b953..66410b901 100644 --- a/lib/inifile/iniFile.cpp +++ b/lib/inifile/iniFile.cpp @@ -584,7 +584,7 @@ Int64 cIniFile::GetValueSetI(const AString & keyname, const AString & valuename, { AString Data; Printf(Data, "%lld", defValue); - Astring resultstring = GetValueSet(keyname, valuename, Data); + AString resultstring = GetValueSet(keyname, valuename, Data); Int64 result; sscanf(resultstring.c_str(), "%lld", &result); return result; -- cgit v1.2.3 From 35b79e5d710862f957bc494638a8d8906992665d Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 10 Jun 2014 20:43:27 +0100 Subject: Portal improvements and suggestions --- lib/inifile/iniFile.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib') diff --git a/lib/inifile/iniFile.cpp b/lib/inifile/iniFile.cpp index 66410b901..30f93e5a3 100644 --- a/lib/inifile/iniFile.cpp +++ b/lib/inifile/iniFile.cpp @@ -586,7 +586,11 @@ Int64 cIniFile::GetValueSetI(const AString & keyname, const AString & valuename, Printf(Data, "%lld", defValue); AString resultstring = GetValueSet(keyname, valuename, Data); Int64 result; +#ifdef _WIN32 + sscanf_s(resultstring.c_str(), "%lld", &result); +#else sscanf(resultstring.c_str(), "%lld", &result); +#endif return result; } -- cgit v1.2.3 From 8050a5b98a3003c2a4bed39b896b4a3a4c1068c0 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 21 Jul 2014 22:49:06 +0100 Subject: Suggestions --- lib/inifile/iniFile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/inifile/iniFile.cpp b/lib/inifile/iniFile.cpp index 30f93e5a3..2bf6c91ed 100644 --- a/lib/inifile/iniFile.cpp +++ b/lib/inifile/iniFile.cpp @@ -585,7 +585,7 @@ Int64 cIniFile::GetValueSetI(const AString & keyname, const AString & valuename, AString Data; Printf(Data, "%lld", defValue); AString resultstring = GetValueSet(keyname, valuename, Data); - Int64 result; + Int64 result = defValue; #ifdef _WIN32 sscanf_s(resultstring.c_str(), "%lld", &result); #else -- cgit v1.2.3