Browse Source

Merge pull request #247 from zrax/string-cleaning

Deprecate hsStlUtils and provide some misc. string-related cleanup
Adam Johnson 12 years ago
parent
commit
2c055f91f5
  1. 3
      Sources/Plasma/Apps/plClient/plClient.h
  2. 3
      Sources/Plasma/CoreLib/CMakeLists.txt
  3. 22
      Sources/Plasma/CoreLib/HeadSpin.cpp
  4. 1
      Sources/Plasma/CoreLib/hsSTLStream.h
  5. 65
      Sources/Plasma/CoreLib/hsStlSortUtils.h
  6. 447
      Sources/Plasma/CoreLib/hsStlUtils.cpp
  7. 210
      Sources/Plasma/CoreLib/hsStlUtils.h
  8. 7
      Sources/Plasma/CoreLib/hsStream.cpp
  9. 3
      Sources/Plasma/CoreLib/hsStream.h
  10. 1
      Sources/Plasma/CoreLib/plGeneric.h
  11. 115
      Sources/Plasma/CoreLib/plString.cpp
  12. 128
      Sources/Plasma/CoreLib/plString.h
  13. 1
      Sources/Plasma/FeatureLib/pfAnimation/pfObjectFlocker.cpp
  14. 1
      Sources/Plasma/FeatureLib/pfAnimation/plAnimDebugList.cpp
  15. 1
      Sources/Plasma/FeatureLib/pfCamera/plCameraBrain.cpp
  16. 2
      Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.cpp
  17. 3
      Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp
  18. 1
      Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp
  19. 3
      Sources/Plasma/FeatureLib/pfConsole/pfConsoleDirSrc.h
  20. 14
      Sources/Plasma/FeatureLib/pfConsole/pfDispatchLog.cpp
  21. 1
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIEditBoxMod.h
  22. 1
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUITextBoxMod.cpp
  23. 1
      Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.cpp
  24. 4
      Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.h
  25. 2
      Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizationDataMgr.h
  26. 1
      Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizationMgr.h
  27. 1
      Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizedString.cpp
  28. 3
      Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizedString.h
  29. 1
      Sources/Plasma/FeatureLib/pfMessage/pfKIMsg.h
  30. 1
      Sources/Plasma/FeatureLib/pfPython/Games/Heek/pyHeekMsg.h
  31. 1
      Sources/Plasma/FeatureLib/pfPython/Games/Marker/pyMarkerMsg.h
  32. 1
      Sources/Plasma/FeatureLib/pfPython/Games/VarSync/pyVarSyncMsg.h
  33. 3
      Sources/Plasma/FeatureLib/pfPython/Pch.h
  34. 1
      Sources/Plasma/FeatureLib/pfPython/cyAccountManagement.h
  35. 2
      Sources/Plasma/FeatureLib/pfPython/cyAvatar.h
  36. 1
      Sources/Plasma/FeatureLib/pfPython/cyMisc.h
  37. 2
      Sources/Plasma/FeatureLib/pfPython/cyPythonInterface.h
  38. 5
      Sources/Plasma/FeatureLib/pfPython/plPythonPack.cpp
  39. 2
      Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.h
  40. 1
      Sources/Plasma/FeatureLib/pfPython/pyAgeInfoStruct.cpp
  41. 1
      Sources/Plasma/FeatureLib/pfPython/pyAgeInfoStruct.h
  42. 1
      Sources/Plasma/FeatureLib/pfPython/pyCCRMgr.h
  43. 1
      Sources/Plasma/FeatureLib/pfPython/pyEnum.cpp
  44. 1
      Sources/Plasma/FeatureLib/pfPython/pyJournalBook.h
  45. 3
      Sources/Plasma/FeatureLib/pfPython/pySDL.h
  46. 1
      Sources/Plasma/NucleusLib/inc/plPipeline.h
  47. 3
      Sources/Plasma/NucleusLib/inc/plProfileManager.h
  48. 2
      Sources/Plasma/NucleusLib/pnDispatch/plDispatch.cpp
  49. 2
      Sources/Plasma/NucleusLib/pnDispatch/plDispatch.h
  50. 2
      Sources/Plasma/NucleusLib/pnKeyedObject/plMsgForwarder.h
  51. 1
      Sources/Plasma/NucleusLib/pnMessage/plClientMsg.h
  52. 39
      Sources/Plasma/NucleusLib/pnMessage/plMessage.cpp
  53. 13
      Sources/Plasma/NucleusLib/pnMessage/plMessage.h
  54. 32
      Sources/Plasma/NucleusLib/pnNetCommon/plGenericVar.cpp
  55. 3
      Sources/Plasma/NucleusLib/pnNetCommon/plGenericVar.h
  56. 1
      Sources/Plasma/NucleusLib/pnNetCommon/plNetAddress.h
  57. 1
      Sources/Plasma/NucleusLib/pnNetCommon/plNetApp.cpp
  58. 3
      Sources/Plasma/NucleusLib/pnNetCommon/plNetApp.h
  59. 2
      Sources/Plasma/NucleusLib/pnNetCommon/plNetGroup.h
  60. 3
      Sources/Plasma/NucleusLib/pnNetCommon/plNetSharedState.h
  61. 1
      Sources/Plasma/NucleusLib/pnNetCommon/plSynchedObject.h
  62. 1
      Sources/Plasma/NucleusLib/pnNetCommon/pnNetCommon.cpp
  63. 1
      Sources/Plasma/NucleusLib/pnProduct/Private/pnPrProductId.cpp
  64. 1
      Sources/Plasma/NucleusLib/pnUUID/pnUUID.h
  65. 3
      Sources/Plasma/PubUtilLib/plAgeDescription/plAgeDescription.cpp
  66. 1
      Sources/Plasma/PubUtilLib/plAgeLoader/plAgeLoader.h
  67. 34
      Sources/Plasma/PubUtilLib/plAgeLoader/plResPatcher.cpp
  68. 3
      Sources/Plasma/PubUtilLib/plAudio/plAudioSystem.h
  69. 2
      Sources/Plasma/PubUtilLib/plAudio/plDSoundBuffer.h
  70. 2
      Sources/Plasma/PubUtilLib/plAudioCore/plWavFile.h
  71. 3
      Sources/Plasma/PubUtilLib/plAvatar/plAGAnim.h
  72. 5
      Sources/Plasma/PubUtilLib/plAvatar/plAGAnimInstance.h
  73. 4
      Sources/Plasma/PubUtilLib/plAvatar/plAGMasterMod.h
  74. 4
      Sources/Plasma/PubUtilLib/plAvatar/plAGModifier.h
  75. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAnimStage.cpp
  76. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAnimStage.h
  77. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvBehaviors.cpp
  78. 1
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainCoop.h
  79. 1
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainCritter.h
  80. 1
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainHuman.cpp
  81. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainSwim.cpp
  82. 1
      Sources/Plasma/PubUtilLib/plAvatar/plAvLadderModifier.cpp
  83. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvTaskSeek.cpp
  84. 5
      Sources/Plasma/PubUtilLib/plAvatar/plAvatarMgr.h
  85. 1
      Sources/Plasma/PubUtilLib/plAvatar/plAvatarSDLModifier.h
  86. 4
      Sources/Plasma/PubUtilLib/plAvatar/plCritterCommands.h
  87. 2
      Sources/Plasma/PubUtilLib/plAvatar/plMatrixChannel.cpp
  88. 1
      Sources/Plasma/PubUtilLib/plAvatar/plMultistageBehMod.h
  89. 2
      Sources/Plasma/PubUtilLib/plAvatar/plPhysicalControllerCore.cpp
  90. 2
      Sources/Plasma/PubUtilLib/plAvatar/plSwimRegion.cpp
  91. 2
      Sources/Plasma/PubUtilLib/plCompression/plZlibStream.h
  92. 284
      Sources/Plasma/PubUtilLib/plContainer/plConfigInfo.cpp
  93. 198
      Sources/Plasma/PubUtilLib/plContainer/plConfigInfo.h
  94. 82
      Sources/Plasma/PubUtilLib/plContainer/plConfigInfoLogging.cpp
  95. 1
      Sources/Plasma/PubUtilLib/plContainer/plContainer.h
  96. 132
      Sources/Plasma/PubUtilLib/plContainer/plKeysAndValues.cpp
  97. 43
      Sources/Plasma/PubUtilLib/plContainer/plKeysAndValues.h
  98. 2
      Sources/Plasma/PubUtilLib/plDrawable/plDynaDecalMgr.h
  99. 2
      Sources/Plasma/PubUtilLib/plFile/hsFiles_Unix.cpp
  100. 1
      Sources/Plasma/PubUtilLib/plFile/plEncryptedStream.cpp
  101. Some files were not shown because too many files have changed in this diff Show More

3
Sources/Plasma/Apps/plClient/plClient.h

@ -48,10 +48,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
//#define NEW_CAMERA_CODE //#define NEW_CAMERA_CODE
#include "HeadSpin.h" #include "HeadSpin.h"
#include <list>
#include "hsBitVector.h" #include "hsBitVector.h"
#include "hsTemplates.h" #include "hsTemplates.h"
#include "hsStlUtils.h"
#include "pnKeyedObject/hsKeyedObject.h" #include "pnKeyedObject/hsKeyedObject.h"
#include "pnKeyedObject/plUoid.h" #include "pnKeyedObject/plUoid.h"
#include "plScene/plRenderRequest.h" #include "plScene/plRenderRequest.h"

3
Sources/Plasma/CoreLib/CMakeLists.txt

@ -27,7 +27,6 @@ set(CoreLib_SOURCES
hsRefCnt.cpp hsRefCnt.cpp
hsSafeRefCnt.cpp hsSafeRefCnt.cpp
hsSTLStream.cpp hsSTLStream.cpp
hsStlUtils.cpp
hsStream.cpp hsStream.cpp
hsStringTokenizer.cpp hsStringTokenizer.cpp
hsTemplates.cpp hsTemplates.cpp
@ -69,9 +68,7 @@ set(CoreLib_HEADERS
hsQuat.h hsQuat.h
hsRefCnt.h hsRefCnt.h
hsSafeRefCnt.h hsSafeRefCnt.h
hsStlSortUtils.h
hsSTLStream.h hsSTLStream.h
hsStlUtils.h
hsStream.h hsStream.h
hsStringTokenizer.h hsStringTokenizer.h
hsTemplates.h hsTemplates.h

22
Sources/Plasma/CoreLib/HeadSpin.cpp

@ -41,13 +41,14 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/ *==LICENSE==*/
#include "HeadSpin.h" #include "HeadSpin.h"
#include "hsWindows.h" #include "hsWindows.h"
#include <wchar.h>
#ifdef _MSC_VER #ifdef _MSC_VER
# include <crtdbg.h> # include <crtdbg.h>
#endif #endif
#include "hsStlUtils.h"
#include "hsTemplates.h" #include "hsTemplates.h"
#include "plString.h"
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@ -214,6 +215,7 @@ void hsStatusMessageF(const char * fmt, ...)
#endif #endif
// TODO: Deprecate these in favor of plString
char * hsFormatStr(const char * fmt, ...) char * hsFormatStr(const char * fmt, ...)
{ {
va_list args; va_list args;
@ -225,8 +227,7 @@ char * hsFormatStr(const char * fmt, ...)
char * hsFormatStrV(const char * fmt, va_list args) char * hsFormatStrV(const char * fmt, va_list args)
{ {
std::string buf; plString buf = plString::IFormat(fmt, args);
xtl::formatv(buf,fmt,args);
return hsStrcpy(buf.c_str()); return hsStrcpy(buf.c_str());
} }
@ -460,6 +461,8 @@ char *hsWStringToString( const wchar_t *str )
// //
char** DisplaySystemVersion() char** DisplaySystemVersion()
{ {
// TODO: I so want to std::vector<plString> this, but that requires
// including more headers in HeadSpin.h :(
#if HS_BUILD_FOR_WIN32 #if HS_BUILD_FOR_WIN32
#ifndef VER_SUITE_PERSONAL #ifndef VER_SUITE_PERSONAL
#define VER_SUITE_PERSONAL 0x200 #define VER_SUITE_PERSONAL 0x200
@ -499,6 +502,15 @@ char** DisplaySystemVersion()
if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 ) if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
versionStrs.Append(hsStrcpy ("Microsoft Windows XP ")); versionStrs.Append(hsStrcpy ("Microsoft Windows XP "));
if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0 )
versionStrs.Append(hsStrcpy ("Microsoft Windows Vista "));
if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 1 )
versionStrs.Append(hsStrcpy ("Microsoft Windows 7 "));
if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 2 )
versionStrs.Append(hsStrcpy ("Microsoft Windows 8 "));
// Test for product type. // Test for product type.
if( bOsVersionInfoEx ) if( bOsVersionInfoEx )
@ -545,7 +557,7 @@ char** DisplaySystemVersion()
if ( osvi.dwMajorVersion <= 4 ) if ( osvi.dwMajorVersion <= 4 )
{ {
versionStrs.Append(hsStrcpy (xtl::format("version %d.%d %s (Build %d)\n", versionStrs.Append(hsStrcpy (plString::Format("version %d.%d %s (Build %d)\n",
osvi.dwMajorVersion, osvi.dwMajorVersion,
osvi.dwMinorVersion, osvi.dwMinorVersion,
osvi.szCSDVersion, osvi.szCSDVersion,
@ -553,7 +565,7 @@ char** DisplaySystemVersion()
} }
else else
{ {
versionStrs.Append(hsStrcpy (xtl::format("%s (Build %d)\n", versionStrs.Append(hsStrcpy (plString::Format("%s (Build %d)\n",
osvi.szCSDVersion, osvi.szCSDVersion,
osvi.dwBuildNumber & 0xFFFF).c_str())); osvi.dwBuildNumber & 0xFFFF).c_str()));
} }

1
Sources/Plasma/CoreLib/hsSTLStream.h

@ -44,7 +44,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define _hsSTLStream_h_inc_ #define _hsSTLStream_h_inc_
#include "hsStream.h" #include "hsStream.h"
#include "hsStlUtils.h"
// //
// In-memory only // In-memory only

65
Sources/Plasma/CoreLib/hsStlSortUtils.h

@ -1,65 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef hsStlSortUtils_inc
#define hsStlSortUtils_inc
// These get used a lot in char * STL maps, so lets just have them in one place
class stringSorter
{
public:
bool operator() (const char *s1, const char *s2) const
{
return (strcmp(s1,s2) < 0);
}
};
class stringISorter
{
public:
bool operator() (const char *s1, const char *s2) const
{
return (stricmp(s1,s2) < 0);
}
};
#endif // hsStlSortUtils_inc

447
Sources/Plasma/CoreLib/hsStlUtils.cpp

@ -1,447 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "hsStlUtils.h"
// stl extensions
namespace xtl {
//std::string
std::string & trimleft(std::string & s, const char * charset)
{
s.erase(0, s.find_first_not_of(charset));
return s;
}
std::wstring & trimleft(std::wstring & s, const wchar_t * charset)
{
s.erase(0, s.find_first_not_of(charset));
return s;
}
std::string & trimright(std::string & s, const char * charset)
{
int idx = s.find_last_not_of(charset);
if (std::string::npos == idx)
{
s.erase();
}
else
{
char c = s.at(idx);
s.erase(idx, std::string::npos);
s.append(1, c);
}
return s;
}
std::wstring & trimright(std::wstring & s, const wchar_t * charset)
{
int idx = s.find_last_not_of(charset);
if (std::wstring::npos == idx)
{
s.erase();
}
else
{
wchar_t c = s.at(idx);
s.erase(idx, std::string::npos);
s.append(1, c);
}
return s;
}
std::string & trim(std::string & s, const char * charset)
{
trimleft(s,charset);
trimright(s,charset);
return s;
}
std::wstring & trim(std::wstring & s, const wchar_t * charset)
{
trimleft(s,charset);
trimright(s,charset);
return s;
}
//xtl::istring
xtl::istring & trimleft(xtl::istring & s, const char * charset)
{
s.erase(0, s.find_first_not_of(charset));
return s;
}
xtl::iwstring & trimleft(xtl::iwstring & s, const wchar_t * charset)
{
s.erase(0, s.find_first_not_of(charset));
return s;
}
xtl::istring & trimright(xtl::istring & s, const char * charset)
{
int idx = s.find_last_not_of(charset);
if (xtl::istring::npos == idx)
{
s.erase();
}
else
{
char c = s.at(idx);
s.erase(idx, xtl::istring::npos);
s.append(1, c);
}
return s;
}
xtl::iwstring & trimright(xtl::iwstring & s, const wchar_t * charset)
{
int idx = s.find_last_not_of(charset);
if (xtl::iwstring::npos == idx)
{
s.erase();
}
else
{
wchar_t c = s.at(idx);
s.erase(idx, xtl::iwstring::npos);
s.append(1, c);
}
return s;
}
xtl::istring & trim(xtl::istring & s, const char * charset)
{
trimleft(s,charset);
trimright(s,charset);
return s;
}
xtl::iwstring & trim(xtl::iwstring & s, const wchar_t * charset)
{
trimleft(s,charset);
trimright(s,charset);
return s;
}
// c-string
std::string trim(const char * s, const char * charset)
{
std::string result = s;
trimleft(result,charset);
trimright(result,charset);
return result;
}
std::wstring trim(const wchar_t * s, const wchar_t * charset)
{
std::wstring result = s;
trimleft(result,charset);
trimright(result,charset);
return result;
}
// format
std::string format(const char * fmt, ...)
{
std::string result;
va_list args;
va_start(args,fmt);
formatv(result,fmt,args);
va_end(args);
return result;
}
std::wstring format(const wchar_t * fmt, ...)
{
std::wstring result;
va_list args;
va_start(args,fmt);
formatv(result,fmt,args);
va_end(args);
return result;
}
std::string formatv(const char * fmt, va_list args)
{
std::string result;
formatv( result, fmt, args );
return result;
}
std::wstring formatv(const wchar_t * fmt, va_list args)
{
std::wstring result;
formatv( result, fmt, args );
return result;
}
bool format(std::string & out, const char * fmt, ...)
{
va_list args;
va_start(args,fmt);
bool r = formatv(out,fmt,args);
va_end(args);
return r;
}
bool format(std::wstring & out, const wchar_t * fmt, ...)
{
va_list args;
va_start(args,fmt);
bool r = formatv(out,fmt,args);
va_end(args);
return r;
}
bool formatv(std::string & out, const char * fmt, va_list args)
{
#define kBufSz 2048
char buf[kBufSz];
char * pbuf = buf;
int len = 0;
int attempts = 0;
bool success = false;
const int kMaxAttempts = 40;
do
{
int maxlen = kBufSz*attempts+kBufSz-1;
len = hsVsnprintf(pbuf,maxlen,fmt,args);
attempts++;
success = (len>=0 && len<maxlen);
if (!success)
{
if (pbuf!=buf)
delete [] pbuf;
pbuf = new char[kBufSz+kBufSz*attempts];
}
}
while (!success && attempts<kMaxAttempts);
if (success)
{
pbuf[len] = '\0';
out = pbuf;
}
if (success)
{
pbuf[len] = '\0';
out = pbuf;
}
else
{
out = "";
if ( attempts==kMaxAttempts )
{
hsDebugMessage( "xtl::formatv - Max reallocs occurred while formatting string. Result is likely truncated!", 0 );
}
}
if (pbuf!=buf)
delete [] pbuf;
return success;
}
bool formatv(std::wstring & out, const wchar_t * fmt, va_list args)
{
#define kBufSz 2048
wchar_t buf[kBufSz];
wchar_t * pbuf = buf;
int len = 0;
int attempts = 0;
bool success = false;
const int kMaxAttempts = 40;
do
{
int maxlen = kBufSz*attempts+kBufSz-1;
len = hsVsnwprintf(pbuf,maxlen,fmt,args);
attempts++;
success = (len>=0 && len<maxlen);
if (!success)
{
if (pbuf!=buf)
delete [] pbuf;
pbuf = new wchar_t[kBufSz+kBufSz*attempts];
}
}
while (!success && attempts<kMaxAttempts);
if (success)
{
pbuf[len] = L'\0';
out = pbuf;
}
if (success)
{
pbuf[len] = L'\0';
out = pbuf;
}
else
{
out = L"";
if ( attempts==kMaxAttempts )
{
hsDebugMessage( "xtl::formatv - Max reallocs occurred while formatting wstring. Result is likely truncated!", 0 );
}
}
if (pbuf!=buf)
delete [] pbuf;
return success;
}
typedef std::vector<std::string> StringVector;
typedef std::vector<std::wstring> WStringVector;
typedef std::list<std::string> StringList;
typedef std::list<std::wstring> WStringList;
typedef std::set<std::string> StringSet;
typedef std::set<std::wstring> WStringSet;
template bool GetStringGroup<StringList>(const std::string& s, StringList& group, char sep);
template bool GetStringGroup<WStringList>(const std::wstring& s, WStringList& group, wchar_t sep);
template bool GetStringGroup<StringVector>(const std::string& s, StringVector& group, char sep);
template bool GetStringGroup<WStringVector>(const std::wstring& s, WStringVector& group, wchar_t sep);
template bool GetStringGroup<StringSet>(const std::string& s, StringSet& group, char sep);
template bool GetStringGroup<WStringSet>(const std::wstring& s, WStringSet& group, wchar_t sep);
template <typename T> bool GetStringGroup(const std::string& s, T& group, char sep)
{
bool ret = false;
std::string::size_type oldpos = 0, newpos = 0;
if (!(s.empty()))
{
do
{
newpos = s.find(',',oldpos);
group.insert(group.end(),s.substr(oldpos,newpos));
if (newpos != s.npos)
oldpos = newpos+1;
}
while(newpos != s.npos);
ret = true;
}
return ret;
}
template <typename T> bool GetStringGroup(const std::wstring& s, T& group, wchar_t sep)
{
bool ret = false;
std::wstring::size_type oldpos = 0, newpos = 0;
if (!(s.empty()))
{
do
{
newpos = s.find(L',',oldpos);
group.insert(group.end(),s.substr(oldpos,newpos));
if (newpos != s.npos)
oldpos = newpos+1;
} while(newpos != s.npos);
ret = true;
}
return ret;
}
template bool GetStringGroupAsString<StringList>(const StringList& group, std::string& s, char sep);
template bool GetStringGroupAsString<WStringList>(const WStringList& group, std::wstring& s, wchar_t sep);
template bool GetStringGroupAsString<StringVector>(const StringVector& group, std::string& s, char sep);
template bool GetStringGroupAsString<WStringVector>(const WStringVector& group, std::wstring& s, wchar_t sep);
template bool GetStringGroupAsString<StringSet>(const StringSet& group, std::string& s, char sep);
template bool GetStringGroupAsString<WStringSet>(const WStringSet& group, std::wstring& s, wchar_t sep);
template <typename T> bool GetStringGroupAsString(const T& group, std::string& s, char sep)
{
typename T::const_iterator it = group.begin();
bool fst = true;
while (it != group.end())
{
if (!fst)
s += ",";
else
fst = false;
s+= (*it).c_str();
it++;
}
return true;
}
template <typename T> bool GetStringGroupAsString(const T& group, std::wstring& s, wchar_t sep)
{
typename T::const_iterator it = group.begin();
bool fst = true;
while (it != group.end())
{
if (!fst)
s += L",";
else
fst = false;
s+= (*it).c_str();
it++;
}
return true;
}
} // namespace std

210
Sources/Plasma/CoreLib/hsStlUtils.h

@ -1,210 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef hsStlUtils_h_inc
#define hsStlUtils_h_inc
#include "HeadSpin.h"
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
/*****************************************************************************
*
* stl extensions
*
***/
namespace xtl
{
// Why oh why doesn't stl have copy_if?
// See Effective STL [Meyers 2001] Item 36.
template< typename InIt, typename OutIt, typename Pred >
OutIt copy_if( InIt srcBegin, InIt srcEnd, OutIt dstBegin, Pred pred )
{
while ( srcBegin!=srcEnd )
{
if ( pred( *srcBegin ) )
*dstBegin++ = *srcBegin;
++srcBegin;
}
return dstBegin;
}
// useful when clearing a vector/list/set of pointers that need to be deleted.
// use like:
// std::vector<foo*> vec;
// std::for_each(vec.begin(),vec.end(),xtl::delete_ptr());
// vec.clear();
struct delete_ptr
{
template< class T > void operator()( T * p ) const { delete p;}
};
// useful when clearing a map of pointers that need to be deleted.
// use like:
// typedef std::map<int,foo*> foomap;
// foomap m;
// std::for_each(m.begin(),m.end(),xtl::delete_map_ptr_T<foomap>());
// m.clear();
template< class A >
struct delete_map_ptr_T
{
void operator()( typename A::value_type & pair ) const { delete pair.second;}
};
// case insensitive string comparer
// useful in maps that use strings
struct stricmp_less : public std::binary_function<std::string, std::string, bool>
{
bool operator()(const std::string & _X, const std::string & _Y) const
{return ( stricmp(_X.c_str(),_Y.c_str()) < 0); }
};
struct wstricmp_less : public std::binary_function<std::wstring, std::wstring, bool>
{
bool operator()(const std::wstring & _X, const std::wstring & _Y) const
{return ( wcsicmp(_X.c_str(),_Y.c_str()) < 0); }
};
// struct stricmp_char_traits
// case insensitive char_traits. used in creating istring class below
#ifdef __SGI_STL_PORT
struct stricmp_char_traits : public __std_alias::char_traits< char >
#else
struct stricmp_char_traits : public std::char_traits< char >
#endif
{
static int compare(const char * A, const char * B, size_t N)
{
for (size_t I=0; I<N; ++I, ++A,++B)
if (tolower(*A)!=tolower(*B))
return (lt(tolower(*A),tolower(*B))?-1:+1);
return (0);
}
static const char * find(const char * S, size_t N, const char & C)
{
char c = tolower(C);
for (; 0<N; --N, ++S)
if (c==tolower(*S))
return S;
return NULL;
}
};
#ifdef __SGI_STL_PORT
struct wstricmp_char_traits : public __std_alias::char_traits< wchar_t >
#else
struct wstricmp_char_traits : public std::char_traits< wchar_t >
#endif
{
static int compare(const wchar_t * A, const wchar_t * B, size_t N)
{
for (size_t I=0; I<N; ++I, ++A,++B)
if (tolower(*A)!=tolower(*B))
return (lt(tolower(*A),tolower(*B))?-1:+1);
return (0);
}
static const wchar_t * find(const wchar_t * S, size_t N, const wchar_t & C)
{
wchar_t c = tolower(C);
for (; 0<N; --N, ++S)
if (c==tolower(*S))
return S;
return NULL;
}
};
// class istring
// A string with case insensitive char_traits.
// Calls to its find* methods are case insensitive.
typedef std::basic_string<char, stricmp_char_traits> istring;
typedef std::basic_string<wchar_t, wstricmp_char_traits> iwstring;
// std::string trim
std::string & trimleft(std::string & s, const char * charset=" \t\n\r");
std::wstring & trimleft(std::wstring & s, const wchar_t * charset=L" \t\n\r");
std::string & trimright(std::string & s, const char * charset=" \t\n\r");
std::wstring & trimright(std::wstring & s, const wchar_t * charset=L" \t\n\r");
std::string & trim(std::string & s, const char * charset=" \t\n\r");
std::wstring & trim(std::wstring & s, const wchar_t * charset=L" \t\n\r");
// xtl::istring trim
xtl::istring & trimleft(xtl::istring & s, const char * charset=" \t\n\r");
xtl::iwstring & trimleft(xtl::iwstring & s, const wchar_t * charset=L" \t\n\r");
xtl::istring & trimright(xtl::istring & s, const char * charset=" \t\n\r");
xtl::iwstring & trimright(xtl::iwstring & s, const wchar_t * charset=L" \t\n\r");
xtl::istring & trim(xtl::istring & s, const char * charset=" \t\n\r");
xtl::iwstring & trim(xtl::iwstring & s, const wchar_t * charset=L" \t\n\r");
// c-string trim
std::string trim(const char * s, const char * charset=" \t\n\r");
std::wstring trim(const wchar_t * s, const wchar_t * charset=L" \t\n\r");
// format
std::string format(const char * fmt, ...);
std::wstring format(const wchar_t * fmt, ...);
std::string formatv(const char * fmt, va_list args);
std::wstring formatv(const wchar_t * fmt, va_list args);
bool format(std::string & out, const char * fmt, ...);
bool format(std::wstring & out, const wchar_t * fmt, ...);
bool formatv(std::string & out, const char * fmt, va_list args);
bool formatv(std::wstring & out, const wchar_t * fmt, va_list args);
template <typename T> bool GetStringGroup(const std::string& s, T& group, char sep = ',');
template <typename T> bool GetStringGroup(const std::wstring& s, T& group, wchar_t sep = L',');
template <typename T> bool GetStringGroupAsString(const T& group, std::string& s, char sep = ',');
template <typename T> bool GetStringGroupAsString(const T& group, std::wstring& s, wchar_t sep = L',');
} // namespace xtd
#endif // hsStlUtils_h_inc

7
Sources/Plasma/CoreLib/hsStream.cpp

@ -45,7 +45,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsTemplates.h" #include "hsTemplates.h"
#include "hsStlUtils.h"
#if HS_BUILD_FOR_UNIX #if HS_BUILD_FOR_UNIX
#include <unistd.h> #include <unistd.h>
@ -55,7 +54,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#if HS_BUILD_FOR_WIN32 #if HS_BUILD_FOR_WIN32
#include <io.h> #include <io.h>
#endif #endif
#include "hsStlUtils.h"
////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////
@ -123,9 +121,8 @@ uint32_t hsStream::WriteFmt(const char * fmt, ...)
uint32_t hsStream::WriteFmtV(const char * fmt, va_list av) uint32_t hsStream::WriteFmtV(const char * fmt, va_list av)
{ {
std::string buf; plString buf = plString::IFormat(fmt, av);
xtl::formatv( buf, fmt, av ); return Write( buf.GetSize(), buf.c_str() );
return Write( buf.length(), buf.data() );
} }
uint32_t hsStream::WriteSafeStringLong(const plString &string) uint32_t hsStream::WriteSafeStringLong(const plString &string)

3
Sources/Plasma/CoreLib/hsStream.h

@ -83,6 +83,9 @@ public:
hsStream() : fBytesRead(0), fPosition(0) {} hsStream() : fBytesRead(0), fPosition(0) {}
virtual ~hsStream() { } virtual ~hsStream() { }
// Pre-filename-stringification shortcut:
bool Open_TEMP(const plString & filename, const char * mode = "rb") { return Open(filename.c_str(), mode); }
virtual bool Open(const char *, const char * = "rb")=0; virtual bool Open(const char *, const char * = "rb")=0;
virtual bool Open(const wchar_t *, const wchar_t * = L"rb")=0; virtual bool Open(const wchar_t *, const wchar_t * = L"rb")=0;
virtual bool Close()=0; virtual bool Close()=0;

1
Sources/Plasma/CoreLib/plGeneric.h

@ -43,7 +43,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define __PLGENERIC_H__ #define __PLGENERIC_H__
#include "hsStream.h" #include "hsStream.h"
#include "hsStlUtils.h"
class plGeneric class plGeneric
{ {

115
Sources/Plasma/CoreLib/plString.cpp

@ -163,7 +163,7 @@ void plString::IConvertFromUtf16(const uint16_t *utf16, size_t size)
while (sp < utf16 + size) { while (sp < utf16 + size) {
if (*sp >= 0xD800 && *sp <= 0xDFFF) { if (*sp >= 0xD800 && *sp <= 0xDFFF) {
// Surrogate pair // Surrogate pair
unsigned int unichar = 0x10000; UniChar unichar = 0x10000;
if (sp + 1 >= utf16 + size) { if (sp + 1 >= utf16 + size) {
hsAssert(0, "Incomplete surrogate pair in UTF-16 data"); hsAssert(0, "Incomplete surrogate pair in UTF-16 data");
@ -204,19 +204,25 @@ void plString::IConvertFromWchar(const wchar_t *wstr, size_t size)
// We assume that if sizeof(wchar_t) == 2, the data is UTF-16 already // We assume that if sizeof(wchar_t) == 2, the data is UTF-16 already
IConvertFromUtf16((const uint16_t *)wstr, size); IConvertFromUtf16((const uint16_t *)wstr, size);
#else #else
IConvertFromUtf32((const UniChar *)wstr, size);
#endif
}
void plString::IConvertFromUtf32(const UniChar *ustr, size_t size)
{
fUtf8Buffer = plStringBuffer<char>(); fUtf8Buffer = plStringBuffer<char>();
if (wstr == nil) if (ustr == nil)
return; return;
if ((int32_t)size < 0) if ((int32_t)size < 0)
size = wcsnlen(wstr, -(int32_t)size); size = ustrlen(ustr, -(int32_t)size);
// Calculate the UTF-8 size // Calculate the UTF-8 size
size_t convlen = 0; size_t convlen = 0;
const wchar_t *sp = wstr; const UniChar *sp = ustr;
while (sp < wstr + size) { while (sp < ustr + size) {
if (*sp > 0x10FFFF) { if (*sp > 0x10FFFF) {
hsAssert(0, "UCS-4 character out of range"); hsAssert(0, "UTF-32 character out of range");
convlen += 3; // Use U+FFFD for release builds convlen += 3; // Use U+FFFD for release builds
} }
else if (*sp > 0xFFFF) else if (*sp > 0xFFFF)
@ -233,8 +239,8 @@ void plString::IConvertFromWchar(const wchar_t *wstr, size_t size)
// And perform the actual conversion // And perform the actual conversion
char *utf8 = fUtf8Buffer.CreateWritableBuffer(convlen); char *utf8 = fUtf8Buffer.CreateWritableBuffer(convlen);
char *dp = utf8; char *dp = utf8;
sp = wstr; sp = ustr;
while (sp < wstr + size) { while (sp < ustr + size) {
if (*sp > 0x10FFFF) { if (*sp > 0x10FFFF) {
// Character out of range; Use U+FFFD instead // Character out of range; Use U+FFFD instead
*dp++ = 0xE0 | ((BADCHAR_REPLACEMENT >> 12) & 0x0F); *dp++ = 0xE0 | ((BADCHAR_REPLACEMENT >> 12) & 0x0F);
@ -258,7 +264,6 @@ void plString::IConvertFromWchar(const wchar_t *wstr, size_t size)
++sp; ++sp;
} }
utf8[convlen] = 0; utf8[convlen] = 0;
#endif
} }
void plString::IConvertFromIso8859_1(const char *astr, size_t size) void plString::IConvertFromIso8859_1(const char *astr, size_t size)
@ -327,7 +332,7 @@ plStringBuffer<uint16_t> plString::ToUtf16() const
uint16_t *dp = ustr; uint16_t *dp = ustr;
sp = utf8; sp = utf8;
while (sp < utf8 + srcSize) { while (sp < utf8 + srcSize) {
unsigned int unichar; UniChar unichar;
if ((*sp & 0xF8) == 0xF0) { if ((*sp & 0xF8) == 0xF0) {
unichar = (*sp++ & 0x07) << 18; unichar = (*sp++ & 0x07) << 18;
unichar |= (*sp++ & 0x3F) << 12; unichar |= (*sp++ & 0x3F) << 12;
@ -361,11 +366,18 @@ plStringBuffer<wchar_t> plString::ToWchar() const
plStringBuffer<uint16_t> utf16 = ToUtf16(); plStringBuffer<uint16_t> utf16 = ToUtf16();
return *reinterpret_cast<plStringBuffer<wchar_t>*>(&utf16); return *reinterpret_cast<plStringBuffer<wchar_t>*>(&utf16);
#else #else
plStringBuffer<wchar_t> result; plUnicodeBuffer utf32 = GetUnicodeArray();
return *reinterpret_cast<plStringBuffer<wchar_t>*>(&utf32);
#endif
}
plStringBuffer<char> plString::ToIso8859_1() const
{
plStringBuffer<char> result;
if (IsEmpty()) if (IsEmpty())
return result; return result;
// Calculate the UCS-4 size // Calculate the ASCII size
size_t convlen = 0; size_t convlen = 0;
const char *utf8 = fUtf8Buffer.GetData(); const char *utf8 = fUtf8Buffer.GetData();
const char *sp = utf8; const char *sp = utf8;
@ -383,11 +395,11 @@ plStringBuffer<wchar_t> plString::ToWchar() const
} }
// And perform the actual conversion // And perform the actual conversion
wchar_t *wstr = result.CreateWritableBuffer(convlen); char *astr = result.CreateWritableBuffer(convlen);
wchar_t *dp = wstr; char *dp = astr;
sp = utf8; sp = utf8;
while (sp < utf8 + srcSize) { while (sp < utf8 + srcSize) {
unsigned int unichar; UniChar unichar;
if ((*sp & 0xF8) == 0xF0) { if ((*sp & 0xF8) == 0xF0) {
unichar = (*sp++ & 0x07) << 18; unichar = (*sp++ & 0x07) << 18;
unichar |= (*sp++ & 0x3F) << 12; unichar |= (*sp++ & 0x3F) << 12;
@ -403,21 +415,20 @@ plStringBuffer<wchar_t> plString::ToWchar() const
} else { } else {
unichar = *sp++; unichar = *sp++;
} }
*dp++ = unichar; *dp++ = (unichar < 0xFF) ? unichar : '?';
} }
wstr[convlen] = 0; astr[convlen] = 0;
return result; return result;
#endif
} }
plStringBuffer<char> plString::ToIso8859_1() const plUnicodeBuffer plString::GetUnicodeArray() const
{ {
plStringBuffer<char> result; plUnicodeBuffer result;
if (IsEmpty()) if (IsEmpty())
return result; return result;
// Calculate the ASCII size // Calculate the UCS-4 size
size_t convlen = 0; size_t convlen = 0;
const char *utf8 = fUtf8Buffer.GetData(); const char *utf8 = fUtf8Buffer.GetData();
const char *sp = utf8; const char *sp = utf8;
@ -435,11 +446,11 @@ plStringBuffer<char> plString::ToIso8859_1() const
} }
// And perform the actual conversion // And perform the actual conversion
char *astr = result.CreateWritableBuffer(convlen); UniChar *ustr = result.CreateWritableBuffer(convlen);
char *dp = astr; UniChar *dp = ustr;
sp = utf8; sp = utf8;
while (sp < utf8 + srcSize) { while (sp < utf8 + srcSize) {
unsigned int unichar; UniChar unichar;
if ((*sp & 0xF8) == 0xF0) { if ((*sp & 0xF8) == 0xF0) {
unichar = (*sp++ & 0x07) << 18; unichar = (*sp++ & 0x07) << 18;
unichar |= (*sp++ & 0x3F) << 12; unichar |= (*sp++ & 0x3F) << 12;
@ -455,25 +466,8 @@ plStringBuffer<char> plString::ToIso8859_1() const
} else { } else {
unichar = *sp++; unichar = *sp++;
} }
*dp++ = (unichar < 0xFF) ? unichar : '?'; *dp++ = unichar;
} }
astr[convlen] = 0;
return result;
}
plStringBuffer<UniChar> plString::GetUnicodeArray() const
{
plStringBuffer<UniChar> result;
if (IsEmpty())
return result;
size_t convlen = GetUniCharCount();
UniChar *ustr = result.CreateWritableBuffer(convlen);
iterator iter = GetIterator();
size_t dp = 0;
while (!iter.AtEnd())
ustr[dp++] = *iter++;
ustr[convlen] = 0; ustr[convlen] = 0;
return result; return result;
@ -518,18 +512,24 @@ plString plString::IFormat(const char *fmt, va_list vptr)
int size = 4096; int size = 4096;
for ( ;; ) { for ( ;; ) {
va_copy(vptr, vptr_save); va_copy(vptr, vptr_save);
std::auto_ptr<char> bigbuffer(new char[size]); plStringBuffer<char> bigbuffer;
chars = vsnprintf(bigbuffer.get(), size, fmt, vptr); char *data = bigbuffer.CreateWritableBuffer(size-1);
if (chars >= 0) chars = vsnprintf(data, size, fmt, vptr);
return plString::FromUtf8(bigbuffer.get(), chars); if (chars >= 0) {
// We need to construct a new string here so the length
// parameter is accurate :(
return plString::FromUtf8(bigbuffer.GetData(), chars);
}
size *= 2; size *= 2;
hsAssert(size > 0, "Formatted string output is waaaaay too long");
} }
} else if (chars >= 256) { } else if (chars >= 256) {
va_copy(vptr, vptr_save); va_copy(vptr, vptr_save);
std::unique_ptr<char> bigbuffer(new char[chars+1]); plStringBuffer<char> bigbuffer;
vsnprintf(bigbuffer.get(), chars+1, fmt, vptr); char *data = bigbuffer.CreateWritableBuffer(chars);
return plString::FromUtf8(bigbuffer.get(), chars); vsnprintf(data, chars+1, fmt, vptr);
return bigbuffer;
} }
return plString::FromUtf8(buffer, chars); return plString::FromUtf8(buffer, chars);
@ -754,6 +754,15 @@ std::vector<plString> plString::Split(const char *split, size_t maxSplits) const
return result; return result;
} }
plString plString::Fill(size_t count, char c)
{
plStringBuffer<char> buf;
char *data = buf.CreateWritableBuffer(count + 1);
memset(data, c, count);
data[count] = 0;
return buf;
}
plString operator+(const plString &left, const plString &right) plString operator+(const plString &left, const plString &right)
{ {
plString cat; plString cat;
@ -822,3 +831,11 @@ plStringStream &plStringStream::operator<<(unsigned int num)
snprintf(buffer, 12, "%u", num); snprintf(buffer, 12, "%u", num);
return operator<<(buffer); return operator<<(buffer);
} }
size_t ustrlen(const UniChar *ustr, size_t max)
{
size_t length = 0;
for ( ; *ustr++ && max--; ++length)
;
return length;
}

128
Sources/Plasma/CoreLib/plString.h

@ -49,6 +49,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
typedef unsigned int UniChar; typedef unsigned int UniChar;
#define SSO_CHARS (16) #define SSO_CHARS (16)
#define WHITESPACE_CHARS " \t\n\r"
template <typename _Ch> template <typename _Ch>
class plStringBuffer class plStringBuffer
@ -121,7 +122,6 @@ public:
const _Ch *GetData() const { return IHaveACow() ? fData->fStringData : fShort; } const _Ch *GetData() const { return IHaveACow() ? fData->fStringData : fShort; }
size_t GetSize() const { return fSize; } size_t GetSize() const { return fSize; }
operator const _Ch *() const { return GetData(); } operator const _Ch *() const { return GetData(); }
// From Haxxia with love // From Haxxia with love
@ -142,14 +142,15 @@ public:
} }
}; };
typedef plStringBuffer<UniChar> plUnicodeBuffer;
class plString class plString
{ {
public:
enum { enum {
kSizeAuto = (size_t)(0x80000000) kSizeAuto = (size_t)(0x80000000)
}; };
public:
static const plString Null; static const plString Null;
private: private:
@ -158,6 +159,7 @@ private:
void IConvertFromUtf8(const char *utf8, size_t size); void IConvertFromUtf8(const char *utf8, size_t size);
void IConvertFromUtf16(const uint16_t *utf16, size_t size); void IConvertFromUtf16(const uint16_t *utf16, size_t size);
void IConvertFromWchar(const wchar_t *wstr, size_t size); void IConvertFromWchar(const wchar_t *wstr, size_t size);
void IConvertFromUtf32(const UniChar *ustr, size_t size);
void IConvertFromIso8859_1(const char *astr, size_t size); void IConvertFromIso8859_1(const char *astr, size_t size);
public: public:
@ -166,10 +168,12 @@ public:
plString(const char *cstr) { IConvertFromUtf8(cstr, kSizeAuto); } plString(const char *cstr) { IConvertFromUtf8(cstr, kSizeAuto); }
plString(const plString &copy) : fUtf8Buffer(copy.fUtf8Buffer) { } plString(const plString &copy) : fUtf8Buffer(copy.fUtf8Buffer) { }
plString(const plStringBuffer<char> &init) { operator=(init); } plString(const plStringBuffer<char> &init) { operator=(init); }
plString(const plUnicodeBuffer &init) { IConvertFromUtf32(init.GetData(), init.GetSize()); }
plString &operator=(const char *cstr) { IConvertFromUtf8(cstr, kSizeAuto); return *this; } plString &operator=(const char *cstr) { IConvertFromUtf8(cstr, kSizeAuto); return *this; }
plString &operator=(const plString &copy) { fUtf8Buffer = copy.fUtf8Buffer; return *this; } plString &operator=(const plString &copy) { fUtf8Buffer = copy.fUtf8Buffer; return *this; }
plString &operator=(const plStringBuffer<char> &init); plString &operator=(const plStringBuffer<char> &init);
plString &operator=(const plUnicodeBuffer &init) { IConvertFromUtf32(init.GetData(), init.GetSize()); return *this; }
plString &operator+=(const char *cstr) { return operator=(*this + cstr); } plString &operator+=(const char *cstr) { return operator=(*this + cstr); }
plString &operator+=(const plString &str) { return operator=(*this + str); } plString &operator+=(const plString &str) { return operator=(*this + str); }
@ -213,7 +217,7 @@ public:
plStringBuffer<char> ToIso8859_1() const; plStringBuffer<char> ToIso8859_1() const;
// For use in displaying characters in a GUI // For use in displaying characters in a GUI
plStringBuffer<UniChar> GetUnicodeArray() const; plUnicodeBuffer GetUnicodeArray() const;
size_t GetSize() const { return fUtf8Buffer.GetSize(); } size_t GetSize() const { return fUtf8Buffer.GetSize(); }
bool IsEmpty() const { return fUtf8Buffer.GetSize() == 0; } bool IsEmpty() const { return fUtf8Buffer.GetSize() == 0; }
@ -276,15 +280,15 @@ public:
int Find(const plString &str, CaseSensitivity sense = kCaseSensitive) const int Find(const plString &str, CaseSensitivity sense = kCaseSensitive) const
{ return Find(str.c_str(), sense); } { return Find(str.c_str(), sense); }
plString TrimLeft(const char *charset = " \t\n\r") const; plString TrimLeft(const char *charset = WHITESPACE_CHARS) const;
plString TrimRight(const char *charset = " \t\n\r") const; plString TrimRight(const char *charset = WHITESPACE_CHARS) const;
plString Trim(const char *charset = " \t\n\r") const; plString Trim(const char *charset = WHITESPACE_CHARS) const;
plString Substr(int start, size_t size = kSizeAuto) const; plString Substr(int start, size_t size = kSizeAuto) const;
plString Left(size_t size) const { return Substr(0, size); } plString Left(size_t size) const { return Substr(0, size); }
plString Right(size_t size) const { return Substr(GetSize() - size, size); } plString Right(size_t size) const { return Substr(GetSize() - size, size); }
// NOTE: Does ::Compare(blah, kCaseInsensitive) make more sense? If // NOTE: Does Compare(blah, kCaseInsensitive) make more sense? If
// so, use that instead -- it's faster and more efficient! // so, use that instead -- it's faster and more efficient!
plString ToUpper() const; plString ToUpper() const;
plString ToLower() const; plString ToLower() const;
@ -294,7 +298,9 @@ public:
// all delimiters and only returns the pieces left between them), whereas // all delimiters and only returns the pieces left between them), whereas
// Split will split on a full string, returning whatever is left between. // Split will split on a full string, returning whatever is left between.
std::vector<plString> Split(const char *split, size_t maxSplits = kSizeAuto) const; std::vector<plString> Split(const char *split, size_t maxSplits = kSizeAuto) const;
std::vector<plString> Tokenize(const char *delims = " \t\r\n\f\v") const; std::vector<plString> Tokenize(const char *delims = WHITESPACE_CHARS) const;
static plString Fill(size_t count, char c);
public: public:
struct less struct less
@ -321,108 +327,6 @@ public:
{ return _L.Compare(_R, kCaseInsensitive) == 0; } { return _L.Compare(_R, kCaseInsensitive) == 0; }
}; };
public:
struct iterator
{
iterator() : m_ptr(nil), m_end(nil) { }
iterator(const iterator &copy) : m_ptr(copy.m_ptr), m_end(copy.m_end) { }
iterator &operator=(const iterator &copy)
{ m_ptr = copy.m_ptr; m_end = copy.m_end; return *this; }
iterator &operator++()
{
if ((*m_ptr & 0xF8) == 0xF0)
m_ptr += 4;
else if ((*m_ptr & 0xF0) == 0xE0)
m_ptr += 3;
else if ((*m_ptr & 0xE0) == 0xC0)
m_ptr += 2;
else
m_ptr += 1;
return *this;
}
iterator operator++(int)
{
iterator iter_save = *this;
(void) operator++();
return iter_save;
}
iterator &operator+=(size_t delta)
{
while (delta) {
operator++();
--delta;
}
return *this;
}
iterator operator+(size_t delta) const
{
iterator copy(*this);
copy += delta;
return copy;
}
int operator-(const iterator &other) const
{
return (int)(m_ptr - other.m_ptr);
}
bool operator==(const iterator &other) const { return m_ptr == other.m_ptr; }
bool operator!=(const iterator &other) const { return m_ptr != other.m_ptr; }
bool operator<(const iterator &other) const { return m_ptr < other.m_ptr; }
bool operator>(const iterator &other) const { return m_ptr > other.m_ptr; }
bool operator<=(const iterator &other) const { return m_ptr <= other.m_ptr; }
bool operator>=(const iterator &other) const { return m_ptr >= other.m_ptr; }
UniChar operator*() const
{
UniChar ch;
if ((*m_ptr & 0xF8) == 0xF0) {
ch = (m_ptr[0] & 0x07) << 18;
ch |= (m_ptr[1] & 0x3F) << 12;
ch |= (m_ptr[2] & 0x3F) << 6;
ch |= (m_ptr[3] & 0x3F);
} else if ((*m_ptr & 0xF0) == 0xE0) {
ch = (m_ptr[0] & 0x0F) << 12;
ch |= (m_ptr[1] & 0x3F) << 6;
ch |= (m_ptr[2] & 0x3F);
} else if ((*m_ptr & 0xE0) == 0xC0) {
ch = (m_ptr[0] & 0x1F) << 6;
ch |= (m_ptr[1] & 0x3F);
} else {
ch = m_ptr[0];
}
return ch;
}
bool AtEnd() const { return m_ptr >= m_end; }
bool IsValid() const { return m_ptr != 0; }
private:
friend class plString;
iterator(const char *ptr, size_t size) : m_ptr(ptr), m_end(ptr + size) { }
const char *m_ptr;
const char *m_end;
};
iterator GetIterator() const { return iterator(c_str(), GetSize()); }
size_t GetUniCharCount() const
{
iterator iter = GetIterator();
size_t count = 0;
while (!iter.AtEnd()) {
++iter;
++count;
}
return count;
}
private: private:
friend plString operator+(const plString &left, const plString &right); friend plString operator+(const plString &left, const plString &right);
friend plString operator+(const plString &left, const char *right); friend plString operator+(const plString &left, const char *right);
@ -464,4 +368,6 @@ private:
size_t fLength; size_t fLength;
}; };
size_t ustrlen(const UniChar *ustr, size_t max = plString::kSizeAuto);
#endif //plString_Defined #endif //plString_Defined

1
Sources/Plasma/FeatureLib/pfAnimation/pfObjectFlocker.cpp

@ -40,7 +40,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/ *==LICENSE==*/
#include "HeadSpin.h" #include "HeadSpin.h"
#include "hsStlUtils.h"
#include "hsMatrix44.h" #include "hsMatrix44.h"
#include "hsGeometry3.h" #include "hsGeometry3.h"
#include "plgDispatch.h" #include "plgDispatch.h"

1
Sources/Plasma/FeatureLib/pfAnimation/plAnimDebugList.cpp

@ -39,7 +39,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
Mead, WA 99021 Mead, WA 99021
*==LICENSE==*/ *==LICENSE==*/
#include "hsStlUtils.h"
#include "hsResMgr.h" #include "hsResMgr.h"
#include "hsTemplates.h" #include "hsTemplates.h"
#include "hsTimer.h" #include "hsTimer.h"

1
Sources/Plasma/FeatureLib/pfCamera/plCameraBrain.cpp

@ -40,6 +40,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/ *==LICENSE==*/
#include "HeadSpin.h" #include "HeadSpin.h"
#include <cmath>
#include "plCameraBrain.h" #include "plCameraBrain.h"
#include "hsTimer.h" #include "hsTimer.h"

2
Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.cpp

@ -41,6 +41,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/ *==LICENSE==*/
#include "HeadSpin.h" #include "HeadSpin.h"
#include <algorithm>
#include "plVirtualCamNeu.h" #include "plVirtualCamNeu.h"
#include "plCameraModifier.h" #include "plCameraModifier.h"
#include "plCameraBrain.h" #include "plCameraBrain.h"

3
Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp

@ -161,7 +161,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plStatusLog/plStatusLog.h" #include "plStatusLog/plStatusLog.h"
#include "pnTimer/pnBuildDates.h" #include "pnTimer/pnBuildDates.h"
#include "hsStlUtils.h"
#include "hsTemplates.h" #include "hsTemplates.h"
#include "plResMgr/plResManagerHelper.h" #include "plResMgr/plResManagerHelper.h"
@ -538,7 +537,7 @@ PF_CONSOLE_CMD(Stats, ListGroups, "", "Prints the names of all the stat groups t
plProfileManagerFull::GroupSet::iterator it; plProfileManagerFull::GroupSet::iterator it;
for (it = groups.begin(); it != groups.end(); it++) for (it = groups.begin(); it != groups.end(); it++)
PrintString((char*)*it); PrintString(it->c_str());
} }
PF_CONSOLE_CMD(Stats, ListLaps, "", "Prints the names of all the stats with laps to the console") PF_CONSOLE_CMD(Stats, ListLaps, "", "Prints the names of all the stats with laps to the console")

1
Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp

@ -88,7 +88,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plStatusLog/plStatusLog.h" #include "plStatusLog/plStatusLog.h"
#include "hsStlUtils.h"
#include "hsTemplates.h" #include "hsTemplates.h"
#include "plVault/plVault.h" #include "plVault/plVault.h"

3
Sources/Plasma/FeatureLib/pfConsole/pfConsoleDirSrc.h

@ -56,7 +56,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define _pfConsoleDirSrc_h #define _pfConsoleDirSrc_h
#include "HeadSpin.h" #include "HeadSpin.h"
#include "hsStlUtils.h" #include <vector>
#include "pfConsoleCore/pfConsoleEngine.h" #include "pfConsoleCore/pfConsoleEngine.h"
//// pfConsoleDirSrc Class Definition //////////////////////////////////////// //// pfConsoleDirSrc Class Definition ////////////////////////////////////////

14
Sources/Plasma/FeatureLib/pfConsole/pfDispatchLog.cpp

@ -48,7 +48,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnKeyedObject/plKey.h" #include "pnKeyedObject/plKey.h"
#include "plString.h" #include "plString.h"
static bool DumpSpecificMsgInfo(plMessage* msg, std::string& info); static bool DumpSpecificMsgInfo(plMessage* msg, plString& info);
plDispatchLog::plDispatchLog() : plDispatchLog::plDispatchLog() :
fLog(nil), fLog(nil),
@ -101,7 +101,7 @@ void plDispatchLog::LogStatusBarChange(const char* name, const char* action)
void plDispatchLog::LogLongReceive(const char* keyname, const char* className, uint32_t clonePlayerID, plMessage* msg, float ms) void plDispatchLog::LogLongReceive(const char* keyname, const char* className, uint32_t clonePlayerID, plMessage* msg, float ms)
{ {
std::string info; plString info;
if (DumpSpecificMsgInfo(msg, info)) if (DumpSpecificMsgInfo(msg, info))
fLog->AddLineF("%-30s[%7u](%-20s) took %6.1f ms to receive %s[%s]\n", keyname, clonePlayerID, className, ms, msg->ClassName(), info.c_str()); fLog->AddLineF("%-30s[%7u](%-20s) took %6.1f ms to receive %s[%s]\n", keyname, clonePlayerID, className, ms, msg->ClassName(), info.c_str());
else else
@ -195,7 +195,7 @@ void plDispatchLog::RemoveFilterExactType(uint16_t type)
#include "plResMgr/plKeyFinder.h" #include "plResMgr/plKeyFinder.h"
#include "plResMgr/plPageInfo.h" #include "plResMgr/plPageInfo.h"
static bool DumpSpecificMsgInfo(plMessage* msg, std::string& info) static bool DumpSpecificMsgInfo(plMessage* msg, plString& info)
{ {
#ifndef PLASMA_EXTERNAL_RELEASE // Don't bloat up the external release with all these strings #ifndef PLASMA_EXTERNAL_RELEASE // Don't bloat up the external release with all these strings
pfKIMsg* kiMsg = pfKIMsg::ConvertNoRef(msg); pfKIMsg* kiMsg = pfKIMsg::ConvertNoRef(msg);
@ -257,7 +257,7 @@ static bool DumpSpecificMsgInfo(plMessage* msg, std::string& info)
PrintKIType(kGZFlashUpdate); // flash an update without saving (for animation of GZFill in) PrintKIType(kGZFlashUpdate); // flash an update without saving (for animation of GZFill in)
PrintKIType(kNoCommand); PrintKIType(kNoCommand);
info = xtl::format("Type: %s Str: %s User: %s(%d) Delay: %f Int: %d", info = plString::Format("Type: %s Str: %s User: %s(%d) Delay: %f Int: %d",
typeName, typeName,
kiMsg->GetString() != "" ? kiMsg->GetString().c_str() : "(nil)", kiMsg->GetString() != "" ? kiMsg->GetString().c_str() : "(nil)",
kiMsg->GetUser() ? kiMsg->GetUser() : "(nil)", kiMsg->GetUser() ? kiMsg->GetUser() : "(nil)",
@ -298,14 +298,14 @@ static bool DumpSpecificMsgInfo(plMessage* msg, std::string& info)
const plPageInfo* pageInfo = plKeyFinder::Instance().GetLocationInfo(loc); const plPageInfo* pageInfo = plKeyFinder::Instance().GetLocationInfo(loc);
if (pageInfo) if (pageInfo)
info += xtl::format("%s-%s ", pageInfo->GetAge(), pageInfo->GetPage()); info += plString::Format("%s-%s ", pageInfo->GetAge(), pageInfo->GetPage());
} }
} }
break; break;
case plClientMsg::kLoadAgeKeys: case plClientMsg::kLoadAgeKeys:
case plClientMsg::kReleaseAgeKeys: case plClientMsg::kReleaseAgeKeys:
info += xtl::format(" - Age: %s", clientMsg->GetAgeName()); info += plString::Format(" - Age: %s", clientMsg->GetAgeName());
break; break;
} }
return true; return true;
@ -321,7 +321,7 @@ static bool DumpSpecificMsgInfo(plMessage* msg, std::string& info)
GetType(kOnRequest); GetType(kOnRequest);
GetType(kOnRemove); GetType(kOnRemove);
GetType(kOnReplace); GetType(kOnReplace);
xtl::format(info, "Obj: %s RefType: %s", refMsg->GetRef()->GetKeyName().c_str(), typeName); info = plString::Format("Obj: %s RefType: %s", refMsg->GetRef()->GetKeyName().c_str(), typeName);
return true; return true;
} }

1
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIEditBoxMod.h

@ -48,7 +48,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#ifndef _pfGUIEditBoxMod_h #ifndef _pfGUIEditBoxMod_h
#define _pfGUIEditBoxMod_h #define _pfGUIEditBoxMod_h
#include "hsStlUtils.h"
#include "pfGUIControlMod.h" #include "pfGUIControlMod.h"
#include "pnInputCore/plKeyDef.h" #include "pnInputCore/plKeyDef.h"

1
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUITextBoxMod.cpp

@ -46,7 +46,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#include "HeadSpin.h" #include "HeadSpin.h"
#include "hsStlUtils.h"
#include "pfGUITextBoxMod.h" #include "pfGUITextBoxMod.h"
#include "pfGameGUIMgr.h" #include "pfGameGUIMgr.h"

1
Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.cpp

@ -51,7 +51,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pfJournalBook.h" #include "pfJournalBook.h"
#include <wchar.h> #include <wchar.h>
#include "hsStlUtils.h"
#include "hsResMgr.h" #include "hsResMgr.h"
#include "pcSmallRect.h" #include "pcSmallRect.h"
#include "plgDispatch.h" #include "plgDispatch.h"

4
Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.h

@ -165,7 +165,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#include "HeadSpin.h" #include "HeadSpin.h"
#include "hsStlUtils.h" #include <map>
#include <string>
#include "hsTemplates.h" #include "hsTemplates.h"
#include "hsColorRGBA.h" #include "hsColorRGBA.h"

2
Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizationDataMgr.h

@ -50,7 +50,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define _pfLocalizationDataMgr_h #define _pfLocalizationDataMgr_h
#include "HeadSpin.h" #include "HeadSpin.h"
#include "hsStlUtils.h" #include <map>
#include "pfLocalizedString.h" #include "pfLocalizedString.h"

1
Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizationMgr.h

@ -50,7 +50,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define _pfLocalizationMgr_h #define _pfLocalizationMgr_h
#include "HeadSpin.h" #include "HeadSpin.h"
#include "hsStlUtils.h"
class pfLocalizationMgr class pfLocalizationMgr
{ {

1
Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizedString.cpp

@ -49,7 +49,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h" #include "HeadSpin.h"
#include "pfLocalizedString.h" #include "pfLocalizedString.h"
// MinGW sucks // MinGW sucks

3
Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizedString.h

@ -51,7 +51,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define _pfLocalizedString_h #define _pfLocalizedString_h
#include "HeadSpin.h" #include "HeadSpin.h"
#include "hsStlUtils.h" #include <vector>
#include <string>
//// pfLocalizedString Class Definition ////////////////////////////// //// pfLocalizedString Class Definition //////////////////////////////

1
Sources/Plasma/FeatureLib/pfMessage/pfKIMsg.h

@ -49,7 +49,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define _pfKIMsg_h #define _pfKIMsg_h
#include "HeadSpin.h" #include "HeadSpin.h"
#include "hsStlUtils.h"
#include "hsStream.h" #include "hsStream.h"
#include "pnMessage/plMessage.h" #include "pnMessage/plMessage.h"

1
Sources/Plasma/FeatureLib/pfPython/Games/Heek/pyHeekMsg.h

@ -49,6 +49,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// PURPOSE: Class wrapper for Heek game messages // PURPOSE: Class wrapper for Heek game messages
// //
#include <string>
#include "../../pyGlueHelpers.h" #include "../../pyGlueHelpers.h"
#include "../pyGameCliMsg.h" #include "../pyGameCliMsg.h"

1
Sources/Plasma/FeatureLib/pfPython/Games/Marker/pyMarkerMsg.h

@ -49,6 +49,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// PURPOSE: Class wrapper for Marker game messages // PURPOSE: Class wrapper for Marker game messages
// //
#include <string>
#include "../../pyGlueHelpers.h" #include "../../pyGlueHelpers.h"
#include "../pyGameCliMsg.h" #include "../pyGameCliMsg.h"

1
Sources/Plasma/FeatureLib/pfPython/Games/VarSync/pyVarSyncMsg.h

@ -49,6 +49,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// PURPOSE: Class wrapper for VarSync game messages // PURPOSE: Class wrapper for VarSync game messages
// //
#include <string>
#include "../../pyGlueHelpers.h" #include "../../pyGlueHelpers.h"
#include "../pyGameCliMsg.h" #include "../pyGameCliMsg.h"

3
Sources/Plasma/FeatureLib/pfPython/Pch.h

@ -52,6 +52,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <algorithm> #include <algorithm>
#include <exception> #include <exception>
#include <locale> #include <locale>
#include <string>
// Platform Library Includes // Platform Library Includes
#include <time.h> #include <time.h>
@ -69,8 +70,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsGeometry3.h" #include "hsGeometry3.h"
#include "hsQuat.h" #include "hsQuat.h"
#include "hsResMgr.h" #include "hsResMgr.h"
#include "hsStlSortUtils.h"
#include "hsStlUtils.h"
#include "hsStream.h" #include "hsStream.h"
#include "hsTemplates.h" #include "hsTemplates.h"
#include "hsTimer.h" #include "hsTimer.h"

1
Sources/Plasma/FeatureLib/pfPython/cyAccountManagement.h

@ -50,6 +50,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// //
#include <vector> #include <vector>
#include <string>
typedef struct _object PyObject; typedef struct _object PyObject;
typedef struct PyMethodDef PyMethodDef; typedef struct PyMethodDef PyMethodDef;

2
Sources/Plasma/FeatureLib/pfPython/cyAvatar.h

@ -48,7 +48,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// //
// PURPOSE: Class wrapper to map animation functions to plasma2 message // PURPOSE: Class wrapper to map animation functions to plasma2 message
// //
#include "hsStlUtils.h" #include <string>
#include "hsTemplates.h" #include "hsTemplates.h"
#include "pnKeyedObject/plKey.h" #include "pnKeyedObject/plKey.h"

1
Sources/Plasma/FeatureLib/pfPython/cyMisc.h

@ -59,6 +59,7 @@ class pyPoint3;
#include "HeadSpin.h" #include "HeadSpin.h"
#include <vector> #include <vector>
#include <string>
class pyGUIDialog; class pyGUIDialog;
class plPipeline; class plPipeline;

2
Sources/Plasma/FeatureLib/pfPython/cyPythonInterface.h

@ -47,8 +47,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// only be one instance of this interface. // only be one instance of this interface.
// //
#include "HeadSpin.h" #include "HeadSpin.h"
#include "hsStlUtils.h"
#include "plString.h" #include "plString.h"
#include <string>
#if defined(HAVE_CYPYTHONIDE) && !defined(PLASMA_EXTERNAL_RELEASE) #if defined(HAVE_CYPYTHONIDE) && !defined(PLASMA_EXTERNAL_RELEASE)
#include "../../Apps/CyPythonIDE/plCyDebug/plCyDebServer.h" #include "../../Apps/CyPythonIDE/plCyDebug/plCyDebServer.h"

5
Sources/Plasma/FeatureLib/pfPython/plPythonPack.cpp

@ -45,11 +45,10 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <time.h> #include <time.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <string>
#include "HeadSpin.h" #include "HeadSpin.h"
#include "hsStlUtils.h"
#include "hsStream.h" #include "hsStream.h"
#include "hsStlSortUtils.h"
#pragma hdrstop #pragma hdrstop
#include "plPythonPack.h" #include "plPythonPack.h"
@ -219,7 +218,7 @@ PyObject* plPythonPack::OpenPacked(const char* fileName)
{ {
char *buf = new char[size]; char *buf = new char[size];
uint32_t readSize = fPackStream->Read(size, buf); uint32_t readSize = fPackStream->Read(size, buf);
hsAssert(readSize <= size, xtl::format("Python PackFile %s: Incorrect amount of data, read %d instead of %d", hsAssert(readSize <= size, plString::Format("Python PackFile %s: Incorrect amount of data, read %d instead of %d",
fileName, readSize, size).c_str()); fileName, readSize, size).c_str());
// let the python marshal make it back into a code object // let the python marshal make it back into a code object

2
Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.h

@ -46,7 +46,7 @@ class plPythonFileMod;
class plStateDataRecord; class plStateDataRecord;
class plSimpleStateVariable; class plSimpleStateVariable;
#include "hsStlUtils.h" #include <map>
#include "plModifier/plSDLModifier.h" #include "plModifier/plSDLModifier.h"
#include "pyGlueHelpers.h" #include "pyGlueHelpers.h"

1
Sources/Plasma/FeatureLib/pfPython/pyAgeInfoStruct.cpp

@ -41,6 +41,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/ *==LICENSE==*/
#include <Python.h> #include <Python.h>
#include <string>
#pragma hdrstop #pragma hdrstop
#include "pyAgeInfoStruct.h" #include "pyAgeInfoStruct.h"

1
Sources/Plasma/FeatureLib/pfPython/pyAgeInfoStruct.h

@ -42,7 +42,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#ifndef pyAgeInfoStruct_h_inc #ifndef pyAgeInfoStruct_h_inc
#define pyAgeInfoStruct_h_inc #define pyAgeInfoStruct_h_inc
#include "hsStlUtils.h"
#include "plNetCommon/plNetServerSessionInfo.h" #include "plNetCommon/plNetServerSessionInfo.h"
#include "pyGlueHelpers.h" #include "pyGlueHelpers.h"

1
Sources/Plasma/FeatureLib/pfPython/pyCCRMgr.h

@ -49,7 +49,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
#include "HeadSpin.h" #include "HeadSpin.h"
#include "hsStlUtils.h"
#include "pfCCR/plCCRMgr.h" #include "pfCCR/plCCRMgr.h"

1
Sources/Plasma/FeatureLib/pfPython/pyEnum.cpp

@ -49,7 +49,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <Python.h> #include <Python.h>
#include <structmember.h> #include <structmember.h>
#include "hsStlUtils.h"
#include "pyGlueHelpers.h" #include "pyGlueHelpers.h"
#pragma hdrstop #pragma hdrstop

1
Sources/Plasma/FeatureLib/pfPython/pyJournalBook.h

@ -50,6 +50,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pyGlueHelpers.h" #include "pyGlueHelpers.h"
#include <vector> #include <vector>
#include <string>
class cyAnimation; class cyAnimation;
class pyImage; class pyImage;

3
Sources/Plasma/FeatureLib/pfPython/pySDL.h

@ -49,7 +49,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
#include "HeadSpin.h" #include "HeadSpin.h"
#include "hsStlUtils.h" #include <vector>
#include "pyGlueHelpers.h" #include "pyGlueHelpers.h"
class plStateDataRecord; class plStateDataRecord;

1
Sources/Plasma/NucleusLib/inc/plPipeline.h

@ -46,7 +46,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnFactory/plCreatable.h" #include "pnFactory/plCreatable.h"
#include "hsGMatState.h" #include "hsGMatState.h"
#include "hsTemplates.h" #include "hsTemplates.h"
#include "hsStlUtils.h"
#define MIN_WIDTH 640 #define MIN_WIDTH 640
#define MIN_HEIGHT 480 #define MIN_HEIGHT 480

3
Sources/Plasma/NucleusLib/inc/plProfileManager.h

@ -43,7 +43,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define plProfileManager_h_inc #define plProfileManager_h_inc
#include "HeadSpin.h" #include "HeadSpin.h"
#include "hsStlUtils.h" #include <vector>
#include "plProfile.h" #include "plProfile.h"
class plProfileManager class plProfileManager

2
Sources/Plasma/NucleusLib/pnDispatch/plDispatch.cpp

@ -331,7 +331,7 @@ void plDispatch::IMsgDispatch()
if (plNetObjectDebuggerBase::GetInstance()->IsDebugObject(ko)) if (plNetObjectDebuggerBase::GetInstance()->IsDebugObject(ko))
{ {
hsLogEntry(plNetObjectDebuggerBase::GetInstance()->LogMsg( hsLogEntry(plNetObjectDebuggerBase::GetInstance()->LogMsg(
xtl::format("<RCV> object:%s, GameMessage %s st=%.3f rt=%.3f", plString::Format("<RCV> object:%s, GameMessage %s st=%.3f rt=%.3f",
ko->GetKeyName().c_str(), msg->ClassName(), hsTimer::GetSysSeconds(), hsTimer::GetSeconds()).c_str())); ko->GetKeyName().c_str(), msg->ClassName(), hsTimer::GetSysSeconds(), hsTimer::GetSeconds()).c_str()));
} }
} }

2
Sources/Plasma/NucleusLib/pnDispatch/plDispatch.h

@ -42,8 +42,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#ifndef plDispatch_inc #ifndef plDispatch_inc
#define plDispatch_inc #define plDispatch_inc
#include <list>
#include "hsTemplates.h" #include "hsTemplates.h"
#include "hsStlUtils.h"
#include "plgDispatch.h" #include "plgDispatch.h"
#include "hsThread.h" #include "hsThread.h"
#include "pnKeyedObject/hsKeyedObject.h" #include "pnKeyedObject/hsKeyedObject.h"

2
Sources/Plasma/NucleusLib/pnKeyedObject/plMsgForwarder.h

@ -42,9 +42,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#ifndef plMsgForwarder_h_inc #ifndef plMsgForwarder_h_inc
#define plMsgForwarder_h_inc #define plMsgForwarder_h_inc
#include <map>
#include "hsKeyedObject.h" #include "hsKeyedObject.h"
#include "hsTemplates.h" #include "hsTemplates.h"
#include "hsStlUtils.h"
class plMessageWithCallbacks; class plMessageWithCallbacks;

1
Sources/Plasma/NucleusLib/pnMessage/plClientMsg.h

@ -47,7 +47,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsStream.h" #include "hsStream.h"
#include "hsResMgr.h" #include "hsResMgr.h"
#include "hsStlUtils.h"
#include "pnKeyedObject/plUoid.h" #include "pnKeyedObject/plUoid.h"
// //

39
Sources/Plasma/NucleusLib/pnMessage/plMessage.cpp

@ -280,7 +280,7 @@ int plMsgStdStringHelper::Peek(std::string & stringref, hsStream* stream, const
stringref.resize(strlen); stringref.resize(strlen);
if (strlen){ if (strlen){
stream->LogRead(strlen,(void*)stringref.data(),"StdString"); stream->LogRead(strlen,(void*)stringref.data(),"StdString");
stream->LogStringString(xtl::format("Value: %s", stringref.data()).c_str()); stream->LogStringString(plString::Format("Value: %s", stringref.data()).c_str());
} }
} }
else else
@ -302,7 +302,7 @@ int plMsgStdStringHelper::PeekBig(std::string & stringref, hsStream* stream, co
stringref.resize(bufsz); stringref.resize(bufsz);
if (bufsz){ if (bufsz){
stream->LogRead(bufsz,(void*)stringref.data(),"StdString"); stream->LogRead(bufsz,(void*)stringref.data(),"StdString");
stream->LogStringString(xtl::format("Value: %s", stringref.data()).c_str()); stream->LogStringString(plString::Format("Value: %s", stringref.data()).c_str());
} }
} }
else else
@ -329,39 +329,6 @@ int plMsgStdStringHelper::PeekBig(plString & stringref, hsStream* stream, const
return pos; return pos;
} }
/////////////////////////////////////////////////////////////////
// STATIC
int plMsgXtlStringHelper::Poke(const xtl::istring & stringref, hsStream* stream, const uint32_t peekOptions)
{
plMessage::plStrLen strlen;
strlen = stringref.length();
stream->WriteLE(strlen);
if (strlen)
stream->Write(strlen,stringref.data());
return stream->GetPosition();
}
// STATIC
int plMsgXtlStringHelper::Peek(xtl::istring & stringref, hsStream* stream, const uint32_t peekOptions)
{
plMessage::plStrLen strlen;
stream->LogSubStreamStart("push me");
stream->LogReadLE(&strlen,"StrLen");
stringref.erase();
if (strlen <= stream->GetSizeLeft())
{
stringref.resize(strlen);
if (strlen){
stream->LogRead(strlen,(void*)stringref.data(),"XtlString");
stream->LogStringString(xtl::format("Value: %s", stringref.data()).c_str());
}
}
stream->LogSubStreamEnd();
return stream->GetPosition();
}
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// STATIC // STATIC
@ -390,7 +357,7 @@ int plMsgCStringHelper::Peek(char *& str, hsStream* stream, const uint32_t peekO
str[strlen] = '\0'; str[strlen] = '\0';
if (strlen) { if (strlen) {
stream->LogRead(strlen,str,"CString"); stream->LogRead(strlen,str,"CString");
stream->LogStringString(xtl::format("Value: %s",str).c_str()); stream->LogStringString(plString::Format("Value: %s",str).c_str());
} }
} }
} }

13
Sources/Plasma/NucleusLib/pnMessage/plMessage.h

@ -43,10 +43,10 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#ifndef plMessage_inc #ifndef plMessage_inc
#define plMessage_inc #define plMessage_inc
#include <string>
#include "pnFactory/plCreatable.h" #include "pnFactory/plCreatable.h"
#include "pnKeyedObject/plKey.h" #include "pnKeyedObject/plKey.h"
#include "hsTemplates.h" #include "hsTemplates.h"
#include "hsStlUtils.h"
class plKey; class plKey;
class hsStream; class hsStream;
@ -157,8 +157,8 @@ public:
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Helpers for reading/writing these types: // Helpers for reading/writing these types:
// plString
// std::string // std::string
// xtl::istring
// c strings (char *) // c strings (char *)
// c arrays (type []) // c arrays (type [])
@ -180,15 +180,6 @@ struct plMsgStdStringHelper
static int PeekBig(plString & stringref, hsStream* stream, const uint32_t peekOptions=0); static int PeekBig(plString & stringref, hsStream* stream, const uint32_t peekOptions=0);
}; };
/////////////////////////////////////////////////////////////////
// reads/writes your xtl::istring field
struct plMsgXtlStringHelper
{
static int Poke(const xtl::istring & stringref, hsStream* stream, const uint32_t peekOptions=0);
static int Peek(xtl::istring & stringref, hsStream* stream, const uint32_t peekOptions=0);
};
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// reads/writes your char * field (deprecated) // reads/writes your char * field (deprecated)

32
Sources/Plasma/NucleusLib/pnNetCommon/plGenericVar.cpp

@ -42,7 +42,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsStream.h" #include "hsStream.h"
#include "plGenericVar.h" #include "plGenericVar.h"
#include "hsMemory.h" #include "hsMemory.h"
#include "hsStlUtils.h"
////////////////////////////////////////////////////// //////////////////////////////////////////////////////
// plGenericType // plGenericType
@ -317,45 +316,28 @@ void plGenericType::SetVar(Types t, unsigned int size, void* val)
} }
std::string plGenericType::GetAsStdString() const plString plGenericType::GetAsString() const
{ {
std::string s;
switch (fType) switch (fType)
{ {
case kInt : case kInt :
{ return plString::Format("%d", fI);
xtl::format(s,"%d",fI);
break;
}
case kBool : case kBool :
case kUInt : case kUInt :
{ return plString::Format("%u", fType==kBool?fB:fU);
xtl::format(s,"%u",fType==kBool?fB:fU);
break;
}
case kFloat : case kFloat :
case kDouble : case kDouble :
{ return plString::Format("%f", fType==kDouble?fD:fF);
xtl::format(s,"%f",fType==kDouble?fD:fF);
break;
}
case kChar : case kChar :
{ return plString::Format("%c", fC);
xtl::format(s,"%c",fC);
break;
}
case kAny : case kAny :
case kString : case kString :
{ return fS;
s = fS;
break;
}
case kNone : case kNone :
break; break;
default: default:
hsAssert(false,"plGenericType::GetAsStdString unknown type"); hsAssert(false,"plGenericType::GetAsStdString unknown type");
} }
return s; return plString::Null;
} }

3
Sources/Plasma/NucleusLib/pnNetCommon/plGenericVar.h

@ -44,7 +44,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h" #include "HeadSpin.h"
#include "hsStlUtils.h"
#include "pnFactory/plCreatable.h" #include "pnFactory/plCreatable.h"
class hsStream; class hsStream;
@ -117,7 +116,7 @@ public:
void SetType(Types t) { fType=t; } void SetType(Types t) { fType=t; }
uint8_t GetType( void ) const { return fType; } uint8_t GetType( void ) const { return fType; }
std::string GetAsStdString() const; plString GetAsString() const;
// implicit set // implicit set
void Set( int32_t i ) { fI = i; fType = kInt; } void Set( int32_t i ) { fI = i; fType = kInt; }

1
Sources/Plasma/NucleusLib/pnNetCommon/plNetAddress.h

@ -48,7 +48,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsWindows.h" // FIXME #include "hsWindows.h" // FIXME
#include "plString.h" #include "plString.h"
#include "hsStlUtils.h"
#include "hsStream.h" #include "hsStream.h"
#if defined(HS_BUILD_FOR_WIN32) #if defined(HS_BUILD_FOR_WIN32)

1
Sources/Plasma/NucleusLib/pnNetCommon/plNetApp.cpp

@ -40,7 +40,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/ *==LICENSE==*/
#include "plNetApp.h" #include "plNetApp.h"
#include "hsStlUtils.h"
#include "pnMessage/plMessage.h" #include "pnMessage/plMessage.h"
plNetApp* plNetApp::fInstance = nil; plNetApp* plNetApp::fInstance = nil;

3
Sources/Plasma/NucleusLib/pnNetCommon/plNetApp.h

@ -43,7 +43,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define plNetApp_h #define plNetApp_h
#include "HeadSpin.h" #include "HeadSpin.h"
#include "hsStlUtils.h"
#include "hsBitVector.h" #include "hsBitVector.h"
#include "plNetGroup.h" #include "plNetGroup.h"
@ -192,7 +191,7 @@ public:
virtual int IsLocallyOwned(const plUoid&) const { hsAssert(false, "stub"); return 0; } virtual int IsLocallyOwned(const plUoid&) const { hsAssert(false, "stub"); return 0; }
virtual plNetGroupId GetEffectiveNetGroup(const plSynchedObject* obj) const { hsAssert(false, "stub"); return plNetGroup::kNetGroupUnknown; } virtual plNetGroupId GetEffectiveNetGroup(const plSynchedObject* obj) const { hsAssert(false, "stub"); return plNetGroup::kNetGroupUnknown; }
virtual int Update(double secs) { return hsOK;} virtual int Update(double secs) { return hsOK;}
virtual const char* GetServerLogTimeAsString(std::string& ts) const { hsAssert(false, "stub"); return nil; } virtual const char* GetServerLogTimeAsString(plString& ts) const { hsAssert(false, "stub"); return nil; }
virtual plUoid GetAgeSDLObjectUoid(const char* ageName) const { hsAssert(false, "stub"); return plUoid(); } virtual plUoid GetAgeSDLObjectUoid(const char* ageName) const { hsAssert(false, "stub"); return plUoid(); }
virtual void StayAlive(double secs) {} virtual void StayAlive(double secs) {}
virtual void QueueDisableNet( bool showDlg, const char msg[] ) {} virtual void QueueDisableNet( bool showDlg, const char msg[] ) {}

2
Sources/Plasma/NucleusLib/pnNetCommon/plNetGroup.h

@ -42,9 +42,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#ifndef plNetGroup_h #ifndef plNetGroup_h
#define plNetGroup_h #define plNetGroup_h
#include <string>
#include "pnKeyedObject/plUoid.h" #include "pnKeyedObject/plUoid.h"
#include "hsStream.h" #include "hsStream.h"
#include "hsStlUtils.h"
class plNetGroupId class plNetGroupId
{ {

3
Sources/Plasma/NucleusLib/pnNetCommon/plNetSharedState.h

@ -43,8 +43,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define plNetSharedState_inc #define plNetSharedState_inc
#include "HeadSpin.h" #include "HeadSpin.h"
#include <string>
#include "hsStlUtils.h"
class hsStream; class hsStream;

1
Sources/Plasma/NucleusLib/pnNetCommon/plSynchedObject.h

@ -45,7 +45,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h" #include "HeadSpin.h"
#include "pnKeyedObject/hsKeyedObject.h" #include "pnKeyedObject/hsKeyedObject.h"
#include "pnKeyedObject/plKey.h" #include "pnKeyedObject/plKey.h"
#include "hsStlUtils.h"
#include "plNetGroup.h" #include "plNetGroup.h"
///////////////////////////////////// /////////////////////////////////////

1
Sources/Plasma/NucleusLib/pnNetCommon/pnNetCommon.cpp

@ -39,6 +39,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
Mead, WA 99021 Mead, WA 99021
*==LICENSE==*/ *==LICENSE==*/
#include <string>
#include "pnNetCommon.h" #include "pnNetCommon.h"
#include "hsWindows.h" #include "hsWindows.h"

1
Sources/Plasma/NucleusLib/pnProduct/Private/pnPrProductId.cpp

@ -46,6 +46,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
***/ ***/
#include "../Pch.h" #include "../Pch.h"
#include <wchar.h>
#pragma hdrstop #pragma hdrstop

1
Sources/Plasma/NucleusLib/pnUUID/pnUUID.h

@ -43,7 +43,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define pnUUID_h_inc #define pnUUID_h_inc
#include "HeadSpin.h" #include "HeadSpin.h"
#include "hsStlUtils.h"
#include "pnUtils/pnUtUuid.h" #include "pnUtils/pnUtUuid.h"
class hsStream; class hsStream;

3
Sources/Plasma/PubUtilLib/plAgeDescription/plAgeDescription.cpp

@ -43,7 +43,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsStream.h" #include "hsStream.h"
#include "plAgeDescription.h" #include "plAgeDescription.h"
#include "hsStlUtils.h"
#include "plFile/hsFiles.h" #include "plFile/hsFiles.h"
#include "plFile/plInitFileReader.h" #include "plFile/plInitFileReader.h"
#include "plFile/plEncryptedStream.h" #include "plFile/plEncryptedStream.h"
@ -162,7 +161,7 @@ char *plAgePage::GetAsString( void ) const
// //
// static // static
char plAgeDescription::kAgeDescPath[]={"dat"PATH_SEPARATOR_STR}; char plAgeDescription::kAgeDescPath[] = { "dat" PATH_SEPARATOR_STR };
const char* plAgeDescription::fCommonPages[] = { "Textures", "BuiltIn" }; const char* plAgeDescription::fCommonPages[] = { "Textures", "BuiltIn" };
// Also gotta init the separators for our helper reading function // Also gotta init the separators for our helper reading function

1
Sources/Plasma/PubUtilLib/plAgeLoader/plAgeLoader.h

@ -43,7 +43,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define plAgeLoader_h #define plAgeLoader_h
#include "HeadSpin.h" #include "HeadSpin.h"
#include "hsStlUtils.h"
#include "pnUtils/pnUtils.h" #include "pnUtils/pnUtils.h"
#include "pnNetBase/pnNetBase.h" #include "pnNetBase/pnNetBase.h"

34
Sources/Plasma/PubUtilLib/plAgeLoader/plResPatcher.cpp

@ -69,19 +69,19 @@ public:
fIsZipped = wcscmp(plFileUtils::GetFileExt(reqFile), L"gz") == 0; fIsZipped = wcscmp(plFileUtils::GetFileExt(reqFile), L"gz") == 0;
} }
~plResDownloadStream() virtual ~plResDownloadStream()
{ {
if (fFilename) if (fFilename)
delete[] fFilename; delete[] fFilename;
} }
bool Open(const char* filename, const char* mode) virtual bool Open(const char* filename, const char* mode)
{ {
fFilename = hsStrcpy(filename); fFilename = hsStrcpy(filename);
return plZlibStream::Open(filename, mode); return plZlibStream::Open(filename, mode);
} }
uint32_t Write(uint32_t count, const void* buf) virtual uint32_t Write(uint32_t count, const void* buf)
{ {
fProgress->Increment((float)count); fProgress->Increment((float)count);
if (fIsZipped) if (fIsZipped)
@ -231,37 +231,33 @@ void plResPatcher::IssueRequest()
Request req = fRequests.front(); Request req = fRequests.front();
fRequests.pop(); fRequests.pop();
std::wstring title; plString title;
if (req.fType == kManifest) if (req.fType == kManifest)
{ {
char* eapSucksString = hsWStringToString(req.fFile.c_str()); PatcherLog(kMajorStatus, " Downloading manifest... %S", req.fFile.c_str());
PatcherLog(kMajorStatus, " Downloading manifest... %s", eapSucksString); title = plString::Format("Checking %S for updates...", req.fFile.c_str());
xtl::format(title, L"Checking %s for updates...", req.fFile.c_str());
NetCliFileManifestRequest(ManifestDownloaded, this, req.fFile.c_str()); NetCliFileManifestRequest(ManifestDownloaded, this, req.fFile.c_str());
delete[] eapSucksString;
} else if (req.fType == kFile) { } else if (req.fType == kFile) {
char* eapSucksString = hsWStringToString(req.fFriendlyName.c_str()); PatcherLog(kMajorStatus, " Downloading file... %S", req.fFriendlyName.c_str());
PatcherLog(kMajorStatus, " Downloading file... %s", eapSucksString); title = plString::Format("Downloading... %S", plFileUtils::GetFileName(req.fFriendlyName.c_str()));
xtl::format(title, L"Downloading... %s", plFileUtils::GetFileName(req.fFriendlyName.c_str()));
// If this is a PRP, we need to unload it from the ResManager // If this is a PRP, we need to unload it from the ResManager
if (stricmp(plFileUtils::GetFileExt(eapSucksString), "prp") == 0)
((plResManager*)hsgResMgr::ResMgr())->RemoveSinglePage(eapSucksString); plString filename = plString::FromWchar(req.fFriendlyName.c_str());
if (stricmp(plFileUtils::GetFileExt(filename.c_str()), "prp") == 0)
((plResManager*)hsgResMgr::ResMgr())->RemoveSinglePage(filename.c_str());
plFileUtils::EnsureFilePathExists(req.fFriendlyName.c_str()); plFileUtils::EnsureFilePathExists(req.fFriendlyName.c_str());
plResDownloadStream* stream = new plResDownloadStream(fProgress, req.fFile.c_str()); plResDownloadStream* stream = new plResDownloadStream(fProgress, req.fFile.c_str());
if(stream->Open(eapSucksString, "wb")) if (stream->Open_TEMP(filename, "wb"))
NetCliFileDownloadRequest(req.fFile.c_str(), stream, FileDownloaded, this); NetCliFileDownloadRequest(req.fFile.c_str(), stream, FileDownloaded, this);
else { else {
PatcherLog(kError, " Unable to create file %s", eapSucksString); PatcherLog(kError, " Unable to create file %s", filename.c_str());
Finish(false); Finish(false);
} }
delete[] eapSucksString;
} }
char* hack = hsWStringToString(title.c_str()); fProgress->SetTitle(title.c_str());
fProgress->SetTitle(hack);
delete[] hack;
} }
} }

3
Sources/Plasma/PubUtilLib/plAudio/plAudioSystem.h

@ -43,7 +43,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define plAudioSystem_h #define plAudioSystem_h
#include "HeadSpin.h" #include "HeadSpin.h"
#include "hsStlUtils.h" #include <string>
#include "hsTemplates.h" #include "hsTemplates.h"
#include "hsGeometry3.h" #include "hsGeometry3.h"
#include "pnKeyedObject/hsKeyedObject.h" #include "pnKeyedObject/hsKeyedObject.h"

2
Sources/Plasma/PubUtilLib/plAudio/plDSoundBuffer.h

@ -50,7 +50,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#ifndef _plDSoundBuffer_h #ifndef _plDSoundBuffer_h
#define _plDSoundBuffer_h #define _plDSoundBuffer_h
#include "hsStlUtils.h" #include <list>
#include "hsTemplates.h" #include "hsTemplates.h"
#include "plEAXEffects.h" #include "plEAXEffects.h"
#define STREAMING_BUFFERS 16 #define STREAMING_BUFFERS 16

2
Sources/Plasma/PubUtilLib/plAudioCore/plWavFile.h

@ -48,7 +48,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h" #include "HeadSpin.h"
#include "hsStlUtils.h" #include <vector>
#include "hsWindows.h" // FIXME #include "hsWindows.h" // FIXME
#include <mmsystem.h> #include <mmsystem.h>
#include "plAudioFileReader.h" #include "plAudioFileReader.h"

3
Sources/Plasma/PubUtilLib/plAvatar/plAGAnim.h

@ -50,9 +50,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*/ */
#pragma warning(disable: 4786) // don't care if mangled names are longer than 255 characters #pragma warning(disable: 4786) // don't care if mangled names are longer than 255 characters
#include <map>
#include "pnNetCommon/plSynchedObject.h" #include "pnNetCommon/plSynchedObject.h"
#include "hsStlUtils.h"
#include "hsStlSortUtils.h"
class plTMController; class plTMController;
class hsAffineParts; class hsAffineParts;

5
Sources/Plasma/PubUtilLib/plAvatar/plAGAnimInstance.h

@ -53,9 +53,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// disable warning C4786: symbol greater than 255 characters, // disable warning C4786: symbol greater than 255 characters,
#pragma warning(disable: 4503 4786) #pragma warning(disable: 4503 4786)
// templates #include "HeadSpin.h"
#include "hsStlUtils.h" #include <map>
#include "hsStlSortUtils.h"
// local // local
#include "plScalarChannel.h" #include "plScalarChannel.h"

4
Sources/Plasma/PubUtilLib/plAvatar/plAGMasterMod.h

@ -58,10 +58,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plAvDefs.h" #include "plAvDefs.h"
#include "pnKeyedObject/plMsgForwarder.h" #include "pnKeyedObject/plMsgForwarder.h"
// templates
#include "hsStlUtils.h"
#include "hsStlSortUtils.h"
class plAGModifier; class plAGModifier;
class plAGAnimInstance; class plAGAnimInstance;

4
Sources/Plasma/PubUtilLib/plAvatar/plAGModifier.h

@ -53,10 +53,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// local // local
#include "plAvatar/plScalarChannel.h" #include "plAvatar/plScalarChannel.h"
// stl
#include "hsStlUtils.h"
#include "hsStlSortUtils.h"
class plSceneObject; class plSceneObject;
class plAGAnimInstance; class plAGAnimInstance;

2
Sources/Plasma/PubUtilLib/plAvatar/plAnimStage.cpp

@ -54,11 +54,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// global // global
#include "hsStlUtils.h"
#include "hsResMgr.h" #include "hsResMgr.h"
#include "hsTimer.h" #include "hsTimer.h"
#include <cstdio> #include <cstdio>
#include <cmath>
// other // other
#include "pnSceneObject/plSceneObject.h" #include "pnSceneObject/plSceneObject.h"

2
Sources/Plasma/PubUtilLib/plAvatar/plAnimStage.h

@ -47,8 +47,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#ifndef PL_ANIM_STAGE_INC #ifndef PL_ANIM_STAGE_INC
#define PL_ANIM_STAGE_INC #define PL_ANIM_STAGE_INC
#include <vector>
#include "hsMatrix44.h" #include "hsMatrix44.h"
#include "hsStlUtils.h"
#include "pnFactory/plCreatable.h" #include "pnFactory/plCreatable.h"
class plMessage; class plMessage;

2
Sources/Plasma/PubUtilLib/plAvatar/plAvBehaviors.cpp

@ -39,6 +39,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
Mead, WA 99021 Mead, WA 99021
*==LICENSE==*/ *==LICENSE==*/
#include <cmath>
#include "plAvBehaviors.h" #include "plAvBehaviors.h"
#include "plAvBrainHuman.h" #include "plAvBrainHuman.h"
#include "plArmatureMod.h" #include "plArmatureMod.h"

1
Sources/Plasma/PubUtilLib/plAvatar/plAvBrainCoop.h

@ -42,7 +42,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#ifndef PLAVBRAINGENERIC_H #ifndef PLAVBRAINGENERIC_H
#define PLAVBRAINGENERIC_H #define PLAVBRAINGENERIC_H
#include "hsStlUtils.h"
#include "plAvBrainGeneric.h" #include "plAvBrainGeneric.h"
/** \class plAvBrainCoop /** \class plAvBrainCoop

1
Sources/Plasma/PubUtilLib/plAvatar/plAvBrainCritter.h

@ -42,6 +42,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#ifndef PL_AV_BRAIN_CRITTER_H #ifndef PL_AV_BRAIN_CRITTER_H
#define PL_AV_BRAIN_CRITTER_H #define PL_AV_BRAIN_CRITTER_H
#include <map>
#include "plAvBrain.h" #include "plAvBrain.h"
#include "hsTemplates.h" #include "hsTemplates.h"
#include "pnKeyedObject/plKey.h" #include "pnKeyedObject/plKey.h"

1
Sources/Plasma/PubUtilLib/plAvatar/plAvBrainHuman.cpp

@ -41,6 +41,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/ *==LICENSE==*/
#include "HeadSpin.h" #include "HeadSpin.h"
#include <cmath>
#include "plPhysicalControllerCore.h" #include "plPhysicalControllerCore.h"
#include "plAvBrainHuman.h" #include "plAvBrainHuman.h"

2
Sources/Plasma/PubUtilLib/plAvatar/plAvBrainSwim.cpp

@ -46,6 +46,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// //
///////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////
#include <cmath>
// singular // singular
#include "plAvBrainSwim.h" #include "plAvBrainSwim.h"

1
Sources/Plasma/PubUtilLib/plAvatar/plAvLadderModifier.cpp

@ -42,6 +42,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plPhysicalControllerCore.h" #include "plPhysicalControllerCore.h"
#include "HeadSpin.h" #include "HeadSpin.h"
#include <cmath>
// singular // singular
#include "plAvLadderModifier.h" #include "plAvLadderModifier.h"

2
Sources/Plasma/PubUtilLib/plAvatar/plAvTaskSeek.cpp

@ -46,6 +46,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// //
///////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////
#include <cmath>
// singular // singular
#include "plAvTaskSeek.h" #include "plAvTaskSeek.h"

5
Sources/Plasma/PubUtilLib/plAvatar/plAvatarMgr.h

@ -45,8 +45,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#ifndef PLAVATARMGR_INC #ifndef PLAVATARMGR_INC
#define PLAVATARMGR_INC #define PLAVATARMGR_INC
#include "hsStlUtils.h" #include "HeadSpin.h"
#include "hsStlSortUtils.h" #include <map>
#include "hsGeometry3.h" #include "hsGeometry3.h"
#include "pnKeyedObject/hsKeyedObject.h" #include "pnKeyedObject/hsKeyedObject.h"

1
Sources/Plasma/PubUtilLib/plAvatar/plAvatarSDLModifier.h

@ -43,7 +43,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define plAvatarSDLModifier_inc #define plAvatarSDLModifier_inc
#include "HeadSpin.h" #include "HeadSpin.h"
#include "hsStlUtils.h"
#include "plModifier/plSDLModifier.h" #include "plModifier/plSDLModifier.h"

4
Sources/Plasma/PubUtilLib/plAvatar/plCritterCommands.h

@ -43,8 +43,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#ifndef __PLCRITTERCMDS_H__ #ifndef __PLCRITTERCMDS_H__
#define __PLCRITTERCMDS_H__ #define __PLCRITTERCMDS_H__
#include "hsStlUtils.h" #include <vector>
#include <string>
typedef std::vector<std::string> VCharArray; typedef std::vector<std::string> VCharArray;

2
Sources/Plasma/PubUtilLib/plAvatar/plMatrixChannel.cpp

@ -50,6 +50,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
//#include <hkmath/quaternion.h> //#include <hkmath/quaternion.h>
//#include <hkmath/quaternion.h> //#include <hkmath/quaternion.h>
#include <cmath>
// singular // singular
#include "plMatrixChannel.h" #include "plMatrixChannel.h"

1
Sources/Plasma/PubUtilLib/plAvatar/plMultistageBehMod.h

@ -43,7 +43,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define plMultistageBehMod_h_inc #define plMultistageBehMod_h_inc
#include "pnModifier/plSingleModifier.h" #include "pnModifier/plSingleModifier.h"
#include "hsStlUtils.h"
class plAnimStageVec; class plAnimStageVec;

2
Sources/Plasma/PubUtilLib/plAvatar/plPhysicalControllerCore.cpp

@ -39,6 +39,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
Mead, WA 99021 Mead, WA 99021
*==LICENSE==*/ *==LICENSE==*/
#include <cmath>
#include "plPhysicalControllerCore.h" #include "plPhysicalControllerCore.h"
#include "plArmatureMod.h" #include "plArmatureMod.h"

2
Sources/Plasma/PubUtilLib/plAvatar/plSwimRegion.cpp

@ -39,6 +39,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
Mead, WA 99021 Mead, WA 99021
*==LICENSE==*/ *==LICENSE==*/
#include <cmath>
#include "hsGeometry3.h" #include "hsGeometry3.h"
#include "hsResMgr.h" #include "hsResMgr.h"

2
Sources/Plasma/PubUtilLib/plCompression/plZlibStream.h

@ -43,7 +43,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define plZlibStream_h_inc #define plZlibStream_h_inc
#include "hsStream.h" #include "hsStream.h"
#include "hsStlUtils.h" #include <string>
// //
// This is for reading a .gz file from a buffer, and writing the uncompressed data to a file. // This is for reading a .gz file from a buffer, and writing the uncompressed data to a file.

284
Sources/Plasma/PubUtilLib/plContainer/plConfigInfo.cpp

@ -42,15 +42,14 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plConfigInfo.h" #include "plConfigInfo.h"
#include "HeadSpin.h" #include "HeadSpin.h"
#include "hsStlUtils.h"
#include <fstream> #include <fstream>
#include <algorithm> #include <algorithm>
#include <stdarg.h> #include <stdarg.h>
#include <sstream> #include <sstream>
const std::string& plConfigInfo::GlobalSection() const plString& plConfigInfo::GlobalSection()
{ {
static std::string section("global"); static plString section("global");
return section; return section;
} }
@ -74,32 +73,32 @@ void plConfigInfo::Clear()
fSections.clear(); fSections.clear();
} }
void plConfigInfo::RemoveSection(const std::string & section) void plConfigInfo::RemoveSection(const plString & section)
{ {
fSections.erase(section.c_str()); fSections.erase(section);
} }
void plConfigInfo::RemoveKey(const std::string & section, const std::string & key) void plConfigInfo::RemoveKey(const plString & section, const plString & key)
{ {
Sections::iterator si = fSections.find(section.c_str()); Sections::iterator si = fSections.find(section);
if (si != fSections.end()) if (si != fSections.end())
fSections[section.c_str()].RemoveKey(key); fSections[section].RemoveKey(key);
} }
bool plConfigInfo::HasSection(const std::string & section) const bool plConfigInfo::HasSection(const plString & section) const
{ {
return fSections.find(section.c_str())!=fSections.end(); return fSections.find(section)!=fSections.end();
} }
bool plConfigInfo::HasKey(const std::string & section, const std::string & key) bool plConfigInfo::HasKey(const plString & section, const plString & key)
{ {
Sections::iterator si = fSections.find(section.c_str()); Sections::iterator si = fSections.find(section);
if (si == fSections.end()) if (si == fSections.end())
return false; return false;
return (si->second.HasKey(key)); return (si->second.HasKey(key));
} }
bool plConfigInfo::HasKeyAny(const std::string & key) bool plConfigInfo::HasKeyAny(const plString & key)
{ {
for (Sections::iterator si=fSections.begin(); si!=fSections.end(); ++si) for (Sections::iterator si=fSections.begin(); si!=fSections.end(); ++si)
{ {
@ -109,12 +108,12 @@ bool plConfigInfo::HasKeyAny(const std::string & key)
return false; return false;
} }
bool plConfigInfo::HasKeyIn(const std::string & key, const char * section1, ...) bool plConfigInfo::HasKeyIn(const plString & key, const char * section1, ...)
{ {
const char * section = section1; const char * section = section1;
va_list va; va_list va;
va_start(va,section1); va_start(va,section1);
std::vector<std::string> sections; std::vector<plString> sections;
while (section) while (section)
{ {
sections.push_back( section ); sections.push_back( section );
@ -124,114 +123,105 @@ bool plConfigInfo::HasKeyIn(const std::string & key, const char * section1, ...)
return HasKeyIn( key, sections ); return HasKeyIn( key, sections );
} }
bool plConfigInfo::HasKeyIn(const std::string & key, const std::vector<std::string> & sections ) bool plConfigInfo::HasKeyIn(const plString & key, const std::vector<plString> & sections )
{ {
for ( int i=0; i<sections.size(); i++ ) for ( int i=0; i<sections.size(); i++ )
{ {
const char * section = sections[i].c_str(); if (HasSection(sections[i]))
if (HasSection(section))
{ {
if (fSections[section].HasKey(key)) if (fSections[sections[i]].HasKey(key))
return true; return true;
} }
} }
return false; return false;
} }
bool plConfigInfo::KeyHasValue(const std::string & section, const std::string & key, const std::string & value) bool plConfigInfo::KeyHasValue(const plString & section, const plString & key, const plString & value)
{ {
Sections::iterator si = fSections.find(section.c_str()); Sections::iterator si = fSections.find(section);
if (si == fSections.end()) if (si == fSections.end())
return false; return false;
return si->second.KeyHasValue(key,value); return si->second.KeyHasValue(key,value);
} }
bool plConfigInfo::KeyHasValue(const std::string & section, const std::string & key, int value) bool plConfigInfo::KeyHasValue(const plString & section, const plString & key, int value)
{ {
Sections::iterator si = fSections.find(section.c_str()); Sections::iterator si = fSections.find(section);
if (si == fSections.end()) if (si == fSections.end())
return false; return false;
return si->second.KeyHasValue(key,value); return si->second.KeyHasValue(key,value);
} }
bool plConfigInfo::KeyHasValue(const std::string & section, const std::string & key, double value) bool plConfigInfo::KeyHasValue(const plString & section, const plString & key, double value)
{ {
Sections::iterator si = fSections.find(section.c_str()); Sections::iterator si = fSections.find(section);
if (si == fSections.end()) if (si == fSections.end())
return false; return false;
return si->second.KeyHasValue(key,value); return si->second.KeyHasValue(key,value);
} }
bool plConfigInfo::AddValue(const std::string & section, const std::string & key, const std::string & value, KAddValueMode mode) bool plConfigInfo::AddValue(const plString & section, const plString & key, const plString & value, KAddValueMode mode)
{ {
fSections[section.c_str()].AddValue(key,value,mode); return fSections[section].AddValue(key,value,mode);
return true;
} }
bool plConfigInfo::AddValue(const std::string & section, const std::string & key, int value, KAddValueMode mode) bool plConfigInfo::AddValue(const plString & section, const plString & key, int value, KAddValueMode mode)
{ {
char buf[20]; return fSections[section].AddValue(key,value,mode);
sprintf(buf, "%d", value);
std::string v(buf);
return AddValue(section,key,v,mode);
} }
bool plConfigInfo::AddValue(const std::string & section, const std::string & key, double value, KAddValueMode mode) bool plConfigInfo::AddValue(const plString & section, const plString & key, double value, KAddValueMode mode)
{ {
char buf[30]; return fSections[section].AddValue(key,value,mode);
sprintf(buf, "%f", value);
std::string v(buf);
return AddValue(section,key,v,mode);
} }
bool plConfigInfo::AddValues(const std::string & section, const std::string & key, const std::vector<std::string> & values, KAddValueMode mode) bool plConfigInfo::AddValues(const plString & section, const plString & key, const std::vector<plString> & values, KAddValueMode mode)
{ {
return fSections[section.c_str()].AddValues(key,values); return fSections[section].AddValues(key,values);
} }
plKeysAndValues plConfigInfo::GetSection(const std::string & section, bool & found) plKeysAndValues plConfigInfo::GetSection(const plString & section, bool & found)
{ {
found = HasSection(section); found = HasSection(section);
if (found) if (found)
return fSections[section.c_str()]; return fSections[section];
else else
return plKeysAndValues(); // empty return plKeysAndValues(); // empty
} }
std::vector<std::string> plConfigInfo::GetSectionNames() std::vector<plString> plConfigInfo::GetSectionNames()
{ {
std::vector<std::string> results; std::vector<plString> results;
for (Sections::const_iterator ii=fSections.begin(); ii!=fSections.end(); ++ii) for (Sections::const_iterator ii=fSections.begin(); ii!=fSections.end(); ++ii)
results.push_back(ii->first.c_str()); results.push_back(ii->first);
return results; return results;
} }
std::string plConfigInfo::GetValue(const std::string & section, const std::string & key, const std::string & defval, bool * outFound) const plString plConfigInfo::GetValue(const plString & section, const plString & key, const plString & defval, bool * outFound) const
{ {
return fSections[section.c_str()].GetValue(key,defval,outFound); return fSections[section].GetValue(key,defval,outFound);
} }
int plConfigInfo::GetValue(const std::string & section, const std::string & key, int defval, bool * outFound) const int plConfigInfo::GetValue(const plString & section, const plString & key, int defval, bool * outFound) const
{ {
return fSections[section.c_str()].GetValue(key,defval,outFound); return fSections[section].GetValue(key,defval,outFound);
} }
double plConfigInfo::GetValue(const std::string & section, const std::string & key, double defval, bool * outFound) const double plConfigInfo::GetValue(const plString & section, const plString & key, double defval, bool * outFound) const
{ {
return fSections[section.c_str()].GetValue(key,defval,outFound); return fSections[section].GetValue(key,defval,outFound);
} }
std::vector<std::string> plConfigInfo::GetAllValues(const std::string & section, const std::string & key) const std::vector<plString> plConfigInfo::GetAllValues(const plString & section, const plString & key) const
{ {
Sections::iterator si = fSections.find(section.c_str()); Sections::iterator si = fSections.find(section);
if (si != fSections.end()) if (si != fSections.end())
return si->second.GetAllValues(key); return si->second.GetAllValues(key);
std::vector<std::string> empty; return std::vector<plString>();
return empty;
} }
std::string plConfigInfo::GetValueAny(const std::string & key, const std::string & defval, bool * outFound) const plString plConfigInfo::GetValueAny(const plString & key, const plString & defval, bool * outFound) const
{ {
if (outFound) *outFound=false; if (outFound) *outFound=false;
for (Sections::iterator si=fSections.begin(); si!=fSections.end(); ++si) for (Sections::iterator si=fSections.begin(); si!=fSections.end(); ++si)
@ -240,7 +230,7 @@ std::string plConfigInfo::GetValueAny(const std::string & key, const std::string
return defval; return defval;
} }
int plConfigInfo::GetValueAny(const std::string & key, int defval, bool * outFound) const int plConfigInfo::GetValueAny(const plString & key, int defval, bool * outFound) const
{ {
if (outFound) *outFound=false; if (outFound) *outFound=false;
for (Sections::iterator si=fSections.begin(); si!=fSections.end(); ++si) for (Sections::iterator si=fSections.begin(); si!=fSections.end(); ++si)
@ -249,7 +239,7 @@ int plConfigInfo::GetValueAny(const std::string & key, int defval, bool * outFou
return defval; return defval;
} }
double plConfigInfo::GetValueAny(const std::string & key, double defval, bool * outFound) const double plConfigInfo::GetValueAny(const plString & key, double defval, bool * outFound) const
{ {
if (outFound) *outFound=false; if (outFound) *outFound=false;
for (Sections::iterator si=fSections.begin(); si!=fSections.end(); ++si) for (Sections::iterator si=fSections.begin(); si!=fSections.end(); ++si)
@ -258,17 +248,16 @@ double plConfigInfo::GetValueAny(const std::string & key, double defval, bool *
return defval; return defval;
} }
std::vector<std::string> plConfigInfo::GetAllValuesAny(const std::string & key) const std::vector<plString> plConfigInfo::GetAllValuesAny(const plString & key) const
{ {
for (Sections::iterator si=fSections.begin(); si!=fSections.end(); ++si) for (Sections::iterator si=fSections.begin(); si!=fSections.end(); ++si)
if (si->second.HasKey(key)) if (si->second.HasKey(key))
return si->second.GetAllValues(key); return si->second.GetAllValues(key);
std::vector<std::string> empty; return std::vector<plString>();
return empty;
} }
std::string plConfigInfo::GetValueIn(const std::string & key, const std::string & defval, bool * outFound, const char * section1, ...) const plString plConfigInfo::GetValueIn(const plString & key, const plString & defval, bool * outFound, const char * section1, ...) const
{ {
if (outFound) *outFound=false; if (outFound) *outFound=false;
const char * section = section1; const char * section = section1;
@ -288,14 +277,14 @@ std::string plConfigInfo::GetValueIn(const std::string & key, const std::string
return defval; return defval;
} }
std::string plConfigInfo::GetValueIn(const std::string & key, const std::string & defval, bool * outFound, const std::vector<std::string> & sections ) const plString plConfigInfo::GetValueIn(const plString & key, const plString & defval, bool * outFound, const std::vector<plString> & sections ) const
{ {
if (outFound) *outFound=false; if (outFound) *outFound=false;
for ( int i=0; i<sections.size(); i++ ) for ( int i=0; i<sections.size(); i++ )
{ {
if (HasSection(sections[i])) if (HasSection(sections[i]))
{ {
plKeysAndValues & kv = fSections[sections[i].c_str()]; plKeysAndValues & kv = fSections[sections[i]];
if (kv.HasKey(key)) if (kv.HasKey(key))
return kv.GetValue(key,defval,outFound); return kv.GetValue(key,defval,outFound);
} }
@ -303,7 +292,7 @@ std::string plConfigInfo::GetValueIn(const std::string & key, const std::string
return defval; return defval;
} }
int plConfigInfo::GetValueIn(const std::string & key, int defval, bool * outFound, const char * section1, ...) const int plConfigInfo::GetValueIn(const plString & key, int defval, bool * outFound, const char * section1, ...) const
{ {
if (outFound) *outFound=false; if (outFound) *outFound=false;
const char * section = section1; const char * section = section1;
@ -323,14 +312,14 @@ int plConfigInfo::GetValueIn(const std::string & key, int defval, bool * outFoun
return defval; return defval;
} }
int plConfigInfo::GetValueIn(const std::string & key, int defval, bool * outFound, const std::vector<std::string> & sections ) const int plConfigInfo::GetValueIn(const plString & key, int defval, bool * outFound, const std::vector<plString> & sections ) const
{ {
if (outFound) *outFound=false; if (outFound) *outFound=false;
for ( int i=0; i<sections.size(); i++ ) for ( int i=0; i<sections.size(); i++ )
{ {
if (HasSection(sections[i])) if (HasSection(sections[i]))
{ {
plKeysAndValues & kv = fSections[sections[i].c_str()]; plKeysAndValues & kv = fSections[sections[i]];
if (kv.HasKey(key)) if (kv.HasKey(key))
return kv.GetValue(key,defval,outFound); return kv.GetValue(key,defval,outFound);
} }
@ -338,7 +327,7 @@ int plConfigInfo::GetValueIn(const std::string & key, int defval, bool * outFoun
return defval; return defval;
} }
double plConfigInfo::GetValueIn(const std::string & key, double defval, bool * outFound, const char * section1, ...) const double plConfigInfo::GetValueIn(const plString & key, double defval, bool * outFound, const char * section1, ...) const
{ {
if (outFound) *outFound=false; if (outFound) *outFound=false;
const char * section = section1; const char * section = section1;
@ -358,14 +347,14 @@ double plConfigInfo::GetValueIn(const std::string & key, double defval, bool * o
return defval; return defval;
} }
double plConfigInfo::GetValueIn(const std::string & key, double defval, bool * outFound, const std::vector<std::string> & sections ) const double plConfigInfo::GetValueIn(const plString & key, double defval, bool * outFound, const std::vector<plString> & sections ) const
{ {
if (outFound) *outFound=false; if (outFound) *outFound=false;
for ( int i=0; i<sections.size(); i++ ) for ( int i=0; i<sections.size(); i++ )
{ {
if (HasSection(sections[i])) if (HasSection(sections[i]))
{ {
plKeysAndValues & kv = fSections[sections[i].c_str()]; plKeysAndValues & kv = fSections[sections[i]];
if (kv.HasKey(key)) if (kv.HasKey(key))
return kv.GetValue(key,defval,outFound); return kv.GetValue(key,defval,outFound);
} }
@ -373,12 +362,12 @@ double plConfigInfo::GetValueIn(const std::string & key, double defval, bool * o
return defval; return defval;
} }
std::vector<std::string> plConfigInfo::GetAllValuesIn(const std::string & key, const char * section1, ...) std::vector<plString> plConfigInfo::GetAllValuesIn(const plString & key, const char * section1, ...)
{ {
const char * section = section1; const char * section = section1;
va_list sections; va_list sections;
va_start(sections,section1); va_start(sections,section1);
std::vector<std::string> result; std::vector<plString> result;
while (section) while (section)
{ {
if (HasSection(section)) if (HasSection(section))
@ -386,7 +375,7 @@ std::vector<std::string> plConfigInfo::GetAllValuesIn(const std::string & key, c
plKeysAndValues & kv = fSections[section]; plKeysAndValues & kv = fSections[section];
if (kv.HasKey(key)) if (kv.HasKey(key))
{ {
std::vector<std::string> values = kv.GetAllValues(key); std::vector<plString> values = kv.GetAllValues(key);
result.insert(result.end(),values.begin(),values.end()); result.insert(result.end(),values.begin(),values.end());
} }
} }
@ -403,7 +392,7 @@ bool plConfigInfo::GetSectionIterators(Sections::const_iterator & iter, Sections
return true; return true;
} }
bool plConfigInfo::GetKeyIterators(const xtl::istring & section, Keys::const_iterator & iter, Keys::const_iterator & end) const bool plConfigInfo::GetKeyIterators(const plString & section, Keys::const_iterator & iter, Keys::const_iterator & end) const
{ {
Sections::const_iterator si = fSections.find(section); Sections::const_iterator si = fSections.find(section);
if (si==fSections.end()) if (si==fSections.end())
@ -411,7 +400,7 @@ bool plConfigInfo::GetKeyIterators(const xtl::istring & section, Keys::const_ite
return fSections[section].GetKeyIterators(iter, end); return fSections[section].GetKeyIterators(iter, end);
} }
bool plConfigInfo::GetValueIterators(const xtl::istring & section, const xtl::istring & key, Values::const_iterator & iter, Values::const_iterator & end) const bool plConfigInfo::GetValueIterators(const plString & section, const plString & key, Values::const_iterator & iter, Values::const_iterator & end) const
{ {
Sections::const_iterator si = fSections.find(section); Sections::const_iterator si = fSections.find(section);
if (si==fSections.end()) if (si==fSections.end())
@ -432,63 +421,62 @@ bool plConfigInfo::WriteTo(plConfigSource * src)
//////////////////////////////////////////////// ////////////////////////////////////////////////
void plConfigSource::SplitAt(std::string & key, std::string & value, char splitter, std::string & in) void plConfigSource::SplitAt(plString & key, plString & value, char splitter, plString & in)
{ {
if(in.length() == 0) if (in.IsEmpty())
return; return;
int t = in.find(splitter); int t = in.Find(splitter);
if(t == std::string::npos) if (t < 0)
{ {
key = in; key = in;
return; return;
} }
key.assign(in.substr(0,t)); key = in.Left(t);
value.assign(in.substr(t+1,in.size()-t-1)); value = in.Substr(t+1,in.GetSize()-t-1);
} }
bool plConfigSource::ReadString(const std::string & in) bool plConfigSource::ReadString(const plString & in)
{ {
std::string work = in; plString work = in.Trim();
xtl::trim(work);
// comment // comment
if (work[0] == '#') if (work.CharAt(0) == '#')
return true; return true;
// comment // comment
if (work[0] == ';') if (work.CharAt(0) == ';')
return true; return true;
// section // section
if (work[0] == '[') if (work.CharAt(0) == '[')
{ {
int close = work.find_first_of("]"); int close = work.Find("]");
if(close == std::string::npos) if (close < 0)
return false; return false;
fCurrSection = work.substr(1,close-1); fCurrSection = work.Substr(1, close-1);
fEffectiveSection = fCurrSection; fEffectiveSection = fCurrSection;
return true; return true;
} }
// key=value // key=value
std::string key, value; plString key, value;
SplitAt(key, value, '=', work); SplitAt(key, value, '=', work);
// dot notation makes section change for this key=value only. // dot notation makes section change for this key=value only.
int t = key.find('.'); int t = key.Find('.');
if (t>0 && t<key.size()-1) if (t>0 && t<key.GetSize()-1)
{ {
fEffectiveSection.assign(key.substr(0,t)); fEffectiveSection = key.Left(t);
key.assign(key.substr(t+1)); key = key.Substr(t+1);
} }
bool ret=ReadPair(key, value); bool ret=ReadPair(key, value);
fEffectiveSection = fCurrSection; fEffectiveSection = fCurrSection;
if(ret && strcmp("LoadIni",key.c_str()) == 0) if(ret && key.Compare("LoadIni") == 0)
{ {
ret = ReadSubSource( value.c_str() ); ret = ReadSubSource( value.c_str() );
} }
@ -496,15 +484,14 @@ bool plConfigSource::ReadString(const std::string & in)
return ret; return ret;
} }
bool plConfigSource::ReadPair(std::string & key, std::string & value) bool plConfigSource::ReadPair(plString & key, plString & value)
{ {
hsAssert(fConfigInfo, "plConfigSource::ProcessPair: fConfigInfo not set."); hsAssert(fConfigInfo, "plConfigSource::ProcessPair: fConfigInfo not set.");
xtl::trim(key); key = key.Trim();
xtl::trim(value); value = value.Trim().Trim("\"'");
xtl::trim(value,"\"'");
if (key.size() == 0) if (key.IsEmpty())
return true; return true;
return fConfigInfo->AddValue(fEffectiveSection, key, value, fAddMode); return fConfigInfo->AddValue(fEffectiveSection, key, value, fAddMode);
@ -542,7 +529,7 @@ bool plConfigSource::WriteOutOf(plConfigInfo & configInfo)
plCmdLineConfigSource::plCmdLineConfigSource(int argc, char ** argv, const char * mySection) plCmdLineConfigSource::plCmdLineConfigSource(int argc, char ** argv, const char * mySection)
: fArgc(argc) : fArgc(argc)
, fArgv(argv) , fArgv(argv)
, fMySection(mySection?mySection:"") , fMySection(mySection)
{} {}
@ -560,7 +547,7 @@ bool plCmdLineConfigSource::ReadInto(plConfigInfo & configInfo, KAddValueMode mo
if(argc < 1) if(argc < 1)
return true; return true;
fConfigInfo->AddValue(fEffectiveSection.c_str(), "ARGV0", *argv, fAddMode); fConfigInfo->AddValue(fEffectiveSection, "ARGV0", *argv, fAddMode);
argc--; argc--;
argv++; argv++;
@ -582,7 +569,7 @@ bool plCmdLineConfigSource::ReadInto(plConfigInfo & configInfo, KAddValueMode mo
plEnvConfigSource::plEnvConfigSource(char ** envp, const char * mySection) plEnvConfigSource::plEnvConfigSource(char ** envp, const char * mySection)
: fEnvp(envp) : fEnvp(envp)
, fMySection(mySection?mySection:"") , fMySection(mySection)
{} {}
@ -617,7 +604,7 @@ bool plIniConfigSource::ReadInto(plConfigInfo & configInfo, KAddValueMode mode)
fCurrSection = plConfigInfo::GlobalSection(); fCurrSection = plConfigInfo::GlobalSection();
fEffectiveSection = fCurrSection; fEffectiveSection = fCurrSection;
if(fFileName.size() < 2) if(fFileName.GetSize() < 2)
return false; return false;
@ -760,33 +747,34 @@ bool plIniStreamConfigSource::WriteOutOf(plConfigInfo & configInfo)
///////////////////////////////////////////////// /////////////////////////////////////////////////
plIniSectionConfigSource::plIniSectionConfigSource(const char * iniFileName, std::vector<std::string> & sections) plIniSectionConfigSource::plIniSectionConfigSource(const char * iniFileName, std::vector<plString> & sections)
: plIniConfigSource(iniFileName) : plIniConfigSource(iniFileName)
{ {
for (int i=0; i<sections.size(); i++) for (int i=0; i<sections.size(); i++)
fSections.push_back(sections[i].c_str()); fSections.push_back(sections[i]);
} }
bool plIniSectionConfigSource::ReadPair(std::string & key, std::string & value) bool plIniSectionConfigSource::ReadPair(plString & key, plString & value)
{ {
hsAssert(fConfigInfo, "plConfigSource::ProcessPair: fConfigInfo not set."); hsAssert(fConfigInfo, "plConfigSource::ProcessPair: fConfigInfo not set.");
// the current section must be in list of sections. // the current section must be in list of sections.
std::vector<xtl::istring>::iterator ii = std::find(fSections.begin(), fSections.end(), fCurrSection.c_str()); Sections::iterator ii = std::find_if(fSections.begin(), fSections.end(),
[this](const plString &v) { return v.CompareI(fCurrSection) == 0; }
);
if (ii==fSections.end()) if (ii==fSections.end())
return true; return true;
xtl::trim(key); key = key.Trim();
xtl::trim(value); value = value.Trim().Trim("\"'");
xtl::trim(value,"\"'");
if (key.size() == 0) if (key.IsEmpty())
return true; return true;
if (key == "section") if (key.CompareI("section") == 0)
fSections.push_back(value.c_str()); fSections.push_back(value);
return fConfigInfo->AddValue(fEffectiveSection, key, value, fAddMode); return fConfigInfo->AddValue(fEffectiveSection, key, value, fAddMode);
} }
@ -794,10 +782,7 @@ bool plIniSectionConfigSource::ReadPair(std::string & key, std::string & value)
bool plIniSectionConfigSource::ReadSubSource( const char * name ) bool plIniSectionConfigSource::ReadSubSource( const char * name )
{ {
std::vector<std::string> sections; plIniSectionConfigSource src(name, fSections);
for ( int i=0; i<fSections.size(); i++ )
sections.push_back( fSections[i].c_str() );
plIniSectionConfigSource src(name, sections);
return fConfigInfo->ReadFrom(&src); return fConfigInfo->ReadFrom(&src);
} }
@ -809,21 +794,20 @@ plIniNoSectionsConfigSource::plIniNoSectionsConfigSource(const char * filename)
fEffectiveSection = fCurrSection = ""; fEffectiveSection = fCurrSection = "";
} }
bool plIniNoSectionsConfigSource::ReadString(const std::string & in) bool plIniNoSectionsConfigSource::ReadString(const plString & in)
{ {
std::string work = in; plString work = in.Trim();
xtl::trim(work);
// ignore comments // ignore comments
if (work[0]=='#' || work[0]==';') if (work.CharAt(0)=='#' || work.CharAt(0)==';')
return true; return true;
// ignore sections // ignore sections
if (work[0] == '[') if (work.CharAt(0) == '[')
return true; return true;
// parse key value // parse key value
std::string key, value; plString key, value;
SplitAt(key, value, '=', work); SplitAt(key, value, '=', work);
return ReadPair(key, value); return ReadPair(key, value);
@ -834,7 +818,7 @@ bool plIniNoSectionsConfigSource::ReadInto(plConfigInfo & configInfo, KAddValueM
if (!plConfigSource::ReadInto(configInfo, mode)) if (!plConfigSource::ReadInto(configInfo, mode))
return false; return false;
if(fFileName.size() < 2) if (fFileName.GetSize() < 2)
return false; return false;
std::ifstream file; std::ifstream file;
@ -944,11 +928,11 @@ void plConfigValueBase::ConfigRead(plConfigInfo * opts)
{ {
if (fReadEvaluate()) if (fReadEvaluate())
{ {
std::string value; plString value;
bool found; bool found;
value = opts->GetValue(GetConfigGroup(),GetConfigName(),"",&found); value = opts->GetValue(GetConfigGroup(),GetConfigName(),"",&found);
if (found) if (found)
SetValue(fReadModify(value).c_str()); SetValue(fReadModify(value));
} }
} }
@ -960,12 +944,12 @@ void plConfigValueBase::ConfigWrite(plConfigInfo * opts)
} }
} }
void plConfigValueBase::SetValue(const char * value) void plConfigValueBase::SetValue(const plString & value)
{ {
ISetValue(fSetModify(value).c_str()); ISetValue(fSetModify(value));
} }
std::string plConfigValueBase::GetValue() const plString plConfigValueBase::GetValue() const
{ {
return fGetModify(IGetValue()); return fGetModify(IGetValue());
} }
@ -1030,7 +1014,7 @@ bool plConfigGroup::Write(plConfigSource * src)
void plConfigGroup::AddItem(plConfigValueBase * item, const char * name) void plConfigGroup::AddItem(plConfigValueBase * item, const char * name)
{ {
item->SetConfigGroup(fGroupName.c_str()); item->SetConfigGroup(fGroupName);
if (name) if (name)
item->SetConfigName(name); item->SetConfigName(name);
fItems.push_back(item); fItems.push_back(item);
@ -1071,29 +1055,28 @@ void plConfigAggregateValue::AddItems(
if (item7) AddItem(item7); if (item7) AddItem(item7);
} }
void plConfigAggregateValue::ISetValue(const char * value) void plConfigAggregateValue::ISetValue(const plString & value)
{ {
std::string work = value; plString work = value.Trim();
int p=0,i=0; int p=0,i=0;
do do
{ {
xtl::trim(work); p = work.Find(" ");
p = work.find(" "); fItems[i]->SetValue(work.Left(p));
fItems[i]->SetValue(work.substr(0,p).c_str()); work = work.Substr(p).TrimLeft();
work.erase(0,p);
i++; i++;
} while (i<fItems.size() && p!=std::string::npos); } while (i<fItems.size() && p>=0);
} }
std::string plConfigAggregateValue::IGetValue() const plString plConfigAggregateValue::IGetValue() const
{ {
std::string value; plStringStream value;
for (int i=0; i<fItems.size(); i++) for (int i=0; i<fItems.size(); i++)
{ {
value.append(fItems[i]->GetValue()); value << fItems[i]->GetValue();
value.append(" "); value << ' ';
} }
return xtl::trim(value); return value.GetString().Trim();
} }
void plConfigAggregateValue::AddItem(plConfigValueBase * item) void plConfigAggregateValue::AddItem(plConfigValueBase * item)
@ -1103,7 +1086,7 @@ void plConfigAggregateValue::AddItem(plConfigValueBase * item)
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
plWWWAuthenticateConfigSource::plWWWAuthenticateConfigSource(const std::string& auth) plWWWAuthenticateConfigSource::plWWWAuthenticateConfigSource(const plString& auth)
: fAuth(auth) : fAuth(auth)
{ {
fEffectiveSection = fCurrSection = ""; fEffectiveSection = fCurrSection = "";
@ -1119,21 +1102,20 @@ bool plWWWAuthenticateConfigSource::ReadInto(plConfigInfo & configInfo, KAddValu
unsigned int i = 0; unsigned int i = 0;
while (i < fAuth.size()) while (i < fAuth.GetSize())
{ {
bool inQuote = false; bool inQuote = false;
unsigned int begin = i,end; unsigned int begin = i,end;
while (i < fAuth.size() while (i < fAuth.GetSize()
&& ((fAuth[i] != ',' && !inQuote) || inQuote)) && ((fAuth.CharAt(i) != ',' && !inQuote) || inQuote))
{ {
if (fAuth[i] == '"') if (fAuth.CharAt(i) == '"')
inQuote = ! inQuote; inQuote = ! inQuote;
i++; i++;
} }
end = i; end = i;
std::string buf; plString buf = fAuth.Substr(begin, end-begin);
buf.assign(fAuth,begin,end-begin);
if(!ReadString(buf.c_str())) if(!ReadString(buf.c_str()))
{ {
// TODO log warning here // TODO log warning here

198
Sources/Plasma/PubUtilLib/plContainer/plConfigInfo.h

@ -43,13 +43,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define plConfigInfo_h_inc #define plConfigInfo_h_inc
#include "plKeysAndValues.h" #include "plKeysAndValues.h"
#include "hsStlUtils.h"
#include <stdarg.h> #include <stdarg.h>
///////////////////////////////////////////////// /////////////////////////////////////////////////
typedef std::vector<std::string> plStringList; typedef std::vector<plString> plStringList;
typedef std::vector<std::wstring> plWStringList;
///////////////////////////////////////////////// /////////////////////////////////////////////////
@ -61,10 +59,10 @@ public:
Keys; Keys;
typedef plKeysAndValues::Values typedef plKeysAndValues::Values
Values; Values;
typedef std::map<xtl::istring, plKeysAndValues> typedef std::map<plString, plKeysAndValues, plString::less_i>
Sections; Sections;
static const std::string& GlobalSection(); static const plString& GlobalSection();
private: private:
mutable Sections fSections; mutable Sections fSections;
@ -79,54 +77,54 @@ public:
// remove all sections // remove all sections
void Clear(); void Clear();
// remove section // remove section
void RemoveSection(const std::string & section); void RemoveSection(const plString & section);
// remove key from section // remove key from section
void RemoveKey(const std::string & section, const std::string & key); void RemoveKey(const plString & section, const plString & key);
// QUERY // QUERY
// does this section exist? // does this section exist?
bool HasSection(const std::string & section) const; bool HasSection(const plString & section) const;
// does the given section contain this key? // does the given section contain this key?
bool HasKey(const std::string & section, const std::string & key); bool HasKey(const plString & section, const plString & key);
// does any section contain this key? // does any section contain this key?
bool HasKeyAny(const std::string & key); bool HasKeyAny(const plString & key);
// does any of the given sections contain this key? // does any of the given sections contain this key?
bool HasKeyIn(const std::string & key, const char * section1, ... /*, nil*/); bool HasKeyIn(const plString & key, const char * section1, ... /*, nil*/);
bool HasKeyIn(const std::string & key, const std::vector<std::string> & sections ); bool HasKeyIn(const plString & key, const std::vector<plString> & sections );
// does key in section have this value? // does key in section have this value?
bool KeyHasValue(const std::string & section, const std::string & key, const std::string & value); bool KeyHasValue(const plString & section, const plString & key, const plString & value);
bool KeyHasValue(const std::string & section, const std::string & key, int value); bool KeyHasValue(const plString & section, const plString & key, int value);
bool KeyHasValue(const std::string & section, const std::string & key, double value); bool KeyHasValue(const plString & section, const plString & key, double value);
// ADD // ADD
// add key=value to the section // add key=value to the section
bool AddValue(const std::string & section, const std::string & key, const std::string & value, KAddValueMode mode=kAlwaysAdd); bool AddValue(const plString & section, const plString & key, const plString & value, KAddValueMode mode=kAlwaysAdd);
bool AddValue(const std::string & section, const std::string & key, int value, KAddValueMode mode=kAlwaysAdd); bool AddValue(const plString & section, const plString & key, int value, KAddValueMode mode=kAlwaysAdd);
bool AddValue(const std::string & section, const std::string & key, double value, KAddValueMode mode=kAlwaysAdd); bool AddValue(const plString & section, const plString & key, double value, KAddValueMode mode=kAlwaysAdd);
bool AddValues(const std::string & section, const std::string & key, const std::vector<std::string> & values, KAddValueMode mode=kAlwaysAdd); bool AddValues(const plString & section, const plString & key, const std::vector<plString> & values, KAddValueMode mode=kAlwaysAdd);
// GET // GET
plKeysAndValues GetSection(const std::string & section, bool & found); plKeysAndValues GetSection(const plString & section, bool & found);
std::vector<std::string> GetSectionNames(); std::vector<plString> GetSectionNames();
// get value for key from given section // get value for key from given section
std::string GetValue(const std::string & section, const std::string & key, const std::string & defval="", bool * outFound=nil) const; plString GetValue(const plString & section, const plString & key, const plString & defval="", bool * outFound=nil) const;
int GetValue(const std::string & section, const std::string & key, int defval, bool * outFound=nil) const; int GetValue(const plString & section, const plString & key, int defval, bool * outFound=nil) const;
double GetValue(const std::string & section, const std::string & key, double defval, bool * outFound=nil) const; double GetValue(const plString & section, const plString & key, double defval, bool * outFound=nil) const;
std::vector<std::string> GetAllValues(const std::string & section, const std::string & key) const; std::vector<plString> GetAllValues(const plString & section, const plString & key) const;
// get value for key from any section // get value for key from any section
std::string GetValueAny(const std::string & key, const std::string & defval="", bool * outFound=nil) const; plString GetValueAny(const plString & key, const plString & defval="", bool * outFound=nil) const;
int GetValueAny(const std::string & key, int defval, bool * outFound=nil) const; int GetValueAny(const plString & key, int defval, bool * outFound=nil) const;
double GetValueAny(const std::string & key, double defval, bool * outFound=nil) const; double GetValueAny(const plString & key, double defval, bool * outFound=nil) const;
std::vector<std::string> GetAllValuesAny(const std::string & key) const; std::vector<plString> GetAllValuesAny(const plString & key) const;
// get value for key from one of the given sections // get value for key from one of the given sections
std::string GetValueIn(const std::string & key, const std::string & defval, bool * outFound, const char * section1, ... /*, nil*/) const; plString GetValueIn(const plString & key, const plString & defval, bool * outFound, const char * section1, ... /*, nil*/) const;
std::string GetValueIn(const std::string & key, const std::string & defval, bool * outFound, const std::vector<std::string> & sections ) const; plString GetValueIn(const plString & key, const plString & defval, bool * outFound, const std::vector<plString> & sections ) const;
int GetValueIn(const std::string & key, int defval, bool * outFound, const char * section1, ... /*, nil*/) const; int GetValueIn(const plString & key, int defval, bool * outFound, const char * section1, ... /*, nil*/) const;
int GetValueIn(const std::string & key, int defval, bool * outFound, const std::vector<std::string> & sections ) const; int GetValueIn(const plString & key, int defval, bool * outFound, const std::vector<plString> & sections ) const;
double GetValueIn(const std::string & key, double defval, bool * outFound, const char * section1, ... /*, nil*/) const; double GetValueIn(const plString & key, double defval, bool * outFound, const char * section1, ... /*, nil*/) const;
double GetValueIn(const std::string & key, double defval, bool * outFound, const std::vector<std::string> & sections ) const; double GetValueIn(const plString & key, double defval, bool * outFound, const std::vector<plString> & sections ) const;
std::vector<std::string> GetAllValuesIn(const std::string & key, const char * section1, ... /*, nil*/); std::vector<plString> GetAllValuesIn(const plString & key, const char * section1, ... /*, nil*/);
// ITERATORS // ITERATORS
bool GetSectionIterators(Sections::const_iterator & iter, Sections::const_iterator & end) const; bool GetSectionIterators(Sections::const_iterator & iter, Sections::const_iterator & end) const;
bool GetKeyIterators(const xtl::istring & section, Keys::const_iterator & iter, Keys::const_iterator & end) const; bool GetKeyIterators(const plString & section, Keys::const_iterator & iter, Keys::const_iterator & end) const;
bool GetValueIterators(const xtl::istring & section, const xtl::istring & key, Values::const_iterator & iter, Values::const_iterator & end) const; bool GetValueIterators(const plString & section, const plString & key, Values::const_iterator & iter, Values::const_iterator & end) const;
// CONFIG SOURCE // CONFIG SOURCE
virtual bool ReadFrom(plConfigSource * src, KAddValueMode mode=kAlwaysAdd); virtual bool ReadFrom(plConfigSource * src, KAddValueMode mode=kAlwaysAdd);
virtual bool WriteTo(plConfigSource * src); virtual bool WriteTo(plConfigSource * src);
@ -145,33 +143,33 @@ public:
plConfigInfo* GetConfigInfo() { return &fConfigInfo; } plConfigInfo* GetConfigInfo() { return &fConfigInfo; }
plConfigInfo* GetConfigInfoLog() { return &fLog; } plConfigInfo* GetConfigInfoLog() { return &fLog; }
bool GetValue(std::string& retval, const std::string & section, const std::string & key, const std::string & desc, const std::string& defval = ""); bool GetValue(plString& retval, const plString & section, const plString & key, const plString & desc, const plString& defval = "");
bool GetValue(int& retval, const std::string & section, const std::string & key, const std::string & desc, int defval); bool GetValue(int& retval, const plString & section, const plString & key, const plString & desc, int defval);
bool GetValue(bool& retval, const std::string & section, const std::string & key, const std::string & desc, bool defval); bool GetValue(bool& retval, const plString & section, const plString & key, const plString & desc, bool defval);
bool GetValue(float& retval, const std::string & section, const std::string & key, const std::string & desc, float defval); bool GetValue(float& retval, const plString & section, const plString & key, const plString & desc, float defval);
bool GetValue(double& retval, const std::string & section, const std::string & key, const std::string & desc, double defval); bool GetValue(double& retval, const plString & section, const plString & key, const plString & desc, double defval);
bool GetAllValues(std::vector<std::string>& values, const std::string & section, const std::string & key, const std::string & desc); bool GetAllValues(std::vector<plString>& values, const plString & section, const plString & key, const plString & desc);
#if USE_MULT_SECTIONS #if USE_MULT_SECTIONS
// get value for key from any section // get value for key from any section
bool GetValueAny(std::string& retval, const std::string & key, const std::string & desc, const std::string & defval); bool GetValueAny(plString& retval, const plString & key, const plString & desc, const plString & defval);
bool GetValueAny(int &retval, const std::string & key, const std::string & desc, int defval); bool GetValueAny(int &retval, const plString & key, const plString & desc, int defval);
bool GetValueAny(bool& retval, const std::string & key, const std::string & desc, bool defval); bool GetValueAny(bool& retval, const plString & key, const plString & desc, bool defval);
bool GetValueAny(float& retval, const std::string & key, const std::string & desc, float defval); bool GetValueAny(float& retval, const plString & key, const plString & desc, float defval);
bool GetValueAny(double& retval, const std::string & key, const std::string & desc, double defval); bool GetValueAny(double& retval, const plString & key, const plString & desc, double defval);
bool GetAllValuesAny(std::vector<std::string>& values, const std::string & key, const std::string & desc); bool GetAllValuesAny(std::vector<plString>& values, const plString & key, const plString & desc);
// get value for key from one of the given sections // get value for key from one of the given sections
bool GetValueIn(std::string& retval, const std::string & key, const std::string & desc, const std::string & defval, const char * section1, ... /*, nil*/); bool GetValueIn(plString& retval, const plString & key, const plString & desc, const plString & defval, const char * section1, ... /*, nil*/);
bool GetValueIn(std::string& retval, const std::string & key, const std::string & desc, const std::string & defval, std::vector<std::string> & sections ); bool GetValueIn(plString& retval, const plString & key, const plString & desc, const plString & defval, std::vector<plString> & sections );
bool GetValueIn(int& retval, const std::string & key, const std::string & desc, int defval, const char * section1, ... /*, nil*/); bool GetValueIn(int& retval, const plString & key, const plString & desc, int defval, const char * section1, ... /*, nil*/);
bool GetValueIn(int& retval, const std::string & key, const std::string & desc, int defval, std::vector<std::string> & sections ); bool GetValueIn(int& retval, const plString & key, const plString & desc, int defval, std::vector<plString> & sections );
bool GetValueIn(bool& retval, const std::string & key, const std::string & desc, bool defval, const char * section1, ... /*, nil*/); bool GetValueIn(bool& retval, const plString & key, const plString & desc, bool defval, const char * section1, ... /*, nil*/);
bool GetValueIn(bool& retval, const std::string & key, const std::string & desc, bool defval, std::vector<std::string> & sections ); bool GetValueIn(bool& retval, const plString & key, const plString & desc, bool defval, std::vector<plString> & sections );
bool GetValueIn(float& retval, const std::string & key, const std::string & desc, double defval, const char * section1, ... /*, nil*/); bool GetValueIn(float& retval, const plString & key, const plString & desc, double defval, const char * section1, ... /*, nil*/);
bool GetValueIn(float& retval, const std::string & key, const std::string & desc, double defval, std::vector<std::string> & sections ); bool GetValueIn(float& retval, const plString & key, const plString & desc, double defval, std::vector<plString> & sections );
bool GetValueIn(double& retval, const std::string & key, const std::string & desc, double defval, const char * section1, ... /*, nil*/); bool GetValueIn(double& retval, const plString & key, const plString & desc, double defval, const char * section1, ... /*, nil*/);
bool GetValueIn(double& retval, const std::string & key, const std::string & desc, double defval, std::vector<std::string> & sections ); bool GetValueIn(double& retval, const plString & key, const plString & desc, double defval, std::vector<plString> & sections );
#endif #endif
}; };
@ -180,14 +178,14 @@ public:
class plConfigSource class plConfigSource
{ {
protected: protected:
std::string fCurrSection; // used in parsing plString fCurrSection; // used in parsing
std::string fEffectiveSection; // used in parsing plString fEffectiveSection; // used in parsing
KAddValueMode fAddMode; // used in parsing KAddValueMode fAddMode; // used in parsing
plConfigInfo * fConfigInfo; plConfigInfo * fConfigInfo;
void SplitAt(std::string & key, std::string & value, char splitter, std::string & in); void SplitAt(plString & key, plString & value, char splitter, plString & in);
virtual bool ReadString(const std::string & in); virtual bool ReadString(const plString & in);
virtual bool ReadPair(std::string & key, std::string & value); virtual bool ReadPair(plString & key, plString & value);
virtual bool ReadList(char ** list); virtual bool ReadList(char ** list);
virtual bool ReadSubSource( const char * name ) { return true; } virtual bool ReadSubSource( const char * name ) { return true; }
@ -209,7 +207,7 @@ class plCmdLineConfigSource : public plConfigSource
{ {
int fArgc; int fArgc;
char ** fArgv; char ** fArgv;
std::string fMySection; plString fMySection;
protected: protected:
bool ReadInto(plConfigInfo & configInfo, KAddValueMode mode=kAlwaysAdd); bool ReadInto(plConfigInfo & configInfo, KAddValueMode mode=kAlwaysAdd);
public: public:
@ -222,7 +220,7 @@ public:
class plEnvConfigSource : public plConfigSource class plEnvConfigSource : public plConfigSource
{ {
char ** fEnvp; char ** fEnvp;
std::string fMySection; plString fMySection;
protected: protected:
bool ReadInto(plConfigInfo & configInfo, KAddValueMode mode=kAlwaysAdd); bool ReadInto(plConfigInfo & configInfo, KAddValueMode mode=kAlwaysAdd);
public: public:
@ -235,7 +233,7 @@ public:
class plIniConfigSource : public plConfigSource class plIniConfigSource : public plConfigSource
{ {
protected: protected:
std::string fFileName; plString fFileName;
bool ReadInto(plConfigInfo & configInfo, KAddValueMode mode=kAlwaysAdd); bool ReadInto(plConfigInfo & configInfo, KAddValueMode mode=kAlwaysAdd);
bool WriteOutOf(plConfigInfo & configInfo); bool WriteOutOf(plConfigInfo & configInfo);
public: public:
@ -262,9 +260,9 @@ public:
// data in an unnamed section, or more accurately, in a section named "". // data in an unnamed section, or more accurately, in a section named "".
class plIniNoSectionsConfigSource : public plConfigSource class plIniNoSectionsConfigSource : public plConfigSource
{ {
std::string fFileName; plString fFileName;
protected: protected:
bool ReadString(const std::string & in); bool ReadString(const plString & in);
bool ReadInto(plConfigInfo & configInfo, KAddValueMode mode=kAlwaysAdd); bool ReadInto(plConfigInfo & configInfo, KAddValueMode mode=kAlwaysAdd);
bool WriteOutOf(plConfigInfo & configInfo); bool WriteOutOf(plConfigInfo & configInfo);
public: public:
@ -276,14 +274,14 @@ public:
// an ini file reader that only reads specified sections // an ini file reader that only reads specified sections
class plIniSectionConfigSource : public plIniConfigSource class plIniSectionConfigSource : public plIniConfigSource
{ {
typedef std::vector<xtl::istring> typedef std::vector<plString>
Sections; Sections;
protected: protected:
Sections fSections; Sections fSections;
bool ReadPair(std::string & key, std::string & value); bool ReadPair(plString & key, plString & value);
bool ReadSubSource( const char * name ); bool ReadSubSource( const char * name );
public: public:
plIniSectionConfigSource(const char * iniFileName, std::vector<std::string> & sections); plIniSectionConfigSource(const char * iniFileName, std::vector<plString> & sections);
}; };
///////////////////////////////////////////////// /////////////////////////////////////////////////
@ -304,7 +302,7 @@ public:
class plDebugConfigSource : public plConfigSource class plDebugConfigSource : public plConfigSource
{ {
protected: protected:
std::string fFileName; plString fFileName;
bool WriteOutOf(plConfigInfo & configInfo); bool WriteOutOf(plConfigInfo & configInfo);
public: public:
plDebugConfigSource(){} plDebugConfigSource(){}
@ -314,11 +312,11 @@ public:
class plWWWAuthenticateConfigSource : public plConfigSource class plWWWAuthenticateConfigSource : public plConfigSource
{ {
const std::string& fAuth; const plString& fAuth;
protected: protected:
bool ReadInto(plConfigInfo & configInfo, KAddValueMode mode=kAlwaysAdd); bool ReadInto(plConfigInfo & configInfo, KAddValueMode mode=kAlwaysAdd);
public: public:
plWWWAuthenticateConfigSource(const std::string& auth); plWWWAuthenticateConfigSource(const plString& auth);
}; };
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -363,18 +361,18 @@ struct plEvaluate
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
typedef std::string (plClass::*TModify)(const std::string & value); typedef plString (plClass::*TModify)(const plString & value);
struct plModify struct plModify
{ {
plClass * fTarget; plClass * fTarget;
std::string (plClass::*fModify)(const std::string & value); plString (plClass::*fModify)(const plString & value);
plModify( plClass * target=nil, TModify modify=nil ) plModify( plClass * target=nil, TModify modify=nil )
: fTarget(target) : fTarget(target)
, fModify(modify) , fModify(modify)
{} {}
std::string operator()(const std::string & value) { return (fTarget)?(fTarget->*fModify)(value):value;} plString operator()(const plString & value) { return (fTarget)?(fTarget->*fModify)(value):value;}
std::string operator()(const std::string & value) const { return (fTarget)?(fTarget->*fModify)(value):value;} plString operator()(const plString & value) const { return (fTarget)?(fTarget->*fModify)(value):value;}
}; };
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -382,8 +380,8 @@ struct plModify
class plConfigValueBase class plConfigValueBase
{ {
public: public:
std::string fConfigName; plString fConfigName;
std::string fConfigGroup; plString fConfigGroup;
plEvaluate fReadEvaluate; // returns true if we want to read this value from options plEvaluate fReadEvaluate; // returns true if we want to read this value from options
plEvaluate fWriteEvaluate; // returns true if we want to write this value to options plEvaluate fWriteEvaluate; // returns true if we want to write this value to options
plModify fReadModify; // may modify the value being read from options plModify fReadModify; // may modify the value being read from options
@ -394,18 +392,18 @@ public:
: fConfigName(configName) : fConfigName(configName)
, fConfigGroup(configGroup) , fConfigGroup(configGroup)
{} {}
void SetConfigName(const char * name) { fConfigName=(name)?name:"";} void SetConfigName(const plString & name) { fConfigName=name;}
std::string GetConfigName() const { return fConfigName;} plString GetConfigName() const { return fConfigName;}
void SetConfigGroup(const char * group) { fConfigGroup=group;} void SetConfigGroup(const plString & group) { fConfigGroup=group;}
std::string GetConfigGroup() const { return fConfigGroup;} plString GetConfigGroup() const { return fConfigGroup;}
bool HasConfigName() { return fConfigName.length()>0;} bool HasConfigName() { return !fConfigName.IsEmpty();}
bool HasConfigGroup() { return fConfigGroup.length()>0;} bool HasConfigGroup() { return !fConfigGroup.IsEmpty();}
virtual void ConfigRead(plConfigInfo * opts); virtual void ConfigRead(plConfigInfo * opts);
virtual void ConfigWrite(plConfigInfo * opts); virtual void ConfigWrite(plConfigInfo * opts);
void SetValue(const char * value); void SetValue(const plString & value);
std::string GetValue() const; plString GetValue() const;
virtual void ISetValue(const char * value) = 0; virtual void ISetValue(const plString & value) = 0;
virtual std::string IGetValue() const = 0; virtual plString IGetValue() const = 0;
void SetReadEvaluate(plClass * targetObj, TEvaluate evalFunc); void SetReadEvaluate(plClass * targetObj, TEvaluate evalFunc);
void SetWriteEvaluate(plClass * targetObj, TEvaluate evalFunc); void SetWriteEvaluate(plClass * targetObj, TEvaluate evalFunc);
@ -424,9 +422,9 @@ public:
plConfigValue( const char * configName="", const char * configGroup="" ) plConfigValue( const char * configName="", const char * configGroup="" )
: plConfigValueBase(configName, configGroup) : plConfigValueBase(configName, configGroup)
{} {}
std::string fConfigValue; plString fConfigValue;
void ISetValue(const char * value) { fConfigValue=value;} void ISetValue(const plString & value) { fConfigValue=value;}
std::string IGetValue() const { return fConfigValue;} plString IGetValue() const { return fConfigValue;}
}; };
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -451,8 +449,8 @@ public:
plConfigValueBase * item5=nil, plConfigValueBase * item5=nil,
plConfigValueBase * item6=nil, plConfigValueBase * item6=nil,
plConfigValueBase * item7=nil); plConfigValueBase * item7=nil);
void ISetValue(const char * value); void ISetValue(const plString & value);
std::string IGetValue() const; plString IGetValue() const;
void AddItem(plConfigValueBase * item); void AddItem(plConfigValueBase * item);
void AddItems( void AddItems(
plConfigValueBase * item1=nil, plConfigValueBase * item1=nil,
@ -474,8 +472,8 @@ public:
: fConfigurable(item) : fConfigurable(item)
{} {}
void Set(plConfigValueBase * item) { fConfigurable=item;} void Set(plConfigValueBase * item) { fConfigurable=item;}
void ISetValue(const char * value) { fConfigurable->ISetValue(value);} void ISetValue(const plString & value) { fConfigurable->ISetValue(value);}
std::string IGetValue() const { return fConfigurable->IGetValue();} plString IGetValue() const { return fConfigurable->IGetValue();}
}; };
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -484,7 +482,7 @@ class plConfigGroup
{ {
public: public:
plConfigInfo fOpts; plConfigInfo fOpts;
std::string fGroupName; plString fGroupName;
std::vector<plConfigValueBase*> fItems; std::vector<plConfigValueBase*> fItems;
plConfigGroup(const char * groupName=""); plConfigGroup(const char * groupName="");
bool Read(plConfigSource * src); bool Read(plConfigSource * src);

82
Sources/Plasma/PubUtilLib/plContainer/plConfigInfoLogging.cpp

@ -49,10 +49,9 @@ plConfigInfoLogging::~plConfigInfoLogging()
{ {
} }
bool plConfigInfoLogging::GetValue(std::string& retval, const std::string & section, const std::string & key, const std::string & desc, const std::string& defval) bool plConfigInfoLogging::GetValue(plString& retval, const plString & section, const plString & key, const plString & desc, const plString& defval)
{ {
std::string descwdef; plString descwdef = plString::Format("%s # %s",defval.c_str(),desc.c_str());
xtl::format(descwdef,"%s # %s",defval.c_str(),desc.c_str());
fLog.AddValue(section,key,descwdef,kReplaceIfExists); fLog.AddValue(section,key,descwdef,kReplaceIfExists);
bool found; bool found;
@ -60,10 +59,9 @@ bool plConfigInfoLogging::GetValue(std::string& retval, const std::string & sect
return found; return found;
} }
bool plConfigInfoLogging::GetValue(int& retval, const std::string & section, const std::string & key, const std::string & desc, int defval) bool plConfigInfoLogging::GetValue(int& retval, const plString & section, const plString & key, const plString & desc, int defval)
{ {
std::string descwdef; plString descwdef = plString::Format("%d # %s",defval,desc.c_str());
xtl::format(descwdef,"%d # %s",defval,desc.c_str());
fLog.AddValue(section,key,descwdef,kReplaceIfExists); fLog.AddValue(section,key,descwdef,kReplaceIfExists);
bool found; bool found;
@ -71,10 +69,9 @@ bool plConfigInfoLogging::GetValue(int& retval, const std::string & section, con
return found; return found;
} }
bool plConfigInfoLogging::GetValue(bool& retval, const std::string & section, const std::string & key, const std::string & desc, bool defval) bool plConfigInfoLogging::GetValue(bool& retval, const plString & section, const plString & key, const plString & desc, bool defval)
{ {
std::string descwdef; plString descwdef = plString::Format("%d # %s",defval,desc.c_str());
xtl::format(descwdef,"%d # %s",defval,desc.c_str());
fLog.AddValue(section,key,descwdef,kReplaceIfExists); fLog.AddValue(section,key,descwdef,kReplaceIfExists);
bool found; bool found;
@ -82,10 +79,9 @@ bool plConfigInfoLogging::GetValue(bool& retval, const std::string & section, co
return found; return found;
} }
bool plConfigInfoLogging::GetValue(float& retval, const std::string & section, const std::string & key, const std::string & desc, float defval) bool plConfigInfoLogging::GetValue(float& retval, const plString & section, const plString & key, const plString & desc, float defval)
{ {
std::string descwdef; plString descwdef = plString::Format("%f # %s",defval,desc.c_str());
xtl::format(descwdef,"%f # %s",defval,desc.c_str());
fLog.AddValue(section,key,descwdef,kReplaceIfExists); fLog.AddValue(section,key,descwdef,kReplaceIfExists);
bool found; bool found;
@ -94,10 +90,9 @@ bool plConfigInfoLogging::GetValue(float& retval, const std::string & section, c
return found; return found;
} }
bool plConfigInfoLogging::GetValue(double& retval, const std::string & section, const std::string & key, const std::string & desc, double defval) bool plConfigInfoLogging::GetValue(double& retval, const plString & section, const plString & key, const plString & desc, double defval)
{ {
std::string descwdef; plString descwdef = plString::Format("%f # %s",defval,desc.c_str());
xtl::format(descwdef,"%f # %s",defval,desc.c_str());
fLog.AddValue(section,key,descwdef,kReplaceIfExists); fLog.AddValue(section,key,descwdef,kReplaceIfExists);
bool found; bool found;
@ -105,10 +100,9 @@ bool plConfigInfoLogging::GetValue(double& retval, const std::string & section,
return found; return found;
} }
bool plConfigInfoLogging::GetAllValues(std::vector<std::string>& values, const std::string & section, const std::string & key, const std::string & desc) bool plConfigInfoLogging::GetAllValues(std::vector<plString>& values, const plString & section, const plString & key, const plString & desc)
{ {
std::string descwdef; plString descwdef = plString::Format("%s # %s","\"Multiple Entries\"",desc.c_str());
xtl::format(descwdef,"%s # %s","\"Multiple Entries\"",desc.c_str());
fLog.AddValue(section,key,descwdef,kReplaceIfExists); fLog.AddValue(section,key,descwdef,kReplaceIfExists);
values = fConfigInfo.GetAllValues(section,key); values = fConfigInfo.GetAllValues(section,key);
@ -117,7 +111,7 @@ bool plConfigInfoLogging::GetAllValues(std::vector<std::string>& values, const s
#if USE_MULT_SECTIONS #if USE_MULT_SECTIONS
bool plConfigInfoLogging::GetValueAny(std::string& retval, const std::string & key, const std::string & desc, const std::string & defval) bool plConfigInfoLogging::GetValueAny(plString& retval, const plString & key, const plString & desc, const plString & defval)
{ {
fLog.AddValue("ANY SECTION",key,desc,kReplaceIfExists); fLog.AddValue("ANY SECTION",key,desc,kReplaceIfExists);
@ -126,7 +120,7 @@ bool plConfigInfoLogging::GetValueAny(std::string& retval, const std::string & k
return found; return found;
} }
bool plConfigInfoLogging::GetValueAny(int &retval, const std::string & key, const std::string & desc, int defval) bool plConfigInfoLogging::GetValueAny(int &retval, const plString & key, const plString & desc, int defval)
{ {
fLog.AddValue("ANY SECTION",key,desc,kReplaceIfExists); fLog.AddValue("ANY SECTION",key,desc,kReplaceIfExists);
@ -135,7 +129,7 @@ bool plConfigInfoLogging::GetValueAny(int &retval, const std::string & key, cons
return found; return found;
} }
bool plConfigInfoLogging::GetValueAny(bool &retval, const std::string & key, const std::string & desc, bool defval) bool plConfigInfoLogging::GetValueAny(bool &retval, const plString & key, const plString & desc, bool defval)
{ {
fLog.AddValue("ANY SECTION",key,desc,kReplaceIfExists); fLog.AddValue("ANY SECTION",key,desc,kReplaceIfExists);
@ -144,7 +138,7 @@ bool plConfigInfoLogging::GetValueAny(bool &retval, const std::string & key, con
return found; return found;
} }
bool plConfigInfoLogging::GetValueAny(float& retval, const std::string & key, const std::string & desc, float defval) bool plConfigInfoLogging::GetValueAny(float& retval, const plString & key, const plString & desc, float defval)
{ {
fLog.AddValue("ANY SECTION",key,desc,kReplaceIfExists); fLog.AddValue("ANY SECTION",key,desc,kReplaceIfExists);
@ -153,7 +147,7 @@ bool plConfigInfoLogging::GetValueAny(float& retval, const std::string & key, co
return found; return found;
} }
bool plConfigInfoLogging::GetValueAny(double& retval, const std::string & key, const std::string & desc, double defval) bool plConfigInfoLogging::GetValueAny(double& retval, const plString & key, const plString & desc, double defval)
{ {
fLog.AddValue("ANY SECTION",key,desc,kReplaceIfExists); fLog.AddValue("ANY SECTION",key,desc,kReplaceIfExists);
@ -162,7 +156,7 @@ bool plConfigInfoLogging::GetValueAny(double& retval, const std::string & key, c
return found; return found;
} }
bool plConfigInfoLogging::GetAllValuesAny(std::vector<std::string>& values, const std::string & key, const std::string & desc) bool plConfigInfoLogging::GetAllValuesAny(std::vector<plString>& values, const plString & key, const plString & desc)
{ {
fLog.AddValue("ANY SECTION",key,desc,kReplaceIfExists); fLog.AddValue("ANY SECTION",key,desc,kReplaceIfExists);
@ -170,12 +164,12 @@ bool plConfigInfoLogging::GetAllValuesAny(std::vector<std::string>& values, cons
return values.size() != 0; return values.size() != 0;
} }
bool plConfigInfoLogging::GetValueIn(std::string& retval, const std::string & key, const std::string & desc, const std::string & defval, const char * section1, ... /*, nil*/) bool plConfigInfoLogging::GetValueIn(plString& retval, const plString & key, const plString & desc, const plString & defval, const char * section1, ... /*, nil*/)
{ {
const char * section = section1; const char * section = section1;
va_list va; va_list va;
va_start(va,section1); va_start(va,section1);
std::vector<std::string> sections; std::vector<plString> sections;
while (section) while (section)
{ {
sections.push_back( section ); sections.push_back( section );
@ -186,9 +180,9 @@ bool plConfigInfoLogging::GetValueIn(std::string& retval, const std::string & ke
return GetValueIn(retval,key,desc,defval,sections); return GetValueIn(retval,key,desc,defval,sections);
} }
bool plConfigInfoLogging::GetValueIn(std::string& retval, const std::string & key, const std::string & desc, const std::string & defval, std::vector<std::string> & sections ) bool plConfigInfoLogging::GetValueIn(plString& retval, const plString & key, const plString & desc, const plString & defval, std::vector<plString> & sections )
{ {
std::vector<std::string>::iterator si = sections.begin(); std::vector<plString>::iterator si = sections.begin();
while (si != sections.end()) while (si != sections.end())
{ {
fLog.AddValue(*si,key,desc,kReplaceIfExists); fLog.AddValue(*si,key,desc,kReplaceIfExists);
@ -200,12 +194,12 @@ bool plConfigInfoLogging::GetValueIn(std::string& retval, const std::string & ke
return found; return found;
} }
bool plConfigInfoLogging::GetValueIn(int& retval, const std::string & key, const std::string & desc, int defval, const char * section1, ... /*, nil*/) bool plConfigInfoLogging::GetValueIn(int& retval, const plString & key, const plString & desc, int defval, const char * section1, ... /*, nil*/)
{ {
const char * section = section1; const char * section = section1;
va_list va; va_list va;
va_start(va,section1); va_start(va,section1);
std::vector<std::string> sections; std::vector<plString> sections;
while (section) while (section)
{ {
sections.push_back( section ); sections.push_back( section );
@ -216,9 +210,9 @@ bool plConfigInfoLogging::GetValueIn(int& retval, const std::string & key, cons
return GetValueIn(retval,key,desc,defval,sections); return GetValueIn(retval,key,desc,defval,sections);
} }
bool plConfigInfoLogging::GetValueIn(int& retval, const std::string & key, const std::string & desc, int defval, std::vector<std::string> & sections ) bool plConfigInfoLogging::GetValueIn(int& retval, const plString & key, const plString & desc, int defval, std::vector<plString> & sections )
{ {
std::vector<std::string>::iterator si = sections.begin(); std::vector<plString>::iterator si = sections.begin();
while (si != sections.end()) while (si != sections.end())
{ {
fLog.AddValue(*si,key,desc,kReplaceIfExists); fLog.AddValue(*si,key,desc,kReplaceIfExists);
@ -230,12 +224,12 @@ bool plConfigInfoLogging::GetValueIn(int& retval, const std::string & key, cons
return found; return found;
} }
bool plConfigInfoLogging::GetValueIn(bool& retval, const std::string & key, const std::string & desc, bool defval, const char * section1, ... /*, nil*/) bool plConfigInfoLogging::GetValueIn(bool& retval, const plString & key, const plString & desc, bool defval, const char * section1, ... /*, nil*/)
{ {
const char * section = section1; const char * section = section1;
va_list va; va_list va;
va_start(va,section1); va_start(va,section1);
std::vector<std::string> sections; std::vector<plString> sections;
while (section) while (section)
{ {
sections.push_back( section ); sections.push_back( section );
@ -246,9 +240,9 @@ bool plConfigInfoLogging::GetValueIn(bool& retval, const std::string & key, con
return GetValueIn(retval,key,desc,defval,sections); return GetValueIn(retval,key,desc,defval,sections);
} }
bool plConfigInfoLogging::GetValueIn(bool& retval, const std::string & key, const std::string & desc, bool defval, std::vector<std::string> & sections ) bool plConfigInfoLogging::GetValueIn(bool& retval, const plString & key, const plString & desc, bool defval, std::vector<plString> & sections )
{ {
std::vector<std::string>::iterator si = sections.begin(); std::vector<plString>::iterator si = sections.begin();
while (si != sections.end()) while (si != sections.end())
{ {
fLog.AddValue(*si,key,desc,kReplaceIfExists); fLog.AddValue(*si,key,desc,kReplaceIfExists);
@ -260,12 +254,12 @@ bool plConfigInfoLogging::GetValueIn(bool& retval, const std::string & key, con
return found; return found;
} }
bool plConfigInfoLogging::GetValueIn(float& retval, const std::string & key, const std::string & desc, double defval, const char * section1, ... /*, nil*/) bool plConfigInfoLogging::GetValueIn(float& retval, const plString & key, const plString & desc, double defval, const char * section1, ... /*, nil*/)
{ {
const char * section = section1; const char * section = section1;
va_list va; va_list va;
va_start(va,section1); va_start(va,section1);
std::vector<std::string> sections; std::vector<plString> sections;
while (section) while (section)
{ {
sections.push_back( section ); sections.push_back( section );
@ -276,9 +270,9 @@ bool plConfigInfoLogging::GetValueIn(float& retval, const std::string & key, co
return GetValueIn(retval,key,desc,defval,sections); return GetValueIn(retval,key,desc,defval,sections);
} }
bool plConfigInfoLogging::GetValueIn(float& retval, const std::string & key, const std::string & desc, double defval, std::vector<std::string> & sections ) bool plConfigInfoLogging::GetValueIn(float& retval, const plString & key, const plString & desc, double defval, std::vector<plString> & sections )
{ {
std::vector<std::string>::iterator si = sections.begin(); std::vector<plString>::iterator si = sections.begin();
while (si != sections.end()) while (si != sections.end())
{ {
fLog.AddValue(*si,key,desc,kReplaceIfExists); fLog.AddValue(*si,key,desc,kReplaceIfExists);
@ -290,12 +284,12 @@ bool plConfigInfoLogging::GetValueIn(float& retval, const std::string & key, co
return found; return found;
} }
bool plConfigInfoLogging::GetValueIn(double& retval, const std::string & key, const std::string & desc, double defval, const char * section1, ... /*, nil*/) bool plConfigInfoLogging::GetValueIn(double& retval, const plString & key, const plString & desc, double defval, const char * section1, ... /*, nil*/)
{ {
const char * section = section1; const char * section = section1;
va_list va; va_list va;
va_start(va,section1); va_start(va,section1);
std::vector<std::string> sections; std::vector<plString> sections;
while (section) while (section)
{ {
sections.push_back( section ); sections.push_back( section );
@ -306,9 +300,9 @@ bool plConfigInfoLogging::GetValueIn(double& retval, const std::string & key, c
return GetValueIn(retval,key,desc,defval,sections); return GetValueIn(retval,key,desc,defval,sections);
} }
bool plConfigInfoLogging::GetValueIn(double& retval, const std::string & key, const std::string & desc, double defval, std::vector<std::string> & sections ) bool plConfigInfoLogging::GetValueIn(double& retval, const plString & key, const plString & desc, double defval, std::vector<plString> & sections )
{ {
std::vector<std::string>::iterator si = sections.begin(); std::vector<plString>::iterator si = sections.begin();
while (si != sections.end()) while (si != sections.end())
{ {
fLog.AddValue(*si,key,desc,kReplaceIfExists); fLog.AddValue(*si,key,desc,kReplaceIfExists);

1
Sources/Plasma/PubUtilLib/plContainer/plContainer.h

@ -43,7 +43,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define plContainer_h_inc #define plContainer_h_inc
#include "HeadSpin.h" #include "HeadSpin.h"
#include "hsStlUtils.h"
template < class T > template < class T >
class plDataContainerT class plDataContainerT

132
Sources/Plasma/PubUtilLib/plContainer/plKeysAndValues.cpp

@ -65,41 +65,37 @@ void plKeysAndValues::Clear()
fKeys.clear(); fKeys.clear();
} }
void plKeysAndValues::RemoveKey(const std::string & key) void plKeysAndValues::RemoveKey(const plString & key)
{ {
fKeys.erase(key.c_str()); fKeys.erase(key);
} }
bool plKeysAndValues::HasKey(const std::string & key) const bool plKeysAndValues::HasKey(const plString & key) const
{ {
return (fKeys.find(key.c_str()) != fKeys.end()); return (fKeys.find(key) != fKeys.end());
} }
bool plKeysAndValues::KeyHasValue(const std::string & key, const std::string & value) bool plKeysAndValues::KeyHasValue(const plString & key, const plString & value)
{ {
Keys::const_iterator ki = fKeys.find(key.c_str()); Keys::const_iterator ki = fKeys.find(key);
if (ki==fKeys.end()) if (ki==fKeys.end())
return false; return false;
return std::find(ki->second.begin(),ki->second.end(), value.c_str()) != ki->second.end(); return std::find_if(ki->second.begin(), ki->second.end(),
[&value](const plString &v) { return v.CompareI(value) == 0; }
) != ki->second.end();
} }
bool plKeysAndValues::KeyHasValue(const std::string & key, int value) bool plKeysAndValues::KeyHasValue(const plString & key, int value)
{ {
char buf[20]; return KeyHasValue(key, plString::Format("%d", value));
sprintf(buf, "%d", value);
std::string v(buf);
return KeyHasValue(key, v);
} }
bool plKeysAndValues::KeyHasValue(const std::string & key, double value) bool plKeysAndValues::KeyHasValue(const plString & key, double value)
{ {
char buf[30]; return KeyHasValue(key, plString::Format("%f", value));
sprintf(buf, "%f", value);
std::string v(buf);
return KeyHasValue(key, v);
} }
bool plKeysAndValues::AddValue(const std::string & key, const std::string & value, KAddValueMode mode) bool plKeysAndValues::AddValue(const plString & key, const plString & value, KAddValueMode mode)
{ {
switch (mode) switch (mode)
{ {
@ -114,97 +110,75 @@ bool plKeysAndValues::AddValue(const std::string & key, const std::string & valu
default: default:
break; break;
} }
fKeys[key.c_str()].push_front(value.c_str()); fKeys[key].push_front(value);
return true; return true;
} }
bool plKeysAndValues::AddValue(const std::string & key, int value, KAddValueMode mode) bool plKeysAndValues::AddValue(const plString & key, int value, KAddValueMode mode)
{ {
char buf[20]; return AddValue(key, plString::Format("%d", value), mode);
sprintf(buf, "%d", value);
std::string v(buf);
return AddValue(key,v,mode);
} }
bool plKeysAndValues::AddValue(const std::string & key, double value, KAddValueMode mode) bool plKeysAndValues::AddValue(const plString & key, double value, KAddValueMode mode)
{ {
char buf[30]; return AddValue(key, plString::Format("%f", value), mode);
sprintf(buf, "%f", value);
std::string v(buf);
return AddValue(key,v,mode);
} }
bool plKeysAndValues::AddValues(const std::string & key, const std::vector<std::string> & values, KAddValueMode mode) bool plKeysAndValues::AddValues(const plString & key, const std::vector<plString> & values, KAddValueMode mode)
{ {
for (int i=0; i<values.size(); i++) for (int i=0; i<values.size(); i++)
AddValue(key,values[i],mode); AddValue(key,values[i],mode);
return true; return true;
} }
bool plKeysAndValues::SetValue(const std::string & key, const std::string & value) bool plKeysAndValues::SetValue(const plString & key, const plString & value)
{ {
fKeys[key.c_str()].clear(); fKeys[key].clear();
return AddValue(key,value); return AddValue(key,value);
} }
bool plKeysAndValues::SetValue(const std::string & key, int value) bool plKeysAndValues::SetValue(const plString & key, int value)
{ {
char buf[20]; return SetValue(key, plString::Format("%d", value));
sprintf(buf, "%d", value);
std::string v(buf);
return SetValue(key, v);
} }
bool plKeysAndValues::SetValue(const std::string & key, double value) bool plKeysAndValues::SetValue(const plString & key, double value)
{ {
char buf[30]; return SetValue(key, plString::Format("%f", value));
sprintf(buf, "%f", value);
std::string v(buf);
return SetValue(key, v);
} }
std::string plKeysAndValues::GetValue(const std::string & key, const std::string & defval, bool * outFound) const plString plKeysAndValues::GetValue(const plString & key, const plString & defval, bool * outFound) const
{ {
Keys::const_iterator ki = fKeys.find(key.c_str()); Keys::const_iterator ki = fKeys.find(key);
if (outFound) if (outFound)
*outFound = (ki!=fKeys.end()); *outFound = (ki!=fKeys.end());
if(ki != fKeys.end()) if(ki != fKeys.end())
return ki->second.front().c_str(); return ki->second.front();
// fKeys[key.c_str()].push_front(defval.c_str()); // fKeys[key].push_front(defval);
return defval; return defval;
} }
uint32_t plKeysAndValues::GetValue(const std::string & key, uint32_t defval, bool * outFound) const uint32_t plKeysAndValues::GetValue(const plString & key, uint32_t defval, bool * outFound) const
{ {
char buf[20]; return strtoul(GetValue(key, plString::Format("%ul", defval), outFound).c_str(), nil, 0);
sprintf(buf, "%ul", defval);
std::string v(buf);
return strtoul(GetValue(key,v,outFound).c_str(), nil, 0);
} }
int plKeysAndValues::GetValue(const std::string & key, int defval, bool * outFound) const int plKeysAndValues::GetValue(const plString & key, int defval, bool * outFound) const
{ {
char buf[20]; return atol(GetValue(key, plString::Format("%d", defval), outFound).c_str());
sprintf(buf, "%d", defval);
std::string v(buf);
return atol(GetValue(key,v,outFound).c_str());
} }
double plKeysAndValues::GetValue(const std::string & key, double defval, bool * outFound) const double plKeysAndValues::GetValue(const plString & key, double defval, bool * outFound) const
{ {
char buf[30]; return atof(GetValue(key, plString::Format("%f", defval), outFound).c_str());
sprintf(buf, "%f", defval);
std::string v(buf);
return atof(GetValue(key,v,outFound).c_str());
} }
std::vector<std::string> plKeysAndValues::GetAllValues(const std::string & key) std::vector<plString> plKeysAndValues::GetAllValues(const plString & key)
{ {
std::vector<std::string> result; std::vector<plString> result;
xtl::istring xkey = key.c_str();
if (HasKey(key)) if (HasKey(key))
for (Values::const_iterator vi=fKeys[xkey].begin(); vi!=fKeys[xkey].end(); ++vi) for (Values::const_iterator vi=fKeys[key].begin(); vi!=fKeys[key].end(); ++vi)
result.push_back(vi->c_str()); result.push_back(*vi);
return result; return result;
} }
@ -215,7 +189,7 @@ bool plKeysAndValues::GetKeyIterators(Keys::const_iterator & iter, Keys::const_i
return true; return true;
} }
bool plKeysAndValues::GetValueIterators(const xtl::istring & key, Values::const_iterator & iter, Values::const_iterator & end) const bool plKeysAndValues::GetValueIterators(const plString & key, Values::const_iterator & iter, Values::const_iterator & end) const
{ {
Keys::const_iterator ki = fKeys.find(key); Keys::const_iterator ki = fKeys.find(key);
if(ki != fKeys.end()) if(ki != fKeys.end())
@ -235,19 +209,19 @@ void plKeysAndValues::Read(hsStream * s)
{ {
uint16_t strlen; uint16_t strlen;
s->ReadLE(&strlen); s->ReadLE(&strlen);
std::string key; plStringBuffer<char> key;
key.assign(strlen+1,'\0'); char* kdata = key.CreateWritableBuffer(strlen);
s->Read(strlen,(void*)key.data()); s->Read(strlen,(void*)kdata);
key.resize(strlen); kdata[strlen] = 0;
uint16_t nvalues; uint16_t nvalues;
s->ReadLE(&nvalues); s->ReadLE(&nvalues);
for (int vi=0; vi<nvalues; vi++) for (int vi=0; vi<nvalues; vi++)
{ {
s->ReadLE(&strlen); s->ReadLE(&strlen);
std::string value; plStringBuffer<char> value;
value.assign(strlen+1,'\0'); char* vdata = value.CreateWritableBuffer(strlen);
s->Read(strlen,(void*)value.data()); s->Read(strlen,(void*)vdata);
value.resize(strlen); vdata[strlen] = 0;
// for now, only single value for key on stream is allowed. // for now, only single value for key on stream is allowed.
SetValue(key,value); SetValue(key,value);
} }
@ -264,8 +238,8 @@ void plKeysAndValues::Write(hsStream * s)
for (;ki!=ke;++ki) for (;ki!=ke;++ki)
{ {
// write key string // write key string
s->WriteLE((uint16_t)ki->first.size()); s->WriteLE((uint16_t)ki->first.GetSize());
s->Write(ki->first.size(),ki->first.c_str()); s->Write(ki->first.GetSize(),ki->first.c_str());
// write nvalues for this key // write nvalues for this key
s->WriteLE((uint16_t)ki->second.size()); s->WriteLE((uint16_t)ki->second.size());
// iterate through values for this key // iterate through values for this key
@ -274,8 +248,8 @@ void plKeysAndValues::Write(hsStream * s)
for (;vi!=ve;++vi) for (;vi!=ve;++vi)
{ {
// write value string // write value string
s->WriteLE((uint16_t)vi->size()); s->WriteLE((uint16_t)vi->GetSize());
s->Write(vi->size(),vi->c_str()); s->Write(vi->GetSize(),vi->c_str());
} }
} }
} }

43
Sources/Plasma/PubUtilLib/plContainer/plKeysAndValues.h

@ -43,8 +43,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define plKeysAndValues_h_inc #define plKeysAndValues_h_inc
#include "HeadSpin.h" #include "HeadSpin.h"
#include <map>
#include <list>
#include "hsStlUtils.h"
#include "hsStream.h" #include "hsStream.h"
#pragma warning(disable:4284) #pragma warning(disable:4284)
@ -62,9 +63,9 @@ enum KAddValueMode
class plKeysAndValues : public hsStreamable class plKeysAndValues : public hsStreamable
{ {
public: public:
typedef std::list<xtl::istring> typedef std::list<plString>
Values; Values;
typedef std::map<xtl::istring, Values> typedef std::map<plString, Values, plString::less_i>
Keys; Keys;
private: private:
@ -79,31 +80,31 @@ public:
plKeysAndValues & operator =(const plKeysAndValues & src); plKeysAndValues & operator =(const plKeysAndValues & src);
// clear // clear
void Clear(); void Clear();
void RemoveKey(const std::string & key); void RemoveKey(const plString & key);
// query // query
bool HasKey(const std::string & key) const; bool HasKey(const plString & key) const;
bool KeyHasValue(const std::string & key, const std::string & value); bool KeyHasValue(const plString & key, const plString & value);
bool KeyHasValue(const std::string & key, int value); bool KeyHasValue(const plString & key, int value);
bool KeyHasValue(const std::string & key, double value); bool KeyHasValue(const plString & key, double value);
// add // add
bool AddValue(const std::string & key, const std::string & value, KAddValueMode mode=kAlwaysAdd); bool AddValue(const plString & key, const plString & value, KAddValueMode mode=kAlwaysAdd);
bool AddValue(const std::string & key, int value, KAddValueMode mode=kAlwaysAdd); bool AddValue(const plString & key, int value, KAddValueMode mode=kAlwaysAdd);
bool AddValue(const std::string & key, double value, KAddValueMode mode=kAlwaysAdd); bool AddValue(const plString & key, double value, KAddValueMode mode=kAlwaysAdd);
bool AddValues(const std::string & key, const std::vector<std::string> & values, KAddValueMode mode=kAlwaysAdd); bool AddValues(const plString & key, const std::vector<plString> & values, KAddValueMode mode=kAlwaysAdd);
// set (clear and add) // set (clear and add)
bool SetValue(const std::string & key, const std::string & value); bool SetValue(const plString & key, const plString & value);
bool SetValue(const std::string & key, int value); bool SetValue(const plString & key, int value);
bool SetValue(const std::string & key, double value); bool SetValue(const plString & key, double value);
// get single value // get single value
std::string GetValue(const std::string & key, const std::string & defval="", bool * outFound=nil) const; plString GetValue(const plString & key, const plString & defval="", bool * outFound=nil) const;
uint32_t GetValue(const std::string & key, uint32_t defval, bool * outFound=nil) const; uint32_t GetValue(const plString & key, uint32_t defval, bool * outFound=nil) const;
int GetValue(const std::string & key, int defval, bool * outFound=nil) const; int GetValue(const plString & key, int defval, bool * outFound=nil) const;
double GetValue(const std::string & key, double defval, bool * outFound=nil) const; double GetValue(const plString & key, double defval, bool * outFound=nil) const;
std::vector<std::string> GetAllValues(const std::string & key); std::vector<plString> GetAllValues(const plString & key);
// key iterator // key iterator
bool GetKeyIterators(Keys::const_iterator & iter, Keys::const_iterator & end) const; bool GetKeyIterators(Keys::const_iterator & iter, Keys::const_iterator & end) const;
// value iterator (use for getting all values for key) // value iterator (use for getting all values for key)
bool GetValueIterators(const xtl::istring & key, Values::const_iterator & iter, Values::const_iterator & end) const; bool GetValueIterators(const plString & key, Values::const_iterator & iter, Values::const_iterator & end) const;
// streamable // streamable
void Read(hsStream * s); void Read(hsStream * s);
void Write(hsStream * s); void Write(hsStream * s);

2
Sources/Plasma/PubUtilLib/plDrawable/plDynaDecalMgr.h

@ -43,11 +43,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#ifndef plDynaDecalMgr_inc #ifndef plDynaDecalMgr_inc
#define plDynaDecalMgr_inc #define plDynaDecalMgr_inc
#include <map>
#include "pnNetCommon/plSynchedObject.h" #include "pnNetCommon/plSynchedObject.h"
#include "hsTemplates.h" #include "hsTemplates.h"
#include "hsGeometry3.h" #include "hsGeometry3.h"
#include "hsMatrix44.h" #include "hsMatrix44.h"
#include "hsStlUtils.h"
class plParticleSystem; class plParticleSystem;

2
Sources/Plasma/PubUtilLib/plFile/hsFiles_Unix.cpp

@ -50,9 +50,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include <glob.h> #include <glob.h>
#include <string>
#include "hsTemplates.h" #include "hsTemplates.h"
#include "plFileUtils.h" #include "plFileUtils.h"
#include "hsStlUtils.h"
struct hsFolderIterator_Data { struct hsFolderIterator_Data {
glob_t fGlobBuf; glob_t fGlobBuf;

1
Sources/Plasma/PubUtilLib/plFile/plEncryptedStream.cpp

@ -45,6 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsSTLStream.h" #include "hsSTLStream.h"
#include <time.h> #include <time.h>
#include <wchar.h>
static const uint32_t kDefaultKey[4] = { 0x6c0a5452, 0x3827d0f, 0x3a170b92, 0x16db7fc2 }; static const uint32_t kDefaultKey[4] = { 0x6c0a5452, 0x3827d0f, 0x3a170b92, 0x16db7fc2 };
static const int kEncryptChunkSize = 8; static const int kEncryptChunkSize = 8;

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save