Merge branch 'development' into cmake/SPEC-7182
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> # Conflicts: # Code/Editor/QtUtil.h # Code/Legacy/CryCommon/Linux_Win32Wrapper.h # Code/Legacy/CryCommon/ProjectDefines.h # Code/Legacy/CryCommon/StringUtils.h # Code/Legacy/CryCommon/UnicodeBinding.h # Code/Legacy/CryCommon/UnicodeEncoding.h # Code/Legacy/CryCommon/UnicodeFunctions.h # Code/Legacy/CryCommon/UnicodeIterator.h # Code/Legacy/CryCommon/WinBase.cpp # Code/Legacy/CryCommon/platform.h # Code/Legacy/CryCommon/platform_impl.cpp # Gems/LyShine/Code/Source/Animation/UiAnimationSystem.cpp # Gems/Maestro/Code/Source/Cinematics/Movie.cpp
This commit is contained in:
@@ -182,13 +182,8 @@ typedef WCHAR* LPUWSTR, * PUWSTR;
|
||||
typedef const WCHAR* LPCWSTR, * PCWSTR;
|
||||
typedef const WCHAR* LPCUWSTR, * PCUWSTR;
|
||||
|
||||
#ifdef UNICODE
|
||||
typedef LPCWSTR LPCTSTR;
|
||||
typedef LPWSTR LPTSTR;
|
||||
#else
|
||||
typedef LPCSTR LPCTSTR;
|
||||
typedef LPSTR LPTSTR;
|
||||
#endif
|
||||
|
||||
typedef DWORD COLORREF;
|
||||
#define RGB(r,g,b) ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16)))
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <CryLegacyAllocator.h>
|
||||
#include <AzCore/std/string/string.h>
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Convenient iteration macros
|
||||
@@ -44,18 +45,6 @@ struct fake_move_helper
|
||||
}
|
||||
};
|
||||
|
||||
// Override for string to ensure proper construction
|
||||
template <>
|
||||
struct fake_move_helper<string>
|
||||
{
|
||||
static void move(string& dest, string& source)
|
||||
{
|
||||
::new((void*)&dest) string();
|
||||
dest = source;
|
||||
source.~string();
|
||||
}
|
||||
};
|
||||
|
||||
// Generic move function: transfer an existing source object to uninitialized dest address.
|
||||
// Addresses must not overlap (requirement on caller).
|
||||
// May be specialized for specific types, to provide a more optimal move.
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "CryTypeInfo.h"
|
||||
#include "CryFixedString.h"
|
||||
#include <Cry_Math.h>
|
||||
#include <Cry_Color.h>
|
||||
#include <AzCore/Casting/numeric_cast.h>
|
||||
#include <AzCore/std/string/fixed_string.h>
|
||||
|
||||
#define STATIC_CONST(T, name, val) \
|
||||
static inline T name() { static T t = val; return t; }
|
||||
@@ -46,7 +46,7 @@ inline bool HasString(const T& val, FToString flags, const void* def_data = 0)
|
||||
float NumToFromString(float val, int digits, bool floating, char buffer[], int buf_size);
|
||||
|
||||
template<class T>
|
||||
string NumToString(T val, int min_digits, int max_digits, bool floating)
|
||||
AZStd::string NumToString(T val, int min_digits, int max_digits, bool floating)
|
||||
{
|
||||
char buffer[64];
|
||||
float f(val);
|
||||
@@ -68,7 +68,7 @@ struct CStructInfo
|
||||
{
|
||||
CStructInfo(cstr name, size_t size, size_t align, Array<CVarInfo> vars = Array<CVarInfo>(), Array<CTypeInfo const*> templates = Array<CTypeInfo const*>());
|
||||
virtual bool IsType(CTypeInfo const& Info) const;
|
||||
virtual string ToString(const void* data, FToString flags = 0, const void* def_data = 0) const;
|
||||
virtual AZStd::string ToString(const void* data, FToString flags = 0, const void* def_data = 0) const;
|
||||
virtual bool FromString(void* data, cstr str, FFromString flags = 0) const;
|
||||
virtual bool ToValue(const void* data, void* value, const CTypeInfo& typeVal) const;
|
||||
virtual bool FromValue(void* data, const void* value, const CTypeInfo& typeVal) const;
|
||||
@@ -86,9 +86,9 @@ struct CStructInfo
|
||||
}
|
||||
|
||||
protected:
|
||||
Array<CVarInfo> Vars;
|
||||
CryStackStringT<char, 16> EndianDesc; // Encodes instructions for endian swapping.
|
||||
bool HasBitfields;
|
||||
Array<CVarInfo> Vars;
|
||||
AZStd::fixed_string<16> EndianDesc; // Encodes instructions for endian swapping.
|
||||
bool HasBitfields;
|
||||
Array<CTypeInfo const*> TemplateTypes;
|
||||
|
||||
void MakeEndianDesc();
|
||||
@@ -124,11 +124,11 @@ struct TTypeInfo
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual string ToString(const void* data, FToString flags = 0, const void* def_data = 0) const
|
||||
virtual AZStd::string ToString(const void* data, FToString flags = 0, const void* def_data = 0) const
|
||||
{
|
||||
if (!HasString(*(const T*)data, flags, def_data))
|
||||
{
|
||||
return string();
|
||||
return AZStd::string();
|
||||
}
|
||||
return ::ToString(*(const T*)data);
|
||||
}
|
||||
@@ -193,7 +193,7 @@ struct TProxyTypeInfo
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual string ToString(const void* data, FToString flags = 0, const void* def_data = 0) const
|
||||
virtual AZStd::string ToString(const void* data, FToString flags = 0, const void* def_data = 0) const
|
||||
{
|
||||
T val = T(*(const S*)data);
|
||||
T def_val = def_data ? T(*(const S*)def_data) : T();
|
||||
@@ -234,32 +234,32 @@ protected:
|
||||
// Customisation for string.
|
||||
|
||||
template<>
|
||||
inline string TTypeInfo<string>::ToString(const void* data, FToString flags, const void* def_data) const
|
||||
inline AZStd::string TTypeInfo<AZStd::string>::ToString(const void* data, FToString flags, const void* def_data) const
|
||||
{
|
||||
const string& val = *(const string*)data;
|
||||
const AZStd::string& val = *(const AZStd::string*)data;
|
||||
if (def_data && flags.SkipDefault)
|
||||
{
|
||||
if (val == *(const string*)def_data)
|
||||
if (val == *(const AZStd::string*)def_data)
|
||||
{
|
||||
return string();
|
||||
return AZStd::string();
|
||||
}
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline bool TTypeInfo<string>::FromString(void* data, cstr str, FFromString flags) const
|
||||
inline bool TTypeInfo<AZStd::string>::FromString(void* data, cstr str, FFromString flags) const
|
||||
{
|
||||
if (!*str && flags.SkipEmpty)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
*(string*)data = str;
|
||||
*(AZStd::string*)data = str;
|
||||
return true;
|
||||
}
|
||||
|
||||
template<>
|
||||
void TTypeInfo<string>::GetMemoryUsage(ICrySizer* pSizer, void const* data) const;
|
||||
void TTypeInfo<AZStd::string>::GetMemoryUsage(ICrySizer* pSizer, void const* data) const;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
@@ -632,11 +632,11 @@ protected:
|
||||
}
|
||||
|
||||
// Override ToString: Limit to significant digits.
|
||||
virtual string ToString(const void* data, FToString flags = 0, const void* def_data = 0) const
|
||||
virtual AZStd::string ToString(const void* data, FToString flags = 0, const void* def_data = 0) const
|
||||
{
|
||||
if (!HasString(*(const S*)data, flags, def_data))
|
||||
{
|
||||
return string();
|
||||
return AZStd::string();
|
||||
}
|
||||
static int digits = int_ceil(log10f(float(nQUANT)));
|
||||
return NumToString(*(const TFixed*)data, 1, digits + 3, true);
|
||||
@@ -907,12 +907,12 @@ struct TEnumInfo
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual string ToString(const void* data, FToString flags, const void* def_data) const
|
||||
virtual AZStd::string ToString(const void* data, FToString flags, const void* def_data) const
|
||||
{
|
||||
TInt val = *(const TInt*)(data);
|
||||
if (flags.SkipDefault && val == (def_data ? *(const TInt*)def_data : TInt(0)))
|
||||
{
|
||||
return string();
|
||||
return AZStd::string();
|
||||
}
|
||||
|
||||
if (cstr sName = TEnumDef::ToName(val))
|
||||
@@ -1153,13 +1153,13 @@ struct CEnumDefUuid
|
||||
return false;
|
||||
}
|
||||
|
||||
string ToString(const void* data, FToString flags, const void* def_data) const override
|
||||
AZStd::string ToString(const void* data, FToString flags, const void* def_data) const override
|
||||
{
|
||||
const AZ::Uuid& uuidData = *reinterpret_cast<const AZ::Uuid*>(data);
|
||||
const AZ::Uuid& defUuidData = *reinterpret_cast<const AZ::Uuid*>(def_data);
|
||||
if (flags.SkipDefault && uuidData == (def_data ? defUuidData : AZ::Uuid::CreateNull()))
|
||||
{
|
||||
return string();
|
||||
return AZStd::string();
|
||||
}
|
||||
|
||||
if (cstr sName = ToName(uuidData))
|
||||
@@ -1167,7 +1167,7 @@ struct CEnumDefUuid
|
||||
return sName;
|
||||
}
|
||||
|
||||
return string();
|
||||
return AZStd::string();
|
||||
}
|
||||
|
||||
bool FromString(void* data, cstr str, FFromString flags) const override
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include <ISystem.h>
|
||||
#include <AzFramework/Archive/IArchive.h>
|
||||
#include <IConsole.h>
|
||||
#include "StringUtils.h"
|
||||
#include <AzCore/IO/FileIO.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -222,7 +221,7 @@ inline CCryFile::~CCryFile()
|
||||
inline bool CCryFile::Open(const char* filename, const char* mode, int nOpenFlagsEx)
|
||||
{
|
||||
char tempfilename[CRYFILE_MAX_PATH] = "";
|
||||
cry_strcpy(tempfilename, filename);
|
||||
azstrcpy(tempfilename, CRYFILE_MAX_PATH, filename);
|
||||
|
||||
#if !defined (_RELEASE)
|
||||
if (gEnv && gEnv->IsEditor() && gEnv->pConsole)
|
||||
@@ -233,8 +232,8 @@ inline bool CCryFile::Open(const char* filename, const char* mode, int nOpenFlag
|
||||
const int lowercasePaths = pCvar->GetIVal();
|
||||
if (lowercasePaths)
|
||||
{
|
||||
const string lowerString = PathUtil::ToLower(tempfilename);
|
||||
cry_strcpy(tempfilename, lowerString.c_str());
|
||||
const AZStd::string lowerString = PathUtil::ToLower(tempfilename);
|
||||
azstrcpy(tempfilename, CRYFILE_MAX_PATH, lowerString.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -243,7 +242,7 @@ inline bool CCryFile::Open(const char* filename, const char* mode, int nOpenFlag
|
||||
{
|
||||
Close();
|
||||
}
|
||||
cry_strcpy(m_filename, tempfilename);
|
||||
azstrcpy(m_filename, CRYFILE_MAX_PATH, tempfilename);
|
||||
|
||||
if (m_pIArchive)
|
||||
{
|
||||
@@ -430,7 +429,7 @@ inline const char* CCryFile::GetAdjustedFilename() const
|
||||
// Returns standard path otherwise.
|
||||
if (gameUrl != &szAdjustedFile[0])
|
||||
{
|
||||
cry_strcpy(szAdjustedFile, gameUrl);
|
||||
azstrcpy(szAdjustedFile, AZ::IO::IArchive::MaxPath, gameUrl);
|
||||
}
|
||||
return szAdjustedFile;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -182,7 +182,7 @@ private: // DO NOT REMOVE - following methods only to be accessed only via CN
|
||||
};
|
||||
|
||||
typedef std::vector<ListenerRecord> TListenerVec;
|
||||
typedef std::vector<string> TAllocatedNameVec;
|
||||
typedef std::vector<AZStd::string> TAllocatedNameVec;
|
||||
|
||||
inline void StartNotificationScope();
|
||||
inline void EndNotificationScope();
|
||||
@@ -418,7 +418,7 @@ inline size_t CListenerSet<T>::MemSize() const
|
||||
size += sizeof(typename TAllocatedNameVec::value_type);
|
||||
for (typename TAllocatedNameVec::const_iterator iter(m_allocatedNames.begin()); iter != m_allocatedNames.end(); ++iter)
|
||||
{
|
||||
size += iter->GetAllocatedMemory();
|
||||
size += iter->capacity() * sizeof(char) + sizeof(AZStd::string);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -395,13 +395,13 @@ inline bool CCryName::operator>(const CCryName& n) const
|
||||
return m_str > n.m_str;
|
||||
}
|
||||
|
||||
inline bool operator==(const string& s, const CCryName& n)
|
||||
inline bool operator==(const AZStd::string& s, const CCryName& n)
|
||||
{
|
||||
return n == s;
|
||||
return s == n.c_str();
|
||||
}
|
||||
inline bool operator!=(const string& s, const CCryName& n)
|
||||
inline bool operator!=(const AZStd::string& s, const CCryName& n)
|
||||
{
|
||||
return n != s;
|
||||
return s != n.c_str();
|
||||
}
|
||||
|
||||
inline bool operator==(const char* s, const CCryName& n)
|
||||
@@ -543,13 +543,13 @@ inline bool CCryNameCRC::operator>(const CCryNameCRC& n) const
|
||||
return m_nID > n.m_nID;
|
||||
}
|
||||
|
||||
inline bool operator==(const string& s, const CCryNameCRC& n)
|
||||
inline bool operator==(const AZStd::string& s, const CCryNameCRC& n)
|
||||
{
|
||||
return n == s;
|
||||
return n == s.c_str();
|
||||
}
|
||||
inline bool operator!=(const string& s, const CCryNameCRC& n)
|
||||
inline bool operator!=(const AZStd::string& s, const CCryNameCRC& n)
|
||||
{
|
||||
return n != s;
|
||||
return n != s.c_str();
|
||||
}
|
||||
|
||||
inline bool operator==(const char* s, const CCryNameCRC& n)
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
#include <ISystem.h>
|
||||
#include <AzFramework/Archive/IArchive.h>
|
||||
#include <IConsole.h>
|
||||
#include <AzCore/std/string/string.h>
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
@@ -31,26 +33,28 @@
|
||||
#define CRY_NATIVE_PATH_SEPSTR DOS_PATH_SEP_STR
|
||||
#endif
|
||||
|
||||
typedef AZStd::fixed_string<512> stack_string;
|
||||
|
||||
namespace PathUtil
|
||||
{
|
||||
const static int maxAliasLength = 32;
|
||||
inline string GetLocalizationFolder()
|
||||
inline AZStd::string GetLocalizationFolder()
|
||||
{
|
||||
return gEnv->pCryPak->GetLocalizationFolder();
|
||||
}
|
||||
|
||||
inline string GetLocalizationRoot()
|
||||
inline AZStd::string GetLocalizationRoot()
|
||||
{
|
||||
return gEnv->pCryPak->GetLocalizationRoot();
|
||||
}
|
||||
|
||||
//! Convert a path to the uniform form.
|
||||
inline string ToUnixPath(const string& strPath)
|
||||
inline AZStd::string ToUnixPath(const AZStd::string& strPath)
|
||||
{
|
||||
if (strPath.find(DOS_PATH_SEP_CHR) != string::npos)
|
||||
if (strPath.find(DOS_PATH_SEP_CHR) != AZStd::string::npos)
|
||||
{
|
||||
string path = strPath;
|
||||
path.replace(DOS_PATH_SEP_CHR, UNIX_PATH_SEP_CHR);
|
||||
AZStd::string path = strPath;
|
||||
AZ::StringFunc::Replace(path, DOS_PATH_SEP_CHR, UNIX_PATH_SEP_CHR);
|
||||
return path;
|
||||
}
|
||||
return strPath;
|
||||
@@ -73,19 +77,19 @@ namespace PathUtil
|
||||
}
|
||||
|
||||
//! Convert a path to the DOS form.
|
||||
inline string ToDosPath(const string& strPath)
|
||||
inline AZStd::string ToDosPath(const AZStd::string& strPath)
|
||||
{
|
||||
if (strPath.find(UNIX_PATH_SEP_CHR) != string::npos)
|
||||
if (strPath.find(UNIX_PATH_SEP_CHR) != AZStd::string::npos)
|
||||
{
|
||||
string path = strPath;
|
||||
path.replace(UNIX_PATH_SEP_CHR, DOS_PATH_SEP_CHR);
|
||||
AZStd::string path = strPath;
|
||||
AZ::StringFunc::Replace(path, UNIX_PATH_SEP_CHR, DOS_PATH_SEP_CHR);
|
||||
return path;
|
||||
}
|
||||
return strPath;
|
||||
}
|
||||
|
||||
//! Convert a path to the Native form.
|
||||
inline string ToNativePath(const string& strPath)
|
||||
inline AZStd::string ToNativePath(const AZStd::string& strPath)
|
||||
{
|
||||
#if AZ_LEGACY_CRYCOMMON_TRAIT_USE_UNIX_PATHS
|
||||
return ToUnixPath(strPath);
|
||||
@@ -95,10 +99,10 @@ namespace PathUtil
|
||||
}
|
||||
|
||||
//! Convert a path to lowercase form
|
||||
inline string ToLower(const string& strPath)
|
||||
inline AZStd::string ToLower(const AZStd::string& strPath)
|
||||
{
|
||||
string path = strPath;
|
||||
path.MakeLower();
|
||||
AZStd::string path = strPath;
|
||||
AZStd::to_lower(path.begin(), path.end());
|
||||
return path;
|
||||
}
|
||||
|
||||
@@ -108,9 +112,9 @@ namespace PathUtil
|
||||
//! @param path [OUT] Extracted file path.
|
||||
//! @param filename [OUT] Extracted file (without extension).
|
||||
//! @param ext [OUT] Extracted files extension.
|
||||
inline void Split(const string& filepath, string& path, string& filename, string& fext)
|
||||
inline void Split(const AZStd::string& filepath, AZStd::string& path, AZStd::string& filename, AZStd::string& fext)
|
||||
{
|
||||
path = filename = fext = string();
|
||||
path = filename = fext = AZStd::string();
|
||||
if (filepath.empty())
|
||||
{
|
||||
return;
|
||||
@@ -142,16 +146,16 @@ namespace PathUtil
|
||||
//! @param filepath [IN] Full file name inclusing path.
|
||||
//! @param path [OUT] Extracted file path.
|
||||
//! @param file [OUT] Extracted file (with extension).
|
||||
inline void Split(const string& filepath, string& path, string& file)
|
||||
inline void Split(const AZStd::string& filepath, AZStd::string& path, AZStd::string& file)
|
||||
{
|
||||
string fext;
|
||||
AZStd::string fext;
|
||||
Split(filepath, path, file, fext);
|
||||
file += fext;
|
||||
}
|
||||
|
||||
// Extract extension from full specified file path
|
||||
// Returns
|
||||
// pointer to the extension (without .) or pointer to an empty 0-terminated string
|
||||
// pointer to the extension (without .) or pointer to an empty 0-terminated AZStd::string
|
||||
inline const char* GetExt(const char* filepath)
|
||||
{
|
||||
const char* str = filepath;
|
||||
@@ -174,7 +178,7 @@ namespace PathUtil
|
||||
}
|
||||
|
||||
//! Extract path from full specified file path.
|
||||
inline string GetPath(const string& filepath)
|
||||
inline AZStd::string GetPath(const AZStd::string& filepath)
|
||||
{
|
||||
const char* str = filepath.c_str();
|
||||
for (const char* p = str + filepath.length() - 1; p >= str; --p)
|
||||
@@ -191,9 +195,9 @@ namespace PathUtil
|
||||
}
|
||||
|
||||
//! Extract path from full specified file path.
|
||||
inline string GetPath(const char* filepath)
|
||||
inline AZStd::string GetPath(const char* filepath)
|
||||
{
|
||||
return GetPath(string(filepath));
|
||||
return GetPath(AZStd::string(filepath));
|
||||
}
|
||||
|
||||
//! Extract path from full specified file path.
|
||||
@@ -214,7 +218,7 @@ namespace PathUtil
|
||||
}
|
||||
|
||||
//! Extract file name with extension from full specified file path.
|
||||
inline string GetFile(const string& filepath)
|
||||
inline AZStd::string GetFile(const AZStd::string& filepath)
|
||||
{
|
||||
const char* str = filepath.c_str();
|
||||
for (const char* p = str + filepath.length() - 1; p >= str; --p)
|
||||
@@ -247,7 +251,7 @@ namespace PathUtil
|
||||
}
|
||||
|
||||
//! Replace extension for given file.
|
||||
inline void RemoveExtension(string& filepath)
|
||||
inline void RemoveExtension(AZStd::string& filepath)
|
||||
{
|
||||
const char* str = filepath.c_str();
|
||||
for (const char* p = str + filepath.length() - 1; p >= str; --p)
|
||||
@@ -291,15 +295,15 @@ namespace PathUtil
|
||||
}
|
||||
|
||||
//! Extract file name without extension from full specified file path.
|
||||
inline string GetFileName(const string& filepath)
|
||||
inline AZStd::string GetFileName(const AZStd::string& filepath)
|
||||
{
|
||||
string file = filepath;
|
||||
AZStd::string file = filepath;
|
||||
RemoveExtension(file);
|
||||
return GetFile(file);
|
||||
}
|
||||
|
||||
//! Removes the trailing slash or backslash from a given path.
|
||||
inline string RemoveSlash(const string& path)
|
||||
inline AZStd::string RemoveSlash(const AZStd::string& path)
|
||||
{
|
||||
if (path.empty() || (path[path.length() - 1] != '/' && path[path.length() - 1] != '\\'))
|
||||
{
|
||||
@@ -309,13 +313,13 @@ namespace PathUtil
|
||||
}
|
||||
|
||||
//! get slash
|
||||
inline string GetSlash()
|
||||
inline AZStd::string GetSlash()
|
||||
{
|
||||
return CRY_NATIVE_PATH_SEPSTR;
|
||||
}
|
||||
|
||||
//! add a backslash if needed
|
||||
inline string AddSlash(const string& path)
|
||||
inline AZStd::string AddSlash(const AZStd::string& path)
|
||||
{
|
||||
if (path.empty() || path[path.length() - 1] == '/')
|
||||
{
|
||||
@@ -343,9 +347,9 @@ namespace PathUtil
|
||||
}
|
||||
|
||||
//! add a backslash if needed
|
||||
inline string AddSlash(const char* path)
|
||||
inline AZStd::string AddSlash(const char* path)
|
||||
{
|
||||
return AddSlash(string(path));
|
||||
return AddSlash(AZStd::string(path));
|
||||
}
|
||||
|
||||
inline stack_string ReplaceExtension(const stack_string& filepath, const char* ext)
|
||||
@@ -364,9 +368,9 @@ namespace PathUtil
|
||||
}
|
||||
|
||||
//! Replace extension for given file.
|
||||
inline string ReplaceExtension(const string& filepath, const char* ext)
|
||||
inline AZStd::string ReplaceExtension(const AZStd::string& filepath, const char* ext)
|
||||
{
|
||||
string str = filepath;
|
||||
AZStd::string str = filepath;
|
||||
if (ext != 0)
|
||||
{
|
||||
RemoveExtension(str);
|
||||
@@ -380,29 +384,30 @@ namespace PathUtil
|
||||
}
|
||||
|
||||
//! Replace extension for given file.
|
||||
inline string ReplaceExtension(const char* filepath, const char* ext)
|
||||
inline AZStd::string ReplaceExtension(const char* filepath, const char* ext)
|
||||
{
|
||||
return ReplaceExtension(string(filepath), ext);
|
||||
return ReplaceExtension(AZStd::string(filepath), ext);
|
||||
}
|
||||
|
||||
//! Makes a fully specified file path from path and file name.
|
||||
inline string Make(const string& path, const string& file)
|
||||
inline AZStd::string Make(const AZStd::string& path, const AZStd::string& file)
|
||||
{
|
||||
return AddSlash(path) + file;
|
||||
}
|
||||
|
||||
//! Makes a fully specified file path from path and file name.
|
||||
inline string Make(const string& dir, const string& filename, const string& ext)
|
||||
inline AZStd::string Make(const AZStd::string& dir, const AZStd::string& filename, const AZStd::string& ext)
|
||||
{
|
||||
string path = ReplaceExtension(filename, ext);
|
||||
AZStd::string path = filename;
|
||||
AZ::StringFunc::Path::ReplaceExtension(path, ext.c_str());
|
||||
path = AddSlash(dir) + path;
|
||||
return path;
|
||||
}
|
||||
|
||||
//! Makes a fully specified file path from path and file name.
|
||||
inline string Make(const string& dir, const string& filename, const char* ext)
|
||||
inline AZStd::string Make(const AZStd::string& dir, const AZStd::string& filename, const char* ext)
|
||||
{
|
||||
return Make(dir, filename, string(ext));
|
||||
return Make(dir, filename, AZStd::string(ext));
|
||||
}
|
||||
|
||||
//! Makes a fully specified file path from path and file name.
|
||||
@@ -414,42 +419,43 @@ namespace PathUtil
|
||||
//! Makes a fully specified file path from path and file name.
|
||||
inline stack_string Make(const stack_string& dir, const stack_string& filename, const stack_string& ext)
|
||||
{
|
||||
stack_string path = ReplaceExtension(filename, ext);
|
||||
path = AddSlash(dir) + path;
|
||||
return path;
|
||||
AZStd::string path = filename.c_str();
|
||||
AZ::StringFunc::Path::ReplaceExtension(path, ext.c_str());
|
||||
path = AddSlash(dir.c_str()) + path;
|
||||
return stack_string(path.c_str());
|
||||
}
|
||||
|
||||
//! Makes a fully specified file path from path and file name.
|
||||
inline string Make(const char* path, const string& file)
|
||||
inline AZStd::string Make(const char* path, const AZStd::string& file)
|
||||
{
|
||||
return Make(string(path), file);
|
||||
return Make(AZStd::string(path), file);
|
||||
}
|
||||
|
||||
//! Makes a fully specified file path from path and file name.
|
||||
inline string Make(const string& path, const char* file)
|
||||
inline AZStd::string Make(const AZStd::string& path, const char* file)
|
||||
{
|
||||
return Make(path, string(file));
|
||||
return Make(path, AZStd::string(file));
|
||||
}
|
||||
|
||||
//! Makes a fully specified file path from path and file name.
|
||||
inline string Make(const char path[], const char file[])
|
||||
inline AZStd::string Make(const char path[], const char file[])
|
||||
{
|
||||
return Make(string(path), string(file));
|
||||
return Make(AZStd::string(path), AZStd::string(file));
|
||||
}
|
||||
|
||||
//! Makes a fully specified file path from path and file name.
|
||||
inline string Make(const char* path, const char* file, const char* ext)
|
||||
inline AZStd::string Make(const char* path, const char* file, const char* ext)
|
||||
{
|
||||
return Make(string(path), string(file), string(ext));
|
||||
return Make(AZStd::string(path), AZStd::string(file), AZStd::string(ext));
|
||||
}
|
||||
|
||||
//! Makes a fully specified file path from path and file name.
|
||||
inline string MakeFullPath(const string& relativePath)
|
||||
inline AZStd::string MakeFullPath(const AZStd::string& relativePath)
|
||||
{
|
||||
return relativePath;
|
||||
}
|
||||
|
||||
inline string GetParentDirectory (const string& strFilePath, int nGeneration = 1)
|
||||
inline AZStd::string GetParentDirectory (const AZStd::string& strFilePath, int nGeneration = 1)
|
||||
{
|
||||
for (const char* p = strFilePath.c_str() + strFilePath.length() - 2; // -2 is for the possible trailing slash: there always must be some trailing symbol which is the file/directory name for which we should get the parent
|
||||
p >= strFilePath.c_str();
|
||||
@@ -458,23 +464,23 @@ namespace PathUtil
|
||||
switch (*p)
|
||||
{
|
||||
case ':':
|
||||
return string (strFilePath.c_str(), p);
|
||||
return AZStd::string(strFilePath.c_str(), p);
|
||||
case '/':
|
||||
case '\\':
|
||||
// we've reached a path separator - return everything before it.
|
||||
if (!--nGeneration)
|
||||
{
|
||||
return string(strFilePath.c_str(), p);
|
||||
return AZStd::string(strFilePath.c_str(), p);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
// it seems the file name is a pure name, without path or extension
|
||||
return string();
|
||||
return AZStd::string();
|
||||
}
|
||||
|
||||
template<typename T, size_t SIZE>
|
||||
inline CryStackStringT<T, SIZE> GetParentDirectoryStackString(const CryStackStringT<T, SIZE>& strFilePath, int nGeneration = 1)
|
||||
inline AZStd::basic_fixed_string<T, SIZE> GetParentDirectoryStackString(const AZStd::basic_fixed_string<T, SIZE>& strFilePath, int nGeneration = 1)
|
||||
{
|
||||
for (const char* p = strFilePath.c_str() + strFilePath.length() - 2; // -2 is for the possible trailing slash: there always must be some trailing symbol which is the file/directory name for which we should get the parent
|
||||
p >= strFilePath.c_str();
|
||||
@@ -483,19 +489,19 @@ namespace PathUtil
|
||||
switch (*p)
|
||||
{
|
||||
case ':':
|
||||
return CryStackStringT<T, SIZE> (strFilePath.c_str(), p);
|
||||
return AZStd::basic_fixed_string<T, SIZE> (strFilePath.c_str(), p);
|
||||
case '/':
|
||||
case '\\':
|
||||
// we've reached a path separator - return everything before it.
|
||||
if (!--nGeneration)
|
||||
{
|
||||
return CryStackStringT<T, SIZE>(strFilePath.c_str(), p);
|
||||
return AZStd::basic_fixed_string<T, SIZE>(strFilePath.c_str(), p);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
// it seems the file name is a pure name, without path or extension
|
||||
return CryStackStringT<T, SIZE>();
|
||||
return AZStd::basic_fixed_string<T, SIZE>();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -503,7 +509,8 @@ namespace PathUtil
|
||||
// Make a game correct path out of any input path.
|
||||
inline stack_string MakeGamePath(const stack_string& path)
|
||||
{
|
||||
stack_string relativePath(ToUnixPath(path));
|
||||
stack_string relativePath = path;
|
||||
ToUnixPath(relativePath);
|
||||
|
||||
if ((!gEnv) || (!gEnv->pFileIO))
|
||||
{
|
||||
@@ -512,7 +519,7 @@ namespace PathUtil
|
||||
unsigned int index = 0;
|
||||
if (relativePath.length() && relativePath[index] == '@') // already aliased
|
||||
{
|
||||
if (relativePath.compareNoCase(0, 9, "@assets@/") == 0)
|
||||
if (AZ::StringFunc::Equal(relativePath.c_str(), "@assets@/", false, 9))
|
||||
{
|
||||
return relativePath.substr(9); // assets is assumed.
|
||||
}
|
||||
@@ -526,7 +533,7 @@ namespace PathUtil
|
||||
if (
|
||||
(rootPath.size() > 0) &&
|
||||
(rootPath.size() < relativePath.size()) &&
|
||||
(relativePath.compareNoCase(0, rootPath.size(), rootPath) == 0)
|
||||
(AZ::StringFunc::Equal(relativePath.c_str(), rootPath.c_str(), false, rootPath.size()))
|
||||
)
|
||||
{
|
||||
stack_string chopped_string = relativePath.substr(rootPath.size());
|
||||
@@ -543,13 +550,13 @@ namespace PathUtil
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Description:
|
||||
// Make a game correct path out of any input path.
|
||||
inline string MakeGamePath(const string& path)
|
||||
inline AZStd::string MakeGamePath(const AZStd::string& path)
|
||||
{
|
||||
stack_string stackPath(path.c_str());
|
||||
return MakeGamePath(stackPath).c_str();
|
||||
}
|
||||
|
||||
// returns true if the string matches the wildcard
|
||||
// returns true if the AZStd::string matches the wildcard
|
||||
inline bool MatchWildcard (const char* szString, const char* szWildcard)
|
||||
{
|
||||
const char* pString = szString, * pWildcard = szWildcard;
|
||||
@@ -595,7 +602,7 @@ namespace PathUtil
|
||||
|
||||
if (!*pWildcard)
|
||||
{
|
||||
return true; // the rest of the string doesn't matter: the wildcard ends with *
|
||||
return true; // the rest of the AZStd::string doesn't matter: the wildcard ends with *
|
||||
}
|
||||
for (; *pString; ++pString)
|
||||
{
|
||||
|
||||
@@ -208,9 +208,7 @@ public:
|
||||
this->AddObject(rPair.first);
|
||||
this->AddObject(rPair.second);
|
||||
}
|
||||
void AddObject(const string& rString) {this->AddObject(rString.c_str(), rString.capacity()); }
|
||||
void AddObject(const CryStringT<wchar_t>& rString) {this->AddObject(rString.c_str(), rString.capacity()); }
|
||||
void AddObject(const CryFixedStringT<32>&){}
|
||||
void AddObject(const AZStd::string& rString) {this->AddObject(rString.c_str(), rString.capacity()); }
|
||||
void AddObject(const wchar_t&) {}
|
||||
void AddObject(const char&) {}
|
||||
void AddObject(const unsigned char&) {}
|
||||
@@ -427,7 +425,7 @@ public:
|
||||
#endif
|
||||
|
||||
#ifndef NOT_USE_CRY_STRING
|
||||
bool Add (const string& strText)
|
||||
bool Add (const AZStd::string& strText)
|
||||
{
|
||||
AddString(strText);
|
||||
return true;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -225,7 +225,7 @@ private:
|
||||
volatile bool m_bIsStarted;
|
||||
volatile bool m_bIsRunning;
|
||||
volatile bool m_bCreatedThread;
|
||||
string m_name;
|
||||
AZStd::string m_name;
|
||||
|
||||
protected:
|
||||
virtual void Terminate()
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "CrySizer.h"
|
||||
#include "CryEndian.h"
|
||||
#include "TypeInfo_impl.h"
|
||||
#include <AzCore/std/string/fixed_string.h>
|
||||
|
||||
// Traits
|
||||
#if defined(AZ_RESTRICTED_PLATFORM)
|
||||
@@ -114,7 +115,7 @@ TYPE_INFO_INT(uint64)
|
||||
TYPE_INFO_BASIC(float)
|
||||
TYPE_INFO_BASIC(double)
|
||||
|
||||
TYPE_INFO_BASIC(string)
|
||||
TYPE_INFO_BASIC(AZStd::string)
|
||||
|
||||
|
||||
const CTypeInfo&PtrTypeInfo()
|
||||
@@ -129,10 +130,9 @@ const CTypeInfo&PtrTypeInfo()
|
||||
// String conversion functions needed by TypeInfo.
|
||||
|
||||
// bool
|
||||
string ToString(bool const& val)
|
||||
AZStd::string ToString(bool const& val)
|
||||
{
|
||||
static string sTrue = "true", sFalse = "false";
|
||||
return val ? sTrue : sFalse;
|
||||
return val ? "true" : "false";
|
||||
}
|
||||
|
||||
bool FromString(bool& val, cstr s)
|
||||
@@ -151,14 +151,14 @@ bool FromString(bool& val, cstr s)
|
||||
}
|
||||
|
||||
// int64
|
||||
string ToString(int64 const& val)
|
||||
AZStd::string ToString(int64 const& val)
|
||||
{
|
||||
char buffer[64];
|
||||
_i64toa_s(val, buffer, sizeof(buffer), 10);
|
||||
return buffer;
|
||||
}
|
||||
// uint64
|
||||
string ToString(uint64 const& val)
|
||||
AZStd::string ToString(uint64 const& val)
|
||||
{
|
||||
char buffer[64];
|
||||
sprintf_s(buffer, "%" PRIu64, val);
|
||||
@@ -168,7 +168,7 @@ string ToString(uint64 const& val)
|
||||
|
||||
|
||||
// long
|
||||
string ToString(long const& val)
|
||||
AZStd::string ToString(long const& val)
|
||||
{
|
||||
char buffer[64];
|
||||
_ltoa_s(val, buffer, sizeof(buffer), 10);
|
||||
@@ -176,7 +176,7 @@ string ToString(long const& val)
|
||||
}
|
||||
|
||||
// ulong
|
||||
string ToString(unsigned long const& val)
|
||||
AZStd::string ToString(unsigned long const& val)
|
||||
{
|
||||
char buffer[64];
|
||||
_ultoa_s(val, buffer, sizeof(buffer), 10);
|
||||
@@ -233,33 +233,33 @@ bool FromString(uint64& val, const char* s) { return Clamped
|
||||
bool FromString(long& val, const char* s) { return ClampedIntFromString(val, s); }
|
||||
bool FromString(unsigned long& val, const char* s) { return ClampedIntFromString(val, s); }
|
||||
|
||||
string ToString(int const& val) { return ToString(long(val)); }
|
||||
AZStd::string ToString(int const& val) { return ToString(long(val)); }
|
||||
bool FromString(int& val, const char* s) { return ClampedIntFromString(val, s); }
|
||||
|
||||
string ToString(unsigned int const& val) { return ToString((unsigned long)(val)); }
|
||||
AZStd::string ToString(unsigned int const& val) { return ToString((unsigned long)(val)); }
|
||||
bool FromString(unsigned int& val, const char* s) { return ClampedIntFromString(val, s); }
|
||||
|
||||
string ToString(short const& val) { return ToString(long(val)); }
|
||||
AZStd::string ToString(short const& val) { return ToString(long(val)); }
|
||||
bool FromString(short& val, const char* s) { return ClampedIntFromString(val, s); }
|
||||
|
||||
string ToString(unsigned short const& val) { return ToString((unsigned long)(val)); }
|
||||
AZStd::string ToString(unsigned short const& val) { return ToString((unsigned long)(val)); }
|
||||
bool FromString(unsigned short& val, const char* s) { return ClampedIntFromString(val, s); }
|
||||
|
||||
string ToString(char const& val) { return ToString(long(val)); }
|
||||
AZStd::string ToString(char const& val) { return ToString(long(val)); }
|
||||
bool FromString(char& val, const char* s) { return ClampedIntFromString(val, s); }
|
||||
|
||||
string ToString(wchar_t const& val) { return ToString(long(val)); }
|
||||
AZStd::string ToString(wchar_t const& val) { return ToString(long(val)); }
|
||||
bool FromString(wchar_t& val, const char* s) { return ClampedIntFromString(val, s); }
|
||||
|
||||
string ToString(signed char const& val) { return ToString(long(val)); }
|
||||
AZStd::string ToString(signed char const& val) { return ToString(long(val)); }
|
||||
bool FromString(signed char& val, const char* s) { return ClampedIntFromString(val, s); }
|
||||
|
||||
string ToString(unsigned char const& val) { return ToString((unsigned long)(val)); }
|
||||
AZStd::string ToString(unsigned char const& val) { return ToString((unsigned long)(val)); }
|
||||
bool FromString(unsigned char& val, const char* s) { return ClampedIntFromString(val, s); }
|
||||
|
||||
string ToString(const AZ::Uuid& val)
|
||||
AZStd::string ToString(const AZ::Uuid& val)
|
||||
{
|
||||
return val.ToString<string>();
|
||||
return val.ToString<AZStd::string>();
|
||||
}
|
||||
|
||||
bool FromString(AZ::Uuid& val, const char* s)
|
||||
@@ -295,7 +295,7 @@ float NumToFromString(float val, int digits, bool floating, char buffer[], int b
|
||||
}
|
||||
|
||||
// double
|
||||
string ToString(double const& val)
|
||||
AZStd::string ToString(double const& val)
|
||||
{
|
||||
char buffer[64];
|
||||
sprintf_s(buffer, "%.16g", val);
|
||||
@@ -307,7 +307,7 @@ bool FromString(double& val, const char* s)
|
||||
}
|
||||
|
||||
// float
|
||||
string ToString(float const& val)
|
||||
AZStd::string ToString(float const& val)
|
||||
{
|
||||
char buffer[64];
|
||||
for (int digits = 7; digits < 10; digits++)
|
||||
@@ -329,11 +329,11 @@ bool FromString(float& val, const char* s)
|
||||
|
||||
// string override.
|
||||
template <>
|
||||
void TTypeInfo<string>::GetMemoryUsage(ICrySizer* pSizer, void const* data) const
|
||||
void TTypeInfo<AZStd::string>::GetMemoryUsage(ICrySizer* pSizer, void const* data) const
|
||||
{
|
||||
// CRAIG: just a temp hack to try and get things working
|
||||
#if !defined(LINUX) && !defined(APPLE)
|
||||
pSizer->AddString(*(string*)data);
|
||||
pSizer->AddString(*(AZStd::string*)data);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -343,7 +343,7 @@ struct STypeInfoTest
|
||||
{
|
||||
STypeInfoTest()
|
||||
{
|
||||
TestType(string("well"));
|
||||
TestType(AZStd::string("well"));
|
||||
|
||||
TestType(true);
|
||||
|
||||
@@ -435,7 +435,7 @@ bool CTypeInfo::CVarInfo::GetAttr(cstr name) const
|
||||
return FindAttr(Attrs, name) != 0;
|
||||
}
|
||||
|
||||
bool CTypeInfo::CVarInfo::GetAttr(cstr name, string& val) const
|
||||
bool CTypeInfo::CVarInfo::GetAttr(cstr name, AZStd::string& val) const
|
||||
{
|
||||
cstr valstr = FindAttr(Attrs, name);
|
||||
if (!valstr)
|
||||
@@ -459,7 +459,7 @@ bool CTypeInfo::CVarInfo::GetAttr(cstr name, string& val) const
|
||||
end--;
|
||||
}
|
||||
}
|
||||
val = string(valstr, end - valstr);
|
||||
val = AZStd::string(valstr, end - valstr);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -735,7 +735,7 @@ bool CStructInfo::ToValue(const void* data, void* value, const CTypeInfo& typeVa
|
||||
Nameless , 1, ,2 1,2 ;
|
||||
*/
|
||||
|
||||
static void StripCommas(string& str)
|
||||
static void StripCommas(AZStd::string& str)
|
||||
{
|
||||
size_t nLast = str.size();
|
||||
while (nLast > 0 && str[nLast - 1] == ',')
|
||||
@@ -745,9 +745,9 @@ static void StripCommas(string& str)
|
||||
str.resize(nLast);
|
||||
}
|
||||
|
||||
string CStructInfo::ToString(const void* data, FToString flags, const void* def_data) const
|
||||
AZStd::string CStructInfo::ToString(const void* data, FToString flags, const void* def_data) const
|
||||
{
|
||||
string str; // Return str.
|
||||
AZStd::string str; // Return str.
|
||||
|
||||
for (int i = 0; i < Vars.size(); i++)
|
||||
{
|
||||
@@ -763,7 +763,7 @@ string CStructInfo::ToString(const void* data, FToString flags, const void* def_
|
||||
str += ",";
|
||||
}
|
||||
|
||||
string substr = var.ToString(data, FToString(flags).Sub(0), def_data);
|
||||
AZStd::string substr = var.ToString(data, FToString(flags).Sub(0), def_data);
|
||||
|
||||
if (flags.SkipDefault && substr.empty())
|
||||
{
|
||||
@@ -772,7 +772,7 @@ string CStructInfo::ToString(const void* data, FToString flags, const void* def_
|
||||
|
||||
if (flags.NamedFields)
|
||||
{
|
||||
if (*str)
|
||||
if (*str.c_str())
|
||||
{
|
||||
str += ",";
|
||||
}
|
||||
@@ -782,7 +782,7 @@ string CStructInfo::ToString(const void* data, FToString flags, const void* def_
|
||||
str += "=";
|
||||
}
|
||||
}
|
||||
if (substr.find(',') != string::npos || substr.find('=') != string::npos)
|
||||
if (substr.find(',') != AZStd::string::npos || substr.find('=') != AZStd::string::npos)
|
||||
{
|
||||
// Encase nested composite types in parens.
|
||||
str += "(";
|
||||
@@ -811,7 +811,7 @@ string CStructInfo::ToString(const void* data, FToString flags, const void* def_
|
||||
// Retrieve and return one subelement from src, advancing the pointer.
|
||||
// Copy to tempstr if necessary.
|
||||
|
||||
typedef CryStackStringT<char, 256> CTempStr;
|
||||
typedef AZStd::fixed_string<256> CTempStr;
|
||||
|
||||
void ParseElement(cstr& src, cstr& varname, cstr& val, CTempStr& tempstr)
|
||||
{
|
||||
@@ -882,21 +882,24 @@ void ParseElement(cstr& src, cstr& varname, cstr& val, CTempStr& tempstr)
|
||||
if (*end)
|
||||
{
|
||||
// Must copy sub string to temp.
|
||||
val = (cstr)tempstr + (val - varname);
|
||||
eq = (cstr)tempstr + (eq - varname);
|
||||
varname = tempstr.assign(varname, end);
|
||||
val = tempstr.c_str() + (val - varname);
|
||||
eq = tempstr.c_str() + (eq - varname);
|
||||
tempstr.assign(varname, end);
|
||||
varname = tempstr.c_str();
|
||||
non_const(*eq) = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Copy just varname to temp, return val in place.
|
||||
varname = tempstr.assign(varname, eq);
|
||||
tempstr.assign(varname, eq);
|
||||
varname = tempstr.c_str();
|
||||
}
|
||||
}
|
||||
else if (*end)
|
||||
{
|
||||
// Must copy sub string to temp.
|
||||
val = tempstr.assign(val, end);
|
||||
tempstr.assign(val, end);
|
||||
val = tempstr.c_str();
|
||||
}
|
||||
|
||||
// Else can return val without copying.
|
||||
@@ -963,7 +966,7 @@ void CStructInfo::SwapEndian(void* data, size_t nCount, bool bWriting) const
|
||||
{
|
||||
non_const(*this).MakeEndianDesc();
|
||||
|
||||
if (EndianDesc.length() == 1 && !HasBitfields && EndianDescSize(EndianDesc) == Size)
|
||||
if (EndianDesc.length() == 1 && !HasBitfields && EndianDescSize(EndianDesc.c_str()) == Size)
|
||||
{
|
||||
// Optimised array swap.
|
||||
size_t nElems = (EndianDesc[0u] & 0x3F) * nCount;
|
||||
@@ -989,7 +992,7 @@ void CStructInfo::SwapEndian(void* data, size_t nCount, bool bWriting) const
|
||||
// First swap bits.
|
||||
// Iterate the endian descriptor.
|
||||
void* step = data;
|
||||
for (cstr desc = EndianDesc; *desc; desc++)
|
||||
for (cstr desc = EndianDesc.c_str(); *desc; desc++)
|
||||
{
|
||||
size_t nElems = *desc & 0x3F;
|
||||
switch (*desc & 0xC0)
|
||||
@@ -1064,7 +1067,7 @@ void CStructInfo::MakeEndianDesc()
|
||||
// Struct-computed endian desc.
|
||||
CStructInfo const& infoSub = static_cast<CStructInfo const&>(var.Type);
|
||||
non_const(infoSub).MakeEndianDesc();
|
||||
subdesc = infoSub.EndianDesc;
|
||||
subdesc = infoSub.EndianDesc.c_str();
|
||||
if (!*subdesc)
|
||||
{
|
||||
// No swapping.
|
||||
|
||||
@@ -17,13 +17,12 @@
|
||||
#include <platform.h>
|
||||
#include "CryArray.h"
|
||||
#include "Options.h"
|
||||
#include "CryString.h"
|
||||
#include "TypeInfo_decl.h"
|
||||
|
||||
class ICrySizer;
|
||||
|
||||
class CCryName;
|
||||
string ToString(CCryName const& val);
|
||||
AZStd::string ToString(CCryName const& val);
|
||||
bool FromString(CCryName& val, const char* s);
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -85,7 +84,7 @@ struct CTypeInfo
|
||||
//
|
||||
|
||||
// Convert value to string.
|
||||
virtual string ToString([[maybe_unused]] const void* data, [[maybe_unused]] FToString flags = 0, [[maybe_unused]] const void* def_data = 0) const
|
||||
virtual AZStd::string ToString([[maybe_unused]] const void* data, [[maybe_unused]] FToString flags = 0, [[maybe_unused]] const void* def_data = 0) const
|
||||
{ return ""; }
|
||||
|
||||
// Write value from string, return success.
|
||||
@@ -180,7 +179,7 @@ struct CTypeInfo
|
||||
assert(!bBitfield);
|
||||
return Type.FromString((char*)base + Offset, str, flags);
|
||||
}
|
||||
string ToString(const void* base, FToString flags = 0, const void* def_base = 0) const
|
||||
AZStd::string ToString(const void* base, FToString flags = 0, const void* def_base = 0) const
|
||||
{
|
||||
assert(!bBitfield);
|
||||
return Type.ToString((const char*)base + Offset, flags, def_base ? (const char*)def_base + Offset : 0);
|
||||
@@ -189,7 +188,7 @@ struct CTypeInfo
|
||||
// Attribute access. Not fast.
|
||||
bool GetAttr(cstr name) const;
|
||||
bool GetAttr(cstr name, float& val) const;
|
||||
bool GetAttr(cstr name, string& val) const;
|
||||
bool GetAttr(cstr name, AZStd::string& val) const;
|
||||
|
||||
// Comment, excluding attributes.
|
||||
cstr GetComment() const;
|
||||
|
||||
@@ -426,7 +426,7 @@ struct IConsole
|
||||
// szPrefix - 0 or prefix e.g. "sys_spec_"
|
||||
// Return
|
||||
// used size
|
||||
virtual size_t GetSortedVars(const char** pszArray, size_t numItems, const char* szPrefix = 0) = 0;
|
||||
virtual size_t GetSortedVars(AZStd::vector<AZStd::string_view>& pszArray, const char* szPrefix = 0) = 0;
|
||||
virtual const char* AutoComplete(const char* substr) = 0;
|
||||
virtual const char* AutoCompletePrev(const char* substr) = 0;
|
||||
virtual const char* ProcessCompletion(const char* szInputBuffer) = 0;
|
||||
|
||||
@@ -205,7 +205,7 @@ struct IRenderNode
|
||||
// Debug info about object.
|
||||
virtual const char* GetName() const = 0;
|
||||
virtual const char* GetEntityClassName() const = 0;
|
||||
virtual string GetDebugString([[maybe_unused]] char type = 0) const { return ""; }
|
||||
virtual AZStd::string GetDebugString([[maybe_unused]] char type = 0) const { return ""; }
|
||||
virtual float GetImportance() const { return 1.f; }
|
||||
|
||||
// Description:
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
#include <Cry_Math.h>
|
||||
#include <Cry_Color.h>
|
||||
#include <CryString.h>
|
||||
#include <smartptr.h>
|
||||
|
||||
#include <AzCore/std/smart_ptr/shared_ptr.h>
|
||||
@@ -101,7 +100,7 @@ struct ICryFont
|
||||
// All font names separated by ,
|
||||
// Example:
|
||||
// "console,default,hud"
|
||||
virtual string GetLoadedFontNames() const = 0;
|
||||
virtual AZStd::string GetLoadedFontNames() const = 0;
|
||||
|
||||
//! \brief Called when the g_language (current language) setting changes.
|
||||
//!
|
||||
@@ -264,7 +263,7 @@ struct IFFont
|
||||
|
||||
// Description:
|
||||
// Wraps text based on specified maximum line width (UTF-8)
|
||||
virtual void WrapText(string& result, float maxWidth, const char* pStr, const STextDrawContext& ctx) = 0;
|
||||
virtual void WrapText(AZStd::string& result, float maxWidth, const char* pStr, const STextDrawContext& ctx) = 0;
|
||||
|
||||
// Description:
|
||||
// Puts the memory used by this font into the given sizer.
|
||||
@@ -338,7 +337,7 @@ struct FontFamily
|
||||
FontFamily& operator=(const FontFamily&) = delete;
|
||||
FontFamily& operator=(const FontFamily&&) = delete;
|
||||
|
||||
string familyName;
|
||||
AZStd::string familyName;
|
||||
IFFont* normal;
|
||||
IFFont* bold;
|
||||
IFFont* italic;
|
||||
|
||||
@@ -34,14 +34,14 @@ struct SLocalizedInfoGame
|
||||
}
|
||||
|
||||
const char* szCharacterName;
|
||||
string sUtf8TranslatedText;
|
||||
AZStd::string sUtf8TranslatedText;
|
||||
|
||||
bool bUseSubtitle;
|
||||
};
|
||||
|
||||
struct SLocalizedAdvancesSoundEntry
|
||||
{
|
||||
string sName;
|
||||
AZStd::string sName;
|
||||
float fValue;
|
||||
void GetMemoryUsage(ICrySizer* pSizer) const
|
||||
{
|
||||
@@ -178,12 +178,12 @@ struct ILocalizationManager
|
||||
// bEnglish - if true, translates the string into the always present English language.
|
||||
// Returns:
|
||||
// true if localization was successful, false otherwise
|
||||
virtual bool LocalizeString_ch([[maybe_unused]] const char* sString, [[maybe_unused]] string& outLocalizedString, [[maybe_unused]] bool bEnglish = false) override { return false; }
|
||||
virtual bool LocalizeString_ch([[maybe_unused]] const char* sString, [[maybe_unused]] AZStd::string& outLocalizedString, [[maybe_unused]] bool bEnglish = false) override { return false; }
|
||||
|
||||
// Summary:
|
||||
// Same as LocalizeString( const char* sString, string& outLocalizedString, bool bEnglish=false )
|
||||
// Same as LocalizeString( const char* sString, AZStd::string& outLocalizedString, bool bEnglish=false )
|
||||
// but at the moment this is faster.
|
||||
virtual bool LocalizeString_s([[maybe_unused]] const string& sString, [[maybe_unused]] string& outLocalizedString, [[maybe_unused]] bool bEnglish = false) override { return false; }
|
||||
virtual bool LocalizeString_s([[maybe_unused]] const AZStd::string& sString, [[maybe_unused]] AZStd::string& outLocalizedString, [[maybe_unused]] bool bEnglish = false) override { return false; }
|
||||
|
||||
// Summary:
|
||||
virtual void LocalizeAndSubstituteInternal([[maybe_unused]] AZStd::string& locString, [[maybe_unused]] const AZStd::vector<AZStd::string>& keys, [[maybe_unused]] const AZStd::vector<AZStd::string>& values) override {}
|
||||
@@ -196,7 +196,7 @@ struct ILocalizationManager
|
||||
// bEnglish - if true, returns the always present English version of the label.
|
||||
// Returns:
|
||||
// True if localization was successful, false otherwise.
|
||||
virtual bool LocalizeLabel([[maybe_unused]] const char* sLabel, [[maybe_unused]] string& outLocalizedString, [[maybe_unused]] bool bEnglish = false) override { return false; }
|
||||
virtual bool LocalizeLabel([[maybe_unused]] const char* sLabel, [[maybe_unused]] AZStd::string& outLocalizedString, [[maybe_unused]] bool bEnglish = false) override { return false; }
|
||||
virtual bool IsLocalizedInfoFound([[maybe_unused]] const char* sKey) { return false; }
|
||||
|
||||
// Summary:
|
||||
@@ -251,7 +251,7 @@ struct ILocalizationManager
|
||||
// sLocalizedString - Corresponding english language string.
|
||||
// Returns:
|
||||
// True if successful, false otherwise (key not found).
|
||||
virtual bool GetEnglishString([[maybe_unused]] const char* sKey, [[maybe_unused]] string& sLocalizedString) override { return false; }
|
||||
virtual bool GetEnglishString([[maybe_unused]] const char* sKey, [[maybe_unused]] AZStd::string& sLocalizedString) override { return false; }
|
||||
|
||||
// Summary:
|
||||
// Get Subtitle for Key or Label .
|
||||
@@ -261,21 +261,21 @@ struct ILocalizationManager
|
||||
// bForceSubtitle - If true, get subtitle (sLocalized or sEnglish) even if not specified in Data file.
|
||||
// Returns:
|
||||
// True if subtitle found (and outSubtitle filled in), false otherwise.
|
||||
virtual bool GetSubtitle([[maybe_unused]] const char* sKeyOrLabel, [[maybe_unused]] string& outSubtitle, [[maybe_unused]] bool bForceSubtitle = false) override { return false; }
|
||||
virtual bool GetSubtitle([[maybe_unused]] const char* sKeyOrLabel, [[maybe_unused]] AZStd::string& outSubtitle, [[maybe_unused]] bool bForceSubtitle = false) override { return false; }
|
||||
|
||||
// Description:
|
||||
// These methods format outString depending on sString with ordered arguments
|
||||
// FormatStringMessage(outString, "This is %2 and this is %1", "second", "first");
|
||||
// Arguments:
|
||||
// outString - This is first and this is second.
|
||||
virtual void FormatStringMessage_List([[maybe_unused]] string& outString, [[maybe_unused]] const string& sString, [[maybe_unused]] const char** sParams, [[maybe_unused]] int nParams) override {}
|
||||
virtual void FormatStringMessage([[maybe_unused]] string& outString, [[maybe_unused]] const string& sString, [[maybe_unused]] const char* param1, [[maybe_unused]] const char* param2 = 0, [[maybe_unused]] const char* param3 = 0, [[maybe_unused]] const char* param4 = 0) override {}
|
||||
virtual void FormatStringMessage_List([[maybe_unused]] AZStd::string& outString, [[maybe_unused]] const AZStd::string& sString, [[maybe_unused]] const char** sParams, [[maybe_unused]] int nParams) override {}
|
||||
virtual void FormatStringMessage([[maybe_unused]] AZStd::string& outString, [[maybe_unused]] const AZStd::string& sString, [[maybe_unused]] const char* param1, [[maybe_unused]] const char* param2 = 0, [[maybe_unused]] const char* param3 = 0, [[maybe_unused]] const char* param4 = 0) override {}
|
||||
|
||||
virtual void LocalizeTime([[maybe_unused]] time_t t, [[maybe_unused]] bool bMakeLocalTime, [[maybe_unused]] bool bShowSeconds, [[maybe_unused]] string& outTimeString) override {}
|
||||
virtual void LocalizeDate([[maybe_unused]] time_t t, [[maybe_unused]] bool bMakeLocalTime, [[maybe_unused]] bool bShort, [[maybe_unused]] bool bIncludeWeekday, [[maybe_unused]] string& outDateString) override {}
|
||||
virtual void LocalizeDuration([[maybe_unused]] int seconds, [[maybe_unused]] string& outDurationString) override {}
|
||||
virtual void LocalizeNumber([[maybe_unused]] int number, [[maybe_unused]] string& outNumberString) override {}
|
||||
virtual void LocalizeNumber_Decimal([[maybe_unused]] float number, [[maybe_unused]] int decimals, [[maybe_unused]] string& outNumberString) override {}
|
||||
virtual void LocalizeTime([[maybe_unused]] time_t t, [[maybe_unused]] bool bMakeLocalTime, [[maybe_unused]] bool bShowSeconds, [[maybe_unused]] AZStd::string& outTimeString) override {}
|
||||
virtual void LocalizeDate([[maybe_unused]] time_t t, [[maybe_unused]] bool bMakeLocalTime, [[maybe_unused]] bool bShort, [[maybe_unused]] bool bIncludeWeekday, [[maybe_unused]] AZStd::string& outDateString) override {}
|
||||
virtual void LocalizeDuration([[maybe_unused]] int seconds, [[maybe_unused]] AZStd::string& outDurationString) override {}
|
||||
virtual void LocalizeNumber([[maybe_unused]] int number, [[maybe_unused]] AZStd::string& outNumberString) override {}
|
||||
virtual void LocalizeNumber_Decimal([[maybe_unused]] float number, [[maybe_unused]] int decimals, [[maybe_unused]] AZStd::string& outNumberString) override {}
|
||||
|
||||
// Summary:
|
||||
// Returns true if the project has localization configured for use, false otherwise.
|
||||
|
||||
@@ -145,9 +145,7 @@ struct ILog
|
||||
virtual void Unindent(class CLogIndenter* indenter) = 0;
|
||||
#endif
|
||||
|
||||
#if !defined(RESOURCE_COMPILER)
|
||||
virtual void FlushAndClose() = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
#if !defined(SUPPORT_LOG_IDENTER)
|
||||
|
||||
@@ -112,7 +112,7 @@ public:
|
||||
CAnimParamType()
|
||||
: m_type(kAnimParamTypeInvalid) {}
|
||||
|
||||
CAnimParamType(const string& name)
|
||||
CAnimParamType(const AZStd::string& name)
|
||||
{
|
||||
*this = name;
|
||||
}
|
||||
@@ -128,17 +128,12 @@ public:
|
||||
m_type = type;
|
||||
}
|
||||
|
||||
void operator =(const string& name)
|
||||
{
|
||||
m_type = kAnimParamTypeByString;
|
||||
m_name = name;
|
||||
}
|
||||
|
||||
void operator =(const AZStd::string& name)
|
||||
{
|
||||
m_type = kAnimParamTypeByString;
|
||||
m_name = name;
|
||||
}
|
||||
|
||||
// Convert to enum. This needs to be explicit,
|
||||
// otherwise operator== will be ambiguous
|
||||
AnimParamType GetType() const { return m_type; }
|
||||
@@ -1437,7 +1432,7 @@ inline void SAnimContext::Serialize(XmlNodeRef& xmlNode, bool bLoading)
|
||||
{
|
||||
if (sequence)
|
||||
{
|
||||
string fullname = sequence->GetName();
|
||||
AZStd::string fullname = sequence->GetName();
|
||||
xmlNode->setAttr("sequence", fullname.c_str());
|
||||
}
|
||||
xmlNode->setAttr("dt", dt);
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include "Cry_Matrix33.h"
|
||||
#include "Cry_Color.h"
|
||||
#include "smartptr.h"
|
||||
#include "StringUtils.h"
|
||||
#include <IXml.h> // <> required for Interfuscator
|
||||
#include "smartptr.h"
|
||||
#include <AzCore/Casting/numeric_cast.h>
|
||||
@@ -1449,7 +1448,7 @@ struct IRenderer
|
||||
virtual const char* EF_GetShaderMissLogPath() = 0;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
virtual string* EF_GetShaderNames(int& nNumShaders) = 0;
|
||||
virtual AZStd::string* EF_GetShaderNames(int& nNumShaders) = 0;
|
||||
// Summary:
|
||||
// Reloads file
|
||||
virtual bool EF_ReloadFile (const char* szFileName) = 0;
|
||||
|
||||
@@ -179,28 +179,16 @@ struct SSerializeString
|
||||
void resize(int sz) { m_str.resize(sz); }
|
||||
void reserve(int sz) { m_str.reserve(sz); }
|
||||
|
||||
void set_string(const string& s)
|
||||
void set_string(const AZStd::string& s)
|
||||
{
|
||||
m_str.assign(s.begin(), s.size());
|
||||
}
|
||||
#if !defined(RESOURCE_COMPILER)
|
||||
void set_string(const CryStringLocal& s)
|
||||
{
|
||||
m_str.assign(s.begin(), s.size());
|
||||
}
|
||||
#endif
|
||||
template<size_t S>
|
||||
void set_string(const CryFixedStringT<S>& s)
|
||||
{
|
||||
m_str.assign(s.begin(), s.size());
|
||||
}
|
||||
|
||||
operator const string () const {
|
||||
operator const AZStd::string() const {
|
||||
return m_str;
|
||||
}
|
||||
|
||||
private:
|
||||
string m_str;
|
||||
AZStd::string m_str;
|
||||
};
|
||||
|
||||
// the ISerialize is intended to be implemented by objects that need
|
||||
@@ -308,7 +296,7 @@ public:
|
||||
m_pSerialize->Value(szName, value);
|
||||
}
|
||||
|
||||
void Value(const char* szName, string& value, int policy)
|
||||
void Value(const char* szName, AZStd::string& value, int policy)
|
||||
{
|
||||
if (IsWriting())
|
||||
{
|
||||
@@ -327,11 +315,11 @@ public:
|
||||
value = serializeString.c_str();
|
||||
}
|
||||
}
|
||||
ILINE void Value(const char* szName, string& value)
|
||||
ILINE void Value(const char* szName, AZStd::string& value)
|
||||
{
|
||||
Value(szName, value, 0);
|
||||
}
|
||||
void Value(const char* szName, const string& value, int policy)
|
||||
void Value(const char* szName, const AZStd::string& value, int policy)
|
||||
{
|
||||
if (IsWriting())
|
||||
{
|
||||
@@ -343,76 +331,7 @@ public:
|
||||
assert(0 && "This function can only be used for Writing");
|
||||
}
|
||||
}
|
||||
ILINE void Value(const char* szName, const string& value)
|
||||
{
|
||||
Value(szName, value, 0);
|
||||
}
|
||||
template <typename T>
|
||||
void Value(const char* szName, CryStringLocalT<T>& value, int policy)
|
||||
{
|
||||
if (IsWriting())
|
||||
{
|
||||
SSerializeString& serializeString = SetSharedSerializeString(value);
|
||||
m_pSerialize->WriteStringValue(szName, serializeString, policy);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GetSerializationTarget() != eST_Script)
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
|
||||
SSerializeString& serializeString = SetSharedSerializeString(value);
|
||||
m_pSerialize->ReadStringValue(szName, serializeString, policy);
|
||||
value = serializeString.c_str();
|
||||
}
|
||||
}
|
||||
template <typename T>
|
||||
ILINE void Value(const char* szName, CryStringLocalT<T>& value)
|
||||
{
|
||||
Value(szName, value, 0);
|
||||
}
|
||||
template <typename T>
|
||||
void Value(const char* szName, const CryStringLocalT<T>& value, int policy)
|
||||
{
|
||||
if (IsWriting())
|
||||
{
|
||||
SSerializeString& serializeString = SetSharedSerializeString(value);
|
||||
m_pSerialize->WriteStringValue(szName, serializeString, policy);
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(0 && "This function can only be used for Writing");
|
||||
}
|
||||
}
|
||||
template <typename T>
|
||||
ILINE void Value(const char* szName, const CryStringLocalT<T>& value)
|
||||
{
|
||||
Value(szName, value, 0);
|
||||
}
|
||||
template<size_t S>
|
||||
void Value(const char* szName, CryFixedStringT<S>& value, int policy)
|
||||
{
|
||||
if (IsWriting())
|
||||
{
|
||||
SSerializeString& serializeString = SetSharedSerializeString(value);
|
||||
m_pSerialize->WriteStringValue(szName, serializeString, policy);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GetSerializationTarget() != eST_Script)
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
|
||||
SSerializeString& serializeString = SetSharedSerializeString(value);
|
||||
m_pSerialize->ReadStringValue(szName, serializeString, policy);
|
||||
assert(serializeString.length() <= S);
|
||||
value = serializeString.c_str();
|
||||
}
|
||||
}
|
||||
template<size_t S>
|
||||
ILINE void Value(const char* szName, CryFixedStringT<S>& value)
|
||||
ILINE void Value(const char* szName, const AZStd::string& value)
|
||||
{
|
||||
Value(szName, value, 0);
|
||||
}
|
||||
@@ -468,7 +387,7 @@ public:
|
||||
|
||||
bool ValueChar(const char* name, char* buffer, int len)
|
||||
{
|
||||
string temp;
|
||||
AZStd::string temp;
|
||||
if (IsReading())
|
||||
{
|
||||
Value(name, temp);
|
||||
@@ -481,7 +400,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
temp = string(buffer, buffer + len);
|
||||
temp = AZStd::string(buffer, buffer + len);
|
||||
Value(name, temp);
|
||||
}
|
||||
return true;
|
||||
@@ -493,7 +412,7 @@ public:
|
||||
m_pSerialize->ValueWithDefault(name, x, defaultValue);
|
||||
}
|
||||
|
||||
void ValueWithDefault(const char* szName, string& value, const string& defaultValue)
|
||||
void ValueWithDefault(const char* szName, AZStd::string& value, const AZStd::string& defaultValue)
|
||||
{
|
||||
static SSerializeString defaultSerializeString;
|
||||
|
||||
@@ -919,34 +838,13 @@ public:
|
||||
return CSerializeWrapper<ISerialize>(m_pSerialize);
|
||||
}
|
||||
|
||||
SSerializeString& SetSharedSerializeString(const string& str)
|
||||
SSerializeString& SetSharedSerializeString(const AZStd::string& str)
|
||||
{
|
||||
static SSerializeString serializeString;
|
||||
serializeString.set_string(str);
|
||||
return serializeString;
|
||||
}
|
||||
|
||||
#if !defined(RESOURCE_COMPILER)
|
||||
SSerializeString& SetSharedSerializeString(const CryStringLocal& str)
|
||||
{
|
||||
|
||||
|
||||
static SSerializeString serializeString;
|
||||
serializeString.set_string(str);
|
||||
return serializeString;
|
||||
}
|
||||
#endif
|
||||
|
||||
template<size_t S>
|
||||
SSerializeString& SetSharedSerializeString(const CryFixedStringT<S>& str)
|
||||
{
|
||||
|
||||
|
||||
static SSerializeString serializeString;
|
||||
serializeString.set_string(str);
|
||||
return serializeString;
|
||||
}
|
||||
|
||||
private:
|
||||
TISerialize* m_pSerialize;
|
||||
};
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include "Cry_Matrix33.h"
|
||||
#include "Cry_Color.h"
|
||||
#include "smartptr.h"
|
||||
#include "StringUtils.h"
|
||||
#include <IXml.h> // <> required for Interfuscator
|
||||
#include "smartptr.h"
|
||||
#include "VertexFormats.h"
|
||||
@@ -1394,12 +1393,12 @@ struct IRenderTarget
|
||||
struct STexSamplerFX
|
||||
{
|
||||
#if SHADER_REFLECT_TEXTURE_SLOTS
|
||||
string m_szUIName;
|
||||
string m_szUIDescription;
|
||||
AZStd::string m_szUIName;
|
||||
AZStd::string m_szUIDescription;
|
||||
#endif
|
||||
|
||||
string m_szName;
|
||||
string m_szTexture;
|
||||
AZStd::string m_szName;
|
||||
AZStd::string m_szTexture;
|
||||
|
||||
union
|
||||
{
|
||||
@@ -1708,7 +1707,7 @@ struct SEfResTextureExt
|
||||
//------------------------------------------------------------------------------
|
||||
struct SEfResTexture
|
||||
{
|
||||
string m_Name;
|
||||
AZStd::string m_Name;
|
||||
bool m_bUTile;
|
||||
bool m_bVTile;
|
||||
signed char m_Filter;
|
||||
@@ -1890,7 +1889,7 @@ struct SEfResTexture
|
||||
struct SBaseShaderResources
|
||||
{
|
||||
AZStd::vector<SShaderParam> m_ShaderParams;
|
||||
string m_TexturePath;
|
||||
AZStd::string m_TexturePath;
|
||||
const char* m_szMaterialName;
|
||||
|
||||
float m_AlphaRef;
|
||||
@@ -2146,8 +2145,8 @@ struct SShaderTextureSlot
|
||||
m_TexType = eTT_MaxTexType;
|
||||
}
|
||||
|
||||
string m_Name;
|
||||
string m_Description;
|
||||
AZStd::string m_Name;
|
||||
AZStd::string m_Description;
|
||||
byte m_TexType; // 2D, 3D, Cube etc..
|
||||
|
||||
void GetMemoryUsage(ICrySizer* pSizer) const
|
||||
@@ -2726,7 +2725,7 @@ protected:
|
||||
virtual ~ILightAnimWrapper() {}
|
||||
|
||||
protected:
|
||||
string m_name;
|
||||
AZStd::string m_name;
|
||||
IAnimNode* m_pNode;
|
||||
};
|
||||
|
||||
@@ -3256,12 +3255,12 @@ enum EGrNodeIOSemantic
|
||||
|
||||
struct SShaderGraphFunction
|
||||
{
|
||||
string m_Data;
|
||||
string m_Name;
|
||||
std::vector<string> inParams;
|
||||
std::vector<string> outParams;
|
||||
std::vector<string> szInTypes;
|
||||
std::vector<string> szOutTypes;
|
||||
AZStd::string m_Data;
|
||||
AZStd::string m_Name;
|
||||
std::vector<AZStd::string> inParams;
|
||||
std::vector<AZStd::string> outParams;
|
||||
std::vector<AZStd::string> szInTypes;
|
||||
std::vector<AZStd::string> szOutTypes;
|
||||
};
|
||||
|
||||
struct SShaderGraphNode
|
||||
@@ -3269,8 +3268,8 @@ struct SShaderGraphNode
|
||||
EGrNodeType m_eType;
|
||||
EGrNodeFormat m_eFormat;
|
||||
EGrNodeIOSemantic m_eSemantic;
|
||||
string m_CustomSemantics;
|
||||
string m_Name;
|
||||
AZStd::string m_CustomSemantics;
|
||||
AZStd::string m_Name;
|
||||
bool m_bEditable;
|
||||
bool m_bWasAdded;
|
||||
SShaderGraphFunction* m_pFunction;
|
||||
@@ -3296,7 +3295,7 @@ struct SShaderGraphBlock
|
||||
{
|
||||
EGrBlockType m_eType;
|
||||
EGrBlockSamplerType m_eSamplerType;
|
||||
string m_ClassName;
|
||||
AZStd::string m_ClassName;
|
||||
FXShaderGraphNodes m_Nodes;
|
||||
|
||||
~SShaderGraphBlock();
|
||||
|
||||
@@ -201,7 +201,7 @@ struct IStreamable
|
||||
virtual void StartStreaming(bool bFinishNow, IReadStream_AutoPtr* ppStream) = 0;
|
||||
virtual int GetStreamableContentMemoryUsage(bool bJustForDebug = false) = 0;
|
||||
virtual void ReleaseStreamableContent() = 0;
|
||||
virtual void GetStreamableName(string& sName) = 0;
|
||||
virtual void GetStreamableName(AZStd::string& sName) = 0;
|
||||
virtual uint32 GetLastDrawMainFrameId() = 0;
|
||||
virtual bool IsUnloadable() const = 0;
|
||||
|
||||
@@ -239,8 +239,8 @@ struct IStatObj
|
||||
SSubObject() { bShadowProxy = 0; }
|
||||
|
||||
EStaticSubObjectType nType;
|
||||
string name;
|
||||
string properties;
|
||||
AZStd::string name;
|
||||
AZStd::string properties;
|
||||
int nParent; // Index of the parent sub object, if there`s hierarchy between them.
|
||||
Matrix34 tm; // Transformation matrix.
|
||||
Matrix34 localTM; // Local transformation matrix, relative to parent.
|
||||
@@ -510,10 +510,10 @@ struct IStatObj
|
||||
virtual bool IsUnloadable() const = 0;
|
||||
virtual void SetCanUnload(bool value) = 0;
|
||||
|
||||
virtual string& GetFileName() = 0;
|
||||
virtual const string& GetFileName() const = 0;
|
||||
virtual AZStd::string& GetFileName() = 0;
|
||||
virtual const AZStd::string& GetFileName() const = 0;
|
||||
|
||||
virtual const string& GetCGFNodeName() const = 0;
|
||||
virtual const AZStd::string& GetCGFNodeName() const = 0;
|
||||
|
||||
// Summary:
|
||||
// Returns the filename of the object
|
||||
|
||||
@@ -85,7 +85,7 @@ struct ISurfaceType
|
||||
};
|
||||
struct SBreakable2DParams
|
||||
{
|
||||
string particle_effect;
|
||||
AZStd::string particle_effect;
|
||||
float blast_radius;
|
||||
float blast_radius_first;
|
||||
float vert_size_spread;
|
||||
@@ -97,12 +97,12 @@ struct ISurfaceType
|
||||
float shard_density;
|
||||
int use_edge_alpha;
|
||||
float crack_decal_scale;
|
||||
string crack_decal_mtl;
|
||||
AZStd::string crack_decal_mtl;
|
||||
float max_fracture;
|
||||
string full_fracture_fx;
|
||||
string fracture_fx;
|
||||
AZStd::string full_fracture_fx;
|
||||
AZStd::string fracture_fx;
|
||||
int no_procedural_full_fracture;
|
||||
string broken_mtl;
|
||||
AZStd::string broken_mtl;
|
||||
float destroy_timeout;
|
||||
float destroy_timeout_spread;
|
||||
|
||||
@@ -125,8 +125,8 @@ struct ISurfaceType
|
||||
};
|
||||
struct SBreakageParticles
|
||||
{
|
||||
string type;
|
||||
string particle_effect;
|
||||
AZStd::string type;
|
||||
AZStd::string particle_effect;
|
||||
int count_per_unit;
|
||||
float count_scale;
|
||||
float scale;
|
||||
|
||||
@@ -942,7 +942,7 @@ struct ISystem
|
||||
// If m_GraphicsSettingsMap is defined (in Graphics Settings Dialog box), fills in mapping based on sys_spec_Full
|
||||
// Arguments:
|
||||
// sPath - e.g. "Game/Config/CVarGroups"
|
||||
virtual void AddCVarGroupDirectory(const string& sPath) = 0;
|
||||
virtual void AddCVarGroupDirectory(const AZStd::string& sPath) = 0;
|
||||
|
||||
// Summary:
|
||||
// Saves system configuration.
|
||||
|
||||
@@ -94,14 +94,20 @@ void testXml(bool bReuseStrings)
|
||||
// Summary:
|
||||
// Special string wrapper for xml nodes.
|
||||
class XmlString
|
||||
: public string
|
||||
: public AZStd::string
|
||||
{
|
||||
public:
|
||||
XmlString() {};
|
||||
XmlString(const char* str)
|
||||
: string(str) {};
|
||||
: AZStd::string(str) {};
|
||||
|
||||
operator const char*() const {
|
||||
size_t GetAllocatedMemory() const
|
||||
{
|
||||
return sizeof(XmlString) + capacity() * sizeof(AZStd::string::value_type);
|
||||
}
|
||||
|
||||
operator const char*() const
|
||||
{
|
||||
return c_str();
|
||||
}
|
||||
};
|
||||
@@ -147,13 +153,11 @@ public:
|
||||
XmlNodeRef& operator=(IXmlNode* newp);
|
||||
XmlNodeRef& operator=(const XmlNodeRef& newp);
|
||||
|
||||
#if !defined(RESOURCE_COMPILER)
|
||||
template<typename Sizer >
|
||||
void GetMemoryUsage(Sizer* pSizer) const
|
||||
{
|
||||
pSizer->AddObject(p);
|
||||
}
|
||||
#endif
|
||||
|
||||
//Support for range based for, and stl algorithms.
|
||||
class XmlNodeRefIterator begin();
|
||||
@@ -399,7 +403,6 @@ public:
|
||||
|
||||
// </interfuscator:shuffle>
|
||||
|
||||
#if !defined(RESOURCE_COMPILER)
|
||||
// <interfuscator:shuffle>
|
||||
// Summary:
|
||||
// Collect all allocated memory
|
||||
@@ -423,7 +426,6 @@ public:
|
||||
// Save in small memory chunks.
|
||||
virtual bool saveToFile(const char* fileName, size_t chunkSizeBytes, AZ::IO::HandleType fileHandle = AZ::IO::InvalidHandle) = 0;
|
||||
// </interfuscator:shuffle>
|
||||
#endif
|
||||
|
||||
//##@}
|
||||
|
||||
@@ -792,12 +794,9 @@ struct IXmlSerializer
|
||||
virtual ISerialize* GetWriter(XmlNodeRef& node) = 0;
|
||||
virtual ISerialize* GetReader(XmlNodeRef& node) = 0;
|
||||
// </interfuscator:shuffle>
|
||||
#if !defined(RESOURCE_COMPILER)
|
||||
virtual void GetMemoryUsage(ICrySizer* pSizer) const = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
#if !defined(RESOURCE_COMPILER)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Summary:
|
||||
// XML Parser interface.
|
||||
@@ -867,7 +866,6 @@ struct IXmlTableReader
|
||||
virtual float GetCurrentRowHeight() = 0;
|
||||
// </interfuscator:shuffle>
|
||||
};
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Summary:
|
||||
@@ -900,7 +898,6 @@ struct IXmlUtils
|
||||
virtual IXmlSerializer* CreateXmlSerializer() = 0;
|
||||
// </interfuscator:shuffle>
|
||||
|
||||
#if !defined(RESOURCE_COMPILER)
|
||||
// <interfuscator:shuffle>
|
||||
// Summary:
|
||||
// Creates XML Parser.
|
||||
@@ -945,7 +942,6 @@ struct IXmlUtils
|
||||
// Set to NULL to clear an existing transform and disable further patching
|
||||
virtual void SetXMLPatcher(XmlNodeRef* pPatcher) = 0;
|
||||
// </interfuscator:shuffle>
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_CRYCOMMON_IXML_H
|
||||
|
||||
@@ -139,13 +139,8 @@ typedef WCHAR* LPUWSTR, * PUWSTR;
|
||||
typedef const WCHAR* LPCWSTR, * PCWSTR;
|
||||
typedef const WCHAR* LPCUWSTR, * PCUWSTR;
|
||||
|
||||
#ifdef UNICODE
|
||||
typedef LPCWSTR LPCTSTR;
|
||||
typedef LPWSTR LPTSTR;
|
||||
#else
|
||||
typedef LPCSTR LPCTSTR;
|
||||
typedef LPSTR LPTSTR;
|
||||
#endif
|
||||
typedef char TCHAR;
|
||||
|
||||
typedef DWORD COLORREF;
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
#include <CryAssert.h>
|
||||
#include <dirent.h>
|
||||
#include <vector>
|
||||
#include <AzCore/std/string/string.h>
|
||||
|
||||
/* Memory block identification */
|
||||
#define _FREE_BLOCK 0
|
||||
#define _NORMAL_BLOCK 1
|
||||
@@ -324,9 +326,6 @@ inline uint32 GetTickCount()
|
||||
#define _strlwr_s(BUF, SIZE) strlwr(BUF)
|
||||
#define _strups strupr
|
||||
|
||||
// Need to include this before using it's used in finddata, but after the strnicmp definition
|
||||
#include "CryString.h"
|
||||
|
||||
typedef struct __finddata64_t
|
||||
{
|
||||
//!< atributes set by find request
|
||||
@@ -342,7 +341,7 @@ private:
|
||||
char m_DirectoryName[260]; //!< directory name, needed when getting file attributes on the fly
|
||||
char m_ToMatch[260]; //!< pattern to match with
|
||||
DIR* m_Dir; //!< directory handle
|
||||
std::vector<string> m_Entries; //!< all file entries in the current directories
|
||||
std::vector<AZStd::string> m_Entries; //!< all file entries in the current directories
|
||||
public:
|
||||
|
||||
inline __finddata64_t()
|
||||
@@ -374,7 +373,7 @@ typedef struct _finddata_t
|
||||
extern int _findnext64(intptr_t last, __finddata64_t* pFindData);
|
||||
extern intptr_t _findfirst64(const char* pFileName, __finddata64_t* pFindData);
|
||||
|
||||
extern DWORD GetFileAttributes(LPCSTR lpFileName);
|
||||
extern DWORD GetFileAttributesW(LPCWSTR lpFileName);
|
||||
|
||||
extern const bool GetFilenameNoCase(const char* file, char*, const bool cCreateNew = false);
|
||||
|
||||
|
||||
@@ -99,12 +99,12 @@ public:
|
||||
// bEnglish - if true, translates the string into the always present English language.
|
||||
// Returns:
|
||||
// true if localization was successful, false otherwise
|
||||
virtual bool LocalizeString_ch(const char* sString, string& outLocalizedString, bool bEnglish = false) = 0;
|
||||
virtual bool LocalizeString_ch(const char* sString, AZStd::string& outLocalizedString, bool bEnglish = false) = 0;
|
||||
|
||||
// Summary:
|
||||
// Same as LocalizeString( const char* sString, string& outLocalizedString, bool bEnglish=false )
|
||||
// Same as LocalizeString( const char* sString, AZStd::string& outLocalizedString, bool bEnglish=false )
|
||||
// but at the moment this is faster.
|
||||
virtual bool LocalizeString_s(const string& sString, string& outLocalizedString, bool bEnglish = false) = 0;
|
||||
virtual bool LocalizeString_s(const AZStd::string& sString, AZStd::string& outLocalizedString, bool bEnglish = false) = 0;
|
||||
|
||||
// Set up system for passing in placeholder data for localized strings
|
||||
// Summary:
|
||||
@@ -138,7 +138,7 @@ public:
|
||||
// bEnglish - if true, returns the always present English version of the label.
|
||||
// Returns:
|
||||
// True if localization was successful, false otherwise.
|
||||
virtual bool LocalizeLabel(const char* sLabel, string& outLocalizedString, bool bEnglish = false) = 0;
|
||||
virtual bool LocalizeLabel(const char* sLabel, AZStd::string& outLocalizedString, bool bEnglish = false) = 0;
|
||||
|
||||
// Summary:
|
||||
// Return number of localization entries.
|
||||
@@ -151,7 +151,7 @@ public:
|
||||
// sLocalizedString - Corresponding english language string.
|
||||
// Returns:
|
||||
// True if successful, false otherwise (key not found).
|
||||
virtual bool GetEnglishString(const char* sKey, string& sLocalizedString) = 0;
|
||||
virtual bool GetEnglishString(const char* sKey, AZStd::string& sLocalizedString) = 0;
|
||||
|
||||
// Summary:
|
||||
// Get Subtitle for Key or Label .
|
||||
@@ -161,21 +161,21 @@ public:
|
||||
// bForceSubtitle - If true, get subtitle (sLocalized or sEnglish) even if not specified in Data file.
|
||||
// Returns:
|
||||
// True if subtitle found (and outSubtitle filled in), false otherwise.
|
||||
virtual bool GetSubtitle(const char* sKeyOrLabel, string& outSubtitle, bool bForceSubtitle = false) = 0;
|
||||
virtual bool GetSubtitle(const char* sKeyOrLabel, AZStd::string& outSubtitle, bool bForceSubtitle = false) = 0;
|
||||
|
||||
// Description:
|
||||
// These methods format outString depending on sString with ordered arguments
|
||||
// FormatStringMessage(outString, "This is %2 and this is %1", "second", "first");
|
||||
// Arguments:
|
||||
// outString - This is first and this is second.
|
||||
virtual void FormatStringMessage_List(string& outString, const string& sString, const char** sParams, int nParams) = 0;
|
||||
virtual void FormatStringMessage(string& outString, const string& sString, const char* param1, const char* param2 = 0, const char* param3 = 0, const char* param4 = 0) = 0;
|
||||
virtual void FormatStringMessage_List(AZStd::string& outString, const AZStd::string& sString, const char** sParams, int nParams) = 0;
|
||||
virtual void FormatStringMessage(AZStd::string& outString, const AZStd::string& sString, const char* param1, const char* param2 = 0, const char* param3 = 0, const char* param4 = 0) = 0;
|
||||
|
||||
virtual void LocalizeTime(time_t t, bool bMakeLocalTime, bool bShowSeconds, string& outTimeString) = 0;
|
||||
virtual void LocalizeDate(time_t t, bool bMakeLocalTime, bool bShort, bool bIncludeWeekday, string& outDateString) = 0;
|
||||
virtual void LocalizeDuration(int seconds, string& outDurationString) = 0;
|
||||
virtual void LocalizeNumber(int number, string& outNumberString) = 0;
|
||||
virtual void LocalizeNumber_Decimal(float number, int decimals, string& outNumberString) = 0;
|
||||
virtual void LocalizeTime(time_t t, bool bMakeLocalTime, bool bShowSeconds, AZStd::string& outTimeString) = 0;
|
||||
virtual void LocalizeDate(time_t t, bool bMakeLocalTime, bool bShort, bool bIncludeWeekday, AZStd::string& outDateString) = 0;
|
||||
virtual void LocalizeDuration(int seconds, AZStd::string& outDurationString) = 0;
|
||||
virtual void LocalizeNumber(int number, AZStd::string& outNumberString) = 0;
|
||||
virtual void LocalizeNumber_Decimal(float number, int decimals, AZStd::string& outNumberString) = 0;
|
||||
|
||||
// Summary:
|
||||
// Returns true if the project has localization configured for use, false otherwise.
|
||||
|
||||
@@ -120,7 +120,7 @@ public:
|
||||
CUiAnimParamType()
|
||||
: m_type(eUiAnimParamType_Invalid) {}
|
||||
|
||||
CUiAnimParamType(const string& name)
|
||||
CUiAnimParamType(const AZStd::string& name)
|
||||
{
|
||||
*this = name;
|
||||
}
|
||||
@@ -136,17 +136,12 @@ public:
|
||||
m_type = (EUiAnimParamType)type;
|
||||
}
|
||||
|
||||
void operator =(const string& name)
|
||||
{
|
||||
m_type = eUiAnimParamType_ByString;
|
||||
m_name = name;
|
||||
}
|
||||
|
||||
void operator =(const AZStd::string& name)
|
||||
{
|
||||
m_type = eUiAnimParamType_ByString;
|
||||
m_name = name.c_str();
|
||||
}
|
||||
|
||||
// Convert to enum. This needs to be explicit,
|
||||
// otherwise operator== will be ambiguous
|
||||
EUiAnimParamType GetType() const { return m_type; }
|
||||
@@ -1301,7 +1296,7 @@ inline void SUiAnimContext::Serialize(IUiAnimationSystem* animationSystem, XmlNo
|
||||
{
|
||||
if (pSequence)
|
||||
{
|
||||
string fullname = pSequence->GetName();
|
||||
AZStd::string fullname = pSequence->GetName();
|
||||
xmlNode->setAttr("sequence", fullname.c_str());
|
||||
}
|
||||
xmlNode->setAttr("dt", dt);
|
||||
|
||||
@@ -101,7 +101,7 @@ public: // member functions
|
||||
|
||||
//! Save this canvas to the given path in XML
|
||||
//! \return true if no error
|
||||
virtual bool SaveToXml(const string& assetIdPathname, const string& sourceAssetPathname) = 0;
|
||||
virtual bool SaveToXml(const AZStd::string& assetIdPathname, const AZStd::string& sourceAssetPathname) = 0;
|
||||
|
||||
//! Initialize a set of entities that have been added to the canvas
|
||||
//! Used when instantiating a slice or for undo/redo, copy/paste
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
virtual AZ::EntityId CreateCanvas() = 0;
|
||||
|
||||
//! Load a UI Canvas from in-game
|
||||
virtual AZ::EntityId LoadCanvas(const string& assetIdPathname) = 0;
|
||||
virtual AZ::EntityId LoadCanvas(const AZStd::string& assetIdPathname) = 0;
|
||||
|
||||
//! Create an empty UI Canvas (for the UI editor)
|
||||
//
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
virtual AZ::EntityId CreateCanvasInEditor(UiEntityContext* entityContext) = 0;
|
||||
|
||||
//! Load a UI Canvas from the UI editor
|
||||
virtual AZ::EntityId LoadCanvasInEditor(const string& assetIdPathname, const string& sourceAssetPathname, UiEntityContext* entityContext) = 0;
|
||||
virtual AZ::EntityId LoadCanvasInEditor(const AZStd::string& assetIdPathname, const AZStd::string& sourceAssetPathname, UiEntityContext* entityContext) = 0;
|
||||
|
||||
//! Reload a UI Canvas from xml. For use in the editor for the undo system only
|
||||
virtual AZ::EntityId ReloadCanvasFromXml(const AZStd::string& xmlString, UiEntityContext* entityContext) = 0;
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
|
||||
//! Get a loaded canvas by path name
|
||||
//! NOTE: this only searches canvases loaded in the game (not the editor)
|
||||
virtual AZ::EntityId FindLoadedCanvasByPathName(const string& assetIdPathname) = 0;
|
||||
virtual AZ::EntityId FindLoadedCanvasByPathName(const AZStd::string& assetIdPathname) = 0;
|
||||
|
||||
//! Release a canvas from use either in-game or in editor, destroy UI Canvas if no longer used in either
|
||||
virtual void ReleaseCanvas(AZ::EntityId canvas, bool forEditor = false) = 0;
|
||||
@@ -74,10 +74,10 @@ public:
|
||||
virtual void ReleaseCanvasDeferred(AZ::EntityId canvas) = 0;
|
||||
|
||||
//! Load a sprite object.
|
||||
virtual ISprite* LoadSprite(const string& pathname) = 0;
|
||||
virtual ISprite* LoadSprite(const AZStd::string& pathname) = 0;
|
||||
|
||||
//! Create a sprite that references the specified render target
|
||||
virtual ISprite* CreateSprite(const string& renderTargetName) = 0;
|
||||
virtual ISprite* CreateSprite(const AZStd::string& renderTargetName) = 0;
|
||||
|
||||
//! Check if a sprite's texture asset exists. The .sprite sidecar file is optional and is not checked
|
||||
virtual bool DoesSpriteTextureAssetExist(const AZStd::string& pathname) = 0;
|
||||
|
||||
@@ -59,10 +59,10 @@ public: // member functions
|
||||
virtual ~ISprite() {}
|
||||
|
||||
//! Get the pathname of this sprite
|
||||
virtual const string& GetPathname() const = 0;
|
||||
virtual const AZStd::string& GetPathname() const = 0;
|
||||
|
||||
//! Get the pathname of the texture of this sprite
|
||||
virtual const string& GetTexturePathname() const = 0;
|
||||
virtual const AZStd::string& GetTexturePathname() const = 0;
|
||||
|
||||
//! Get the borders of this sprite
|
||||
virtual Borders GetBorders() const = 0;
|
||||
@@ -77,7 +77,7 @@ public: // member functions
|
||||
virtual void Serialize(TSerialize ser) = 0;
|
||||
|
||||
//! Save this sprite data to disk
|
||||
virtual bool SaveToXml(const string& pathname) = 0;
|
||||
virtual bool SaveToXml(const AZStd::string& pathname) = 0;
|
||||
|
||||
//! Test if this sprite has any borders
|
||||
virtual bool AreBordersZeroWidth() const = 0;
|
||||
@@ -136,4 +136,3 @@ public: // member functions
|
||||
//! Returns true if this sprite is configured as a sprite-sheet, false otherwise
|
||||
virtual bool IsSpriteSheet() const = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/RTTI/TypeInfo.h>
|
||||
#include <AzCore/RTTI/TypeInfoSimple.h>
|
||||
#include <AzFramework/Asset/SimpleAsset.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -65,6 +65,5 @@ namespace AZ
|
||||
AZ_TYPE_INFO_SPECIALIZE(ColorF, "{63782551-A309-463B-A301-3A360800DF1E}");
|
||||
AZ_TYPE_INFO_SPECIALIZE(ColorB, "{6F0CC2C0-0CC6-4DBF-9297-B043F270E6A4}");
|
||||
AZ_TYPE_INFO_SPECIALIZE(Vec4, "{CAC9510C-8C00-41D4-BC4D-2C6A8136EB30}");
|
||||
AZ_TYPE_INFO_SPECIALIZE(CryStringT<char>, "{835199FB-292B-4DB3-BC7C-366E356300FA}");
|
||||
} // namespace AZ
|
||||
|
||||
|
||||
@@ -22,154 +22,6 @@
|
||||
|
||||
namespace LyShine
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Helper function to VersionConverter to convert a CryString field to an AZStd::String
|
||||
// Inline to avoid DLL linkage issues
|
||||
inline bool ConvertSubElementFromCryStringToAzString(
|
||||
AZ::SerializeContext& context,
|
||||
AZ::SerializeContext::DataElementNode& classElement,
|
||||
const char* subElementName)
|
||||
{
|
||||
int index = classElement.FindElement(AZ_CRC(subElementName));
|
||||
if (index != -1)
|
||||
{
|
||||
AZ::SerializeContext::DataElementNode& elementNode = classElement.GetSubElement(index);
|
||||
|
||||
CryStringT<char> oldData;
|
||||
|
||||
if (!elementNode.GetData(oldData))
|
||||
{
|
||||
// Error, old subElement was not a string or not valid
|
||||
AZ_Error("Serialization", false, "Cannot get string data for element %s.", subElementName);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remove old version.
|
||||
classElement.RemoveElement(index);
|
||||
|
||||
// Add a new element for the new data.
|
||||
int newElementIndex = classElement.AddElement<AZStd::string>(context, subElementName);
|
||||
if (newElementIndex == -1)
|
||||
{
|
||||
// Error adding the new sub element
|
||||
AZ_Error("Serialization", false, "AddElement failed for converted element %s", subElementName);
|
||||
return false;
|
||||
}
|
||||
|
||||
AZStd::string newData(oldData.c_str());
|
||||
classElement.GetSubElement(newElementIndex).SetData(context, newData);
|
||||
}
|
||||
|
||||
// if the field did not exist then we do not report an error
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Helper function to VersionConverter to convert a CryString field to a char
|
||||
// Inline to avoid DLL linkage issues
|
||||
inline bool ConvertSubElementFromCryStringToChar(
|
||||
AZ::SerializeContext& context,
|
||||
AZ::SerializeContext::DataElementNode& classElement,
|
||||
const char* subElementName,
|
||||
char defaultValue)
|
||||
{
|
||||
int index = classElement.FindElement(AZ_CRC(subElementName));
|
||||
if (index != -1)
|
||||
{
|
||||
AZ::SerializeContext::DataElementNode& elementNode = classElement.GetSubElement(index);
|
||||
|
||||
CryStringT<char> oldData;
|
||||
|
||||
if (!elementNode.GetData(oldData))
|
||||
{
|
||||
// Error, old subElement was not a CryString
|
||||
AZ_Error("Serialization", false, "Element %s is not a CryString.", subElementName);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remove old version.
|
||||
classElement.RemoveElement(index);
|
||||
|
||||
// Add a new element for the new data.
|
||||
int newElementIndex = classElement.AddElement<char>(context, subElementName);
|
||||
if (newElementIndex == -1)
|
||||
{
|
||||
// Error adding the new sub element
|
||||
AZ_Error("Serialization", false, "AddElement failed for converted element %s", subElementName);
|
||||
return false;
|
||||
}
|
||||
|
||||
char newData = (oldData.empty()) ? defaultValue : oldData[0];
|
||||
classElement.GetSubElement(newElementIndex).SetData(context, newData);
|
||||
}
|
||||
|
||||
// if the field did not exist then we do not report an error
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Helper function to VersionConverter to convert a CryString field to a simple asset reference
|
||||
// Inline to avoid DLL linkage issues
|
||||
template<typename T>
|
||||
inline bool ConvertSubElementFromCryStringToAssetRef(
|
||||
AZ::SerializeContext& context,
|
||||
AZ::SerializeContext::DataElementNode& classElement,
|
||||
const char* subElementName)
|
||||
{
|
||||
int index = classElement.FindElement(AZ_CRC(subElementName));
|
||||
if (index != -1)
|
||||
{
|
||||
AZ::SerializeContext::DataElementNode& elementNode = classElement.GetSubElement(index);
|
||||
|
||||
CryStringT<char> oldData;
|
||||
|
||||
if (!elementNode.GetData(oldData))
|
||||
{
|
||||
// Error, old subElement was not a CryString
|
||||
AZ_Error("Serialization", false, "Element %s is not a CryString.", subElementName);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remove old version.
|
||||
classElement.RemoveElement(index);
|
||||
|
||||
// Add a new element for the new data.
|
||||
int simpleAssetRefIndex = classElement.AddElement<AzFramework::SimpleAssetReference<T> >(context, subElementName);
|
||||
if (simpleAssetRefIndex == -1)
|
||||
{
|
||||
// Error adding the new sub element
|
||||
AZ_Error("Serialization", false, "AddElement failed for simpleAssetRefIndex %s", subElementName);
|
||||
return false;
|
||||
}
|
||||
|
||||
// add a sub element for the SimpleAssetReferenceBase within the SimpleAssetReference
|
||||
AZ::SerializeContext::DataElementNode& simpleAssetRefNode = classElement.GetSubElement(simpleAssetRefIndex);
|
||||
int simpleAssetRefBaseIndex = simpleAssetRefNode.AddElement<AzFramework::SimpleAssetReferenceBase>(context, "BaseClass1");
|
||||
if (simpleAssetRefBaseIndex == -1)
|
||||
{
|
||||
// Error adding the new sub element
|
||||
AZ_Error("Serialization", false, "AddElement failed for converted element BaseClass1");
|
||||
return false;
|
||||
}
|
||||
|
||||
// add a sub element for the AssetPath within the SimpleAssetReference
|
||||
AZ::SerializeContext::DataElementNode& simpleAssetRefBaseNode = simpleAssetRefNode.GetSubElement(simpleAssetRefBaseIndex);
|
||||
int assetPathElementIndex = simpleAssetRefBaseNode.AddElement<AZStd::string>(context, "AssetPath");
|
||||
if (assetPathElementIndex == -1)
|
||||
{
|
||||
// Error adding the new sub element
|
||||
AZ_Error("Serialization", false, "AddElement failed for converted element AssetPath");
|
||||
return false;
|
||||
}
|
||||
|
||||
AZStd::string newData(oldData.c_str());
|
||||
simpleAssetRefBaseNode.GetSubElement(assetPathElementIndex).SetData(context, newData);
|
||||
}
|
||||
|
||||
// if the field did not exist then we do not report an error
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Helper function to VersionConverter to convert an AZStd::string field to a simple asset reference
|
||||
// Inline to avoid DLL linkage issues
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
MOCK_METHOD0(IsOpened, bool ());
|
||||
MOCK_METHOD0(GetNumVars, int());
|
||||
MOCK_METHOD0(GetNumVisibleVars, int());
|
||||
MOCK_METHOD3(GetSortedVars, size_t (const char** pszArray, size_t numItems, const char* szPrefix));
|
||||
MOCK_METHOD2(GetSortedVars, size_t (AZStd::vector<AZStd::string_view>& pszArray, const char* szPrefix));
|
||||
MOCK_METHOD1(AutoComplete, const char*(const char* substr));
|
||||
MOCK_METHOD1(AutoCompletePrev, const char*(const char* substr));
|
||||
MOCK_METHOD1(ProcessCompletion, const char*(const char* szInputBuffer));
|
||||
|
||||
@@ -283,7 +283,7 @@ public:
|
||||
MOCK_METHOD0(EF_GetShaderMissLogPath,
|
||||
const char*());
|
||||
MOCK_METHOD1(EF_GetShaderNames,
|
||||
string * (int& nNumShaders));
|
||||
AZStd::string * (int& nNumShaders));
|
||||
MOCK_METHOD1(EF_ReloadFile,
|
||||
bool(const char* szFileName));
|
||||
MOCK_METHOD1(EF_ReloadFile_Request,
|
||||
|
||||
@@ -118,7 +118,7 @@ public:
|
||||
const SFileVersion&());
|
||||
|
||||
MOCK_METHOD1(AddCVarGroupDirectory,
|
||||
void(const string&));
|
||||
void(const AZStd::string&));
|
||||
MOCK_METHOD0(SaveConfiguration,
|
||||
void());
|
||||
MOCK_METHOD3(LoadConfiguration,
|
||||
|
||||
@@ -35,10 +35,7 @@
|
||||
|
||||
// Type used for vertex indices
|
||||
// WARNING: If you change this typedef, you need to update AssetProcessorPlatformConfig.ini to convert cgf and abc files to the proper index format.
|
||||
#if defined(RESOURCE_COMPILER)
|
||||
typedef uint32 vtx_idx;
|
||||
#define AZ_RESTRICTED_SECTION_IMPLEMENTED
|
||||
#elif defined(MOBILE)
|
||||
#if defined(MOBILE)
|
||||
typedef uint16 vtx_idx;
|
||||
#define AZ_RESTRICTED_SECTION_IMPLEMENTED
|
||||
#elif defined(AZ_RESTRICTED_PLATFORM)
|
||||
@@ -100,7 +97,7 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (!defined(_RELEASE) || defined(PERFORMANCE_BUILD)) && !defined(RESOURCE_COMPILER)
|
||||
#if (!defined(_RELEASE) || defined(PERFORMANCE_BUILD))
|
||||
#ifndef ENABLE_PROFILING_CODE
|
||||
#define ENABLE_PROFILING_CODE
|
||||
#endif
|
||||
|
||||
@@ -494,7 +494,7 @@ namespace stl
|
||||
|
||||
//! Specialization of string to const char cast.
|
||||
template <>
|
||||
inline const char* constchar_cast(const string& type)
|
||||
inline const char* constchar_cast(const AZStd::string& type)
|
||||
{
|
||||
return type.c_str();
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -15,6 +15,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Math/Uuid.h>
|
||||
#include <AzCore/std/string/string.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Meta-type support.
|
||||
@@ -55,7 +56,7 @@ inline const CTypeInfo& TypeInfo(const T* t)
|
||||
|
||||
// Type info declaration, with additional prototypes for string conversions.
|
||||
#define BASIC_TYPE_INFO(Type) \
|
||||
string ToString(Type const & val); \
|
||||
AZStd::string ToString(Type const & val); \
|
||||
bool FromString(Type & val, const char* s); \
|
||||
DECLARE_TYPE_INFO(Type)
|
||||
|
||||
@@ -105,7 +106,7 @@ BASIC_TYPE_INFO(double)
|
||||
|
||||
BASIC_TYPE_INFO(AZ::Uuid)
|
||||
|
||||
DECLARE_TYPE_INFO(string)
|
||||
DECLARE_TYPE_INFO(AZStd::string)
|
||||
|
||||
// All pointers share same TypeInfo.
|
||||
const CTypeInfo&PtrTypeInfo();
|
||||
|
||||
@@ -1,986 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// Note: The utilities in this file should typically not be used directly,
|
||||
// consider including UnicodeFunctions.h or UnicodeIterator.h instead.
|
||||
//
|
||||
// (At least) the following string types can be bound with these helper functions:
|
||||
// Types Input Output Null-Terminator
|
||||
// CryStringT<T>, (::string, ::wstring): yes yes implied by type (also Stack and Fixed variants)
|
||||
// std::basic_string<T>, std::string, std::wstring: yes yes implied by type
|
||||
// QString: yes yes implied by type
|
||||
// std::vector<T>, std::list<T>, std::deque<T>: yes yes not present
|
||||
// T[] (fixed-length buffer): yes yes guaranteed to be emitted on output, accepted on input
|
||||
// T * and size_t (user-specified-size buffer): no yes guaranteed to be emitted on output
|
||||
// const T * (null-terminated string): yes no expected
|
||||
// const T[] (literal): yes no implied as the last item in the array
|
||||
// pair of iterators over T: yes no should not be included in the range
|
||||
// uint32 (single UCS code-point): yes no not present
|
||||
// If some other string type is not listed, you can still use it for input easily by passing begin/end iterators.
|
||||
// Note: For all types, T can be any 8-bit, 16-bit or 32-bit integral or character type.
|
||||
// Further T types may be processed by explicitly passing InputEncoding and OutputEncoding.
|
||||
// We never actively tested such scenario's, so no guarantees on floating and user-defined types as code-units.
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef assert
|
||||
// Some tools use CRT's assert, most engine and game modules use CryAssert.h (via platform.h maybe).
|
||||
// We don't want to force a choice upon all code that uses Unicode utilities, so we just assume assert is defined.
|
||||
#error This header uses assert macro, please provide an applicable definition before including UnicodeXXX.h
|
||||
#endif
|
||||
|
||||
#include "UnicodeEncoding.h"
|
||||
#include <string.h> // For str(n)len and memcpy.
|
||||
#include <wchar.h> // For wcs(n)len.
|
||||
#include <stddef.h> // For size_t and ptrdiff_t.
|
||||
#include <iterator> // For std::iterator_traits.
|
||||
#include <string> // For std::basic_string.
|
||||
#include <vector> // For std::vector.
|
||||
#include <list> // For std::list.
|
||||
#include <deque> // For std::deque.
|
||||
#include <type_traits> // ... standard type-traits (as of C++11).
|
||||
|
||||
#if defined(AZ_RESTRICTED_PLATFORM)
|
||||
#undef AZ_RESTRICTED_SECTION
|
||||
#define UNICODEBINDING_H_SECTION_1 1
|
||||
#define UNICODEBINDING_H_SECTION_2 2
|
||||
#endif
|
||||
|
||||
// Forward declare the supported types.
|
||||
// Before actually instantiating a binding however, you need to have the full definition included.
|
||||
// Also, this allows us to work with QChar/QString as declared names without a dependency on Qt.
|
||||
template<typename T, size_t S>
|
||||
class CryStackStringT;
|
||||
template<size_t S>
|
||||
class CryFixedStringT;
|
||||
template<size_t S>
|
||||
class CryFixedWStringT;
|
||||
template<typename T>
|
||||
class CryStringLocalT;
|
||||
template<typename T>
|
||||
class CryStringT;
|
||||
class QChar;
|
||||
class QString;
|
||||
namespace Unicode
|
||||
{
|
||||
namespace Detail
|
||||
{
|
||||
// Import standard type traits.
|
||||
// This requires C++11 compiler support.
|
||||
using std::add_const;
|
||||
using std::conditional;
|
||||
using std::extent;
|
||||
using std::integral_constant;
|
||||
using std::is_arithmetic;
|
||||
using std::is_array;
|
||||
using std::is_base_of;
|
||||
using std::is_const;
|
||||
using std::is_convertible;
|
||||
using std::is_integral;
|
||||
using std::is_pointer;
|
||||
using std::is_same;
|
||||
using std::make_unsigned;
|
||||
using std::remove_cv;
|
||||
using std::remove_extent;
|
||||
using std::remove_pointer;
|
||||
|
||||
// SVoid<T>:
|
||||
// Result type will be void if T is well-formed.
|
||||
// Note: This is mostly used to test the presence of member types at compile-time.
|
||||
template<typename T>
|
||||
struct SVoid
|
||||
{
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
// SValidChar<T, InferEncoding, Input>:
|
||||
// Determine if T is a valid character type in the given compile-time context.
|
||||
// The InferEncoding flag is set if the encoding has to be detected automatically.
|
||||
// The Input flag is set if the type is used for input (and not set if the type is used for output).
|
||||
template<typename T, bool InferEncoding, bool Input>
|
||||
struct SValidChar
|
||||
{
|
||||
typedef typename remove_cv<T>::type BaseType;
|
||||
static const bool isArithmeticType = is_arithmetic<BaseType>::value;
|
||||
static const bool isQChar = is_same<BaseType, QChar>::value;
|
||||
static const bool isUsable = isArithmeticType || isQChar;
|
||||
static const bool isValidQualified = !is_const<T>::value || Input;
|
||||
static const bool isKnownSize = sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4;
|
||||
static const bool isValidInferred = isKnownSize || !InferEncoding;
|
||||
static const bool value = isUsable && isValidQualified && isValidInferred;
|
||||
};
|
||||
|
||||
// SPackedIterators<T>:
|
||||
// A pair of iterators over some range.
|
||||
// Note: Packing iterators into a single object allows us to pass them as a single argument like all other types.
|
||||
template<typename T>
|
||||
struct SPackedIterators
|
||||
{
|
||||
const T begin, end;
|
||||
SPackedIterators(const T& _begin, const T& _end)
|
||||
: begin(_begin)
|
||||
, end(_end) {}
|
||||
};
|
||||
|
||||
// SPackedBuffer<T>:
|
||||
// A buffer-pointer/length tuple.
|
||||
// Note: Packing them into a single object allows us to pass them as a single argument like all other types.
|
||||
template<typename T>
|
||||
struct SPackedBuffer
|
||||
{
|
||||
T buffer;
|
||||
size_t size;
|
||||
SPackedBuffer(T _buffer, size_t _size)
|
||||
: buffer(_buffer)
|
||||
, size(_size) {}
|
||||
};
|
||||
|
||||
// SDependentType<T, X>:
|
||||
// Makes the name of type T dependent on X (which is otherwise meaningless).
|
||||
// Note: This is used to force two-phase lookup so we don't need the definition of T until instantiation.
|
||||
// This way we can convince standards-compliant compilers Clang and GCC to not require definition of forward-declared types.
|
||||
// Specifically, we forward-declare Qt's QString and QChar, for which the definition will never be available outside Editor.
|
||||
template<typename T, int X>
|
||||
struct SDependentType
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
// EBind:
|
||||
// Methods of binding a type for input and/or output.
|
||||
// Note: These are used for tag-dispatch by binding functions, and are private to the implementation.
|
||||
enum EBind
|
||||
{ // Input Output Description
|
||||
eBind_Impossible, // No No Can't bind this type.
|
||||
eBind_Iterators, // Yes Yes Bind by using begin() and end() member functions.
|
||||
eBind_Data, // Yes Yes Bind by using data() and size() member functions.
|
||||
eBind_Literal, // Yes No Bind a fixed size buffer (const element, aka string literal).
|
||||
eBind_Buffer, // Yes No Bind a fixed size buffer (non-const element) that may be null-terminated.
|
||||
eBind_PackedBuffer, // No Yes Bind a user-specified size buffer (non-const element).
|
||||
eBind_NullTerminated, // Yes No Bind a null-terminated buffer of unknown length (C string).
|
||||
eBind_CodePoint, // Yes No Bind a single code-point value.
|
||||
};
|
||||
|
||||
// SBindIterator<T, InferEncoding>:
|
||||
// Find the EBind for input from iterator pair of type T at compile-time.
|
||||
// If the type is not supported, the resulting value will be eBind_Impossible
|
||||
template<typename T, bool InferEncoding, typename HasValueType = void, typename HasIteratorCategory = void>
|
||||
struct SBindIterator
|
||||
{
|
||||
typedef const void CharType;
|
||||
static const EBind value = eBind_Impossible;
|
||||
};
|
||||
template<typename T, bool InferEncoding, typename HasValueType, typename HasIteratorCategory>
|
||||
struct SBindIterator<T*, InferEncoding, HasValueType, HasIteratorCategory>
|
||||
{
|
||||
typedef typename add_const<T>::type CharType;
|
||||
static const bool isValid = SValidChar<CharType, InferEncoding, true>::value;
|
||||
static const EBind value = isValid ? eBind_Iterators : eBind_Impossible;
|
||||
};
|
||||
template<typename T, bool InferEncoding>
|
||||
struct SBindIterator<T, InferEncoding,
|
||||
typename SVoid<typename T::value_type>::type,
|
||||
typename SVoid<typename T::iterator_category>::type
|
||||
>
|
||||
{
|
||||
typedef typename add_const<typename T::value_type>::type CharType;
|
||||
typedef typename T::iterator_category IteratorCategory;
|
||||
static const bool isInputIterator = is_base_of<std::input_iterator_tag, IteratorCategory>::value;
|
||||
static const bool isValid = SValidChar<CharType, InferEncoding, true>::value;
|
||||
static const EBind value = isValid && isInputIterator ? eBind_Iterators : eBind_Impossible;
|
||||
};
|
||||
|
||||
// SBindObject<T, InferEncoding>:
|
||||
// Find the EBind for input from object of type T at compile-time.
|
||||
// If the type is not supported, the resulting value will be eBind_Impossible.
|
||||
template<typename T, bool InferEncoding>
|
||||
struct SBindObject
|
||||
{
|
||||
typedef typename add_const<
|
||||
typename conditional<
|
||||
is_array<T>::value,
|
||||
typename remove_extent<T>::type,
|
||||
typename remove_pointer<T>::type
|
||||
>::type
|
||||
>::type CharType;
|
||||
static const size_t FixedSize = extent<T>::value;
|
||||
static_assert(!is_array<T>::value || FixedSize > 0);
|
||||
static const bool isConstArray = is_array<T>::value && is_const<typename remove_extent<T>::type>::value;
|
||||
static const bool isBufferArray = is_array<T>::value && !isConstArray;
|
||||
static const bool isPointer = is_pointer<T>::value;
|
||||
static const bool isCodePoint = is_integral<T>::value;
|
||||
static const bool isValidChar = SValidChar<CharType, InferEncoding, true>::value;
|
||||
static const EBind value =
|
||||
!isValidChar ? eBind_Impossible :
|
||||
isConstArray ? eBind_Literal :
|
||||
isBufferArray ? eBind_Buffer :
|
||||
isPointer ? eBind_NullTerminated :
|
||||
isCodePoint ? eBind_CodePoint :
|
||||
eBind_Impossible;
|
||||
};
|
||||
template<typename CharT, typename Traits, typename Allocator, bool InferEncoding>
|
||||
struct SBindObject<std::basic_string<CharT, Traits, Allocator>, InferEncoding>
|
||||
{
|
||||
typedef typename add_const<CharT>::type CharType;
|
||||
static const bool isValid = SValidChar<CharT, InferEncoding, true>::value;
|
||||
static const EBind value = isValid ? eBind_Data : eBind_Impossible;
|
||||
};
|
||||
template<typename T, typename Allocator, bool InferEncoding>
|
||||
struct SBindObject<std::vector<T, Allocator>, InferEncoding>
|
||||
{
|
||||
typedef typename add_const<T>::type CharType;
|
||||
static const bool isValid = SValidChar<T, InferEncoding, true>::value;
|
||||
static const EBind value = isValid ? eBind_Data : eBind_Impossible;
|
||||
};
|
||||
template<typename T, typename Allocator, bool InferEncoding>
|
||||
struct SBindObject<std::list<T, Allocator>, InferEncoding>
|
||||
{
|
||||
typedef typename add_const<T>::type CharType;
|
||||
static const bool isValid = SValidChar<T, InferEncoding, true>::value;
|
||||
static const EBind value = isValid ? eBind_Iterators : eBind_Impossible;
|
||||
};
|
||||
template<typename T, typename Allocator, bool InferEncoding>
|
||||
struct SBindObject<std::deque<T, Allocator>, InferEncoding>
|
||||
{
|
||||
typedef typename add_const<T>::type CharType;
|
||||
static const bool isValid = SValidChar<T, InferEncoding, true>::value;
|
||||
static const EBind value = isValid ? eBind_Iterators : eBind_Impossible;
|
||||
};
|
||||
template<typename T, bool InferEncoding>
|
||||
struct SBindObject<CryStringT<T>, InferEncoding>
|
||||
{
|
||||
typedef typename add_const<T>::type CharType;
|
||||
static const bool isValid = SValidChar<T, InferEncoding, true>::value;
|
||||
static const EBind value = isValid ? eBind_Data : eBind_Impossible;
|
||||
};
|
||||
template<typename T, bool InferEncoding>
|
||||
struct SBindObject<CryStringLocalT<T>, InferEncoding>
|
||||
{
|
||||
typedef typename add_const<T>::type CharType;
|
||||
static const bool isValid = SValidChar<T, InferEncoding, true>::value;
|
||||
static const EBind value = isValid ? eBind_Data : eBind_Impossible;
|
||||
};
|
||||
template<typename T, size_t S, bool InferEncoding>
|
||||
struct SBindObject<CryStackStringT<T, S>, InferEncoding>
|
||||
{
|
||||
typedef typename add_const<T>::type CharType;
|
||||
static const bool isValid = SValidChar<T, InferEncoding, true>::value;
|
||||
static const EBind value = isValid ? eBind_Data : eBind_Impossible;
|
||||
};
|
||||
template<size_t S, bool InferEncoding>
|
||||
struct SBindObject<CryFixedStringT<S>, InferEncoding>
|
||||
{
|
||||
typedef char CharType;
|
||||
static const bool isValid = SValidChar<CharType, InferEncoding, true>::value;
|
||||
static const EBind value = isValid ? eBind_Data : eBind_Impossible;
|
||||
};
|
||||
template<size_t S, bool InferEncoding>
|
||||
struct SBindObject<CryFixedWStringT<S>, InferEncoding>
|
||||
{
|
||||
typedef wchar_t CharType;
|
||||
static const bool isValid = SValidChar<CharType, InferEncoding, true>::value;
|
||||
static const EBind value = isValid ? eBind_Data : eBind_Impossible;
|
||||
};
|
||||
template<bool InferEncoding>
|
||||
struct SBindObject<QString, InferEncoding>
|
||||
{
|
||||
typedef const QChar CharType;
|
||||
static const EBind value = eBind_Data;
|
||||
};
|
||||
template<typename T, bool InferEncoding>
|
||||
struct SBindObject<SPackedIterators<T>, InferEncoding>
|
||||
{
|
||||
typedef typename SBindIterator<T, InferEncoding>::CharType CharType;
|
||||
static const EBind value = eBind_Iterators;
|
||||
};
|
||||
|
||||
// SBindOutput<T, InferEncoding>:
|
||||
// Find the EBind for output to object of type T at compile-time.
|
||||
// If the type is not supported, the resulting value will be eBind_Impossible.
|
||||
template<typename T, bool InferEncoding>
|
||||
struct SBindOutput
|
||||
{
|
||||
typedef typename remove_extent<T>::type CharType;
|
||||
static const size_t FixedSize = extent<T>::value;
|
||||
static const bool isArray = is_array<T>::value;
|
||||
static const bool isValid = SValidChar<typename remove_extent<T>::type, InferEncoding, false>::value;
|
||||
static const EBind value = isArray && isValid ? eBind_Buffer : eBind_Impossible;
|
||||
};
|
||||
template<typename OutputCharType, bool InferEncoding>
|
||||
struct SBindOutput<SPackedBuffer<OutputCharType*>, InferEncoding>
|
||||
{
|
||||
typedef OutputCharType CharType;
|
||||
static const bool isValid = SValidChar<CharType, InferEncoding, false>::value;
|
||||
static const EBind value = isValid ? eBind_PackedBuffer : eBind_Impossible;
|
||||
};
|
||||
template<typename CharT, typename Traits, typename Allocator, bool InferEncoding>
|
||||
struct SBindOutput<std::basic_string<CharT, Traits, Allocator>, InferEncoding>
|
||||
{
|
||||
typedef CharT CharType;
|
||||
static const bool isValid = SValidChar<CharT, InferEncoding, false>::value;
|
||||
static const EBind value = isValid ? eBind_Data : eBind_Impossible;
|
||||
};
|
||||
template<typename T, typename Allocator, bool InferEncoding>
|
||||
struct SBindOutput<std::vector<T, Allocator>, InferEncoding>
|
||||
{
|
||||
typedef T CharType;
|
||||
static const bool isValid = SValidChar<T, InferEncoding, false>::value;
|
||||
static const EBind value = isValid ? eBind_Data : eBind_Impossible;
|
||||
};
|
||||
template<typename T, typename Allocator, bool InferEncoding>
|
||||
struct SBindOutput<std::list<T, Allocator>, InferEncoding>
|
||||
{
|
||||
typedef T CharType;
|
||||
static const bool isValid = SValidChar<T, InferEncoding, false>::value;
|
||||
static const EBind value = isValid ? eBind_Iterators : eBind_Impossible;
|
||||
};
|
||||
template<typename T, typename Allocator, bool InferEncoding>
|
||||
struct SBindOutput<std::deque<T, Allocator>, InferEncoding>
|
||||
{
|
||||
typedef T CharType;
|
||||
static const bool isValid = SValidChar<T, InferEncoding, false>::value;
|
||||
static const EBind value = isValid ? eBind_Iterators : eBind_Impossible;
|
||||
};
|
||||
template<typename T, bool InferEncoding>
|
||||
struct SBindOutput<CryStringT<T>, InferEncoding>
|
||||
{
|
||||
typedef T CharType;
|
||||
static const bool isValid = SValidChar<T, InferEncoding, false>::value;
|
||||
static const EBind value = isValid ? eBind_Data : eBind_Impossible;
|
||||
};
|
||||
template<typename T, bool InferEncoding>
|
||||
struct SBindOutput<CryStringLocalT<T>, InferEncoding>
|
||||
{
|
||||
typedef T CharType;
|
||||
static const bool isValid = SValidChar<T, InferEncoding, false>::value;
|
||||
static const EBind value = isValid ? eBind_Data : eBind_Impossible;
|
||||
};
|
||||
template<typename T, size_t S, bool InferEncoding>
|
||||
struct SBindOutput<CryStackStringT<T, S>, InferEncoding>
|
||||
{
|
||||
typedef T CharType;
|
||||
static const bool isValid = SValidChar<T, InferEncoding, false>::value;
|
||||
static const EBind value = isValid ? eBind_Data : eBind_Impossible;
|
||||
};
|
||||
template<bool InferEncoding>
|
||||
struct SBindOutput<QString, InferEncoding>
|
||||
{
|
||||
typedef QChar CharType;
|
||||
static const EBind value = eBind_Data;
|
||||
};
|
||||
|
||||
// SInferEncoding<T>:
|
||||
// Infers the encoding of the given character type.
|
||||
// Note: This will always pick an UTF encoding type based on the size of the element type.
|
||||
template<typename T, bool Input>
|
||||
struct SInferEncoding
|
||||
{
|
||||
typedef SBindObject<T, true> ObjectType;
|
||||
typedef SBindIterator<T, true> IteratorType;
|
||||
typedef typename conditional<
|
||||
IteratorType::value != eBind_Impossible,
|
||||
typename IteratorType::CharType,
|
||||
typename ObjectType::CharType
|
||||
>::type CharType;
|
||||
static const EEncoding value =
|
||||
sizeof(CharType) == 1 ? eEncoding_UTF8 :
|
||||
sizeof(CharType) == 2 ? eEncoding_UTF16 :
|
||||
eEncoding_UTF32;
|
||||
static_assert(value != eEncoding_UTF32 || sizeof(CharType) == 4);
|
||||
};
|
||||
|
||||
// SBindCharacter<T, Input>:
|
||||
// Pick the base character type to use during input or output with this element type.
|
||||
template<typename T, bool Input, bool Integral = is_integral<T>::value, bool IsQChar = is_same<QChar, typename remove_cv<T>::type>::value>
|
||||
struct SBindCharacter
|
||||
{
|
||||
typedef typename make_unsigned<T>::type BaseType; // The standard doesn't define if a character type is signed or unsigned.
|
||||
typedef typename remove_cv<BaseType>::type UnqualifiedType;
|
||||
typedef typename conditional<Input, const UnqualifiedType, UnqualifiedType>::type type;
|
||||
};
|
||||
template<typename T, bool Input>
|
||||
struct SBindCharacter<T, Input, false, false>
|
||||
{
|
||||
static_assert(is_arithmetic<T>::value);
|
||||
typedef typename remove_cv<T>::type UnqualifiedType;
|
||||
typedef typename conditional<Input, const UnqualifiedType, UnqualifiedType>::type type;
|
||||
};
|
||||
template<typename T, bool Input>
|
||||
struct SBindCharacter<T, Input, false, true>
|
||||
{
|
||||
typedef typename conditional<Input, const uint16, uint16>::type type;
|
||||
typedef typename SDependentType<QChar, Input>::type ActuallyQChar; // Force two-phase name lookup on QChar.
|
||||
static_assert(sizeof(ActuallyQChar) == sizeof(type)); // In case Qt ever changes QChar.
|
||||
};
|
||||
|
||||
// SBindPointer<T, Input>:
|
||||
// Pick the pointer type to use during input or output with buffers (potentially inside string types).
|
||||
template<typename T, bool Input>
|
||||
struct SBindPointer
|
||||
{
|
||||
static_assert(is_pointer<T>::value || is_array<T>::value);
|
||||
typedef typename conditional<
|
||||
is_pointer<T>::value,
|
||||
typename remove_pointer<T>::type,
|
||||
typename remove_extent<T>::type
|
||||
>::type UnboundCharType;
|
||||
typedef typename SBindCharacter<UnboundCharType, Input>::type BoundCharType;
|
||||
typedef BoundCharType* type;
|
||||
};
|
||||
|
||||
// SAutomaticallyDeduced:
|
||||
// Placeholder type that is never defined, used by SRequire for SFINAE overloading.
|
||||
struct SAutomaticallyDeduced;
|
||||
|
||||
// SRequire<Expr, T>:
|
||||
// Helper for SFINAE overloading.
|
||||
// Similar to C++11's std::enable_if, which is not in boost (with that exact name anyway).
|
||||
template<bool SFINAE, typename T = SAutomaticallyDeduced>
|
||||
struct SRequire
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
template<typename T>
|
||||
struct SRequire<false, T> {};
|
||||
|
||||
// SafeCast<T, SourceChar>:
|
||||
// Cast a pointer to type T, but only allowing safe casts.
|
||||
// This guards against bad code in other functions since it prevents unintended casts.
|
||||
template<typename T, typename SourceChar>
|
||||
inline T SafeCast(SourceChar* ptr, typename SRequire<is_integral<SourceChar>::value>::type* = 0)
|
||||
{
|
||||
// Allow casts from pointer-to-integral to unrelated pointer-to-integral, provided they are of the same size.
|
||||
typedef typename remove_pointer<T>::type TargetChar;
|
||||
static_assert(is_integral<SourceChar>::value && is_integral<TargetChar>::value);
|
||||
static_assert(sizeof(SourceChar) == sizeof(TargetChar));
|
||||
return reinterpret_cast<T>(ptr);
|
||||
}
|
||||
template<typename T, typename SourceChar>
|
||||
inline T SafeCast(SourceChar* ptr, typename SRequire<is_same<typename remove_cv<SourceChar>::type, QChar>::value>::type* = 0)
|
||||
{
|
||||
// Allow casts from pointer-to-QChar to unrelated pointer-to-integral, provided they are of the same size.
|
||||
typedef typename remove_pointer<T>::type TargetChar;
|
||||
static_assert(is_integral<TargetChar>::value);
|
||||
static_assert(sizeof(SourceChar) == sizeof(TargetChar));
|
||||
return reinterpret_cast<T>(ptr);
|
||||
}
|
||||
template<typename T, typename SourceChar>
|
||||
inline T SafeCast(SourceChar* ptr, typename SRequire<!is_integral<SourceChar>::value&& !is_same<typename remove_cv<SourceChar>::type, QChar>::value>::type* = 0)
|
||||
{
|
||||
// Any other casts that are allowed by C++.
|
||||
return static_cast<T>(ptr);
|
||||
}
|
||||
|
||||
// SCharacterTrait<T>:
|
||||
// Exposes some basic traits for a given character.
|
||||
// Note: Map to (hopefully optimized) CRT functions where possible.
|
||||
template<typename T, size_t Size = sizeof(T)* is_integral<T>::value>
|
||||
struct SCharacterTrait
|
||||
{
|
||||
static size_t StrLen(const T* nts) // Fall-back strlen.
|
||||
{
|
||||
size_t result = 0;
|
||||
while (*nts != 0)
|
||||
{
|
||||
++nts;
|
||||
++result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
static size_t StrNLen(const T* ptr, size_t len) // Fall-back strnlen.
|
||||
{
|
||||
size_t result = 0;
|
||||
while (*ptr != 0 && result != len)
|
||||
{
|
||||
++ptr;
|
||||
++result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
template<typename T>
|
||||
struct SCharacterTrait<T, sizeof(char)>
|
||||
{
|
||||
static size_t StrLen(const T* nts) // Narrow CRT strlen.
|
||||
{
|
||||
return ::strlen(SafeCast<const char*>(nts));
|
||||
}
|
||||
static size_t StrNLen(const T* ptr, size_t len) // Narrow CRT strnlen.
|
||||
{
|
||||
return ::strnlen(SafeCast<const char*>(ptr), len);
|
||||
}
|
||||
};
|
||||
template<typename T>
|
||||
struct SCharacterTrait<T, sizeof(wchar_t)>
|
||||
{
|
||||
static size_t StrLen(const T* nts) // Wide CRT strlen.
|
||||
{
|
||||
return ::wcslen(SafeCast<const wchar_t*>(nts));
|
||||
}
|
||||
static size_t StrNLen(const T* ptr, size_t len) // Wide CRT strnlen.
|
||||
{
|
||||
#if defined(AZ_RESTRICTED_PLATFORM)
|
||||
#define AZ_RESTRICTED_SECTION UNICODEBINDING_H_SECTION_1
|
||||
#include AZ_RESTRICTED_FILE(UnicodeBinding_h)
|
||||
#endif
|
||||
return ::wcsnlen(SafeCast<const wchar_t*>(ptr), len);
|
||||
#if defined(AZ_RESTRICTED_PLATFORM)
|
||||
#define AZ_RESTRICTED_SECTION UNICODEBINDING_H_SECTION_2
|
||||
#include AZ_RESTRICTED_FILE(UnicodeBinding_h)
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
// void Feed(const SPackedIterators<InputIteratorType> &its, Sink &out, tag):
|
||||
// Feeds the provided sink from provided packed iterator-range.
|
||||
template<typename InputIteratorType, typename Sink>
|
||||
inline void Feed(const SPackedIterators<InputIteratorType>& its, Sink& out, integral_constant<EBind, eBind_Iterators>)
|
||||
{
|
||||
typedef typename std::iterator_traits<InputIteratorType>::value_type UnboundCharType;
|
||||
typedef typename SBindCharacter<UnboundCharType, true>::type BoundCharType;
|
||||
for (InputIteratorType it = its.begin; it != its.end; ++it)
|
||||
{
|
||||
const UnboundCharType unbound = *it;
|
||||
const BoundCharType bound = static_cast<BoundCharType>(unbound);
|
||||
const uint32 item = static_cast<uint32>(bound);
|
||||
out(item);
|
||||
}
|
||||
}
|
||||
|
||||
// void Feed(const SPackedIterators<const InputCharType *> &its, Sink &out, tag):
|
||||
// Feeds the provided sink from provided packed pointer-range.
|
||||
// This is slightly better code-generation than using generic iterators.
|
||||
template<typename InputCharType, typename Sink>
|
||||
inline void Feed(const SPackedIterators<const InputCharType*>& its, Sink& out, integral_constant<EBind, eBind_Iterators>)
|
||||
{
|
||||
typedef typename SBindPointer<const InputCharType*, true>::type PointerType;
|
||||
assert(reinterpret_cast<size_t>(its.begin) <= reinterpret_cast<size_t>(its.end) && "Invalid range specified");
|
||||
const size_t length = its.end - its.begin;
|
||||
PointerType ptr = SafeCast<PointerType>(its.begin);
|
||||
assert((ptr || !length) && "Passed a non-empty range containing a null-pointer");
|
||||
for (size_t i = 0; i < length; ++i, ++ptr)
|
||||
{
|
||||
const uint32 item = static_cast<uint32>(*ptr);
|
||||
out(item);
|
||||
}
|
||||
}
|
||||
|
||||
// void Feed(const InputStringType &in, Sink &out, tag):
|
||||
// Feeds the provided sink from a container, using it's iterators.
|
||||
// Note: Dispatches to one of the packed-range overloads.
|
||||
template<typename InputStringType, typename Sink>
|
||||
inline void Feed(const InputStringType& in, Sink& out, integral_constant<EBind, eBind_Iterators> tag)
|
||||
{
|
||||
typedef typename InputStringType::const_iterator IteratorType;
|
||||
Detail::SPackedIterators<IteratorType> its(in.begin(), in.end());
|
||||
Feed(its, out, tag);
|
||||
}
|
||||
|
||||
// void Feed(const InputStringType &in, Sink &out, tag):
|
||||
// Feeds the provided sink from a string-object's buffer.
|
||||
template<typename InputStringType, typename Sink>
|
||||
inline void Feed(const InputStringType& in, Sink& out, integral_constant<EBind, eBind_Data>)
|
||||
{
|
||||
typedef typename InputStringType::size_type SizeType;
|
||||
typedef typename InputStringType::value_type ValueType;
|
||||
typedef typename SBindPointer<const ValueType*, true>::type PointerType;
|
||||
const SizeType length = in.size();
|
||||
if (length)
|
||||
{
|
||||
PointerType ptr = SafeCast<PointerType>(in.data());
|
||||
for (SizeType i = 0; i < length; ++i, ++ptr)
|
||||
{
|
||||
const uint32 item = static_cast<uint32>(*ptr);
|
||||
out(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// void Feed(const InputStringType &in, Sink &out, tag):
|
||||
// Feeds the provided sink from a string-literal.
|
||||
// Note: The literal is assumed to be null-terminated.
|
||||
// It's possible that a const-element fixed-size-buffer is mistaken as a literal.
|
||||
// However, we expect no-one uses such buffers that are not null-terminated already.
|
||||
// If somehow this use-case is desired, either terminate the buffer, or remove const from the buffer, or pass iterators.
|
||||
template<typename InputStringType, typename Sink>
|
||||
inline void Feed(const InputStringType& in, Sink& out, integral_constant<EBind, eBind_Literal>)
|
||||
{
|
||||
static_assert(is_array<InputStringType>::value && extent<InputStringType>::value > 0);
|
||||
typedef typename SBindPointer<InputStringType, true>::type PointerType;
|
||||
const size_t length = extent<InputStringType>::value - 1;
|
||||
PointerType ptr = SafeCast<PointerType>(in);
|
||||
assert(ptr[length] == 0 && "Literal is not null-terminated");
|
||||
for (size_t i = 0; i < length; ++i, ++ptr)
|
||||
{
|
||||
const uint32 item = static_cast<uint32>(*ptr);
|
||||
out(item);
|
||||
}
|
||||
}
|
||||
|
||||
// void Feed(const InputStringType &in, Sink &out, tag):
|
||||
// Feeds the provided sink from a non-const-element fixed-size buffer.
|
||||
// Note: The buffer is allowed to be null-terminated, but it's not required.
|
||||
template<typename InputStringType, typename Sink>
|
||||
inline void Feed(const InputStringType& in, Sink& out, integral_constant<EBind, eBind_Buffer>)
|
||||
{
|
||||
static_assert(is_array<InputStringType>::value && extent<InputStringType>::value > 0);
|
||||
typedef typename SBindPointer<InputStringType, true>::type PointerType;
|
||||
typedef typename SBindPointer<InputStringType, true>::BoundCharType CharType;
|
||||
const size_t length = extent<InputStringType>::value;
|
||||
PointerType ptr = SafeCast<PointerType>(in);
|
||||
for (size_t i = 0; i < length; ++i, ++ptr)
|
||||
{
|
||||
const CharType unbound = *ptr;
|
||||
if (unbound == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
const uint32 item = static_cast<uint32>(unbound);
|
||||
out(item);
|
||||
}
|
||||
}
|
||||
|
||||
// void Feed(const InputStringType &in, Sink &out, tag):
|
||||
// Feeds the provided sink from a null-terminated C-style string.
|
||||
template<typename InputStringType, typename Sink>
|
||||
inline void Feed(const InputStringType& in, Sink& out, integral_constant<EBind, eBind_NullTerminated>)
|
||||
{
|
||||
static_assert(is_pointer<InputStringType>::value);
|
||||
typedef typename SBindPointer<InputStringType, true>::type PointerType;
|
||||
typedef typename SBindPointer<InputStringType, true>::BoundCharType CharType;
|
||||
PointerType ptr = SafeCast<PointerType>(in);
|
||||
if (ptr)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
const CharType unbound = *ptr;
|
||||
++ptr;
|
||||
if (unbound == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
const uint32 item = static_cast<uint32>(unbound);
|
||||
out(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// void Feed(const InputCharType &in, Sink &out, tag):
|
||||
// Feeds the provided sink from a single value (interpreted as an UCS code-point).
|
||||
template<typename InputCharType, typename Sink>
|
||||
inline void Feed(const InputCharType& in, Sink& out, integral_constant<EBind, eBind_CodePoint>)
|
||||
{
|
||||
static_assert(is_arithmetic<InputCharType>::value);
|
||||
const uint32 item = static_cast<uint32>(in);
|
||||
out(item);
|
||||
}
|
||||
|
||||
// size_t EncodedLength(const SPackedIterators<InputIteratorType> &its, tag):
|
||||
// Determines the length of the input sequence in a range of iterators.
|
||||
template<typename InputIteratorType>
|
||||
inline size_t EncodedLength(const SPackedIterators<InputIteratorType>& its, integral_constant<EBind, eBind_Iterators>)
|
||||
{
|
||||
return std::distance(its.begin, its.end); // std::distance will pick optimal implementation depending on iterator category.
|
||||
}
|
||||
|
||||
// size_t EncodedLength(const InputStringType &in, tag):
|
||||
// Determines the length of an input container, which would otherwise be enumerated with iterators.
|
||||
template<typename InputStringType>
|
||||
inline size_t EncodedLength(const InputStringType& in, integral_constant<EBind, eBind_Iterators>)
|
||||
{
|
||||
return in.size(); // Can there be a container without size()? At the very least, not in the supported types.
|
||||
}
|
||||
|
||||
// size_t EncodedLength(const InputStringType &in, tag):
|
||||
// Determines the length of the input container. The container uses contiguous element layout.
|
||||
template<typename InputStringType>
|
||||
inline size_t EncodedLength(const InputStringType& in, integral_constant<EBind, eBind_Data>)
|
||||
{
|
||||
return in.size();
|
||||
}
|
||||
|
||||
// size_t EncodedLength(const InputStringType &in, tag):
|
||||
// Determines the length of the input string-literal. This is a compile-time constant.
|
||||
template<typename InputStringType>
|
||||
inline size_t EncodedLength(const InputStringType& in, integral_constant<EBind, eBind_Literal>)
|
||||
{
|
||||
static_assert(is_array<InputStringType>::value && extent<InputStringType>::value > 0);
|
||||
return extent<InputStringType>::value - 1;
|
||||
}
|
||||
|
||||
// size_t EncodedLength(const InputStringType &in, tag):
|
||||
// Determines the length of the input fixed-size-buffer. We look for an (optional) null-terminator in the buffer.
|
||||
template<typename InputStringType>
|
||||
inline size_t EncodedLength(const InputStringType& in, integral_constant<EBind, eBind_Buffer>)
|
||||
{
|
||||
static_assert(is_array<InputStringType>::value && extent<InputStringType>::value > 0);
|
||||
typedef typename remove_extent<InputStringType>::type CharType;
|
||||
return SCharacterTrait<CharType>::StrNLen(in, extent<InputStringType>::value);
|
||||
}
|
||||
|
||||
// size_t EncodedLength(const InputStringType &in, tag):
|
||||
// Determines the length of the input used-specified buffer. We look for an (optional) null-terminator in the buffer.
|
||||
template<typename InputCharType>
|
||||
inline size_t EncodedLength(const SPackedBuffer<InputCharType*>& in, integral_constant<EBind, eBind_PackedBuffer>)
|
||||
{
|
||||
return in.buffer ? SCharacterTrait<InputCharType>::StrNLen(in.buffer, in.size) : 0;
|
||||
}
|
||||
|
||||
// size_t EncodedLength(const InputStringType &in, tag):
|
||||
// Determines the length of the input null-terminated c-style string. We just use strlen() if available.
|
||||
template<typename InputStringType>
|
||||
inline size_t EncodedLength(const InputStringType& in, integral_constant<EBind, eBind_NullTerminated>)
|
||||
{
|
||||
static_assert(is_pointer<InputStringType>::value);
|
||||
typedef typename remove_pointer<InputStringType>::type CharType;
|
||||
return in ? SCharacterTrait<CharType>::StrLen(in) : 0;
|
||||
}
|
||||
|
||||
// size_t EncodedLength(const InputCharType &in, tag):
|
||||
// Determines the length of a single UCS code-point. This is always 1.
|
||||
template<typename InputCharType>
|
||||
inline size_t EncodedLength([[maybe_unused]] const InputCharType& in, integral_constant<EBind, eBind_CodePoint>)
|
||||
{
|
||||
static_assert(is_arithmetic<InputCharType>::value);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// const void *EncodedPointer(const SPackedIterators<const InputCharType *> &its, tag):
|
||||
// Get a pointer to contiguous storage for an iterator range.
|
||||
// Note: This can only work if the iterators are pointers, or the storage won't be guaranteed contiguous.
|
||||
template<typename InputCharType>
|
||||
inline const void* EncodedPointer(const SPackedIterators<const InputCharType*>& its, integral_constant<EBind, eBind_Iterators>)
|
||||
{
|
||||
return its.begin;
|
||||
}
|
||||
|
||||
// const void *EncodedPointer(const InputStringType &in, tag):
|
||||
// Get a pointer to contiguous storage for string/vector object.
|
||||
// Note: This can only work for containers that actually use contiguous storage, which is determined by the SBindXXX helpers.
|
||||
template<typename InputStringType>
|
||||
inline const void* EncodedPointer(const InputStringType& in, integral_constant<EBind, eBind_Data>)
|
||||
{
|
||||
return in.data();
|
||||
}
|
||||
|
||||
// const void *EncodedPointer(const InputStringType &in, tag):
|
||||
// Get a pointer to contiguous storage for a string-literal.
|
||||
template<typename InputStringType>
|
||||
inline const void* EncodedPointer(const InputStringType& in, integral_constant<EBind, eBind_Literal>)
|
||||
{
|
||||
static_assert(is_array<InputStringType>::value && extent<InputStringType>::value > 0);
|
||||
return in; // We can just let the array type decay to a pointer.
|
||||
}
|
||||
|
||||
// const void *EncodedPointer(const InputStringType &in, tag):
|
||||
// Get a pointer to contiguous storage for a fixed-size-buffer.
|
||||
template<typename InputStringType>
|
||||
inline const void* EncodedPointer(const InputStringType& in, integral_constant<EBind, eBind_Buffer>)
|
||||
{
|
||||
static_assert(is_array<InputStringType>::value && extent<InputStringType>::value > 0);
|
||||
return in; // We can just let the array type decay to a pointer.
|
||||
}
|
||||
|
||||
// const void *EncodedPointer(const InputStringType &in, tag):
|
||||
// Get a pointer to contiguous storage for a null-terminated c-style-string.
|
||||
template<typename InputStringType>
|
||||
inline const void* EncodedPointer(const InputStringType& in, integral_constant<EBind, eBind_NullTerminated>)
|
||||
{
|
||||
static_assert(is_pointer<InputStringType>::value);
|
||||
return in; // Implied
|
||||
}
|
||||
|
||||
// const void *EncodedPointer(const InputCharType &in, tag):
|
||||
// Get a pointer to contiguous storage for a single UCS code-point.
|
||||
template<typename InputCharType>
|
||||
inline const void* EncodedPointer(const InputCharType& in, integral_constant<EBind, eBind_CodePoint>)
|
||||
{
|
||||
static_assert(is_arithmetic<InputCharType>::value);
|
||||
return ∈ // Take the address of the parameter (which is kept on the stack of the caller).
|
||||
}
|
||||
|
||||
// SWriteSink<T, Append, BindMethod>:
|
||||
// A helper that performs writing to the type T and can be passed as Sink type to a trans-coder helper.
|
||||
template<typename T, bool Append, EBind>
|
||||
struct SWriteSink;
|
||||
template<typename T, bool Append>
|
||||
struct SWriteSink<T, Append, eBind_Iterators>
|
||||
{
|
||||
typedef typename T::value_type OutputCharType;
|
||||
T& out;
|
||||
SWriteSink(T& _out, size_t)
|
||||
: out(_out)
|
||||
{
|
||||
if (!Append)
|
||||
{
|
||||
// If not appending, clear the object beforehand.
|
||||
out.clear();
|
||||
}
|
||||
}
|
||||
void operator()(uint32 item)
|
||||
{
|
||||
const OutputCharType bound = static_cast<OutputCharType>(item);
|
||||
out.push_back(bound); // We assume this can't fail and STL container takes care of memory.
|
||||
}
|
||||
void operator()(const void*, size_t); // Not implemented.
|
||||
void HintSequence(uint32 length) {} // Don't care about sequences.
|
||||
bool CanWrite() const { return true; } // Always writable
|
||||
};
|
||||
template<typename T, bool Append>
|
||||
struct SWriteSink<T, Append, eBind_Data>
|
||||
{
|
||||
typedef SBindPointer<typename T::value_type*, false> BindHelper;
|
||||
typedef typename BindHelper::UnboundCharType CharType;
|
||||
CharType* ptr;
|
||||
SWriteSink(T& out, size_t length)
|
||||
{
|
||||
const size_t offset = Append ? out.size() : 0;
|
||||
length += offset;
|
||||
out.resize(static_cast<int>(length)); // resize() can't fail without exceptions, so assert instead.
|
||||
assert((out.size() == length) && "Buffer resize failed (out-of-memory?)");
|
||||
const CharType* base = length ? out.data() : 0;
|
||||
ptr = const_cast<CharType*>(base + offset);
|
||||
}
|
||||
void operator()(uint32 item)
|
||||
{
|
||||
*SafeCast<typename BindHelper::type>(ptr) = static_cast<typename BindHelper::BoundCharType>(item);
|
||||
++ptr;
|
||||
}
|
||||
void operator()(const void* src, size_t length)
|
||||
{
|
||||
::memcpy(ptr, src, length * sizeof(CharType));
|
||||
ptr += length;
|
||||
}
|
||||
void HintSequence([[maybe_unused]] uint32 length) {} // Don't care about sequences.
|
||||
bool CanWrite() const { return true; } // Always writable
|
||||
};
|
||||
template<typename P, bool Append>
|
||||
struct SWriteSink<SPackedBuffer<P>, Append, eBind_PackedBuffer>
|
||||
{
|
||||
typedef typename remove_pointer<P>::type ElementType;
|
||||
typedef SBindPointer<ElementType*, false> BindHelper;
|
||||
typedef typename BindHelper::UnboundCharType CharType;
|
||||
CharType* ptr;
|
||||
CharType* const terminator;
|
||||
SWriteSink(CharType* _terminator)
|
||||
: terminator(_terminator) {}
|
||||
SWriteSink(SPackedBuffer<P>& out, size_t)
|
||||
: terminator(out.size && out.buffer ? out.buffer + out.size - 1 : 0)
|
||||
{
|
||||
const size_t offset = Append
|
||||
? EncodedLength(out, integral_constant<EBind, eBind_PackedBuffer>())
|
||||
: 0;
|
||||
const size_t fixedOffset = Append && offset >= out.size
|
||||
? out.size - 1 // In case the buffer is already full and not terminated.
|
||||
: offset;
|
||||
CharType* base = static_cast<CharType*>(out.buffer);
|
||||
ptr = terminator ? base + fixedOffset : 0;
|
||||
}
|
||||
~SWriteSink()
|
||||
{
|
||||
if (ptr)
|
||||
{
|
||||
*ptr = 0; // Guarantees that the output is null-terminated.
|
||||
}
|
||||
}
|
||||
void operator()(uint32 item)
|
||||
{
|
||||
if (ptr != terminator) // Guarantees we don't overflow the buffer.
|
||||
{
|
||||
*SafeCast<typename BindHelper::type>(ptr) = static_cast<typename BindHelper::BoundCharType>(item);
|
||||
++ptr;
|
||||
}
|
||||
}
|
||||
void operator()(const void* src, size_t length)
|
||||
{
|
||||
const size_t maxLength = terminator - ptr;
|
||||
if (length > maxLength)
|
||||
{
|
||||
length = maxLength;
|
||||
}
|
||||
::memcpy(ptr, src, length * sizeof(CharType));
|
||||
ptr += length;
|
||||
}
|
||||
void HintSequence(uint32 length)
|
||||
{
|
||||
if (terminator && (ptr + length >= terminator))
|
||||
{
|
||||
// This sequence will overflow the buffer.
|
||||
// In this case, we prefer to not generate any part of the sequence.
|
||||
// Terminate at the current position and flag as full.
|
||||
*ptr = 0;
|
||||
ptr = terminator;
|
||||
}
|
||||
}
|
||||
bool CanWrite() const
|
||||
{
|
||||
return terminator != ptr;
|
||||
}
|
||||
};
|
||||
template<typename T, bool Append>
|
||||
struct SWriteSink<T, Append, eBind_Buffer> // Uses above implementation with specialized constructor
|
||||
: SWriteSink<SPackedBuffer<typename remove_extent<T>::type*>, Append, eBind_PackedBuffer>
|
||||
{
|
||||
typedef typename remove_extent<T>::type ElementType;
|
||||
typedef SWriteSink<SPackedBuffer<ElementType*>, Append, eBind_PackedBuffer> Super;
|
||||
typedef SBindPointer<ElementType*, false> BindHelper;
|
||||
typedef typename BindHelper::UnboundCharType CharType;
|
||||
SWriteSink(T& out, size_t)
|
||||
: Super(out + extent<T>::value - 1)
|
||||
{
|
||||
const size_t offset = Append
|
||||
? EncodedLength(out, integral_constant<EBind, eBind_Buffer>())
|
||||
: 0;
|
||||
const size_t fixedOffset = Append && offset >= extent<T>::value
|
||||
? extent<T>::value - 1 // In case the buffer is already full and not terminated.
|
||||
: offset;
|
||||
Super::ptr = out + fixedOffset; // Qualification for Super required for two-phase lookup.
|
||||
}
|
||||
};
|
||||
|
||||
// SIsBlockCopyable<InputType, OutputType>:
|
||||
// Check if block-copy optimization is possible for these types.
|
||||
// InputType should be an instantiation of SBindObject or SBindIterator.
|
||||
// OutputType should be an instantiation of SBindOutput.
|
||||
// Note: This doesn't take into account safe/unsafe conversions, just if the underlying storage types are compatible.
|
||||
template<typename InputType, typename OutputType>
|
||||
struct SIsBlockCopyable
|
||||
{
|
||||
template<EBind M>
|
||||
struct SIsContiguous
|
||||
{
|
||||
static const bool value =
|
||||
M == eBind_Data ||
|
||||
M == eBind_Literal ||
|
||||
M == eBind_Buffer ||
|
||||
M == eBind_PackedBuffer ||
|
||||
M == eBind_NullTerminated ||
|
||||
M == eBind_CodePoint;
|
||||
};
|
||||
template<typename T>
|
||||
struct SIsPointers
|
||||
{
|
||||
static const bool value = false;
|
||||
};
|
||||
template<typename T>
|
||||
struct SIsPointers<SPackedIterators<T*> >
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
typedef typename SBindCharacter<typename InputType::CharType, true>::type InputCharType;
|
||||
typedef typename SBindCharacter<typename OutputType::CharType, false>::type OutputCharType;
|
||||
static const bool isIntegral = is_integral<InputCharType>::value && is_integral<OutputCharType>::value;
|
||||
static const bool isSameSize = sizeof(InputCharType) == sizeof(OutputCharType);
|
||||
static const bool isInputContiguous = (SIsContiguous<InputType::value>::value || SIsPointers<InputType>::value);
|
||||
static const bool isOutputContiguous = (SIsContiguous<OutputType::value>::value || SIsPointers<OutputType>::value);
|
||||
static const bool value = isIntegral && isSameSize && isInputContiguous && isOutputContiguous;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,767 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// Description : Generic Unicode encoding helpers.
|
||||
//
|
||||
// Defines encoding and decoding functions used by the higher-level functions.
|
||||
// These are used by the various conversion functions in UnicodeFunctions.h and UnicodeIterator.h.
|
||||
// Note: You can use these functions manually for low-level functionality, but we don't recommend that.
|
||||
// In that case, you probably want to check inside the nested Detail namespace for the elementary bits.
|
||||
|
||||
|
||||
#pragma once
|
||||
#include "BaseTypes.h" // For uint8, uint16, uint32
|
||||
|
||||
namespace Unicode
|
||||
{
|
||||
// Supported encoding/conversion types.
|
||||
enum EEncoding
|
||||
{
|
||||
// UTF-8 encoding, see http://www.unicode.org/resources/utf8.html.
|
||||
// Input and output are supported.
|
||||
// Note: This format maps the entire UCS, where each code-point can take [1, 4] 8-bit code-units.
|
||||
// Note: This is a strict super-set of Latin1/ISO-885901 as well as ASCII.
|
||||
eEncoding_UTF8,
|
||||
|
||||
// UTF-16 encoding, see http://tools.ietf.org/html/rfc2781.
|
||||
// Input and output are supported.
|
||||
// Note: This format maps the entire UCS, where each code-point can take [1, 2] 16-bit code-units.
|
||||
eEncoding_UTF16,
|
||||
|
||||
// UTF-32 encoding, see http://www.unicode.org/reports/tr17/.
|
||||
// Input and output are supported.
|
||||
// Note: This format maps the entire UCS, each code-point is stored in a single 32-bit code-unit.
|
||||
eEncoding_UTF32,
|
||||
|
||||
// ASCII encoding, see http://en.wikipedia.org/wiki/ASCII.
|
||||
// Input and output are supported (any output UCS values out of supported range are mapped to question mark).
|
||||
// Note: Only values [U+0000, U+007F] can be mapped.
|
||||
eEncoding_ASCII,
|
||||
|
||||
// Latin1, aka ISO-8859-1 encoding, see http://en.wikipedia.org/wiki/ISO/IEC_8859-1.
|
||||
// Only input is supported.
|
||||
// Note: This is a strict super-set of ASCII, it additionally maps [U+00A0, U+00FF].
|
||||
eEncoding_Latin1,
|
||||
|
||||
// Windows ANSI codepage 1252, see http://en.wikipedia.org/wiki/Windows-1252.
|
||||
// Only input is supported.
|
||||
// Note: This is a strict super-set of ASCII and Latin1/ISO-8859-1, it maps some code-units from [0x80, 0x9F].
|
||||
eEncoding_Win1252,
|
||||
};
|
||||
|
||||
// Methods of recovery from invalid encoded sequences.
|
||||
enum EErrorRecovery
|
||||
{
|
||||
// No attempt to detect invalid encoding is performed, the input is assumed to be valid.
|
||||
// If the input is not valid, the output is undefined (in debug, this condition will cause an assert to trigger).
|
||||
eErrorRecovery_None,
|
||||
|
||||
// When an invalidly encoded sequence is detected, the sequence is discarded (will not be part of the output).
|
||||
// Typically used for logic/hashing purposes when the input is almost certainly valid.
|
||||
eErrorRecovery_Discard,
|
||||
|
||||
// When an invalidly encoded sequence is detected, the sequence is replaced with the replacement-character (U+FFFD).
|
||||
// Typically used when the output sequence is used for UI display purposes.
|
||||
eErrorRecovery_Replace,
|
||||
|
||||
// When an invalidly encoded sequence is detected, the sequence is replaced with the eEncoding_Latin1 equivalent.
|
||||
// If the sequence is also not valid Latin1 encoded, the sequence is discarded.
|
||||
// Typically used when reading generic text files with 1-byte code-units.
|
||||
// Note: This recovery method can only be used when decoding UTF-8.
|
||||
eErrorRecovery_FallbackLatin1ThenDiscard,
|
||||
|
||||
// When an invalidly encoded sequence is detected, the sequence is replaced with the eEncoding_Win1252 equivalent.
|
||||
// If the sequence is also not valid codepage 1252 encoded, the sequence is discarded.
|
||||
// Typically used when reading text files generated on Windows with 1-byte code-units.
|
||||
// Note: This recovery method can only be used when decoding UTF-8.
|
||||
eErrorRecovery_FallbackWin1252ThenDiscard,
|
||||
|
||||
// When an invalidly encoded sequence is detected, the sequence is replaced with the eEncoding_Latin1 equivalent.
|
||||
// If the sequence is also not valid Latin1 encoded, it is replaced with the replacement-character (U+FFFD).
|
||||
// Typically used when reading generic text files with 1-byte code-units.
|
||||
// Note: This recovery method can only be used when decoding UTF-8.
|
||||
eErrorRecovery_FallbackLatin1ThenReplace,
|
||||
|
||||
// When an invalidly encoded sequence is detected, the sequence is replaced with the eEncoding_Win1252 equivalent.
|
||||
// If the sequence is also not valid codepage 1252 encoded, it is replaced with the replacement-character (U+FFFD).
|
||||
// Typically used when reading text files generated on Windows with 1-byte code-units.
|
||||
// Note: This recovery method can only be used when decoding UTF-8.
|
||||
eErrorRecovery_FallbackWin1252ThenReplace,
|
||||
};
|
||||
|
||||
namespace Detail
|
||||
{
|
||||
// Decode<Encoding, Safe>(state, unit): Decodes a single code-unit of an encoding into an UCS code-point.
|
||||
// When Safe flag is set, encoding errors are detected so a fall-back encoding or other recovery method can be used.
|
||||
// Interpret return value as follows:
|
||||
// < 0x001FFFFF: Decoded codepoint (== return value), call again with next code-unit and clear state.
|
||||
// < 0x80000000: Intermediate state returned, call again with next code-unit and the returned state.
|
||||
// >= 0x80000000: Bad encoding detected, up to 16 bits (UTF-16) or 24 bits (UTF-8, last in lower bits)
|
||||
// contain previous consumed values (does not happen if Safe == false).
|
||||
template<EEncoding InputEncoding, bool Safe>
|
||||
inline uint32 Decode(uint32 state, uint32 unit);
|
||||
|
||||
// Some constant values used when encoding/decoding.
|
||||
enum
|
||||
{
|
||||
cDecodeShiftRemaining = 26, // Where to store the remaining count in the state.
|
||||
cDecodeOneRemaining = 1 << cDecodeShiftRemaining, // Remaining value of one.
|
||||
cDecodeMaskRemaining = 3 << cDecodeShiftRemaining, // All possible remaining bits that can be used.
|
||||
cDecodeLeadBit = 1 << 22, // All bits up to and including this one are reserved.
|
||||
cDecodeErrorBit = 1 << 31, // Set if an error occurs during decoding.
|
||||
cDecodeOverlongBit = 1 << 30, // Set if overlong sequence was used.
|
||||
cDecodeSurrogateBit = 1 << 29, // Set if surrogate code-point decoded in UTF-8.
|
||||
cDecodeInvalidBit = 1 << 28, // Set if invalid code-point decoded (U+FFFE/FFFF).
|
||||
cDecodeSuccess = 0, // Placeholder to indicate no error occurred.
|
||||
cCodepointMax = 0x10FFFF, // The maximum value of an UCS code-point.
|
||||
cLeadSurrogateFirst = 0xD800, // The first valid UTF-16 lead-surrogate value.
|
||||
cLeadSurrogateLast = 0xDBFF, // The last valid UTF-16 lead-surrogate value.
|
||||
cTrailSurrogateFirst = 0xDC00, // The first valid UTF-16 trail-surrogate value.
|
||||
cTrailSurrogateLast = 0xDFFF, // The last valid UTF-16 trail-surrogate value.
|
||||
cReplacementCharacter = 0xFFFD, // The default replacement character.
|
||||
};
|
||||
|
||||
// Validate the UTF-8 state of a multi-byte sequence.
|
||||
// The safe decoder of UTF-8 will call this function when a full potential code-point has been decoded.
|
||||
// This function is (at most) called for 50% of the decoded UTF-8 code-units, but likely at much lower frequency.
|
||||
inline uint32 DecodeValidate8(uint32 state)
|
||||
{
|
||||
uint32 errorbits = (state >> 8) | cDecodeErrorBit;
|
||||
state ^= (state & 0x400000) >> 1; // For 3-byte sequences, bit 5 of the lead byte needs to be cleared.
|
||||
const uint32 cp =
|
||||
(state & 0x3F) |
|
||||
((state & 0x3F00) >> 2) |
|
||||
((state & 0x3F0000) >> 4) |
|
||||
((state & 0x07000000) >> 6);
|
||||
if (cp <= cCodepointMax)
|
||||
{
|
||||
if (cp >= cLeadSurrogateFirst && cp <= cTrailSurrogateLast)
|
||||
{
|
||||
errorbits += cDecodeSurrogateBit; // CESU-8 encoding might have been used.
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32 minval = 0x80;
|
||||
minval += (0x00400000 & state) ? 0x800 - 0x80 : 0;
|
||||
minval += (0x40000000 & state) ? 0x10000 - 0x80 : 0;
|
||||
if (cp >= minval)
|
||||
{
|
||||
if ((cp & 0xFFFFFFFEU) != 0xFFFEU)
|
||||
{
|
||||
return cp; // Valid code-point.
|
||||
}
|
||||
errorbits += cDecodeInvalidBit; // Invalid character used.
|
||||
}
|
||||
errorbits += cDecodeOverlongBit; // Overlong encoding used.
|
||||
}
|
||||
}
|
||||
return errorbits;
|
||||
}
|
||||
|
||||
// Decode UTF-8, unsafe.
|
||||
template<>
|
||||
inline uint32 Decode<eEncoding_UTF8, false>(uint32 state, uint32 unit)
|
||||
{
|
||||
if (state == 0) // First byte.
|
||||
{
|
||||
unit = unit & 0xFF;
|
||||
if (unit < 0xC0)
|
||||
{
|
||||
return unit; // Single-unit (ASCII).
|
||||
}
|
||||
uint32 remaining = (unit >> 4) - 0xC;
|
||||
remaining += (remaining == 0);
|
||||
return (unit & 0x1F) + (remaining << cDecodeShiftRemaining); // Lead byte of multi-byte.
|
||||
}
|
||||
state = (state << 6) + (unit & 0x3F) + (state & cDecodeMaskRemaining) - cDecodeOneRemaining; // Apply c-byte.
|
||||
return state & ~cDecodeLeadBit; // Mask off the lead bits of a 4-byte sequence.
|
||||
}
|
||||
|
||||
// Decode UTF-8, safe
|
||||
template<>
|
||||
inline uint32 Decode<eEncoding_UTF8, true>(uint32 state, uint32 unit)
|
||||
{
|
||||
if (unit <= 0xF4) // Discard out-of-range values immediately.
|
||||
{
|
||||
if (state == 0) // First byte.
|
||||
{
|
||||
if (unit < 0x80)
|
||||
{
|
||||
return unit; // Single-byte.
|
||||
}
|
||||
if (unit < 0xC2)
|
||||
{
|
||||
return cDecodeErrorBit; // Invalid continuation byte (or illegal 0xC0/0xC1).
|
||||
}
|
||||
uint32 remaining = (unit >> 4) - 0xC;
|
||||
remaining += (remaining == 0);
|
||||
return unit + (remaining << cDecodeShiftRemaining); // Multi-byte.
|
||||
}
|
||||
if ((unit & 0xC0) == 0x80)
|
||||
{
|
||||
const uint32 remaining = (state & cDecodeMaskRemaining) - cDecodeOneRemaining;
|
||||
state = (state << 8) + unit;
|
||||
if (remaining != 0)
|
||||
{
|
||||
return state | remaining; // Intermediate byte of a multi-byte sequence.
|
||||
}
|
||||
return DecodeValidate8(state); // Final byte of a multi-byte sequence.
|
||||
}
|
||||
}
|
||||
return cDecodeErrorBit | state;
|
||||
}
|
||||
|
||||
// Decode UTF-16, unsafe.
|
||||
template<>
|
||||
inline uint32 Decode<eEncoding_UTF16, false>(uint32 state, uint32 unit)
|
||||
{
|
||||
const bool bLead = (unit >= cLeadSurrogateFirst) && (unit <= cLeadSurrogateLast);
|
||||
const uint32 initial = unit + (bLead << cDecodeShiftRemaining);
|
||||
const uint32 pair = 0x10000 + ((state & 0x3FF) << 10) + (unit & 0x3FF);
|
||||
return state == 0 ? initial : pair;
|
||||
}
|
||||
|
||||
// Decode UTF-16, safe.
|
||||
template<>
|
||||
inline uint32 Decode<eEncoding_UTF16, true>(uint32 state, uint32 unit)
|
||||
{
|
||||
const bool bTrail = (unit >= cTrailSurrogateFirst) && (unit <= cTrailSurrogateLast);
|
||||
if (state != 0 && !bTrail)
|
||||
{
|
||||
return cDecodeErrorBit + (state & 0xFFFF); // Lead surrogate without trail surrogate
|
||||
}
|
||||
uint32 result = Decode<eEncoding_UTF16, false>(state, unit);
|
||||
bool bValid = (result & 0xFFFFFFFEU) != 0xFFFEU;
|
||||
return bValid ? result : result + cDecodeErrorBit + cDecodeInvalidBit;
|
||||
}
|
||||
|
||||
// Decode UTF-32, unsafe.
|
||||
template<>
|
||||
inline uint32 Decode<eEncoding_UTF32, false>([[maybe_unused]] uint32 state, uint32 unit)
|
||||
{
|
||||
return unit;
|
||||
}
|
||||
|
||||
// Decode UTF-32, safe.
|
||||
template<>
|
||||
inline uint32 Decode<eEncoding_UTF32, true>([[maybe_unused]] uint32 state, uint32 unit)
|
||||
{
|
||||
if (unit > cCodepointMax)
|
||||
{
|
||||
return cDecodeErrorBit;
|
||||
}
|
||||
if (unit >= cLeadSurrogateFirst && unit <= cTrailSurrogateLast)
|
||||
{
|
||||
return cDecodeErrorBit | cDecodeSurrogateBit;
|
||||
}
|
||||
if ((unit & 0xFFFEU) == 0xFFFEU)
|
||||
{
|
||||
return cDecodeErrorBit | cDecodeInvalidBit;
|
||||
}
|
||||
return unit;
|
||||
}
|
||||
|
||||
// Decode ASCII, unsafe.
|
||||
template<>
|
||||
inline uint32 Decode<eEncoding_ASCII, false>([[maybe_unused]] uint32 state, uint32 unit)
|
||||
{
|
||||
return unit;
|
||||
}
|
||||
|
||||
// Decode ASCII, safe.
|
||||
template<>
|
||||
inline uint32 Decode<eEncoding_ASCII, true>([[maybe_unused]] uint32 state, uint32 unit)
|
||||
{
|
||||
if (unit > 0x7F)
|
||||
{
|
||||
return cDecodeErrorBit;
|
||||
}
|
||||
return unit;
|
||||
}
|
||||
|
||||
// Decode Latin1, unsafe.
|
||||
template<>
|
||||
inline uint32 Decode<eEncoding_Latin1, false>([[maybe_unused]] uint32 state, uint32 unit)
|
||||
{
|
||||
return unit;
|
||||
}
|
||||
|
||||
// Decode Latin1, safe.
|
||||
template<>
|
||||
inline uint32 Decode<eEncoding_Latin1, true>([[maybe_unused]] uint32 state, uint32 unit)
|
||||
{
|
||||
if ((unit >= 0x80 && unit <= 0x9F) || (unit > 0xFF))
|
||||
{
|
||||
return cDecodeErrorBit;
|
||||
}
|
||||
return unit;
|
||||
}
|
||||
|
||||
// Decode Windows CP-1252, unsafe.
|
||||
template<>
|
||||
inline uint32 Decode<eEncoding_Win1252, false>([[maybe_unused]] uint32 state, uint32 unit)
|
||||
{
|
||||
static const uint16 cp1252[] =
|
||||
{
|
||||
0x20AC, 0x0081, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
|
||||
0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0x008D, 0x017D, 0x008F,
|
||||
0x0090, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
|
||||
0x02DC, 0x2122, 0x0161, 0x203A, 0x0153, 0x009D, 0x017E, 0x0178,
|
||||
};
|
||||
return (unit < 0x80 || unit > 0x9F) ? unit : cp1252[unit - 0x80];
|
||||
}
|
||||
|
||||
// Decode Windows CP-1252, safe.
|
||||
template<>
|
||||
inline uint32 Decode<eEncoding_Win1252, true>(uint32 state, uint32 unit)
|
||||
{
|
||||
if (unit > 0xFF)
|
||||
{
|
||||
return cDecodeErrorBit;
|
||||
}
|
||||
uint32 result = Decode<eEncoding_Win1252, false>(state, unit);
|
||||
if (!(unit < 0x80 || unit > 0x9F) && (result == unit))
|
||||
{
|
||||
return cDecodeErrorBit; // Not defined in codepage 1252.
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// SBase<T>:
|
||||
// Utility to apply empty-base-optimization on type T.
|
||||
// Will fall back to a member if T is a reference type.
|
||||
template<typename T, int Tag = 0>
|
||||
struct SBase
|
||||
: T
|
||||
{
|
||||
SBase(T base)
|
||||
: T(base) {}
|
||||
T& GetBase() { return *this; }
|
||||
const T& GetBase() const { return *this; }
|
||||
};
|
||||
template<typename T, int Tag>
|
||||
struct SBase<T&, Tag>
|
||||
{
|
||||
T& base;
|
||||
SBase(T& b)
|
||||
: base(b) {}
|
||||
T& GetBase() { return base; }
|
||||
const T& GetBase() const { return base; }
|
||||
};
|
||||
|
||||
// SDecoder<Encoding, Sink, Recovery>:
|
||||
// Functor to decode UCS code-points from an input range.
|
||||
// Recovery functor will be invoked as a fall-back if decoding fails.
|
||||
// This allows ensuring all the output is valid (even if the input isn't).
|
||||
// Note: The destructor will automatically flush any remaining (erroneous) state, you can also call Finalize().
|
||||
template<EEncoding InputEncoding, typename Sink, typename Recovery = void>
|
||||
struct SDecoder
|
||||
: SBase<Sink, 1>
|
||||
, SBase<Recovery, 2>
|
||||
{
|
||||
uint32 state;
|
||||
SDecoder(Sink sink, Recovery recovery = Recovery())
|
||||
: SBase<Sink, 1>(sink)
|
||||
, SBase<Recovery, 2>(recovery)
|
||||
, state(0) {}
|
||||
SDecoder() { Finalize(); }
|
||||
Recovery& recovery() { return SBase<Recovery, 2>::GetBase(); }
|
||||
Sink& sink() { return SBase<Sink, 1>::GetBase(); }
|
||||
void operator()(uint32 unit)
|
||||
{
|
||||
state = Detail::Decode<InputEncoding, true>(state, unit);
|
||||
if (state <= 0x1FFFFF)
|
||||
{
|
||||
sink()(state);
|
||||
state = 0;
|
||||
}
|
||||
else if (state & Detail::cDecodeErrorBit)
|
||||
{
|
||||
recovery()(sink(), state, unit);
|
||||
state = 0;
|
||||
}
|
||||
}
|
||||
void Finalize()
|
||||
{
|
||||
if (state)
|
||||
{
|
||||
recovery()(sink(), state, 0);
|
||||
state = 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// SDecoder<Encoding, Sink>:
|
||||
// Functor to decode to UCS code-points from an input range.
|
||||
// No attempt to discover or recover from encoding errors is made, can only safely be used with known-valid input.
|
||||
template<EEncoding InputEncoding, typename Sink>
|
||||
struct SDecoder<InputEncoding, Sink, void>
|
||||
: SBase<Sink>
|
||||
{
|
||||
uint32 state;
|
||||
SDecoder(Sink sink)
|
||||
: SBase<Sink>(sink)
|
||||
, state(0) {}
|
||||
Sink& sink() { return SBase<Sink>::GetBase(); }
|
||||
void operator()(uint32 unit)
|
||||
{
|
||||
state = Detail::Decode<InputEncoding, false>(state, unit);
|
||||
if (state <= 0x1FFFFF)
|
||||
{
|
||||
sink()(state);
|
||||
state = 0;
|
||||
}
|
||||
}
|
||||
void Finalize() {}
|
||||
};
|
||||
|
||||
// SEncoder<Encoding, Sink>:
|
||||
// Generic Unicode encoder functor.
|
||||
// Encoding must be one an encoding type for which output is supported.
|
||||
// The Sink type must have HintSequence member for UTF-8 and UTF-16 (although it may be a no-op).
|
||||
// In general, you feed operator() with UCS code-points and it will emit code-units.
|
||||
template<EEncoding OutputEncoding, typename Sink>
|
||||
struct SEncoder
|
||||
{
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
// SEncoder<Encoding, Sink>:
|
||||
// Specialization of ASCII encoder functor.
|
||||
// Note: Any out-of-range character is mapped to question mark.
|
||||
template<typename Sink>
|
||||
struct SEncoder<eEncoding_ASCII, Sink>
|
||||
: SBase<Sink>
|
||||
{
|
||||
static const bool value = true;
|
||||
typedef uint8 value_type;
|
||||
SEncoder(Sink sink)
|
||||
: SBase<Sink>(sink) {}
|
||||
void operator()(uint32 cp)
|
||||
{
|
||||
cp = cp < 0x80 ? cp : (uint32)'?';
|
||||
SBase<Sink>::GetBase()(value_type(cp));
|
||||
}
|
||||
};
|
||||
|
||||
// SEncoder<Encoding, Sink>:
|
||||
// Specialization of UTF-8 encoder functor.
|
||||
template<typename Sink>
|
||||
struct SEncoder<eEncoding_UTF8, Sink>
|
||||
: SBase<Sink>
|
||||
{
|
||||
static const bool value = true;
|
||||
typedef uint8 value_type;
|
||||
SEncoder(Sink sink)
|
||||
: SBase<Sink>(sink) {}
|
||||
Sink& sink() { return SBase<Sink>::GetBase(); }
|
||||
void operator()(uint32 cp)
|
||||
{
|
||||
if (cp < 0x80)
|
||||
{
|
||||
// Single byte sequence.
|
||||
sink()(value_type(cp));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Expand 21-bit value to 32-bit.
|
||||
uint32 bits =
|
||||
(cp & 0x00003F) +
|
||||
((cp & 0x000FC0) << 2) +
|
||||
((cp & 0x03F000) << 4) +
|
||||
((cp & 0x1C0000) << 6);
|
||||
|
||||
// Type of sequence.
|
||||
const bool bSeq4 = (cp >= 0x10000);
|
||||
const bool bSeq3 = (cp >= 0x800);
|
||||
|
||||
// Mask lead-bytes and continuation-bytes.
|
||||
uint32 mask = 0xEFE0C080;
|
||||
mask ^= (bSeq3 << 14);
|
||||
mask += (bSeq4 ? 0xA00000 : 0);
|
||||
bits |= mask;
|
||||
|
||||
// Length of the sequence.
|
||||
const uint32 length = (uint32)bSeq4 + (uint32)bSeq3 + 1;
|
||||
sink().HintSequence(length);
|
||||
|
||||
// Sink the multi-byte sequence.
|
||||
if (bSeq4)
|
||||
{
|
||||
sink()(value_type(bits >> 24));
|
||||
}
|
||||
if (bSeq3)
|
||||
{
|
||||
sink()(value_type(bits >> 16));
|
||||
}
|
||||
sink()(value_type(bits >> 8));
|
||||
sink()(value_type(bits));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// SEncoder<Encoding, Sink>:
|
||||
// Specialization of UTF-16 encoder functor.
|
||||
template<typename Sink>
|
||||
struct SEncoder<eEncoding_UTF16, Sink>
|
||||
: SBase<Sink>
|
||||
{
|
||||
static const bool value = true;
|
||||
typedef uint16 value_type;
|
||||
SEncoder(Sink sink)
|
||||
: SBase<Sink>(sink) {}
|
||||
Sink& sink() { return SBase<Sink>::GetBase(); }
|
||||
void operator()(uint32 cp)
|
||||
{
|
||||
if (cp < 0x10000)
|
||||
{
|
||||
// Single unit
|
||||
sink()(value_type(cp));
|
||||
}
|
||||
else
|
||||
{
|
||||
// We will generate two-element sequence
|
||||
sink().HintSequence(2);
|
||||
|
||||
// Surrogate pair
|
||||
cp -= 0x10000;
|
||||
uint32 lead = ((cp >> 10) & 0x3FF) + Detail::cLeadSurrogateFirst;
|
||||
uint32 trail = (cp & 0x3FF) + Detail::cTrailSurrogateFirst;
|
||||
sink()(value_type(lead));
|
||||
sink()(value_type(trail));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// SEncoder<Encoding, Sink>:
|
||||
// Specialization of UTF-32 encoder functor.
|
||||
// Note: This is a no-op, but we want to be able to express UTF-32 just like the other encodings.
|
||||
template<typename Sink>
|
||||
struct SEncoder<eEncoding_UTF32, Sink>
|
||||
: SBase<Sink>
|
||||
{
|
||||
static const bool value = true;
|
||||
typedef uint32 value_type;
|
||||
SEncoder(Sink sink)
|
||||
: SBase<Sink>(sink) {}
|
||||
void operator()(uint32 cp)
|
||||
{
|
||||
SBase<Sink>::GetBase()(value_type(cp));
|
||||
}
|
||||
};
|
||||
|
||||
// SDecoder<Encoding, SEncoder<Encoding>, void>:
|
||||
// Specialization for unsafe no-op trans-coding.
|
||||
// Since the conversion is a no-op, no need to keep any state or do any computation.
|
||||
// Note: For a decoding with a fallback, this is not possible since we can't guarantee the input is valid.
|
||||
template<EEncoding SameEncoding, typename Sink>
|
||||
struct SDecoder<SameEncoding, SEncoder<SameEncoding, Sink>, void>
|
||||
{
|
||||
Sink sink;
|
||||
SDecoder(Sink s)
|
||||
: sink(s) {}
|
||||
void operator()(uint32 unit)
|
||||
{
|
||||
sink(unit);
|
||||
}
|
||||
void Finalize() {}
|
||||
};
|
||||
|
||||
// SRecoveryDiscard<Sink>:
|
||||
// Recovery handler that, on encoding error, discards the offending sequence.
|
||||
template<typename Sink>
|
||||
struct SRecoveryDiscard
|
||||
{
|
||||
SRecoveryDiscard() {}
|
||||
void operator()([[maybe_unused]] Sink& sink, [[maybe_unused]] uint32 error, [[maybe_unused]] uint32 unit) {}
|
||||
};
|
||||
|
||||
// SRecoveryReplace<Sink>:
|
||||
// Recovery handler that, on encoding error, replaces the sequence with replacement-character (U+FFFD).
|
||||
// Note: This implementation matches a whole invalid sequence, it could be changed to emit for every code-unit.
|
||||
template<typename Sink>
|
||||
struct SRecoveryReplace
|
||||
{
|
||||
SRecoveryReplace() {}
|
||||
void operator()(Sink& sink, uint32 error, uint32 unit) { sink(cReplacementCharacter); }
|
||||
};
|
||||
|
||||
// SRecoveryFallback<Sink>:
|
||||
// Recovery handler that, on encoding error, falls back to another encoding.
|
||||
// The fallback encoding must be stateless (ie: ASCII, Latin1 or Win1252).
|
||||
// This type assumes an 8-bit primary encoding since the only viable fallback encodings are 8-bit.
|
||||
template<typename Sink, EEncoding FallbackEncoding, typename NextFallback>
|
||||
struct SRecoveryFallback
|
||||
: NextFallback
|
||||
{
|
||||
SRecoveryFallback()
|
||||
: NextFallback() {}
|
||||
void operator()(Sink& sink, uint32 error, uint32 unit)
|
||||
{
|
||||
SDecoder<FallbackEncoding, Sink&, NextFallback&> fallback(sink, *static_cast<NextFallback*>(this));
|
||||
uint8 byte1(error >> 16);
|
||||
uint8 byte2(error >> 8);
|
||||
uint8 byte3(error);
|
||||
uint8 byte4(unit);
|
||||
if (byte1)
|
||||
{
|
||||
fallback(byte1);
|
||||
}
|
||||
if (byte1 | byte2)
|
||||
{
|
||||
fallback(byte2);
|
||||
}
|
||||
if (byte1 | byte2 | byte3)
|
||||
{
|
||||
fallback(byte3);
|
||||
}
|
||||
fallback(byte4);
|
||||
}
|
||||
};
|
||||
|
||||
// SRecoveryFallbackHelper<Sink, RecoveryMethod>:
|
||||
// Helper to pick a SRecoveryFallback instantiation based on RecoveryMethod.
|
||||
template<EEncoding OutputEncoding, typename Sink, EErrorRecovery RecoveryMethod>
|
||||
struct SRecoveryFallbackHelper
|
||||
{
|
||||
// A compilation error here means RecoveryMethod value was unexpected here
|
||||
static_assert(
|
||||
RecoveryMethod == eErrorRecovery_FallbackLatin1ThenDiscard ||
|
||||
RecoveryMethod == eErrorRecovery_FallbackLatin1ThenReplace ||
|
||||
RecoveryMethod == eErrorRecovery_FallbackWin1252ThenDiscard ||
|
||||
RecoveryMethod == eErrorRecovery_FallbackWin1252ThenReplace);
|
||||
typedef SEncoder<OutputEncoding, Sink> SinkType;
|
||||
static const EEncoding FallbackEncoding =
|
||||
RecoveryMethod == eErrorRecovery_FallbackLatin1ThenDiscard ||
|
||||
RecoveryMethod == eErrorRecovery_FallbackLatin1ThenReplace
|
||||
? eEncoding_Latin1 : eEncoding_Win1252;
|
||||
template<typename Dummy, bool WithDiscard>
|
||||
struct Pick
|
||||
{
|
||||
typedef SRecoveryDiscard<SinkType> type;
|
||||
};
|
||||
template<typename Dummy>
|
||||
struct Pick<Dummy, false>
|
||||
{
|
||||
typedef SRecoveryReplace<SinkType> type;
|
||||
};
|
||||
typedef typename Pick<Sink,
|
||||
RecoveryMethod == eErrorRecovery_FallbackLatin1ThenDiscard ||
|
||||
RecoveryMethod == eErrorRecovery_FallbackWin1252ThenDiscard>::type NextFallback;
|
||||
typedef SRecoveryFallback<SinkType, FallbackEncoding, NextFallback> RecoveryType;
|
||||
typedef SDecoder<eEncoding_UTF8, SinkType, RecoveryType> FullType;
|
||||
};
|
||||
|
||||
// STranscoderSelect<InputEncoding, OutputEncoding, Sink, RecoveryMethod>:
|
||||
// Derives a chained decoder/encoder pair that performs code-unit -> code-unit transform.
|
||||
// The RecoveryMethod template parameter determines the behavior during encoding.
|
||||
// This is the basic way to perform trans-coding, and is the type instantiated by the higher-level functions.
|
||||
template<EEncoding InputEncoding, EEncoding OutputEncoding, typename Sink, EErrorRecovery RecoveryMethod>
|
||||
struct STranscoderSelect;
|
||||
template<EEncoding InputEncoding, EEncoding OutputEncoding, typename Sink>
|
||||
struct STranscoderSelect<InputEncoding, OutputEncoding, Sink, eErrorRecovery_None>
|
||||
: SDecoder<InputEncoding, SEncoder<OutputEncoding, Sink>, void>
|
||||
{
|
||||
typedef SDecoder<InputEncoding, SEncoder<OutputEncoding, Sink>, void> TranscoderType;
|
||||
STranscoderSelect(Sink sink)
|
||||
: TranscoderType(sink) {}
|
||||
};
|
||||
template<EEncoding InputEncoding, EEncoding OutputEncoding, typename Sink>
|
||||
struct STranscoderSelect<InputEncoding, OutputEncoding, Sink, eErrorRecovery_Discard>
|
||||
: SDecoder<InputEncoding, SEncoder<OutputEncoding, Sink>, SRecoveryDiscard<SEncoder<OutputEncoding, Sink> > >
|
||||
{
|
||||
typedef SRecoveryDiscard<SEncoder<OutputEncoding, Sink> > RecoveryType;
|
||||
typedef SDecoder<InputEncoding, SEncoder<OutputEncoding, Sink>, RecoveryType> TranscoderType;
|
||||
STranscoderSelect(Sink sink)
|
||||
: TranscoderType(sink) {}
|
||||
};
|
||||
template<EEncoding InputEncoding, EEncoding OutputEncoding, typename Sink>
|
||||
struct STranscoderSelect<InputEncoding, OutputEncoding, Sink, eErrorRecovery_Replace>
|
||||
: SDecoder<InputEncoding, SEncoder<OutputEncoding, Sink>, SRecoveryReplace<SEncoder<OutputEncoding, Sink> > >
|
||||
{
|
||||
typedef SRecoveryReplace<SEncoder<OutputEncoding, Sink> > RecoveryType;
|
||||
typedef SDecoder<InputEncoding, SEncoder<OutputEncoding, Sink>, RecoveryType> TranscoderType;
|
||||
STranscoderSelect(Sink sink)
|
||||
: TranscoderType(sink) {}
|
||||
};
|
||||
template<EEncoding OutputEncoding, typename Sink>
|
||||
struct STranscoderSelect<eEncoding_UTF8, OutputEncoding, Sink, eErrorRecovery_FallbackLatin1ThenDiscard>
|
||||
: SRecoveryFallbackHelper<OutputEncoding, Sink, eErrorRecovery_FallbackLatin1ThenDiscard>::FullType
|
||||
{
|
||||
static const EErrorRecovery RecoveryMethod = eErrorRecovery_FallbackLatin1ThenDiscard;
|
||||
typedef typename SRecoveryFallbackHelper<OutputEncoding, Sink, RecoveryMethod>::RecoveryType RecoveryType;
|
||||
typedef typename SRecoveryFallbackHelper<OutputEncoding, Sink, RecoveryMethod>::FullType TranscoderType;
|
||||
STranscoderSelect(Sink sink)
|
||||
: TranscoderType(sink) {}
|
||||
};
|
||||
template<EEncoding OutputEncoding, typename Sink>
|
||||
struct STranscoderSelect<eEncoding_UTF8, OutputEncoding, Sink, eErrorRecovery_FallbackLatin1ThenReplace>
|
||||
: SRecoveryFallbackHelper<OutputEncoding, Sink, eErrorRecovery_FallbackLatin1ThenReplace>::FullType
|
||||
{
|
||||
static const EErrorRecovery RecoveryMethod = eErrorRecovery_FallbackLatin1ThenReplace;
|
||||
typedef typename SRecoveryFallbackHelper<OutputEncoding, Sink, RecoveryMethod>::RecoveryType RecoveryType;
|
||||
typedef typename SRecoveryFallbackHelper<OutputEncoding, Sink, RecoveryMethod>::FullType TranscoderType;
|
||||
STranscoderSelect(Sink sink)
|
||||
: TranscoderType(sink) {}
|
||||
};
|
||||
template<EEncoding OutputEncoding, typename Sink>
|
||||
struct STranscoderSelect<eEncoding_UTF8, OutputEncoding, Sink, eErrorRecovery_FallbackWin1252ThenDiscard>
|
||||
: SRecoveryFallbackHelper<OutputEncoding, Sink, eErrorRecovery_FallbackWin1252ThenDiscard>::FullType
|
||||
{
|
||||
static const EErrorRecovery RecoveryMethod = eErrorRecovery_FallbackWin1252ThenDiscard;
|
||||
typedef typename SRecoveryFallbackHelper<OutputEncoding, Sink, RecoveryMethod>::RecoveryType RecoveryType;
|
||||
typedef typename SRecoveryFallbackHelper<OutputEncoding, Sink, RecoveryMethod>::FullType TranscoderType;
|
||||
STranscoderSelect(Sink sink)
|
||||
: TranscoderType(sink) {}
|
||||
};
|
||||
template<EEncoding OutputEncoding, typename Sink>
|
||||
struct STranscoderSelect<eEncoding_UTF8, OutputEncoding, Sink, eErrorRecovery_FallbackWin1252ThenReplace>
|
||||
: SRecoveryFallbackHelper<OutputEncoding, Sink, eErrorRecovery_FallbackWin1252ThenReplace>::FullType
|
||||
{
|
||||
static const EErrorRecovery RecoveryMethod = eErrorRecovery_FallbackWin1252ThenReplace;
|
||||
typedef typename SRecoveryFallbackHelper<OutputEncoding, Sink, RecoveryMethod>::RecoveryType RecoveryType;
|
||||
typedef typename SRecoveryFallbackHelper<OutputEncoding, Sink, RecoveryMethod>::FullType TranscoderType;
|
||||
STranscoderSelect(Sink sink)
|
||||
: TranscoderType(sink) {}
|
||||
};
|
||||
|
||||
// SIsSafeEncoding<R>:
|
||||
// Check if the given recovery mode is safe.
|
||||
// This is used for SFINAE checks in higher-level functions.
|
||||
template<EErrorRecovery R>
|
||||
struct SIsSafeEncoding
|
||||
{
|
||||
static const bool value =
|
||||
R == eErrorRecovery_Discard ||
|
||||
R == eErrorRecovery_Replace ||
|
||||
R == eErrorRecovery_FallbackLatin1ThenDiscard ||
|
||||
R == eErrorRecovery_FallbackLatin1ThenReplace ||
|
||||
R == eErrorRecovery_FallbackWin1252ThenDiscard ||
|
||||
R == eErrorRecovery_FallbackWin1252ThenReplace;
|
||||
};
|
||||
|
||||
// SIsCopyableEncoding<I, O>:
|
||||
// Check if data in one encoding can be copied directly to another encoding.
|
||||
// This is the basis for block-copy and string-assign optimizations in un-safe conversion functions.
|
||||
// Note: There are more valid combinations, they are left out since those can't occur with the output encodings supported.
|
||||
// Note: Only used for un-safe functions since it doesn't account for potential invalid sequences (they would be copied over).
|
||||
template<EEncoding InputEncoding, EEncoding OutputEncoding>
|
||||
struct SIsCopyableEncoding
|
||||
{
|
||||
static const bool value =
|
||||
InputEncoding == eEncoding_ASCII || // ASCII and Latin1 values don't change in any encoding.
|
||||
(InputEncoding == eEncoding_Latin1 && OutputEncoding != eEncoding_ASCII); // Except Latin1 -> ASCII is lossy.
|
||||
};
|
||||
template<EEncoding SameEncoding>
|
||||
struct SIsCopyableEncoding<SameEncoding, SameEncoding>
|
||||
{
|
||||
static const bool value = true; // If the input and output encodings are the same, then it's copyable.
|
||||
};
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,615 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// Description : Encoded Unicode sequence iteration.
|
||||
//
|
||||
// For lower level accessing of encoded text, an STL compatible iterator wrapper is provided.
|
||||
// This iterator will decode the underlying sequence, abstracting it to a sequence of UCS code-points.
|
||||
// Using the iterator wrapper, you can find where in an encoded string code-points (or encoding errors) are located.
|
||||
// Note: The iterator is an input-only iterator, you cannot write to the underlying sequence.
|
||||
|
||||
|
||||
#pragma once
|
||||
#include "UnicodeBinding.h"
|
||||
namespace Unicode
|
||||
{
|
||||
namespace Detail
|
||||
{
|
||||
// MoveNext(it, checker, tag):
|
||||
// Moves the iterator to the next UCS code-point in the encoded sequence.
|
||||
// Non-specialized version (for 1:1 code-unit to code-point).
|
||||
template<typename BaseIterator, typename BoundsChecker, EEncoding Encoding>
|
||||
inline void MoveNext(BaseIterator& it, const BoundsChecker& checker, const integral_constant<EEncoding, Encoding>)
|
||||
{
|
||||
static_assert(
|
||||
Encoding == eEncoding_ASCII ||
|
||||
Encoding == eEncoding_UTF32 ||
|
||||
Encoding == eEncoding_Latin1 ||
|
||||
Encoding == eEncoding_Win1252);
|
||||
assert(!checker.IsEnd(it) && "Attempt to iterate past the end of the sequence");
|
||||
|
||||
// All of these encodings use a single code-unit for each code-point.
|
||||
++it;
|
||||
}
|
||||
|
||||
// MoveNext(it, checker, tag):
|
||||
// Moves the iterator to the next UCS code-point in the encoded sequence.
|
||||
// Specialized for UTF-8.
|
||||
template<typename BaseIterator, typename BoundsChecker>
|
||||
inline void MoveNext(BaseIterator& it, const BoundsChecker& checker, integral_constant<EEncoding, eEncoding_UTF8>)
|
||||
{
|
||||
assert(!checker.IsEnd(it) && "Attempt to iterate past the end of the sequence");
|
||||
|
||||
// UTF-8: just need to skip up to 3 continuation bytes.
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
++it;
|
||||
if (checker.IsEnd(it)) // :WARN: always returns false if "safe" bool is false!
|
||||
{
|
||||
break;
|
||||
}
|
||||
uint32 val = static_cast<uint32>(*it);
|
||||
if ((val & 0xC0) != 0x80)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MoveNext(it, checker, tag):
|
||||
// Moves the iterator to the next UCS code-point in the encoded sequence.
|
||||
// Specialized for UTF-16.
|
||||
template<typename BaseIterator, typename BoundsChecker>
|
||||
inline void MoveNext(BaseIterator& it, const BoundsChecker& checker, integral_constant<EEncoding, eEncoding_UTF16>)
|
||||
{
|
||||
assert(!checker.IsEnd(it) && "Attempt to iterate past the end of the sequence");
|
||||
|
||||
// UTF-16: just need to skip one lead surrogate.
|
||||
++it;
|
||||
uint32 val = static_cast<uint32>(*it);
|
||||
if (val >= cLeadSurrogateFirst && val <= cLeadSurrogateLast)
|
||||
{
|
||||
if (!checker.IsEnd(it))
|
||||
{
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MovePrev(it, checker, tag):
|
||||
// Moves the iterator to the previous UCS code-point in the encoded sequence.
|
||||
// Non-specialized version (for 1:1 code-unit to code-point).
|
||||
template<typename BaseIterator, typename BoundsChecker, EEncoding Encoding>
|
||||
inline void MovePrev(BaseIterator& it, const BoundsChecker& checker, const integral_constant<EEncoding, Encoding>)
|
||||
{
|
||||
static_assert(
|
||||
Encoding == eEncoding_ASCII ||
|
||||
Encoding == eEncoding_UTF32 ||
|
||||
Encoding == eEncoding_Latin1 ||
|
||||
Encoding == eEncoding_Win1252);
|
||||
assert(!checker.IsBegin(it) && "Attempt to iterate past the beginning of the sequence");
|
||||
|
||||
// All of these encodings use a single code-unit for each code-point.
|
||||
--it;
|
||||
}
|
||||
|
||||
// MovePrev(it, checker, tag):
|
||||
// Moves the iterator to the previous UCS code-point in the encoded sequence.
|
||||
// Specialized for UTF-8.
|
||||
template<typename BaseIterator, typename BoundsChecker>
|
||||
inline void MovePrev(BaseIterator& it, const BoundsChecker& checker, integral_constant<EEncoding, eEncoding_UTF8>)
|
||||
{
|
||||
assert(!checker.IsBegin(it) && "Attempt to iterate past the beginning of the sequence");
|
||||
|
||||
// UTF-8: just need to skip up to 3 continuation bytes.
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
--it;
|
||||
if (checker.IsBegin(it))
|
||||
{
|
||||
break;
|
||||
}
|
||||
uint32 val = static_cast<uint32>(*it);
|
||||
if ((val & 0xC0) != 0x80)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MovePrev(it, checker, tag):
|
||||
// Moves the iterator to the previous UCS code-point in the encoded sequence.
|
||||
// Specialized for UTF-16.
|
||||
template<typename BaseIterator, typename BoundsChecker>
|
||||
inline void MovePrev(BaseIterator& it, const BoundsChecker& checker, integral_constant<EEncoding, eEncoding_UTF16>)
|
||||
{
|
||||
assert(!checker.IsBegin(it) && "Attempt to iterate past the beginning of the sequence");
|
||||
|
||||
// UTF-16: just need to skip one lead surrogate.
|
||||
--it;
|
||||
uint32 val = static_cast<uint32>(*it);
|
||||
if (val >= cLeadSurrogateFirst && val <= cLeadSurrogateLast)
|
||||
{
|
||||
if (!checker.IsBegin(it))
|
||||
{
|
||||
--it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SBaseIterators<BaseIterator, BoundsChecked>:
|
||||
// Utility to access base iterators properties from CIterator.
|
||||
// This is the bounds-checked specialization, the range information is kept to defend against malformed sequences.
|
||||
template<typename BaseIterator, bool BoundsChecked>
|
||||
struct SBaseIterators
|
||||
{
|
||||
typedef BaseIterator type;
|
||||
type begin, end;
|
||||
type it;
|
||||
|
||||
SBaseIterators(const BaseIterator& _begin, const BaseIterator& _end)
|
||||
: begin(_begin)
|
||||
, end(_end)
|
||||
, it(_begin) {}
|
||||
|
||||
SBaseIterators(const SBaseIterators& other)
|
||||
: begin(other.begin)
|
||||
, end(other.end)
|
||||
, it(other.it) {}
|
||||
|
||||
SBaseIterators& operator =(const SBaseIterators& other)
|
||||
{
|
||||
begin = other.begin;
|
||||
end = other.end;
|
||||
it = other.it;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool IsBegin(const BaseIterator& _it) const
|
||||
{
|
||||
return begin == _it;
|
||||
}
|
||||
|
||||
bool IsEnd(const BaseIterator& _it) const
|
||||
{
|
||||
return end == _it;
|
||||
}
|
||||
|
||||
bool IsEqual(const SBaseIterators& other) const
|
||||
{
|
||||
return it == other.it
|
||||
&& begin == other.begin
|
||||
&& end == other.end;
|
||||
}
|
||||
|
||||
// Note: Only called inside assert.
|
||||
// O(N) version; works with any forward-iterator (or better)
|
||||
bool IsInRange(const BaseIterator& _it, std::forward_iterator_tag) const
|
||||
{
|
||||
for (BaseIterator i = begin; i != end; ++i)
|
||||
{
|
||||
if (_it == i)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Note: Only called inside assert.
|
||||
// O(1) version; requires random-access-iterator.
|
||||
bool IsInRange(const BaseIterator& _it, std::random_access_iterator_tag) const
|
||||
{
|
||||
return (begin <= _it && _it < end);
|
||||
}
|
||||
|
||||
// Note: Only called inside assert.
|
||||
// Dispatches to the O(1) version if a random-access iterator is used (common case).
|
||||
bool IsInRange(const BaseIterator& _it) const
|
||||
{
|
||||
return IsInRange(_it, typename std::iterator_traits<BaseIterator>::iterator_category());
|
||||
}
|
||||
};
|
||||
|
||||
// SBaseIterators<BaseIterator, BoundsChecked>:
|
||||
// Utility to access base iterators properties from CIterator.
|
||||
// This is the un-checked specialization for known-safe sequences.
|
||||
template<typename BaseIterator>
|
||||
struct SBaseIterators<BaseIterator, false>
|
||||
{
|
||||
typedef BaseIterator type;
|
||||
type it;
|
||||
|
||||
explicit SBaseIterators(const BaseIterator& begin)
|
||||
: it(begin) {}
|
||||
|
||||
SBaseIterators(const BaseIterator& begin, const BaseIterator& end)
|
||||
: it(begin) {}
|
||||
|
||||
SBaseIterators(const SBaseIterators& other)
|
||||
: it(other.it) {}
|
||||
|
||||
SBaseIterators& operator =(const SBaseIterators& other)
|
||||
{
|
||||
it = other.it;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool IsBegin(const BaseIterator&) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsEnd(const BaseIterator&) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsEqual(const SBaseIterators& other) const
|
||||
{
|
||||
return it == other.it;
|
||||
}
|
||||
|
||||
bool IsInRange(const BaseIterator&) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
// SIteratorSink<Safe>:
|
||||
// Helper to store the last code-point and error bit that was decoded.
|
||||
// This is the safe specialization for potentially malformed sequences.
|
||||
template<bool Safe>
|
||||
struct SIteratorSink
|
||||
{
|
||||
static const uint32 cEmpty = 0xFFFFFFFFU;
|
||||
uint32 value;
|
||||
bool error;
|
||||
|
||||
void Clear()
|
||||
{
|
||||
value = cEmpty;
|
||||
error = false;
|
||||
}
|
||||
|
||||
bool IsEmpty() const
|
||||
{
|
||||
return value == cEmpty;
|
||||
}
|
||||
|
||||
bool IsError() const
|
||||
{
|
||||
return error;
|
||||
}
|
||||
|
||||
const uint32& GetValue() const
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
void MarkDecodingError()
|
||||
{
|
||||
value = cReplacementCharacter;
|
||||
error = true;
|
||||
}
|
||||
|
||||
template<EEncoding Encoding, typename BaseIterator, bool BoundsChecked>
|
||||
void Decode(const SBaseIterators<BaseIterator, BoundsChecked>& its, integral_constant<EEncoding, Encoding>)
|
||||
{
|
||||
typedef SDecoder<Encoding, SIteratorSink&, SIteratorSink&> DecoderType;
|
||||
DecoderType decoder(*this, *this);
|
||||
Clear();
|
||||
for (BaseIterator it = its.it; IsEmpty(); ++it)
|
||||
{
|
||||
uint32 val = static_cast<uint32>(*it);
|
||||
decoder(val);
|
||||
if (its.IsEnd(it))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (IsEmpty())
|
||||
{
|
||||
// If we still have neither a new value or an error flag, just treat as error.
|
||||
// This can happen if we reached the end of the sequence, but it ends in an incomplete code-sequence.
|
||||
MarkDecodingError();
|
||||
}
|
||||
}
|
||||
|
||||
template<EEncoding Encoding, typename BaseIterator, bool BoundsChecked>
|
||||
void DecodeIfEmpty(const SBaseIterators<BaseIterator, BoundsChecked>& its, integral_constant<EEncoding, Encoding> tag)
|
||||
{
|
||||
if (IsEmpty())
|
||||
{
|
||||
Decode(its, tag);
|
||||
}
|
||||
}
|
||||
|
||||
void operator()(uint32 unit)
|
||||
{
|
||||
value = unit;
|
||||
}
|
||||
|
||||
void operator()(SIteratorSink&, uint32, uint32)
|
||||
{
|
||||
MarkDecodingError();
|
||||
}
|
||||
};
|
||||
|
||||
// SIteratorSink<Safe>:
|
||||
// Helper to store the last code-point that was decoded.
|
||||
// This is the un-safe specialization for known-valid sequences.
|
||||
// Note: No error-state is tracked since we won't handle that regardless for un-safe CIterator.
|
||||
template<>
|
||||
struct SIteratorSink<false>
|
||||
{
|
||||
static const uint32 cEmpty = 0xFFFFFFFFU;
|
||||
uint32 value;
|
||||
|
||||
void Clear()
|
||||
{
|
||||
value = cEmpty;
|
||||
}
|
||||
|
||||
bool IsEmpty() const
|
||||
{
|
||||
return value == cEmpty;
|
||||
}
|
||||
|
||||
bool IsError() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const uint32& GetValue() const
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
template<EEncoding Encoding, typename BaseIterator, bool BoundsChecked>
|
||||
void Decode(const SBaseIterators<BaseIterator, BoundsChecked>& its, integral_constant<EEncoding, Encoding>)
|
||||
{
|
||||
typedef SDecoder<Encoding, SIteratorSink&, void> DecoderType;
|
||||
DecoderType decoder(*this);
|
||||
for (BaseIterator it = its.it; IsEmpty(); ++it)
|
||||
{
|
||||
uint32 val = static_cast<uint32>(*it);
|
||||
decoder(val);
|
||||
}
|
||||
}
|
||||
|
||||
template<EEncoding Encoding, typename BaseIterator, bool BoundsChecked>
|
||||
void DecodeIfEmpty(const SBaseIterators<BaseIterator, BoundsChecked>& its, integral_constant<EEncoding, Encoding> tag)
|
||||
{
|
||||
if (IsEmpty())
|
||||
{
|
||||
Decode(its, tag);
|
||||
}
|
||||
}
|
||||
|
||||
void operator()(uint32 unit)
|
||||
{
|
||||
value = unit;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// CIterator<BaseIterator [, Safe, Encoding]>:
|
||||
// Helper class that can iterate over an encoded text sequence and read the underlying UCS code-points.
|
||||
// If the Safe flag is set, bounds checking is performed inside multi-unit sequences to guard against decoding errors.
|
||||
// This requires the user to know where the sequence ends (use the constructor taking two parameters).
|
||||
// Note: The BaseIterator must be forward-iterator or better when Safe flag is set.
|
||||
// If the Safe flag is not set, you must guarantee the sequence is validly encoded, and allows the use of the single argument constructor.
|
||||
// In the case of unsafe iterator used for C-style string pointer, look for a U+0000 dereferenced value to end the iteration.
|
||||
// Regardless of the Safe flag, the user must ensure that the iterator is never moved past the beginning or end of the range (just like any other STL iterator).
|
||||
// Example of typical usage:
|
||||
// string utf8 = "foo"; // UTF-8
|
||||
// for (Unicode::CIterator<string::const_iterator> it(utf8.begin(), utf8.end()); it != utf8.end(); ++it)
|
||||
// {
|
||||
// uint32 codepoint = *it; // 32-bit UCS code-point
|
||||
// }
|
||||
// Example unsafe usage: (for known-valid encoded C-style strings):
|
||||
// const char *pValid = "foo"; // UTF-8
|
||||
// for (Unicode::CIterator<const char *, false> it = pValid; *it != 0; ++it)
|
||||
// {
|
||||
// uint32 codepoint = *it; // 32-bit UCS code-point
|
||||
// }
|
||||
template<typename BaseIterator, bool Safe = true, EEncoding Encoding = Detail::SInferEncoding<BaseIterator, true>::value>
|
||||
class CIterator
|
||||
{
|
||||
// The iterator value in the encoded sequence.
|
||||
// Optionally provides bounds-checking.
|
||||
Detail::SBaseIterators<BaseIterator, Safe> its;
|
||||
|
||||
// The cached UCS code-point at the current position.
|
||||
// Mutable because dereferencing is conceptually const, but does cache some state in this case.
|
||||
mutable Detail::SIteratorSink<Safe> sink;
|
||||
|
||||
public:
|
||||
// Types for compatibility with STL bidirectional iterator requirements.
|
||||
typedef const uint32 value_type;
|
||||
typedef const uint32& reference;
|
||||
typedef const uint32* pointer;
|
||||
typedef const ptrdiff_t difference_type;
|
||||
typedef std::bidirectional_iterator_tag iterator_category;
|
||||
|
||||
// Construct an iterator for the given range.
|
||||
// The initial position of the iterator as at the beginning of the range.
|
||||
CIterator(const BaseIterator& begin, const BaseIterator& end)
|
||||
: its(begin, end)
|
||||
{
|
||||
sink.Clear();
|
||||
}
|
||||
|
||||
// Construct an iterator from a single iterator (typically C-style string pointer).
|
||||
// This can only be used for unsafe iterators.
|
||||
template<typename IteratorType>
|
||||
CIterator(const IteratorType& it, typename Detail::SRequire<!Safe&& Detail::is_convertible<IteratorType, BaseIterator>::value, IteratorType>::type* = 0)
|
||||
: its(static_cast<const BaseIterator&>(it))
|
||||
{
|
||||
sink.Clear();
|
||||
}
|
||||
|
||||
// Copy-construct an iterator.
|
||||
CIterator(const CIterator& other)
|
||||
: its(other.its)
|
||||
, sink(other.sink) {}
|
||||
|
||||
// Copy-assign an iterator.
|
||||
CIterator& operator =(const CIterator& other)
|
||||
{
|
||||
its = other.its;
|
||||
sink = other.sink;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Test if the iterator points at an encoding error in the underlying encoded sequence.
|
||||
// If so, the function returns false.
|
||||
// When using an un-safe iterator, this function always returns true, if a sequence can contain encoding errors, you must use the safe variant.
|
||||
// Note: This requires the underlying iterator to be dereferenced, so you cannot use it only while the iterator is inside the valid range.
|
||||
bool IsAtValidCodepoint() const
|
||||
{
|
||||
assert(!its.IsEnd(its.it) && "Attempt to dereference the past-the-end iterator");
|
||||
Detail::integral_constant<EEncoding, Encoding> tag;
|
||||
sink.DecodeIfEmpty(its, tag);
|
||||
return !sink.IsError();
|
||||
}
|
||||
|
||||
// Gets the current position in the underlying encoded sequence.
|
||||
// If the iterator points to an invalidly encoded sequence (ie, IsError() returns true), the direction of iteration is significant.
|
||||
// In that case the returned position is approximated; to work around this: move all iterators of which the position is compared in the same direction.
|
||||
const BaseIterator& GetPosition() const
|
||||
{
|
||||
return its.it;
|
||||
}
|
||||
|
||||
// Sets the current position in the underlying encoded sequence.
|
||||
// You may not set the position outside the range for which this iterator was constructed.
|
||||
void SetPosition(const BaseIterator& it)
|
||||
{
|
||||
assert(its.IsInRange(it) && "Attempt to set the underlying iterator outside of the supported range");
|
||||
its.it = it;
|
||||
}
|
||||
|
||||
// Test if this iterator is equal to another iterator instance.
|
||||
// Note: In the presence of an invalidly encoded sequence (ie, IsError() returns true), the direction of iteration is significant.
|
||||
// To work around this, you can either:
|
||||
// 1) Move all iterators that will be compared in the same direction; or
|
||||
// 2) Compare the dereferenced iterator value(s) instead (if applicable).
|
||||
bool operator ==(const CIterator& other) const
|
||||
{
|
||||
return its.IsEqual(other.its);
|
||||
}
|
||||
|
||||
// Test if this iterator is equal to another base iterator.
|
||||
// Note: If the provided iterator does not point to the the first code-unit of an UCS code-point, the behavior is undefined.
|
||||
bool operator ==(const BaseIterator& other) const
|
||||
{
|
||||
return its.it == other;
|
||||
}
|
||||
|
||||
// Test if this iterator is equal to another iterator instance.
|
||||
// Note: In the presence of an invalidly encoded sequence (ie, IsError() returns true), the direction of iteration is significant.
|
||||
// To work around this, you can either:
|
||||
// 1) Move all iterators that will be compared in the same direction; or
|
||||
// 2) Compare the dereferenced iterator value(s) instead (if applicable).
|
||||
bool operator !=(const CIterator& other) const
|
||||
{
|
||||
return !its.IsEqual(other.its);
|
||||
}
|
||||
|
||||
// Test if this iterator is equal to another base iterator.
|
||||
// Note: If the provided iterator does not point to the the first code-unit of an UCS code-point, the behavior is undefined.
|
||||
bool operator !=(const BaseIterator& other) const
|
||||
{
|
||||
return its.it != other;
|
||||
}
|
||||
|
||||
// Get the decoded UCS code-point at the current position in the sequence.
|
||||
// If the iterator points to an invalidly encoded sequence (ie, IsError() returns true) the function returns U+FFFD (replacement character).
|
||||
reference operator *() const
|
||||
{
|
||||
assert(!its.IsEnd(its.it) && "Attempt to dereference the past-the-end iterator");
|
||||
Detail::integral_constant<EEncoding, Encoding> tag;
|
||||
sink.DecodeIfEmpty(its, tag);
|
||||
return sink.GetValue();
|
||||
}
|
||||
|
||||
// Advance the iterator to the next UCS code-point.
|
||||
// Note: You must make sure the iterator is not at the end of the sequence, even in Safe mode.
|
||||
// However, in Safe mode, the iterator will never move past the end of the sequence in the presence of encoding errors.
|
||||
CIterator& operator ++()
|
||||
{
|
||||
Detail::integral_constant<EEncoding, Encoding> tag;
|
||||
Detail::MoveNext(its.it, its, tag);
|
||||
sink.Clear();
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Go back to the previous UCS code-point.
|
||||
// Note: You must make sure the iterator is not at the beginning of the sequence, even in Safe mode.
|
||||
// However, in Safe mode, the iterators will never move past the beginning of the sequence in the presence of encoding errors.
|
||||
CIterator& operator --()
|
||||
{
|
||||
Detail::integral_constant<EEncoding, Encoding> tag;
|
||||
Detail::MovePrev(its.it, its, tag);
|
||||
sink.Clear();
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Advance the iterator to the next UCS code-point, return a copy of the iterator position before advancing.
|
||||
// Note: You must make sure the iterator is not at the end of the sequence, even in Safe mode.
|
||||
// However, in Safe mode, the iterator will never move past the end of the sequence in the presence of encoding errors.
|
||||
CIterator operator ++(int)
|
||||
{
|
||||
CIterator result = *this;
|
||||
++*this;
|
||||
return result;
|
||||
}
|
||||
|
||||
// Go back to the previous UCS code-point, return a copy of the iterator position before going back.
|
||||
// Note: You must make sure the iterator is not at the beginning of the sequence, even in Safe mode.
|
||||
// However, in Safe mode, the iterators will never move past the beginning of the sequence in the presence of encoding errors.
|
||||
CIterator operator --(int)
|
||||
{
|
||||
CIterator result = *this;
|
||||
--*this;
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
namespace Detail
|
||||
{
|
||||
// SIteratorSpecializer<T>:
|
||||
// Specializes the CIterator template to use for a given string type.
|
||||
// Note: The reason we use this is because MSVC doesn't want to deduce this on the MakeIterator declaration.
|
||||
template<typename StringType>
|
||||
struct SIteratorSpecializer
|
||||
{
|
||||
typedef CIterator<typename StringType::const_iterator> type;
|
||||
};
|
||||
}
|
||||
|
||||
// MakeIterator(const StringType &str):
|
||||
// Helper function to make an UCS code-point iterator given an Unicode string.
|
||||
// Example usage:
|
||||
// string utf8 = "foo"; // UTF-8
|
||||
// auto it = Unicode::MakeIterator(utf8);
|
||||
// while (it != utf8.end())
|
||||
// {
|
||||
// uint32 codepoint = *it; // 32-bit UCS code-point
|
||||
// }
|
||||
// Or, in a for-loop:
|
||||
// for (auto it = Unicode::MakeIterator(utf8); it != utf8.end(); ++it) {}
|
||||
template<typename StringType>
|
||||
inline typename Detail::SIteratorSpecializer<StringType>::type MakeIterator(const StringType& str)
|
||||
{
|
||||
return typename Detail::SIteratorSpecializer<StringType>::type(str.begin(), str.end());
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <AzCore/IO/SystemFile.h>
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
|
||||
#ifdef APPLE
|
||||
#include <mach/mach.h>
|
||||
@@ -77,8 +78,6 @@ unsigned int g_EnableMultipleAssert = 0;//set to something else than 0 if to ena
|
||||
#include <AzFramework/Utils/SystemUtilsApple.h>
|
||||
#endif
|
||||
|
||||
#include "StringUtils.h"
|
||||
|
||||
#if AZ_TRAIT_COMPILER_DEFINE_FS_ERRNO_TYPE
|
||||
typedef int FS_ERRNO_TYPE;
|
||||
#if AZ_TRAIT_COMPILER_DEFINE_FS_STAT_TYPE
|
||||
@@ -349,23 +348,23 @@ void _makepath(char* path, const char* drive, const char* dir, const char* filen
|
||||
}
|
||||
if (dir && dir[0])
|
||||
{
|
||||
cry_strcat(tmp, dir);
|
||||
azstrcat(tmp, MAX_PATH, dir);
|
||||
ch = tmp[strlen(tmp) - 1];
|
||||
if (ch != '/' && ch != '\\')
|
||||
{
|
||||
cry_strcat(tmp, "\\");
|
||||
azstrcat(tmp, MAX_PATH, "\\");
|
||||
}
|
||||
}
|
||||
if (filename && filename[0])
|
||||
{
|
||||
cry_strcat(tmp, filename);
|
||||
azstrcat(tmp, MAX_PATH, filename);
|
||||
if (ext && ext[0])
|
||||
{
|
||||
if (ext[0] != '.')
|
||||
{
|
||||
cry_strcat(tmp, ".");
|
||||
azstrcat(tmp, MAX_PATH, ".");
|
||||
}
|
||||
cry_strcat(tmp, ext);
|
||||
azstrcat(tmp, MAX_PATH, ext);
|
||||
}
|
||||
}
|
||||
azstrcpy(path, strlen(tmp) + 1, tmp);
|
||||
@@ -486,12 +485,12 @@ void _splitpath(const char* inpath, char* drv, char* dir, char* fname, char* ext
|
||||
drv[0] = 0;
|
||||
}
|
||||
|
||||
typedef CryStackStringT<char, AZ_MAX_PATH_LEN> path_stack_string;
|
||||
typedef AZStd::fixed_string<AZ_MAX_PATH_LEN> path_stack_string;
|
||||
|
||||
const path_stack_string inPath(inpath);
|
||||
string::size_type s = inPath.rfind('/', inPath.size());//position of last /
|
||||
AZStd::string::size_type s = inPath.rfind('/', inPath.size());//position of last /
|
||||
path_stack_string fName;
|
||||
if (s == string::npos)
|
||||
if (s == AZStd::string::npos)
|
||||
{
|
||||
if (dir)
|
||||
{
|
||||
@@ -503,9 +502,9 @@ void _splitpath(const char* inpath, char* drv, char* dir, char* fname, char* ext
|
||||
{
|
||||
if (dir)
|
||||
{
|
||||
azstrcpy(dir, AZ_MAX_PATH_LEN, (inPath.substr((string::size_type)0, (string::size_type)(s + 1))).c_str()); //assign directory
|
||||
azstrcpy(dir, AZ_MAX_PATH_LEN, (inPath.substr((AZStd::string::size_type)0, (AZStd::string::size_type)(s + 1))).c_str()); //assign directory
|
||||
}
|
||||
fName = inPath.substr((string::size_type)(s + 1)); //assign remaining string as rest
|
||||
fName = inPath.substr((AZStd::string::size_type)(s + 1)); //assign remaining string as rest
|
||||
}
|
||||
if (fName.size() == 0)
|
||||
{
|
||||
@@ -521,8 +520,8 @@ void _splitpath(const char* inpath, char* drv, char* dir, char* fname, char* ext
|
||||
else
|
||||
{
|
||||
//dir and drive are now set
|
||||
s = fName.find(".", (string::size_type)0);//position of first .
|
||||
if (s == string::npos)
|
||||
s = fName.find(".", (AZStd::string::size_type)0);//position of first .
|
||||
if (s == AZStd::string::npos)
|
||||
{
|
||||
if (ext)
|
||||
{
|
||||
@@ -547,7 +546,7 @@ void _splitpath(const char* inpath, char* drv, char* dir, char* fname, char* ext
|
||||
}
|
||||
else
|
||||
{
|
||||
azstrcpy(fname, AZ_MAX_PATH_LEN, (fName.substr((string::size_type)0, s)).c_str()); //assign filename
|
||||
azstrcpy(fname, AZ_MAX_PATH_LEN, (fName.substr((AZStd::string::size_type)0, s)).c_str()); //assign filename
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -779,17 +778,17 @@ BOOL SystemTimeToFileTime(const SYSTEMTIME* syst, LPFILETIME ft)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void adaptFilenameToLinux(string& rAdjustedFilename)
|
||||
void adaptFilenameToLinux(AZStd::string& rAdjustedFilename)
|
||||
{
|
||||
//first replace all \\ by /
|
||||
string::size_type loc = 0;
|
||||
while ((loc = rAdjustedFilename.find("\\", loc)) != string::npos)
|
||||
AZStd::string::size_type loc = 0;
|
||||
while ((loc = rAdjustedFilename.find("\\", loc)) != AZStd::string::npos)
|
||||
{
|
||||
rAdjustedFilename.replace(loc, 1, "/");
|
||||
}
|
||||
loc = 0;
|
||||
//remove /./
|
||||
while ((loc = rAdjustedFilename.find("/./", loc)) != string::npos)
|
||||
while ((loc = rAdjustedFilename.find("/./", loc)) != AZStd::string::npos)
|
||||
{
|
||||
rAdjustedFilename.replace(loc, 3, "/");
|
||||
}
|
||||
@@ -798,16 +797,16 @@ void adaptFilenameToLinux(string& rAdjustedFilename)
|
||||
void replaceDoublePathFilename(char* szFileName)
|
||||
{
|
||||
//replace "\.\" by "\"
|
||||
string s(szFileName);
|
||||
string::size_type loc = 0;
|
||||
AZStd::string s(szFileName);
|
||||
AZStd::string::size_type loc = 0;
|
||||
//remove /./
|
||||
while ((loc = s.find("/./", loc)) != string::npos)
|
||||
while ((loc = s.find("/./", loc)) != AZStd::string::npos)
|
||||
{
|
||||
s.replace(loc, 3, "/");
|
||||
}
|
||||
loc = 0;
|
||||
//remove "\.\"
|
||||
while ((loc = s.find("\\.\\", loc)) != string::npos)
|
||||
while ((loc = s.find("\\.\\", loc)) != AZStd::string::npos)
|
||||
{
|
||||
s.replace(loc, 3, "\\");
|
||||
}
|
||||
@@ -817,8 +816,8 @@ void replaceDoublePathFilename(char* szFileName)
|
||||
const int comparePathNames(const char* cpFirst, const char* cpSecond, unsigned int len)
|
||||
{
|
||||
//create two strings and replace the \\ by / and /./ by /
|
||||
string first(cpFirst);
|
||||
string second(cpSecond);
|
||||
AZStd::string first(cpFirst);
|
||||
AZStd::string second(cpSecond);
|
||||
adaptFilenameToLinux(first);
|
||||
adaptFilenameToLinux(second);
|
||||
if (strlen(cpFirst) < len || strlen(cpSecond) < len)
|
||||
@@ -1568,14 +1567,16 @@ const bool GetFilenameNoCase
|
||||
return true;
|
||||
}
|
||||
|
||||
DWORD GetFileAttributes(LPCSTR lpFileName)
|
||||
DWORD GetFileAttributes(LPCWSTR lpFileNameW)
|
||||
{
|
||||
AZStd::string lpFileName;
|
||||
AZStd::to_string(lpFileName, lpFileNameW);
|
||||
struct stat fileStats;
|
||||
const int success = stat(lpFileName, &fileStats);
|
||||
const int success = stat(lpFileName.c_str(), &fileStats);
|
||||
if (success == -1)
|
||||
{
|
||||
char adjustedFilename[MAX_PATH];
|
||||
GetFilenameNoCase(lpFileName, adjustedFilename);
|
||||
GetFilenameNoCase(lpFileName.c_str(), adjustedFilename);
|
||||
if (stat(adjustedFilename, &fileStats) == -1)
|
||||
{
|
||||
return (DWORD)INVALID_FILE_ATTRIBUTES;
|
||||
|
||||
@@ -77,7 +77,6 @@ set(FILES
|
||||
CryCrc32.h
|
||||
CryCustomTypes.h
|
||||
CryFile.h
|
||||
CryFixedString.h
|
||||
CryHeaders.h
|
||||
CryHeaders_info.cpp
|
||||
CryListenerSet.h
|
||||
@@ -86,7 +85,6 @@ set(FILES
|
||||
CryPath.h
|
||||
CryPodArray.h
|
||||
CrySizer.h
|
||||
CryString.h
|
||||
CrySystemBus.h
|
||||
CryThread.h
|
||||
CryThreadImpl.h
|
||||
@@ -110,7 +108,6 @@ set(FILES
|
||||
SimpleSerialize.h
|
||||
smartptr.h
|
||||
StlUtils.h
|
||||
StringUtils.h
|
||||
Synchronization.h
|
||||
Tarray.h
|
||||
Timer.h
|
||||
@@ -118,10 +115,6 @@ set(FILES
|
||||
TimeValue_info.h
|
||||
TypeInfo_decl.h
|
||||
TypeInfo_impl.h
|
||||
UnicodeBinding.h
|
||||
UnicodeEncoding.h
|
||||
UnicodeFunctions.h
|
||||
UnicodeIterator.h
|
||||
VectorMap.h
|
||||
VectorSet.h
|
||||
VertexFormats.h
|
||||
|
||||
@@ -362,9 +362,6 @@ void SetFlags(T& dest, U flags, bool b)
|
||||
#include AZ_RESTRICTED_FILE(platform_h)
|
||||
#endif
|
||||
|
||||
// Platform wrappers must be included before CryString.h
|
||||
# include "CryString.h"
|
||||
|
||||
// Include support for meta-type data.
|
||||
#include "TypeInfo_decl.h"
|
||||
|
||||
@@ -374,12 +371,6 @@ void SetFlags(T& dest, U flags, bool b)
|
||||
bool CrySetFileAttributes(const char* lpFileName, uint32 dwFileAttributes);
|
||||
threadID CryGetCurrentThreadId();
|
||||
|
||||
#if !defined(NOT_USE_CRY_STRING)
|
||||
// Fixed-Sized (stack based string)
|
||||
// put after the platform wrappers because of missing wcsicmp/wcsnicmp functions
|
||||
#include "CryFixedString.h"
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define NO_INLINE __attribute__ ((noinline))
|
||||
#define NO_INLINE_WEAK __attribute__ ((noinline)) __attribute__((weak)) // marks a function as no_inline, but also as weak to prevent multiple-defined errors
|
||||
|
||||
@@ -8,16 +8,16 @@
|
||||
|
||||
|
||||
#include <platform.h>
|
||||
#include <StringUtils.h>
|
||||
#include <ISystem.h>
|
||||
#include <Random.h>
|
||||
#include <UnicodeFunctions.h>
|
||||
#include <IConsole.h>
|
||||
|
||||
#include <AzCore/Debug/Profiler.h>
|
||||
#include <AzCore/Debug/ProfileModuleInit.h>
|
||||
#include <AzCore/Memory/AllocatorManager.h>
|
||||
#include <AzCore/Module/Environment.h>
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
|
||||
// Section dictionary
|
||||
#if defined(AZ_RESTRICTED_PLATFORM)
|
||||
@@ -215,28 +215,28 @@ void CrySleep(unsigned int dwMilliseconds)
|
||||
int CryMessageBox([[maybe_unused]] const char* lpText, [[maybe_unused]] const char* lpCaption, [[maybe_unused]] unsigned int uType)
|
||||
{
|
||||
#ifdef WIN32
|
||||
#if !defined(RESOURCE_COMPILER)
|
||||
ICVar* const pCVar = gEnv && gEnv->pConsole ? gEnv->pConsole->GetCVar("sys_no_crash_dialog") : NULL;
|
||||
if ((pCVar && pCVar->GetIVal() != 0) || (gEnv && gEnv->bNoAssertDialog))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
wstring wideText, wideCaption;
|
||||
Unicode::Convert(wideText, lpText);
|
||||
Unicode::Convert(wideCaption, lpCaption);
|
||||
return MessageBoxW(NULL, wideText.c_str(), wideCaption.c_str(), uType);
|
||||
AZStd::wstring lpTextW;
|
||||
AZStd::to_wstring(lpTextW, lpText);
|
||||
AZStd::wstring lpCaptionW;
|
||||
AZStd::to_wstring(lpCaptionW, lpCaption);
|
||||
return MessageBoxW(NULL, lpTextW.c_str(), lpCaptionW.c_str(), uType);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Initializes root folder of the game, optionally returns exe and path name.
|
||||
void InitRootDir(char szExeFileName[], uint nExeSize, char szExeRootName[], [[maybe_unused]] uint nRootSize)
|
||||
void InitRootDir(char szExeFileName[], uint nExeSize, char szExeRootName[], uint nRootSize)
|
||||
{
|
||||
WCHAR szPath[_MAX_PATH];
|
||||
size_t nLen = GetModuleFileNameW(GetModuleHandle(NULL), szPath, _MAX_PATH);
|
||||
assert(nLen < _MAX_PATH && "The path to the current executable exceeds the expected length");
|
||||
char szPath[_MAX_PATH];
|
||||
AZ::Utils::GetExecutablePathReturnType ret = AZ::Utils::GetExecutablePath(szPath, _MAX_PATH);
|
||||
AZ_Assert(ret.m_pathStored == AZ::Utils::ExecutablePathResult::Success, "The path to the current executable exceeds the expected length");
|
||||
const size_t nLen = strnlen(szPath, _MAX_PATH);
|
||||
|
||||
// Find path above exe name and deepest folder.
|
||||
bool firstIteration = true;
|
||||
@@ -251,25 +251,27 @@ void InitRootDir(char szExeFileName[], uint nExeSize, char szExeRootName[], [[ma
|
||||
// Return exe path
|
||||
if (szExeRootName)
|
||||
{
|
||||
Unicode::Convert(szExeRootName, n+1, szPath);
|
||||
azstrncpy(szExeRootName, nRootSize, szPath + n + 1, nLen - n - 1);
|
||||
}
|
||||
|
||||
// Return exe name
|
||||
if (szExeFileName)
|
||||
{
|
||||
Unicode::Convert(szExeFileName, nExeSize, szPath + n);
|
||||
azstrncpy(szExeFileName, nExeSize, szPath + n, nLen - n);
|
||||
}
|
||||
firstIteration = false;
|
||||
}
|
||||
// Check if the engineroot exists
|
||||
wcscat_s(szPath, L"\\engine.json");
|
||||
azstrcat(szPath, AZ_ARRAY_SIZE(szPath), "\\engine.json");
|
||||
WIN32_FILE_ATTRIBUTE_DATA data;
|
||||
BOOL res = GetFileAttributesExW(szPath, GetFileExInfoStandard, &data);
|
||||
wchar_t szPathW[_MAX_PATH];
|
||||
AZStd::to_wstring(szPathW, _MAX_PATH, szPath);
|
||||
BOOL res = GetFileAttributesExW(szPathW, GetFileExInfoStandard, &data);
|
||||
if (res != 0 && data.dwFileAttributes != INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
// Found file
|
||||
szPath[n] = 0;
|
||||
SetCurrentDirectoryW(szPath);
|
||||
SetCurrentDirectoryW(szPathW);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -391,7 +393,9 @@ bool CrySetFileAttributes(const char* lpFileName, uint32 dwFileAttributes)
|
||||
#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
|
||||
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
|
||||
#else
|
||||
return SetFileAttributes(lpFileName, dwFileAttributes) != 0;
|
||||
AZStd::wstring lpFileNameW;
|
||||
AZStd::to_wstring(lpFileNameW, lpFileName);
|
||||
return SetFileAttributes(lpFileNameW.c_str(), dwFileAttributes) != 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -440,7 +444,7 @@ inline void CryDebugStr([[maybe_unused]] const char* format, ...)
|
||||
va_start(ArgList, format);
|
||||
azvsnprintf(szBuffer,sizeof(szBuffer)-1, format, ArgList);
|
||||
va_end(ArgList);
|
||||
cry_strcat(szBuffer,"\n");
|
||||
azstrcat(szBuffer,"\n");
|
||||
OutputDebugString(szBuffer);
|
||||
#endif
|
||||
*/
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "CmdLine.h"
|
||||
|
||||
|
||||
void CCmdLine::PushCommand(const string& sCommand, const string& sParameter)
|
||||
void CCmdLine::PushCommand(const AZStd::string& sCommand, const AZStd::string& sParameter)
|
||||
{
|
||||
if (sCommand.empty())
|
||||
{
|
||||
@@ -47,7 +47,7 @@ CCmdLine::CCmdLine(const char* commandLine)
|
||||
|
||||
char* src = (char*)commandLine;
|
||||
|
||||
string command, parameter;
|
||||
AZStd::string command, parameter;
|
||||
|
||||
for (;; )
|
||||
{
|
||||
@@ -56,12 +56,12 @@ CCmdLine::CCmdLine(const char* commandLine)
|
||||
break;
|
||||
}
|
||||
|
||||
string arg = Next(src);
|
||||
AZStd::string arg = Next(src);
|
||||
|
||||
if (m_args.empty())
|
||||
{
|
||||
// this is the filename, convert backslash to forward slash
|
||||
arg.replace('\\', '/');
|
||||
AZ::StringFunc::Replace(arg, '\\', '/');
|
||||
m_args.push_back(CCmdLineArg("filename", arg.c_str(), eCLAT_Executable));
|
||||
}
|
||||
else
|
||||
@@ -90,7 +90,7 @@ CCmdLine::CCmdLine(const char* commandLine)
|
||||
}
|
||||
else
|
||||
{
|
||||
parameter += string(" ") + arg;
|
||||
parameter += AZStd::string(" ") + arg;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -151,7 +151,7 @@ const ICmdLineArg* CCmdLine::FindArg(const ECmdLineArgType ArgType, const char*
|
||||
}
|
||||
|
||||
|
||||
string CCmdLine::Next(char*& src)
|
||||
AZStd::string CCmdLine::Next(char*& src)
|
||||
{
|
||||
char ch = 0;
|
||||
char* org = src;
|
||||
@@ -170,7 +170,7 @@ string CCmdLine::Next(char*& src)
|
||||
;
|
||||
}
|
||||
|
||||
return string(org, src - 1);
|
||||
return AZStd::string(org, src - 1);
|
||||
|
||||
case '[':
|
||||
org = src;
|
||||
@@ -178,7 +178,7 @@ string CCmdLine::Next(char*& src)
|
||||
{
|
||||
;
|
||||
}
|
||||
return string(org, src - 1);
|
||||
return AZStd::string(org, src - 1);
|
||||
|
||||
case ' ':
|
||||
ch = *src++;
|
||||
@@ -190,12 +190,12 @@ string CCmdLine::Next(char*& src)
|
||||
;
|
||||
}
|
||||
|
||||
return string(org, src);
|
||||
return AZStd::string(org, src);
|
||||
}
|
||||
ch = *src++;
|
||||
}
|
||||
|
||||
return string();
|
||||
return AZStd::string();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -29,13 +29,13 @@ public:
|
||||
virtual const ICmdLineArg* GetArg(int n) const;
|
||||
virtual int GetArgCount() const;
|
||||
virtual const ICmdLineArg* FindArg(const ECmdLineArgType ArgType, const char* name, bool caseSensitive = false) const;
|
||||
virtual const char* GetCommandLine() const { return m_sCmdLine; };
|
||||
virtual const char* GetCommandLine() const { return m_sCmdLine.c_str(); };
|
||||
|
||||
private:
|
||||
void PushCommand(const string& sCommand, const string& sParameter);
|
||||
string Next(char*& str);
|
||||
void PushCommand(const AZStd::string& sCommand, const AZStd::string& sParameter);
|
||||
AZStd::string Next(char*& str);
|
||||
|
||||
string m_sCmdLine;
|
||||
AZStd::string m_sCmdLine;
|
||||
std::vector<CCmdLineArg> m_args;
|
||||
};
|
||||
|
||||
|
||||
@@ -34,8 +34,8 @@ public:
|
||||
private:
|
||||
|
||||
ECmdLineArgType m_type;
|
||||
string m_name;
|
||||
string m_value;
|
||||
AZStd::string m_name;
|
||||
AZStd::string m_value;
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_CRYSYSTEM_CMDLINEARG_H
|
||||
|
||||
@@ -57,7 +57,7 @@ bool CConsoleBatchFile::ExecuteConfigFile(const char* sFilename)
|
||||
Init();
|
||||
}
|
||||
|
||||
string filename;
|
||||
AZStd::string filename;
|
||||
|
||||
if (sFilename[0] != '@') // console config files are actually by default in @root@ instead of @assets@
|
||||
{
|
||||
@@ -78,7 +78,7 @@ bool CConsoleBatchFile::ExecuteConfigFile(const char* sFilename)
|
||||
filename = sFilename;
|
||||
}
|
||||
|
||||
if (strlen(PathUtil::GetExt(filename)) == 0)
|
||||
if (strlen(PathUtil::GetExt(filename.c_str())) == 0)
|
||||
{
|
||||
filename = PathUtil::ReplaceExtension(filename, "cfg");
|
||||
}
|
||||
@@ -88,20 +88,20 @@ bool CConsoleBatchFile::ExecuteConfigFile(const char* sFilename)
|
||||
|
||||
{
|
||||
const char* szLog = "Executing console batch file (try game,config,root):";
|
||||
string filenameLog;
|
||||
string sfn = PathUtil::GetFile(filename);
|
||||
AZStd::string filenameLog;
|
||||
AZStd::string sfn = PathUtil::GetFile(filename);
|
||||
|
||||
if (file.Open(filename, "rb", AZ::IO::IArchive::FOPEN_HINT_QUIET | AZ::IO::IArchive::FOPEN_ONDISK))
|
||||
if (file.Open(filename.c_str(), "rb", AZ::IO::IArchive::FOPEN_HINT_QUIET | AZ::IO::IArchive::FOPEN_ONDISK))
|
||||
{
|
||||
filenameLog = string("game/") + sfn;
|
||||
filenameLog = AZStd::string("game/") + sfn;
|
||||
}
|
||||
else if (file.Open(string("config/") + sfn, "rb", AZ::IO::IArchive::FOPEN_HINT_QUIET | AZ::IO::IArchive::FOPEN_ONDISK))
|
||||
else if (file.Open((AZStd::string("config/") + sfn).c_str(), "rb", AZ::IO::IArchive::FOPEN_HINT_QUIET | AZ::IO::IArchive::FOPEN_ONDISK))
|
||||
{
|
||||
filenameLog = string("game/config/") + sfn;
|
||||
filenameLog = AZStd::string("game/config/") + sfn;
|
||||
}
|
||||
else if (file.Open(string("./") + sfn, "rb", AZ::IO::IArchive::FOPEN_HINT_QUIET | AZ::IO::IArchive::FOPEN_ONDISK))
|
||||
else if (file.Open((AZStd::string("./") + sfn).c_str(), "rb", AZ::IO::IArchive::FOPEN_HINT_QUIET | AZ::IO::IArchive::FOPEN_ONDISK))
|
||||
{
|
||||
filenameLog = string("./") + sfn;
|
||||
filenameLog = AZStd::string("./") + sfn;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -142,11 +142,11 @@ bool CConsoleBatchFile::ExecuteConfigFile(const char* sFilename)
|
||||
str++;
|
||||
}
|
||||
|
||||
string strLine = s;
|
||||
AZStd::string strLine = s;
|
||||
|
||||
|
||||
//trim all whitespace characters at the beginning and the end of the current line and store its size
|
||||
strLine.Trim();
|
||||
AZ::StringFunc::TrimWhiteSpace(strLine, true, true);
|
||||
size_t strLineSize = strLine.size();
|
||||
|
||||
//skip comments, comments start with ";" or "--" but may have preceding whitespace characters
|
||||
@@ -168,7 +168,7 @@ bool CConsoleBatchFile::ExecuteConfigFile(const char* sFilename)
|
||||
}
|
||||
|
||||
{
|
||||
m_pConsole->ExecuteString(strLine);
|
||||
m_pConsole->ExecuteString(strLine.c_str());
|
||||
}
|
||||
}
|
||||
// See above
|
||||
|
||||
@@ -6,20 +6,20 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#if defined(WIN32) || defined(WIN64)
|
||||
|
||||
#include "CrySystem_precompiled.h"
|
||||
|
||||
#if defined(WIN32) || defined(WIN64)
|
||||
|
||||
#include "ConsoleHelpGen.h"
|
||||
#include "System.h"
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
|
||||
|
||||
|
||||
// remove bad characters, toupper, not very fast
|
||||
string CConsoleHelpGen::FixAnchorName(const char* szName)
|
||||
AZStd::string CConsoleHelpGen::FixAnchorName(const char* szName)
|
||||
{
|
||||
string ret;
|
||||
AZStd::string ret;
|
||||
|
||||
const char* p = szName;
|
||||
|
||||
@@ -45,9 +45,9 @@ string CConsoleHelpGen::FixAnchorName(const char* szName)
|
||||
return ret;
|
||||
}
|
||||
|
||||
string CConsoleHelpGen::GetCleanPrefix(const char* p)
|
||||
AZStd::string CConsoleHelpGen::GetCleanPrefix(const char* p)
|
||||
{
|
||||
string sRet;
|
||||
AZStd::string sRet;
|
||||
|
||||
while (*p != '_' && *p != 0)
|
||||
{
|
||||
@@ -58,9 +58,9 @@ string CConsoleHelpGen::GetCleanPrefix(const char* p)
|
||||
}
|
||||
|
||||
|
||||
string CConsoleHelpGen::SplitPrefixString_Part1(const char* p)
|
||||
AZStd::string CConsoleHelpGen::SplitPrefixString_Part1(const char* p)
|
||||
{
|
||||
string sRet;
|
||||
AZStd::string sRet;
|
||||
|
||||
while (*p != 10 && *p != 13 && *p != 0)
|
||||
{
|
||||
@@ -132,7 +132,7 @@ void CConsoleHelpGen::LogVersion(FILE* f) const
|
||||
char s[1024];
|
||||
|
||||
{
|
||||
GetModuleFileName(NULL, s, sizeof(s));
|
||||
AZ::Utils::GetExecutablePath(s, 1024);
|
||||
|
||||
char fdir[_MAX_PATH];
|
||||
char fdrive[_MAX_PATH];
|
||||
@@ -140,7 +140,7 @@ void CConsoleHelpGen::LogVersion(FILE* f) const
|
||||
char fext[_MAX_PATH];
|
||||
_splitpath_s(s, fdrive, fdir, file, fext);
|
||||
|
||||
KeyValue(f, "Executable", (string(file) + fext).c_str());
|
||||
KeyValue(f, "Executable", (AZStd::string(file) + fext).c_str());
|
||||
}
|
||||
|
||||
{
|
||||
@@ -273,11 +273,11 @@ void CConsoleHelpGen::SingleLinePrefix(FILE* f, const char* szPrefix, const char
|
||||
}
|
||||
else if (m_eWorkMode == eWM_Confluence)
|
||||
{
|
||||
string sPrefix;
|
||||
AZStd::string sPrefix;
|
||||
|
||||
if (*szPrefix)
|
||||
{
|
||||
sPrefix = string(szPrefix) + "_";
|
||||
sPrefix = AZStd::string(szPrefix) + "_";
|
||||
}
|
||||
|
||||
// fprintf(f,"| %s | [%s|%s] |\n",sPrefix.c_str(),szPrefixDesc,szLink); // e.g. "" "CL_" "CC_" "I_" "T_"
|
||||
@@ -406,7 +406,7 @@ void CConsoleHelpGen::InsertConsoleCommands(std::set<const char*, string_nocase_
|
||||
{
|
||||
const CConsoleCommand& cmd = itrCmd->second;
|
||||
|
||||
if (_strnicmp(cmd.m_sName, szLocalPrefix, strlen(szLocalPrefix)) == 0)
|
||||
if (_strnicmp(cmd.m_sName.c_str(), szLocalPrefix, strlen(szLocalPrefix)) == 0)
|
||||
{
|
||||
setCmdAndVars.insert(cmd.m_sName.c_str());
|
||||
}
|
||||
@@ -415,7 +415,7 @@ void CConsoleHelpGen::InsertConsoleCommands(std::set<const char*, string_nocase_
|
||||
|
||||
|
||||
|
||||
void CConsoleHelpGen::InsertConsoleVars(std::set<const char*, string_nocase_lt>& setCmdAndVars, std::map<string, const char*> mapPrefix) const
|
||||
void CConsoleHelpGen::InsertConsoleVars(std::set<const char*, string_nocase_lt>& setCmdAndVars, std::map<AZStd::string, const char*> mapPrefix) const
|
||||
{
|
||||
CXConsole::ConsoleVariablesMap::const_iterator itrVar, itrVarEnd = m_rParent.m_mapVariables.end();
|
||||
|
||||
@@ -425,11 +425,11 @@ void CConsoleHelpGen::InsertConsoleVars(std::set<const char*, string_nocase_lt>&
|
||||
bool bInsert = true;
|
||||
|
||||
{
|
||||
std::map<string, const char*>::const_iterator it2, end = mapPrefix.end();
|
||||
std::map<AZStd::string, const char*>::const_iterator it2, end = mapPrefix.end();
|
||||
|
||||
for (it2 = mapPrefix.begin(); it2 != end; ++it2)
|
||||
{
|
||||
if (it2->first != "___" && _strnicmp(var->GetName(), it2->first, it2->first.size()) == 0)
|
||||
if (it2->first != "___" && _strnicmp(var->GetName(), it2->first.c_str(), it2->first.size()) == 0)
|
||||
{
|
||||
bInsert = false;
|
||||
break;
|
||||
@@ -446,7 +446,7 @@ void CConsoleHelpGen::InsertConsoleVars(std::set<const char*, string_nocase_lt>&
|
||||
|
||||
|
||||
|
||||
void CConsoleHelpGen::InsertConsoleCommands(std::set<const char*, string_nocase_lt>& setCmdAndVars, std::map<string, const char*> mapPrefix) const
|
||||
void CConsoleHelpGen::InsertConsoleCommands(std::set<const char*, string_nocase_lt>& setCmdAndVars, std::map<AZStd::string, const char*> mapPrefix) const
|
||||
{
|
||||
CXConsole::ConsoleCommandsMap::const_iterator itrCmd, itrCmdEnd = m_rParent.m_mapCommands.end();
|
||||
|
||||
@@ -456,11 +456,11 @@ void CConsoleHelpGen::InsertConsoleCommands(std::set<const char*, string_nocase_
|
||||
bool bInsert = true;
|
||||
|
||||
{
|
||||
std::map<string, const char*>::const_iterator it2, end = mapPrefix.end();
|
||||
std::map<AZStd::string, const char*>::const_iterator it2, end = mapPrefix.end();
|
||||
|
||||
for (it2 = mapPrefix.begin(); it2 != end; ++it2)
|
||||
{
|
||||
if (it2->first != "___" && _strnicmp(cmd.m_sName, it2->first, it2->first.size()) == 0)
|
||||
if (it2->first != "___" && _strnicmp(cmd.m_sName.c_str(), it2->first.c_str(), it2->first.size()) == 0)
|
||||
{
|
||||
bInsert = false;
|
||||
break;
|
||||
@@ -480,7 +480,7 @@ void CConsoleHelpGen::CreateSingleEntryFile(const char* szName) const
|
||||
assert(m_eWorkMode == eWM_Confluence); // only needed for confluence
|
||||
|
||||
FILE* f3 = nullptr;
|
||||
azfopen(&f3, (string(GetFolderName()) + GetFileExtension() + "/" + FixAnchorName(szName)).c_str(), "w");
|
||||
azfopen(&f3, (AZStd::string(GetFolderName()) + GetFileExtension() + "/" + FixAnchorName(szName)).c_str(), "w");
|
||||
|
||||
if (!f3)
|
||||
{
|
||||
@@ -582,7 +582,7 @@ void CConsoleHelpGen::IncludeSingleEntry(FILE* f, const char* szName) const
|
||||
{
|
||||
fprintf(f, "<pre>\n");
|
||||
|
||||
string sHelp = szHelp;
|
||||
AZStd::string sHelp = szHelp;
|
||||
|
||||
// currently not required as the {noformat} is used
|
||||
// sHelp.replace("[","\\["); sHelp.replace("]","\\]");
|
||||
@@ -604,7 +604,7 @@ void CConsoleHelpGen::IncludeSingleEntry(FILE* f, const char* szName) const
|
||||
|
||||
void CConsoleHelpGen::Work()
|
||||
{
|
||||
// string sEngineFolder = string("@user@/")+GetFolderName();
|
||||
// AZStd::string sEngineFolder = AZStd::string("@user@/")+GetFolderName();
|
||||
// gEnv->pCryPak->RemoveDir(sEngineFolder.c_str()); // todo: check if that works
|
||||
// gEnv->pFileIO->CreatePath(sEngineFolder.c_str());
|
||||
|
||||
@@ -653,7 +653,7 @@ void CConsoleHelpGen::CreateMainPages()
|
||||
{
|
||||
gEnv->pFileIO->CreatePath(GetFolderName());
|
||||
|
||||
std::map<string, const char*> mapPrefix;
|
||||
std::map<AZStd::string, const char*> mapPrefix;
|
||||
|
||||
// order here doesn't matter, after the name some help can be added (after the first return)
|
||||
mapPrefix[ "AI_"] = "Artificial Intelligence";
|
||||
@@ -701,7 +701,7 @@ void CConsoleHelpGen::CreateMainPages()
|
||||
mapPrefix[ "___"] = "Remaining"; // key defined to get it sorted in the end
|
||||
|
||||
FILE* f1 = nullptr;
|
||||
azfopen(&f1, (string(GetFolderName()) + "/index" + GetFileExtension()).c_str(), "w");
|
||||
azfopen(&f1, (AZStd::string(GetFolderName()) + "/index" + GetFileExtension()).c_str(), "w");
|
||||
if (!f1)
|
||||
{
|
||||
return;
|
||||
@@ -729,17 +729,17 @@ void CConsoleHelpGen::CreateMainPages()
|
||||
|
||||
// show all registered Prefix with one line
|
||||
{
|
||||
std::map<string, const char*>::const_iterator it, end = mapPrefix.end();
|
||||
std::map<AZStd::string, const char*>::const_iterator it, end = mapPrefix.end();
|
||||
|
||||
StartH3(f1, "Registered Prefixes");
|
||||
|
||||
for (it = mapPrefix.begin(); it != end; ++it)
|
||||
{
|
||||
const char* szLocalPrefix = it->first.c_str(); // can be 0 for remaining ones
|
||||
string sCleanPrefix = GetCleanPrefix(szLocalPrefix);
|
||||
string sPrefixName = SplitPrefixString_Part1(it->second);
|
||||
AZStd::string sCleanPrefix = GetCleanPrefix(szLocalPrefix);
|
||||
AZStd::string sPrefixName = SplitPrefixString_Part1(it->second);
|
||||
|
||||
SingleLinePrefix(f1, sCleanPrefix.c_str(), sPrefixName.c_str(), (string("CONSOLEPREFIX") + FixAnchorName(sCleanPrefix.c_str()) + GetFileExtension()).c_str());
|
||||
SingleLinePrefix(f1, sCleanPrefix.c_str(), sPrefixName.c_str(), (AZStd::string("CONSOLEPREFIX") + FixAnchorName(sCleanPrefix.c_str()) + GetFileExtension()).c_str());
|
||||
// fprintf(f1," * [[CONSOLEPREFIX%s][%s_ %s]]\n",FixAnchorName(sCleanPrefix.c_str()).c_str(),sCleanPrefix.c_str(),sPrefixName.c_str());
|
||||
}
|
||||
|
||||
@@ -750,15 +750,15 @@ void CConsoleHelpGen::CreateMainPages()
|
||||
|
||||
|
||||
{
|
||||
std::map<string, const char*>::const_iterator it, it2, end = mapPrefix.end();
|
||||
std::map<AZStd::string, const char*>::const_iterator it, it2, end = mapPrefix.end();
|
||||
|
||||
StartH3(f1, "Console Commands and Variables Sorted by Prefix");
|
||||
|
||||
for (it = mapPrefix.begin(); it != end; ++it)
|
||||
{
|
||||
const char* szLocalPrefix = it->first.c_str(); // can be 0 for remaining ones
|
||||
string sCleanPrefix = GetCleanPrefix(szLocalPrefix);
|
||||
string sPrefixName = SplitPrefixString_Part1(it->second);
|
||||
AZStd::string sCleanPrefix = GetCleanPrefix(szLocalPrefix);
|
||||
AZStd::string sPrefixName = SplitPrefixString_Part1(it->second);
|
||||
|
||||
std::set<const char*, string_nocase_lt> setCmdAndVars; // to get console variables and commands sorted together
|
||||
|
||||
@@ -777,11 +777,11 @@ void CConsoleHelpGen::CreateMainPages()
|
||||
|
||||
// -------------------------------
|
||||
|
||||
string sSubName = string("CONSOLEPREFIX") + sCleanPrefix;
|
||||
AZStd::string sSubName = AZStd::string("CONSOLEPREFIX") + sCleanPrefix;
|
||||
|
||||
StartPrefix(f1, sCleanPrefix.c_str(), sPrefixName.c_str(), (sSubName + GetFileExtension()).c_str());
|
||||
|
||||
string sFileOut = string(GetFolderName()) + "/" + sSubName + GetFileExtension();
|
||||
AZStd::string sFileOut = AZStd::string(GetFolderName()) + "/" + sSubName + GetFileExtension();
|
||||
FILE* f2 = nullptr;
|
||||
azfopen(&f2, sFileOut.c_str(), "w");
|
||||
if (!f2)
|
||||
@@ -792,7 +792,7 @@ void CConsoleHelpGen::CreateMainPages()
|
||||
|
||||
// headline
|
||||
{
|
||||
string sHeadline;
|
||||
AZStd::string sHeadline;
|
||||
|
||||
if (sCleanPrefix.empty())
|
||||
{
|
||||
@@ -800,7 +800,7 @@ void CConsoleHelpGen::CreateMainPages()
|
||||
}
|
||||
else
|
||||
{
|
||||
sHeadline = string("Console Commands and Variables with Prefix ") + sCleanPrefix + "_";
|
||||
sHeadline = AZStd::string("Console Commands and Variables with Prefix ") + sCleanPrefix + "_";
|
||||
}
|
||||
|
||||
StartH1(f2, sHeadline.c_str());
|
||||
@@ -821,7 +821,7 @@ void CConsoleHelpGen::CreateMainPages()
|
||||
for (itI = setCmdAndVars.begin(); itI != endI; ++itI)
|
||||
{
|
||||
SingleLineEntry_InGlobal(f1, *itI, (sSubName + GetFileExtension() + "#Anchor" + FixAnchorName(*itI)).c_str());
|
||||
SingleLineEntry_InGroup(f2, *itI, (string("#Anchor") + FixAnchorName(*itI)).c_str());
|
||||
SingleLineEntry_InGroup(f2, *itI, (AZStd::string("#Anchor") + FixAnchorName(*itI)).c_str());
|
||||
}
|
||||
|
||||
EndH3(f2);
|
||||
@@ -842,7 +842,7 @@ void CConsoleHelpGen::CreateMainPages()
|
||||
}
|
||||
bFirst = false;
|
||||
|
||||
Anchor(f2, (string("Anchor") + FixAnchorName(*itI)).c_str()); // anchor
|
||||
Anchor(f2, (AZStd::string("Anchor") + FixAnchorName(*itI)).c_str()); // anchor
|
||||
|
||||
IncludeSingleEntry(f2, *itI);
|
||||
}
|
||||
|
||||
@@ -59,19 +59,19 @@ private: // --------------------------------------------------------
|
||||
// insert if the name starts with the with prefix
|
||||
void InsertConsoleCommands(std::set<const char*, string_nocase_lt>& setCmdAndVars, const char* szPrefix) const;
|
||||
// insert if the name does not start with any of the prefix in the map
|
||||
void InsertConsoleVars(std::set<const char*, string_nocase_lt>& setCmdAndVars, std::map<string, const char*> mapPrefix) const;
|
||||
void InsertConsoleVars(std::set<const char*, string_nocase_lt>& setCmdAndVars, std::map<AZStd::string, const char*> mapPrefix) const;
|
||||
// insert if the name does not start with any of the prefix in the map
|
||||
void InsertConsoleCommands(std::set<const char*, string_nocase_lt>& setCmdAndVars, std::map<string, const char*> mapPrefix) const;
|
||||
void InsertConsoleCommands(std::set<const char*, string_nocase_lt>& setCmdAndVars, std::map<AZStd::string, const char*> mapPrefix) const;
|
||||
|
||||
// a single file for the entry is generate
|
||||
void CreateSingleEntryFile(const char* szName) const;
|
||||
|
||||
void IncludeSingleEntry(FILE* f, const char* szName) const;
|
||||
|
||||
static string FixAnchorName(const char* szName);
|
||||
static string GetCleanPrefix(const char* p);
|
||||
static AZStd::string FixAnchorName(const char* szName);
|
||||
static AZStd::string GetCleanPrefix(const char* p);
|
||||
// split before "|" (to get the prefix itself)
|
||||
static string SplitPrefixString_Part1(const char* p);
|
||||
static AZStd::string SplitPrefixString_Part1(const char* p);
|
||||
// split string after "|" (to get the optional help)
|
||||
static const char* SplitPrefixString_Part2(const char* p);
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include <AzCore/Debug/StackTracer.h>
|
||||
#include <AzCore/Debug/EventTraceDrillerBus.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
|
||||
#define VS_VERSION_INFO 1
|
||||
#define IDD_CRITICAL_ERROR 101
|
||||
@@ -348,7 +349,7 @@ void DebugCallStack::ReportBug(const char* szErrorMessage)
|
||||
m_szBugMessage = NULL;
|
||||
}
|
||||
|
||||
void DebugCallStack::dumpCallStack(std::vector<string>& funcs)
|
||||
void DebugCallStack::dumpCallStack(std::vector<AZStd::string>& funcs)
|
||||
{
|
||||
WriteLineToLog("=============================================================================");
|
||||
int len = (int)funcs.size();
|
||||
@@ -364,7 +365,7 @@ void DebugCallStack::dumpCallStack(std::vector<string>& funcs)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void DebugCallStack::LogExceptionInfo(EXCEPTION_POINTERS* pex)
|
||||
{
|
||||
string path("");
|
||||
AZStd::string path("");
|
||||
if ((gEnv) && (gEnv->pFileIO))
|
||||
{
|
||||
const char* logAlias = gEnv->pFileIO->GetAlias("@log@");
|
||||
@@ -379,12 +380,12 @@ void DebugCallStack::LogExceptionInfo(EXCEPTION_POINTERS* pex)
|
||||
}
|
||||
}
|
||||
|
||||
string fileName = path;
|
||||
AZStd::string fileName = path;
|
||||
fileName += "error.log";
|
||||
|
||||
struct stat fileInfo;
|
||||
string timeStamp;
|
||||
string backupPath;
|
||||
AZStd::string timeStamp;
|
||||
AZStd::string backupPath;
|
||||
if (gEnv->IsDedicated())
|
||||
{
|
||||
backupPath = PathUtil::ToUnixPath(PathUtil::AddSlash(path + "DumpBackups"));
|
||||
@@ -399,8 +400,12 @@ void DebugCallStack::LogExceptionInfo(EXCEPTION_POINTERS* pex)
|
||||
strftime(tempBuffer, sizeof(tempBuffer), "%d %b %Y (%H %M %S)", &creationTime);
|
||||
timeStamp = tempBuffer;
|
||||
|
||||
string backupFileName = backupPath + timeStamp + " error.log";
|
||||
CopyFile(fileName.c_str(), backupFileName.c_str(), true);
|
||||
AZStd::string backupFileName = backupPath + timeStamp + " error.log";
|
||||
AZStd::wstring fileNameW;
|
||||
AZStd::to_wstring(fileNameW, fileName.c_str());
|
||||
AZStd::wstring backupFileNameW;
|
||||
AZStd::to_wstring(backupFileNameW, backupFileName.c_str());
|
||||
CopyFileW(fileNameW.c_str(), backupFileNameW.c_str(), true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -414,8 +419,8 @@ void DebugCallStack::LogExceptionInfo(EXCEPTION_POINTERS* pex)
|
||||
char versionbuf[1024];
|
||||
azstrcpy(versionbuf, AZ_ARRAY_SIZE(versionbuf), "");
|
||||
PutVersion(versionbuf, AZ_ARRAY_SIZE(versionbuf));
|
||||
cry_strcat(errorString, versionbuf);
|
||||
cry_strcat(errorString, "\n");
|
||||
azstrcat(errorString, AZ_ARRAY_SIZE(errorString), versionbuf);
|
||||
azstrcat(errorString, AZ_ARRAY_SIZE(errorString), "\n");
|
||||
|
||||
char excCode[MAX_WARNING_LENGTH];
|
||||
char excAddr[80];
|
||||
@@ -430,18 +435,18 @@ void DebugCallStack::LogExceptionInfo(EXCEPTION_POINTERS* pex)
|
||||
{
|
||||
const char* const szMessage = m_bIsFatalError ? s_szFatalErrorCode : m_szBugMessage;
|
||||
excName = szMessage;
|
||||
cry_strcpy(excCode, szMessage);
|
||||
cry_strcpy(excAddr, "");
|
||||
cry_strcpy(desc, "");
|
||||
cry_strcpy(m_excModule, "");
|
||||
cry_strcpy(excDesc, szMessage);
|
||||
azstrcpy(excCode, AZ_ARRAY_SIZE(excCode), szMessage);
|
||||
azstrcpy(excAddr, AZ_ARRAY_SIZE(excAddr), "");
|
||||
azstrcpy(desc, AZ_ARRAY_SIZE(desc), "");
|
||||
azstrcpy(m_excModule, AZ_ARRAY_SIZE(m_excModule), "");
|
||||
azstrcpy(excDesc, AZ_ARRAY_SIZE(excDesc), szMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf_s(excAddr, "0x%04X:0x%p", pex->ContextRecord->SegCs, pex->ExceptionRecord->ExceptionAddress);
|
||||
sprintf_s(excCode, "0x%08X", pex->ExceptionRecord->ExceptionCode);
|
||||
excName = TranslateExceptionCode(pex->ExceptionRecord->ExceptionCode);
|
||||
cry_strcpy(desc, "");
|
||||
azstrcpy(desc, AZ_ARRAY_SIZE(desc), "");
|
||||
sprintf_s(excDesc, "%s\r\n%s", excName, desc);
|
||||
|
||||
|
||||
@@ -471,9 +476,9 @@ void DebugCallStack::LogExceptionInfo(EXCEPTION_POINTERS* pex)
|
||||
WriteLineToLog("Exception Description: %s", desc);
|
||||
|
||||
|
||||
cry_strcpy(m_excDesc, excDesc);
|
||||
cry_strcpy(m_excAddr, excAddr);
|
||||
cry_strcpy(m_excCode, excCode);
|
||||
azstrcpy(m_excDesc, AZ_ARRAY_SIZE(m_excDesc), excDesc);
|
||||
azstrcpy(m_excAddr, AZ_ARRAY_SIZE(m_excAddr), excAddr);
|
||||
azstrcpy(m_excCode, AZ_ARRAY_SIZE(m_excCode), excCode);
|
||||
|
||||
|
||||
char errs[32768];
|
||||
@@ -481,9 +486,9 @@ void DebugCallStack::LogExceptionInfo(EXCEPTION_POINTERS* pex)
|
||||
excCode, excAddr, m_excModule, excName, desc);
|
||||
|
||||
|
||||
cry_strcat(errs, "\nCall Stack Trace:\n");
|
||||
azstrcat(errs, AZ_ARRAY_SIZE(errs), "\nCall Stack Trace:\n");
|
||||
|
||||
std::vector<string> funcs;
|
||||
std::vector<AZStd::string> funcs;
|
||||
{
|
||||
AZ::Debug::StackFrame frames[25];
|
||||
AZ::Debug::SymbolStorage::StackLine lines[AZ_ARRAY_SIZE(frames)];
|
||||
@@ -499,20 +504,20 @@ void DebugCallStack::LogExceptionInfo(EXCEPTION_POINTERS* pex)
|
||||
dumpCallStack(funcs);
|
||||
// Fill call stack.
|
||||
char str[s_iCallStackSize];
|
||||
cry_strcpy(str, "");
|
||||
azstrcpy(str, AZ_ARRAY_SIZE(str), "");
|
||||
for (unsigned int i = 0; i < funcs.size(); i++)
|
||||
{
|
||||
char temp[s_iCallStackSize];
|
||||
sprintf_s(temp, "%2zd) %s", funcs.size() - i, (const char*)funcs[i].c_str());
|
||||
cry_strcat(str, temp);
|
||||
cry_strcat(str, "\r\n");
|
||||
cry_strcat(errs, temp);
|
||||
cry_strcat(errs, "\n");
|
||||
azstrcat(str, AZ_ARRAY_SIZE(str), temp);
|
||||
azstrcat(str, AZ_ARRAY_SIZE(str), "\r\n");
|
||||
azstrcat(errs, AZ_ARRAY_SIZE(errs), temp);
|
||||
azstrcat(errs, AZ_ARRAY_SIZE(errs), "\n");
|
||||
}
|
||||
cry_strcpy(m_excCallstack, str);
|
||||
azstrcpy(m_excCallstack, AZ_ARRAY_SIZE(m_excCallstack), str);
|
||||
}
|
||||
|
||||
cry_strcat(errorString, errs);
|
||||
azstrcat(errorString, AZ_ARRAY_SIZE(errorString), errs);
|
||||
|
||||
if (f)
|
||||
{
|
||||
@@ -593,8 +598,12 @@ void DebugCallStack::LogExceptionInfo(EXCEPTION_POINTERS* pex)
|
||||
timeStamp = tempBuffer;
|
||||
}
|
||||
|
||||
string backupFileName = backupPath + timeStamp + " error.dmp";
|
||||
CopyFile(fileName.c_str(), backupFileName.c_str(), true);
|
||||
AZStd::string backupFileName = backupPath + timeStamp + " error.dmp";
|
||||
AZStd::wstring fileNameW;
|
||||
AZStd::to_wstring(fileNameW, fileName.c_str());
|
||||
AZStd::wstring backupFileNameW;
|
||||
AZStd::to_wstring(backupFileNameW, backupFileName.c_str());
|
||||
CopyFileW(fileNameW.c_str(), backupFileNameW.c_str(), true);
|
||||
}
|
||||
|
||||
CryEngineExceptionFilterMiniDump(pex, fileName.c_str(), mdumpValue);
|
||||
@@ -635,11 +644,11 @@ void DebugCallStack::LogExceptionInfo(EXCEPTION_POINTERS* pex)
|
||||
{
|
||||
if (SaveCurrentLevel())
|
||||
{
|
||||
MessageBox(NULL, "Level has been successfully saved!\r\nPress Ok to terminate Editor.", "Save", MB_OK);
|
||||
MessageBoxW(NULL, L"Level has been successfully saved!\r\nPress Ok to terminate Editor.", L"Save", MB_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox(NULL, "Error saving level.\r\nPress Ok to terminate Editor.", "Save", MB_OK | MB_ICONWARNING);
|
||||
MessageBoxW(NULL, L"Error saving level.\r\nPress Ok to terminate Editor.", L"Save", MB_OK | MB_ICONWARNING);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -818,7 +827,7 @@ void DebugCallStack::ResetFPU(EXCEPTION_POINTERS* pex)
|
||||
}
|
||||
}
|
||||
|
||||
string DebugCallStack::GetModuleNameForAddr(void* addr)
|
||||
AZStd::string DebugCallStack::GetModuleNameForAddr(void* addr)
|
||||
{
|
||||
if (m_modules.empty())
|
||||
{
|
||||
@@ -844,7 +853,7 @@ string DebugCallStack::GetModuleNameForAddr(void* addr)
|
||||
return m_modules.rbegin()->second;
|
||||
}
|
||||
|
||||
void DebugCallStack::GetProcNameForAddr(void* addr, string& procName, void*& baseAddr, string& filename, int& line)
|
||||
void DebugCallStack::GetProcNameForAddr(void* addr, AZStd::string& procName, void*& baseAddr, AZStd::string& filename, int& line)
|
||||
{
|
||||
AZ::Debug::SymbolStorage::StackLine func, file, module;
|
||||
AZ::Debug::SymbolStorage::FindFunctionFromIP(addr, &func, &file, &module, line, baseAddr);
|
||||
@@ -852,10 +861,10 @@ void DebugCallStack::GetProcNameForAddr(void* addr, string& procName, void*& bas
|
||||
filename = file;
|
||||
}
|
||||
|
||||
string DebugCallStack::GetCurrentFilename()
|
||||
AZStd::string DebugCallStack::GetCurrentFilename()
|
||||
{
|
||||
char fullpath[MAX_PATH_LENGTH + 1];
|
||||
GetModuleFileName(NULL, fullpath, MAX_PATH_LENGTH);
|
||||
AZ::Utils::GetExecutablePath(fullpath, MAX_PATH_LENGTH);
|
||||
return fullpath;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,20 +35,20 @@ public:
|
||||
|
||||
ISystem* GetSystem() { return m_pSystem; };
|
||||
|
||||
virtual string GetModuleNameForAddr(void* addr);
|
||||
virtual void GetProcNameForAddr(void* addr, string& procName, void*& baseAddr, string& filename, int& line);
|
||||
virtual string GetCurrentFilename();
|
||||
virtual AZStd::string GetModuleNameForAddr(void* addr);
|
||||
virtual void GetProcNameForAddr(void* addr, AZStd::string& procName, void*& baseAddr, AZStd::string& filename, int& line);
|
||||
virtual AZStd::string GetCurrentFilename();
|
||||
|
||||
void installErrorHandler(ISystem* pSystem);
|
||||
virtual int handleException(EXCEPTION_POINTERS* exception_pointer);
|
||||
|
||||
virtual void ReportBug(const char*);
|
||||
|
||||
void dumpCallStack(std::vector<string>& functions);
|
||||
void dumpCallStack(std::vector<AZStd::string>& functions);
|
||||
|
||||
void SetUserDialogEnable(const bool bUserDialogEnable);
|
||||
|
||||
typedef std::map<void*, string> TModules;
|
||||
typedef std::map<void*, AZStd::string> TModules;
|
||||
protected:
|
||||
static void RemoveOldFiles();
|
||||
static void RemoveFile(const char* szFileName);
|
||||
|
||||
@@ -187,7 +187,7 @@ AZ_PUSH_DISABLE_WARNING(4996, "-Wunknown-warning-option")
|
||||
azstrcat(str, length, "\n");
|
||||
|
||||
#if AZ_LEGACY_CRYSYSTEM_TRAIT_DEBUGCALLSTACK_APPEND_MODULENAME
|
||||
GetModuleFileNameA(NULL, s, sizeof(s));
|
||||
AZ::Utils::GetExecutablePath(s, sizeof(s));
|
||||
|
||||
// Log EXE filename only if possible (not full EXE path which could contain sensitive info)
|
||||
AZStd::string exeName;
|
||||
@@ -237,7 +237,7 @@ void IDebugCallStack::WriteLineToLog(const char* format, ...)
|
||||
char szBuffer[MAX_WARNING_LENGTH];
|
||||
va_start(ArgList, format);
|
||||
vsnprintf_s(szBuffer, sizeof(szBuffer), sizeof(szBuffer) - 1, format, ArgList);
|
||||
cry_strcat(szBuffer, "\n");
|
||||
azstrcat(szBuffer, MAX_WARNING_LENGTH, "\n");
|
||||
szBuffer[sizeof(szBuffer) - 1] = '\0';
|
||||
va_end(ArgList);
|
||||
|
||||
|
||||
@@ -33,23 +33,19 @@ public:
|
||||
virtual int handleException([[maybe_unused]] EXCEPTION_POINTERS* exception_pointer){return 0; }
|
||||
|
||||
// returns the module name of a given address
|
||||
virtual string GetModuleNameForAddr([[maybe_unused]] void* addr) { return "[unknown]"; }
|
||||
virtual AZStd::string GetModuleNameForAddr([[maybe_unused]] void* addr) { return "[unknown]"; }
|
||||
|
||||
// returns the function name of a given address together with source file and line number (if available) of a given address
|
||||
virtual void GetProcNameForAddr(void* addr, string& procName, void*& baseAddr, string& filename, int& line)
|
||||
virtual void GetProcNameForAddr(void* addr, AZStd::string& procName, void*& baseAddr, AZStd::string& filename, int& line)
|
||||
{
|
||||
filename = "[unknown]";
|
||||
line = 0;
|
||||
baseAddr = addr;
|
||||
#if defined(PLATFORM_64BIT)
|
||||
procName.Format("[%016llX]", addr);
|
||||
#else
|
||||
procName.Format("[%08X]", addr);
|
||||
#endif
|
||||
procName = AZStd::string::format("[%p]", addr);
|
||||
}
|
||||
|
||||
// returns current filename
|
||||
virtual string GetCurrentFilename() { return "[unknown]"; }
|
||||
virtual AZStd::string GetCurrentFilename() { return "[unknown]"; }
|
||||
|
||||
//! Dumps Current Call Stack to log.
|
||||
virtual void LogCallstack();
|
||||
|
||||
@@ -476,7 +476,7 @@ CLevelInfo* CLevelSystem::GetLevelInfoInternal(const AZStd::string& levelName)
|
||||
for (AZStd::vector<CLevelInfo>::iterator it = m_levelInfos.begin(); it != m_levelInfos.end(); ++it)
|
||||
{
|
||||
{
|
||||
if (!azstricmp(PathUtil::GetFileName(it->GetName()), levelName.c_str()))
|
||||
if (!azstricmp(PathUtil::GetFileName(it->GetName()).c_str(), levelName.c_str()))
|
||||
{
|
||||
return &(*it);
|
||||
}
|
||||
@@ -563,7 +563,7 @@ ILevel* CLevelSystem::LoadLevelInternal(const char* _levelName)
|
||||
INDENT_LOG_DURING_SCOPE();
|
||||
|
||||
char levelName[256];
|
||||
cry_strcpy(levelName, _levelName);
|
||||
azstrcpy(levelName, AZ_ARRAY_SIZE(levelName), _levelName);
|
||||
|
||||
// Not remove a scope!!!
|
||||
{
|
||||
|
||||
@@ -20,12 +20,12 @@
|
||||
#include "System.h" // to access InitLocalization()
|
||||
#include <CryPath.h>
|
||||
#include <IConsole.h>
|
||||
#include <StringUtils.h>
|
||||
#include <locale.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
#include <AzFramework/StringFunc/StringFunc.h>
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
|
||||
#define MAX_CELL_COUNT 32
|
||||
|
||||
@@ -146,9 +146,9 @@ static void ReloadDialogData([[maybe_unused]] IConsoleCmdArgs* pArgs)
|
||||
#if !defined(_RELEASE)
|
||||
static void TestFormatMessage ([[maybe_unused]] IConsoleCmdArgs* pArgs)
|
||||
{
|
||||
string fmt1 ("abc %1 def % gh%2i %");
|
||||
string fmt2 ("abc %[action:abc] %2 def % gh%1i %1");
|
||||
string out1, out2;
|
||||
AZStd::string fmt1 ("abc %1 def % gh%2i %");
|
||||
AZStd::string fmt2 ("abc %[action:abc] %2 def % gh%1i %1");
|
||||
AZStd::string out1, out2;
|
||||
LocalizationManagerRequestBus::Broadcast(&LocalizationManagerRequestBus::Events::FormatStringMessage, out1, fmt1, "first", "second", "third", nullptr);
|
||||
CryLogAlways("%s", out1.c_str());
|
||||
LocalizationManagerRequestBus::Broadcast(&LocalizationManagerRequestBus::Events::FormatStringMessage, out2, fmt2, "second", nullptr, nullptr, nullptr);
|
||||
@@ -206,18 +206,18 @@ CLocalizedStringsManager::CLocalizedStringsManager(ISystem* pSystem)
|
||||
|
||||
// Populate available languages by scanning the localization directory for paks
|
||||
// Default to US English if language is not supported
|
||||
string sPath;
|
||||
const string sLocalizationFolder(PathUtil::GetLocalizationFolder());
|
||||
AZStd::string sPath;
|
||||
const AZStd::string sLocalizationFolder(PathUtil::GetLocalizationFolder());
|
||||
ILocalizationManager::TLocalizationBitfield availableLanguages = 0;
|
||||
|
||||
AZ::IO::FileIOBase* fileIO = AZ::IO::FileIOBase::GetInstance();
|
||||
// test language name against supported languages
|
||||
for (int i = 0; i < ILocalizationManager::ePILID_MAX_OR_INVALID; i++)
|
||||
{
|
||||
string sCurrentLanguage = LangNameFromPILID((ILocalizationManager::EPlatformIndependentLanguageID)i);
|
||||
AZStd::string sCurrentLanguage = LangNameFromPILID((ILocalizationManager::EPlatformIndependentLanguageID)i);
|
||||
sPath = sLocalizationFolder.c_str() + sCurrentLanguage;
|
||||
sPath.MakeLower();
|
||||
if (fileIO && fileIO->IsDirectory(sPath))
|
||||
AZStd::to_lower(sPath.begin(), sPath.end());
|
||||
if (fileIO && fileIO->IsDirectory(sPath.c_str()))
|
||||
{
|
||||
availableLanguages |= ILocalizationManager::LocalizationBitfieldFromPILID((ILocalizationManager::EPlatformIndependentLanguageID)i);
|
||||
if (m_cvarLocalizationDebug >= 2)
|
||||
@@ -366,7 +366,7 @@ bool CLocalizedStringsManager::SetLanguage(const char* sLanguage)
|
||||
// Check if already language loaded.
|
||||
for (uint32 i = 0; i < m_languages.size(); i++)
|
||||
{
|
||||
if (_stricmp(sLanguage, m_languages[i]->sLanguage) == 0)
|
||||
if (_stricmp(sLanguage, m_languages[i]->sLanguage.c_str()) == 0)
|
||||
{
|
||||
InternalSetCurrentLanguage(m_languages[i]);
|
||||
return true;
|
||||
@@ -441,9 +441,9 @@ void CLocalizedStringsManager::AddControl([[maybe_unused]] int nKey)
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CLocalizedStringsManager::ParseFirstLine(IXmlTableReader* pXmlTableReader, char* nCellIndexToType, std::map<int, string>& SoundMoodIndex, std::map<int, string>& EventParameterIndex)
|
||||
void CLocalizedStringsManager::ParseFirstLine(IXmlTableReader* pXmlTableReader, char* nCellIndexToType, std::map<int, AZStd::string>& SoundMoodIndex, std::map<int, AZStd::string>& EventParameterIndex)
|
||||
{
|
||||
string sCellContent;
|
||||
AZStd::string sCellContent;
|
||||
|
||||
for (;; )
|
||||
{
|
||||
@@ -466,7 +466,7 @@ void CLocalizedStringsManager::ParseFirstLine(IXmlTableReader* pXmlTableReader,
|
||||
}
|
||||
|
||||
sCellContent.assign(pContent, contentSize);
|
||||
sCellContent.MakeLower();
|
||||
AZStd::to_lower(sCellContent.begin(), sCellContent.end());
|
||||
|
||||
for (int i = 0; i < sizeof(sLocalizedColumnNames) / sizeof(sLocalizedColumnNames[0]); ++i)
|
||||
{
|
||||
@@ -528,15 +528,15 @@ static void CopyLowercase(char* dst, size_t dstSize, const char* src, size_t src
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
static void ReplaceEndOfLine(CryFixedStringT<CLocalizedStringsManager::LOADING_FIXED_STRING_LENGTH>& s)
|
||||
static void ReplaceEndOfLine(AZStd::fixed_string<CLocalizedStringsManager::LOADING_FIXED_STRING_LENGTH>& s)
|
||||
{
|
||||
const string oldSubstr("\\n");
|
||||
const string newSubstr(" \n");
|
||||
const AZStd::string oldSubstr("\\n");
|
||||
const AZStd::string newSubstr(" \n");
|
||||
size_t pos = 0;
|
||||
for (;; )
|
||||
{
|
||||
pos = s.find(oldSubstr, pos);
|
||||
if (pos == CryFixedStringT<CLocalizedStringsManager::LOADING_FIXED_STRING_LENGTH>::npos)
|
||||
if (pos == AZStd::fixed_string<CLocalizedStringsManager::LOADING_FIXED_STRING_LENGTH>::npos)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -565,7 +565,7 @@ void CLocalizedStringsManager::OnSystemEvent(
|
||||
|
||||
for (TStringVec::iterator it = m_tagLoadRequests.begin(); it != m_tagLoadRequests.end(); ++it)
|
||||
{
|
||||
LoadLocalizationDataByTag(*it);
|
||||
LoadLocalizationDataByTag(it->c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -577,7 +577,7 @@ void CLocalizedStringsManager::OnSystemEvent(
|
||||
// Load all tags after the Editor has finished initialization.
|
||||
for (TTagFileNames::iterator it = m_tagFileNames.begin(); it != m_tagFileNames.end(); ++it)
|
||||
{
|
||||
LoadLocalizationDataByTag(it->first);
|
||||
LoadLocalizationDataByTag(it->first.c_str());
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -600,7 +600,7 @@ bool CLocalizedStringsManager::InitLocalizationData(
|
||||
for (int i = 0; i < root->getChildCount(); i++)
|
||||
{
|
||||
XmlNodeRef typeNode = root->getChild(i);
|
||||
string sType = typeNode->getTag();
|
||||
AZStd::string sType = typeNode->getTag();
|
||||
|
||||
// tags should be unique
|
||||
if (m_tagFileNames.find(sType) != m_tagFileNames.end())
|
||||
@@ -678,9 +678,9 @@ bool CLocalizedStringsManager::LoadLocalizationDataByTag(
|
||||
for (TStringVec::iterator it2 = vEntries.begin(); it2 != vEntries.end(); ++it2)
|
||||
{
|
||||
//Only load files of the correct type for the configured format
|
||||
if ((m_cvarLocalizationFormat == 0 && strstr(*it2, ".xml")) || (m_cvarLocalizationFormat == 1 && strstr(*it2, ".agsxml")))
|
||||
if ((m_cvarLocalizationFormat == 0 && strstr(it2->c_str(), ".xml")) || (m_cvarLocalizationFormat == 1 && strstr(it2->c_str(), ".agsxml")))
|
||||
{
|
||||
bResult &= (this->*loadFunction)(*it2, it->second.id, bReload);
|
||||
bResult &= (this->*loadFunction)(it2->c_str(), it->second.id, bReload);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -824,7 +824,7 @@ bool CLocalizedStringsManager::LoadAllLocalizationData(bool bReload)
|
||||
{
|
||||
for (TTagFileNames::iterator it = m_tagFileNames.begin(); it != m_tagFileNames.end(); ++it)
|
||||
{
|
||||
if(!LoadLocalizationDataByTag(it->first, bReload))
|
||||
if(!LoadLocalizationDataByTag(it->first.c_str(), bReload))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -837,6 +837,37 @@ bool CLocalizedStringsManager::LoadExcelXmlSpreadsheet(const char* sFileName, bo
|
||||
return (this->*loadFunction)(sFileName, 0, bReload);
|
||||
}
|
||||
|
||||
enum class YesNoType
|
||||
{
|
||||
Yes,
|
||||
No,
|
||||
Invalid
|
||||
};
|
||||
|
||||
// parse the yes/no string
|
||||
/*!
|
||||
\param szString any of the following strings: yes, enable, true, 1, no, disable, false, 0
|
||||
\return YesNoType::Yes if szString is yes/enable/true/1, YesNoType::No if szString is no, disable, false, 0 and YesNoType::Invalid if the string is not one of the expected values.
|
||||
*/
|
||||
inline YesNoType ToYesNoType(const char* szString)
|
||||
{
|
||||
if (!_stricmp(szString, "yes")
|
||||
|| !_stricmp(szString, "enable")
|
||||
|| !_stricmp(szString, "true")
|
||||
|| !_stricmp(szString, "1"))
|
||||
{
|
||||
return YesNoType::Yes;
|
||||
}
|
||||
if (!_stricmp(szString, "no")
|
||||
|| !_stricmp(szString, "disable")
|
||||
|| !_stricmp(szString, "false")
|
||||
|| !_stricmp(szString, "0"))
|
||||
{
|
||||
return YesNoType::No;
|
||||
}
|
||||
return YesNoType::Invalid;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Loads a string-table from a Excel XML Spreadsheet file.
|
||||
bool CLocalizedStringsManager::DoLoadExcelXmlSpreadsheet(const char* sFileName, uint8 nTagID, bool bReload)
|
||||
@@ -850,7 +881,7 @@ bool CLocalizedStringsManager::DoLoadExcelXmlSpreadsheet(const char* sFileName,
|
||||
//check if this table has already been loaded
|
||||
if (!bReload)
|
||||
{
|
||||
if (m_loadedTables.find(CONST_TEMP_STRING(sFileName)) != m_loadedTables.end())
|
||||
if (m_loadedTables.find(AZStd::string(sFileName)) != m_loadedTables.end())
|
||||
{
|
||||
return (true);
|
||||
}
|
||||
@@ -866,12 +897,12 @@ bool CLocalizedStringsManager::DoLoadExcelXmlSpreadsheet(const char* sFileName,
|
||||
}
|
||||
|
||||
XmlNodeRef root;
|
||||
string sPath;
|
||||
AZStd::string sPath;
|
||||
{
|
||||
const string sLocalizationFolder(PathUtil::GetLocalizationRoot());
|
||||
const string& languageFolder = m_pLanguage->sLanguage;
|
||||
const AZStd::string sLocalizationFolder(PathUtil::GetLocalizationRoot());
|
||||
const AZStd::string& languageFolder = m_pLanguage->sLanguage;
|
||||
sPath = sLocalizationFolder.c_str() + languageFolder + PathUtil::GetSlash() + sFileName;
|
||||
root = m_pSystem->LoadXmlFromFile(sPath);
|
||||
root = m_pSystem->LoadXmlFromFile(sPath.c_str());
|
||||
if (!root)
|
||||
{
|
||||
CryLog("Loading Localization File %s failed!", sPath.c_str());
|
||||
@@ -948,14 +979,14 @@ bool CLocalizedStringsManager::DoLoadExcelXmlSpreadsheet(const char* sFileName,
|
||||
memset(nCellIndexToType, 0, sizeof(nCellIndexToType));
|
||||
|
||||
// SoundMood Index
|
||||
std::map<int, string> SoundMoodIndex;
|
||||
std::map<int, AZStd::string> SoundMoodIndex;
|
||||
|
||||
// EventParameter Index
|
||||
std::map<int, string> EventParameterIndex;
|
||||
std::map<int, AZStd::string> EventParameterIndex;
|
||||
|
||||
bool bFirstRow = true;
|
||||
|
||||
CryFixedStringT<LOADING_FIXED_STRING_LENGTH> sTmp;
|
||||
AZStd::fixed_string<LOADING_FIXED_STRING_LENGTH> sTmp;
|
||||
|
||||
// lower case event name
|
||||
char szLowerCaseEvent[128];
|
||||
@@ -1083,7 +1114,7 @@ bool CLocalizedStringsManager::DoLoadExcelXmlSpreadsheet(const char* sFileName,
|
||||
break;
|
||||
case ELOCALIZED_COLUMN_USE_SUBTITLE:
|
||||
sTmp.assign(cell.ptr, cell.count);
|
||||
bUseSubtitle = CryStringUtils::ToYesNoType(sTmp.c_str()) == CryStringUtils::YesNoType::No ? false : true; // favor yes (yes and invalid -> yes)
|
||||
bUseSubtitle = ToYesNoType(sTmp.c_str()) == YesNoType::No ? false : true; // favor yes (yes and invalid -> yes)
|
||||
break;
|
||||
case ELOCALIZED_COLUMN_VOLUME:
|
||||
sTmp.assign(cell.ptr, cell.count);
|
||||
@@ -1121,7 +1152,7 @@ bool CLocalizedStringsManager::DoLoadExcelXmlSpreadsheet(const char* sFileName,
|
||||
{
|
||||
bIsIntercepted = true;
|
||||
}
|
||||
bIsDirectRadio = bIsIntercepted || (CryStringUtils::ToYesNoType(sTmp.c_str()) == CryStringUtils::YesNoType::Yes ? true : false); // favor no (no and invalid -> no)
|
||||
bIsDirectRadio = bIsIntercepted || (ToYesNoType(sTmp.c_str()) == YesNoType::Yes ? true : false); // favor no (no and invalid -> no)
|
||||
++nItems;
|
||||
break;
|
||||
// legacy names
|
||||
@@ -1358,7 +1389,7 @@ bool CLocalizedStringsManager::DoLoadExcelXmlSpreadsheet(const char* sFileName,
|
||||
}
|
||||
else
|
||||
{
|
||||
pEntry->TranslatedText.psUtf8Uncompressed = new string(sTmp.c_str(), sTmp.c_str() + sTmp.length());
|
||||
pEntry->TranslatedText.psUtf8Uncompressed = new AZStd::string(sTmp.c_str(), sTmp.c_str() + sTmp.length());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1367,7 +1398,7 @@ bool CLocalizedStringsManager::DoLoadExcelXmlSpreadsheet(const char* sFileName,
|
||||
// the CryString makes sure, that only the ref-count is increment on assignment
|
||||
if (*szLowerCaseEvent)
|
||||
{
|
||||
PrototypeSoundEvents::iterator it = m_prototypeEvents.find(CONST_TEMP_STRING(szLowerCaseEvent));
|
||||
PrototypeSoundEvents::iterator it = m_prototypeEvents.find(AZStd::string(szLowerCaseEvent));
|
||||
if (it != m_prototypeEvents.end())
|
||||
{
|
||||
pEntry->sPrototypeSoundEvent = *it;
|
||||
@@ -1384,8 +1415,8 @@ bool CLocalizedStringsManager::DoLoadExcelXmlSpreadsheet(const char* sFileName,
|
||||
{
|
||||
sTmp.assign(sWho.ptr, sWho.count);
|
||||
ReplaceEndOfLine(sTmp);
|
||||
sTmp.replace(" ", "_");
|
||||
string tmp;
|
||||
AZStd::replace(sTmp.begin(), sTmp.end(), ' ', '_');
|
||||
AZStd::string tmp;
|
||||
{
|
||||
tmp = sTmp.c_str();
|
||||
}
|
||||
@@ -1531,19 +1562,19 @@ bool CLocalizedStringsManager::DoLoadAGSXmlDocument(const char* sFileName, uint8
|
||||
}
|
||||
if (!bReload)
|
||||
{
|
||||
if (m_loadedTables.find(CONST_TEMP_STRING(sFileName)) != m_loadedTables.end())
|
||||
if (m_loadedTables.find(AZStd::string(sFileName)) != m_loadedTables.end())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
ListAndClearProblemLabels();
|
||||
XmlNodeRef root;
|
||||
string sPath;
|
||||
AZStd::string sPath;
|
||||
{
|
||||
const string sLocalizationFolder(PathUtil::GetLocalizationRoot());
|
||||
const string& languageFolder = m_pLanguage->sLanguage;
|
||||
const AZStd::string sLocalizationFolder(PathUtil::GetLocalizationRoot());
|
||||
const AZStd::string& languageFolder = m_pLanguage->sLanguage;
|
||||
sPath = sLocalizationFolder.c_str() + languageFolder + PathUtil::GetSlash() + sFileName;
|
||||
root = m_pSystem->LoadXmlFromFile(sPath);
|
||||
root = m_pSystem->LoadXmlFromFile(sPath.c_str());
|
||||
if (!root)
|
||||
{
|
||||
AZ_TracePrintf(LOC_WINDOW, "Loading Localization File %s failed!", sPath.c_str());
|
||||
@@ -1609,7 +1640,7 @@ bool CLocalizedStringsManager::DoLoadAGSXmlDocument(const char* sFileName, uint8
|
||||
{
|
||||
continue;
|
||||
}
|
||||
AzFramework::StringFunc::Replace(textValue, "\\n", " \n"); // carried over from helper func ReplaceEndOfLine(CryFixedStringT<>& s)
|
||||
AzFramework::StringFunc::Replace(textValue, "\\n", " \n");
|
||||
if (keyString[0] == '@')
|
||||
{
|
||||
AzFramework::StringFunc::LChop(keyString, 1);
|
||||
@@ -1654,7 +1685,7 @@ bool CLocalizedStringsManager::DoLoadAGSXmlDocument(const char* sFileName, uint8
|
||||
}
|
||||
else
|
||||
{
|
||||
pEntry->TranslatedText.psUtf8Uncompressed = new string(textString, textString + textLength);
|
||||
pEntry->TranslatedText.psUtf8Uncompressed = new AZStd::string(textString, textString + textLength);
|
||||
}
|
||||
}
|
||||
{
|
||||
@@ -1714,7 +1745,7 @@ void CLocalizedStringsManager::ReloadData()
|
||||
FreeLocalizationData();
|
||||
for (tmapFilenames::iterator it = temp.begin(); it != temp.end(); it++)
|
||||
{
|
||||
(this->*loadFunction)((*it).first, (*it).second.nTagID, true);
|
||||
(this->*loadFunction)((*it).first.c_str(), (*it).second.nTagID, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1732,19 +1763,19 @@ void CLocalizedStringsManager::AddLocalizedString(SLanguage* pLanguage, SLocaliz
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CLocalizedStringsManager::LocalizeString_ch(const char* sString, string& outLocalizedString, bool bEnglish)
|
||||
bool CLocalizedStringsManager::LocalizeString_ch(const char* sString, AZStd::string& outLocalizedString, bool bEnglish)
|
||||
{
|
||||
return LocalizeStringInternal(sString, strlen(sString), outLocalizedString, bEnglish);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CLocalizedStringsManager::LocalizeString_s(const string& sString, string& outLocalizedString, bool bEnglish)
|
||||
bool CLocalizedStringsManager::LocalizeString_s(const AZStd::string& sString, AZStd::string& outLocalizedString, bool bEnglish)
|
||||
{
|
||||
return LocalizeStringInternal(sString.c_str(), sString.length(), outLocalizedString, bEnglish);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CLocalizedStringsManager::LocalizeStringInternal(const char* pStr, size_t len, string& outLocalizedString, bool bEnglish)
|
||||
bool CLocalizedStringsManager::LocalizeStringInternal(const char* pStr, size_t len, AZStd::string& outLocalizedString, bool bEnglish)
|
||||
{
|
||||
assert (m_pLanguage);
|
||||
if (m_pLanguage == 0)
|
||||
@@ -1755,7 +1786,7 @@ bool CLocalizedStringsManager::LocalizeStringInternal(const char* pStr, size_t l
|
||||
}
|
||||
|
||||
// note: we don't write directly to outLocalizedString, in case it aliases pStr
|
||||
string out;
|
||||
AZStd::string out;
|
||||
|
||||
// scan the string
|
||||
const char* pPos = pStr;
|
||||
@@ -1783,8 +1814,8 @@ bool CLocalizedStringsManager::LocalizeStringInternal(const char* pStr, size_t l
|
||||
}
|
||||
|
||||
// localize token
|
||||
string token(pLabel, pLabelEnd);
|
||||
string sLocalizedToken;
|
||||
AZStd::string token(pLabel, pLabelEnd);
|
||||
AZStd::string sLocalizedToken;
|
||||
if (bEnglish)
|
||||
{
|
||||
GetEnglishString(token.c_str(), sLocalizedToken);
|
||||
@@ -1803,7 +1834,7 @@ bool CLocalizedStringsManager::LocalizeStringInternal(const char* pStr, size_t l
|
||||
|
||||
void CLocalizedStringsManager::LocalizeAndSubstituteInternal(AZStd::string& locString, const AZStd::vector<AZStd::string>& keys, const AZStd::vector<AZStd::string>& values)
|
||||
{
|
||||
string outString;
|
||||
AZStd::string outString;
|
||||
LocalizeString_ch(locString.c_str(), outString);
|
||||
locString = outString .c_str();
|
||||
if (values.size() != keys.size())
|
||||
@@ -1866,7 +1897,7 @@ static void LogDecompTimer(__int64 nTotalTicks, __int64 nDecompTicks, __int64 nA
|
||||
}
|
||||
#endif
|
||||
|
||||
string CLocalizedStringsManager::SLocalizedStringEntry::GetTranslatedText(const SLanguage* pLanguage) const
|
||||
AZStd::string CLocalizedStringsManager::SLocalizedStringEntry::GetTranslatedText(const SLanguage* pLanguage) const
|
||||
{
|
||||
FUNCTION_PROFILER_FAST(GetISystem(), PROFILE_SYSTEM, g_bProfilerEnabled);
|
||||
if ((flags & IS_COMPRESSED) != 0)
|
||||
@@ -1876,7 +1907,7 @@ string CLocalizedStringsManager::SLocalizedStringEntry::GetTranslatedText(const
|
||||
nTotalTicks = CryGetTicks();
|
||||
#endif //LOG_DECOMP_TIMES
|
||||
|
||||
string outputString;
|
||||
AZStd::string outputString;
|
||||
if (TranslatedText.szCompressed != NULL)
|
||||
{
|
||||
uint8 decompressionBuffer[COMPRESSION_FIXED_BUFFER_LENGTH];
|
||||
@@ -1923,7 +1954,7 @@ string CLocalizedStringsManager::SLocalizedStringEntry::GetTranslatedText(const
|
||||
}
|
||||
else
|
||||
{
|
||||
string emptyOutputString;
|
||||
AZStd::string emptyOutputString;
|
||||
return emptyOutputString;
|
||||
}
|
||||
}
|
||||
@@ -1949,7 +1980,7 @@ void CLocalizedStringsManager::ListAndClearProblemLabels()
|
||||
CryLog ("These labels caused localization problems:");
|
||||
INDENT_LOG_DURING_SCOPE();
|
||||
|
||||
for (std::map<string, bool>::iterator iter = m_warnedAboutLabels.begin(); iter != m_warnedAboutLabels.end(); iter++)
|
||||
for (std::map<AZStd::string, bool>::iterator iter = m_warnedAboutLabels.begin(); iter != m_warnedAboutLabels.end(); iter++)
|
||||
{
|
||||
CryLog ("%s", iter->first.c_str());
|
||||
}
|
||||
@@ -1961,7 +1992,7 @@ void CLocalizedStringsManager::ListAndClearProblemLabels()
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CLocalizedStringsManager::LocalizeLabel(const char* sLabel, string& outLocalString, bool bEnglish)
|
||||
bool CLocalizedStringsManager::LocalizeLabel(const char* sLabel, AZStd::string& outLocalString, bool bEnglish)
|
||||
{
|
||||
assert(sLabel);
|
||||
if (!m_pLanguage || !sLabel)
|
||||
@@ -1979,8 +2010,7 @@ bool CLocalizedStringsManager::LocalizeLabel(const char* sLabel, string& outLoca
|
||||
|
||||
if (entry != NULL)
|
||||
{
|
||||
|
||||
string translatedText = entry->GetTranslatedText(m_pLanguage);
|
||||
AZStd::string translatedText = entry->GetTranslatedText(m_pLanguage);
|
||||
if ((bEnglish || translatedText.empty()) && entry->pEditorExtension != NULL)
|
||||
{
|
||||
//assert(!"No Localization Text available!");
|
||||
@@ -2011,7 +2041,7 @@ bool CLocalizedStringsManager::LocalizeLabel(const char* sLabel, string& outLoca
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CLocalizedStringsManager::GetEnglishString(const char* sKey, string& sLocalizedString)
|
||||
bool CLocalizedStringsManager::GetEnglishString(const char* sKey, AZStd::string& sLocalizedString)
|
||||
{
|
||||
assert(sKey);
|
||||
if (!m_pLanguage || !sKey)
|
||||
@@ -2086,7 +2116,7 @@ bool CLocalizedStringsManager::GetLocalizedInfoByKey(const char* sKey, SLocalize
|
||||
const SLocalizedStringEntry* entry = stl::find_in_map(m_pLanguage->m_keysMap, keyCRC32, NULL);
|
||||
if (entry != NULL)
|
||||
{
|
||||
outGameInfo.szCharacterName = entry->sCharacterName;
|
||||
outGameInfo.szCharacterName = entry->sCharacterName.c_str();
|
||||
outGameInfo.sUtf8TranslatedText = entry->GetTranslatedText(m_pLanguage);
|
||||
|
||||
outGameInfo.bUseSubtitle = (entry->flags & SLocalizedStringEntry::USE_SUBTITLE);
|
||||
@@ -2119,7 +2149,7 @@ bool CLocalizedStringsManager::GetLocalizedInfoByKey(const char* sKey, SLocalize
|
||||
{
|
||||
bResult = true;
|
||||
|
||||
pOutSoundInfo->szCharacterName = pEntry->sCharacterName;
|
||||
pOutSoundInfo->szCharacterName = pEntry->sCharacterName.c_str();
|
||||
pOutSoundInfo->sUtf8TranslatedText = pEntry->GetTranslatedText(m_pLanguage);
|
||||
|
||||
//pOutSoundInfo->sOriginalActorLine = pEntry->sOriginalActorLine.c_str();
|
||||
@@ -2213,7 +2243,7 @@ bool CLocalizedStringsManager::GetLocalizedInfoByIndex(int nIndex, SLocalizedInf
|
||||
}
|
||||
const SLocalizedStringEntry* pEntry = entryVec[nIndex];
|
||||
|
||||
outGameInfo.szCharacterName = pEntry->sCharacterName;
|
||||
outGameInfo.szCharacterName = pEntry->sCharacterName.c_str();
|
||||
outGameInfo.sUtf8TranslatedText = pEntry->GetTranslatedText(m_pLanguage);
|
||||
|
||||
outGameInfo.bUseSubtitle = (pEntry->flags & SLocalizedStringEntry::USE_SUBTITLE);
|
||||
@@ -2233,18 +2263,18 @@ bool CLocalizedStringsManager::GetLocalizedInfoByIndex(int nIndex, SLocalizedInf
|
||||
return false;
|
||||
}
|
||||
const SLocalizedStringEntry* pEntry = entryVec[nIndex];
|
||||
outEditorInfo.szCharacterName = pEntry->sCharacterName;
|
||||
outEditorInfo.szCharacterName = pEntry->sCharacterName.c_str();
|
||||
outEditorInfo.sUtf8TranslatedText = pEntry->GetTranslatedText(m_pLanguage);
|
||||
|
||||
assert(pEntry->pEditorExtension != NULL);
|
||||
|
||||
outEditorInfo.sKey = pEntry->pEditorExtension->sKey;
|
||||
outEditorInfo.sKey = pEntry->pEditorExtension->sKey.c_str();
|
||||
|
||||
outEditorInfo.sOriginalActorLine = pEntry->pEditorExtension->sOriginalActorLine;
|
||||
outEditorInfo.sUtf8TranslatedActorLine = pEntry->pEditorExtension->sUtf8TranslatedActorLine;
|
||||
outEditorInfo.sOriginalActorLine = pEntry->pEditorExtension->sOriginalActorLine.c_str();
|
||||
outEditorInfo.sUtf8TranslatedActorLine = pEntry->pEditorExtension->sUtf8TranslatedActorLine.c_str();
|
||||
|
||||
//outEditorInfo.sOriginalText = pEntry->sOriginalText;
|
||||
outEditorInfo.sOriginalCharacterName = pEntry->pEditorExtension->sOriginalCharacterName;
|
||||
outEditorInfo.sOriginalCharacterName = pEntry->pEditorExtension->sOriginalCharacterName.c_str();
|
||||
|
||||
outEditorInfo.nRow = pEntry->pEditorExtension->nRow;
|
||||
outEditorInfo.bUseSubtitle = (pEntry->flags & SLocalizedStringEntry::USE_SUBTITLE);
|
||||
@@ -2252,7 +2282,7 @@ bool CLocalizedStringsManager::GetLocalizedInfoByIndex(int nIndex, SLocalizedInf
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CLocalizedStringsManager::GetSubtitle(const char* sKeyOrLabel, string& outSubtitle, bool bForceSubtitle)
|
||||
bool CLocalizedStringsManager::GetSubtitle(const char* sKeyOrLabel, AZStd::string& outSubtitle, bool bForceSubtitle)
|
||||
{
|
||||
assert(sKeyOrLabel);
|
||||
if (!m_pLanguage || !sKeyOrLabel || !*sKeyOrLabel)
|
||||
@@ -2300,21 +2330,20 @@ bool CLocalizedStringsManager::GetSubtitle(const char* sKeyOrLabel, string& outS
|
||||
}
|
||||
}
|
||||
|
||||
template<typename StringClass, typename CharType>
|
||||
void InternalFormatStringMessage(StringClass& outString, const StringClass& sString, const CharType** sParams, int nParams)
|
||||
void InternalFormatStringMessage(AZStd::string& outString, const AZStd::string& sString, const char** sParams, int nParams)
|
||||
{
|
||||
static const CharType token = (CharType) '%';
|
||||
static const CharType tokens1[2] = { token, (CharType) '\0' };
|
||||
static const CharType tokens2[3] = { token, token, (CharType) '\0' };
|
||||
static const char token = '%';
|
||||
static const char tokens1[2] = { token, '\0' };
|
||||
static const char tokens2[3] = { token, token, '\0' };
|
||||
|
||||
int maxArgUsed = 0;
|
||||
int lastPos = 0;
|
||||
int curPos = 0;
|
||||
size_t lastPos = 0;
|
||||
size_t curPos = 0;
|
||||
const int sourceLen = static_cast<int>(sString.length());
|
||||
while (true)
|
||||
{
|
||||
int foundPos = static_cast<int>(sString.find(token, curPos));
|
||||
if (foundPos != string::npos)
|
||||
auto foundPos = sString.find(token, curPos);
|
||||
if (foundPos != AZStd::string::npos)
|
||||
{
|
||||
if (foundPos + 1 < sourceLen)
|
||||
{
|
||||
@@ -2331,8 +2360,8 @@ void InternalFormatStringMessage(StringClass& outString, const StringClass& sStr
|
||||
}
|
||||
else
|
||||
{
|
||||
StringClass tmp (sString);
|
||||
tmp.replace(tokens1, tokens2);
|
||||
AZStd::string tmp(sString);
|
||||
AZ::StringFunc::Replace(tmp, tokens1, tokens2);
|
||||
if constexpr (sizeof(*tmp.c_str()) == sizeof(char))
|
||||
{
|
||||
CryWarning(VALIDATOR_MODULE_SYSTEM, VALIDATOR_WARNING, "Parameter for argument %d is missing. [%s]", nArg + 1, (const char*)tmp.c_str());
|
||||
@@ -2362,11 +2391,10 @@ void InternalFormatStringMessage(StringClass& outString, const StringClass& sStr
|
||||
}
|
||||
}
|
||||
|
||||
template<typename StringClass, typename CharType>
|
||||
void InternalFormatStringMessage(StringClass& outString, const StringClass& sString, const CharType* param1, const CharType* param2 = 0, const CharType* param3 = 0, const CharType* param4 = 0)
|
||||
void InternalFormatStringMessage(AZStd::string& outString, const AZStd::string& sString, const char* param1, const char* param2 = 0, const char* param3 = 0, const char* param4 = 0)
|
||||
{
|
||||
static const int MAX_PARAMS = 4;
|
||||
const CharType* params[MAX_PARAMS] = { param1, param2, param3, param4 };
|
||||
const char* params[MAX_PARAMS] = { param1, param2, param3, param4 };
|
||||
int nParams = 0;
|
||||
while (nParams < MAX_PARAMS && params[nParams])
|
||||
{
|
||||
@@ -2376,13 +2404,13 @@ void InternalFormatStringMessage(StringClass& outString, const StringClass& sStr
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CLocalizedStringsManager::FormatStringMessage_List(string& outString, const string& sString, const char** sParams, int nParams)
|
||||
void CLocalizedStringsManager::FormatStringMessage_List(AZStd::string& outString, const AZStd::string& sString, const char** sParams, int nParams)
|
||||
{
|
||||
InternalFormatStringMessage(outString, sString, sParams, nParams);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CLocalizedStringsManager::FormatStringMessage(string& outString, const string& sString, const char* param1, const char* param2, const char* param3, const char* param4)
|
||||
void CLocalizedStringsManager::FormatStringMessage(AZStd::string& outString, const AZStd::string& sString, const char* param1, const char* param2, const char* param3, const char* param4)
|
||||
{
|
||||
InternalFormatStringMessage(outString, sString, param1, param2, param3, param4);
|
||||
}
|
||||
@@ -2462,7 +2490,7 @@ void CLocalizedStringsManager::InternalSetCurrentLanguage(CLocalizedStringsManag
|
||||
#if defined (WIN32) || defined(WIN64)
|
||||
if (m_pLanguage != 0)
|
||||
{
|
||||
g_currentLanguageID = GetLanguageID(m_pLanguage->sLanguage);
|
||||
g_currentLanguageID = GetLanguageID(m_pLanguage->sLanguage.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2494,7 +2522,7 @@ void CLocalizedStringsManager::InternalSetCurrentLanguage(CLocalizedStringsManag
|
||||
}
|
||||
}
|
||||
|
||||
void CLocalizedStringsManager::LocalizeDuration(int seconds, string& outDurationString)
|
||||
void CLocalizedStringsManager::LocalizeDuration(int seconds, AZStd::string& outDurationString)
|
||||
{
|
||||
int s = seconds;
|
||||
int d, h, m;
|
||||
@@ -2504,27 +2532,27 @@ void CLocalizedStringsManager::LocalizeDuration(int seconds, string& outDuration
|
||||
s -= h * 3600;
|
||||
m = s / 60;
|
||||
s = s - m * 60;
|
||||
string str;
|
||||
AZStd::string str;
|
||||
if (d > 1)
|
||||
{
|
||||
str.Format("%d @ui_days %02d:%02d:%02d", d, h, m, s);
|
||||
str = AZStd::string::format("%d @ui_days %02d:%02d:%02d", d, h, m, s);
|
||||
}
|
||||
else if (d > 0)
|
||||
{
|
||||
str.Format("%d @ui_day %02d:%02d:%02d", d, h, m, s);
|
||||
str = AZStd::string::format("%d @ui_day %02d:%02d:%02d", d, h, m, s);
|
||||
}
|
||||
else if (h > 0)
|
||||
{
|
||||
str.Format("%02d:%02d:%02d", h, m, s);
|
||||
str = AZStd::string::format("%02d:%02d:%02d", h, m, s);
|
||||
}
|
||||
else
|
||||
{
|
||||
str.Format("%02d:%02d", m, s);
|
||||
str = AZStd::string::format("%02d:%02d", m, s);
|
||||
}
|
||||
LocalizeString_s(str, outDurationString);
|
||||
}
|
||||
|
||||
void CLocalizedStringsManager::LocalizeNumber(int number, string& outNumberString)
|
||||
void CLocalizedStringsManager::LocalizeNumber(int number, AZStd::string& outNumberString)
|
||||
{
|
||||
if (number == 0)
|
||||
{
|
||||
@@ -2535,8 +2563,8 @@ void CLocalizedStringsManager::LocalizeNumber(int number, string& outNumberStrin
|
||||
outNumberString.assign("");
|
||||
|
||||
int n = abs(number);
|
||||
string separator;
|
||||
CryFixedStringT<64> tmp;
|
||||
AZStd::string separator;
|
||||
AZStd::fixed_string<64> tmp;
|
||||
LocalizeString_ch("@ui_thousand_separator", separator);
|
||||
while (n > 0)
|
||||
{
|
||||
@@ -2544,49 +2572,49 @@ void CLocalizedStringsManager::LocalizeNumber(int number, string& outNumberStrin
|
||||
int b = n - (a * 1000);
|
||||
if (a > 0)
|
||||
{
|
||||
tmp.Format("%s%03d%s", separator.c_str(), b, tmp.c_str());
|
||||
tmp = AZStd::string::format("%s%03d%s", separator.c_str(), b, tmp.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp.Format("%d%s", b, tmp.c_str());
|
||||
tmp = AZStd::string::format("%d%s", b, tmp.c_str());
|
||||
}
|
||||
n = a;
|
||||
}
|
||||
|
||||
if (number < 0)
|
||||
{
|
||||
tmp.Format("-%s", tmp.c_str());
|
||||
tmp = AZStd::string::format("-%s", tmp.c_str());
|
||||
}
|
||||
|
||||
outNumberString.assign(tmp.c_str());
|
||||
}
|
||||
|
||||
void CLocalizedStringsManager::LocalizeNumber_Decimal(float number, int decimals, string& outNumberString)
|
||||
void CLocalizedStringsManager::LocalizeNumber_Decimal(float number, int decimals, AZStd::string& outNumberString)
|
||||
{
|
||||
if (number == 0.0f)
|
||||
{
|
||||
CryFixedStringT<64> tmp;
|
||||
tmp.Format("%.*f", decimals, number);
|
||||
AZStd::fixed_string<64> tmp;
|
||||
tmp = AZStd::fixed_string<64>::format("%.*f", decimals, number);
|
||||
outNumberString.assign(tmp.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
outNumberString.assign("");
|
||||
|
||||
string commaSeparator;
|
||||
AZStd::string commaSeparator;
|
||||
LocalizeString_ch("@ui_decimal_separator", commaSeparator);
|
||||
float f = number > 0.0f ? number : -number;
|
||||
int d = (int)f;
|
||||
|
||||
string intPart;
|
||||
AZStd::string intPart;
|
||||
LocalizeNumber(d, intPart);
|
||||
|
||||
float decimalsOnly = f - (float)d;
|
||||
|
||||
int decimalsAsInt = aznumeric_cast<int>(int_round(decimalsOnly * pow(10.0f, decimals)));
|
||||
|
||||
CryFixedStringT<64> tmp;
|
||||
tmp.Format("%s%s%0*d", intPart.c_str(), commaSeparator.c_str(), decimals, decimalsAsInt);
|
||||
AZStd::fixed_string<64> tmp;
|
||||
tmp = AZStd::fixed_string<64>::format("%s%s%0*d", intPart.c_str(), commaSeparator.c_str(), decimals, decimalsAsInt);
|
||||
|
||||
outNumberString.assign(tmp.c_str());
|
||||
}
|
||||
@@ -2640,7 +2668,7 @@ namespace
|
||||
}
|
||||
};
|
||||
|
||||
void CLocalizedStringsManager::LocalizeTime(time_t t, bool bMakeLocalTime, bool bShowSeconds, string& outTimeString)
|
||||
void CLocalizedStringsManager::LocalizeTime(time_t t, bool bMakeLocalTime, bool bShowSeconds, AZStd::string& outTimeString)
|
||||
{
|
||||
if (bMakeLocalTime)
|
||||
{
|
||||
@@ -2648,7 +2676,7 @@ void CLocalizedStringsManager::LocalizeTime(time_t t, bool bMakeLocalTime, bool
|
||||
localtime_s(&thetime, &t);
|
||||
t = gEnv->pTimer->DateToSecondsUTC(thetime);
|
||||
}
|
||||
outTimeString.resize(0);
|
||||
outTimeString.clear();
|
||||
LCID lcID = g_currentLanguageID.lcID ? g_currentLanguageID.lcID : LOCALE_USER_DEFAULT;
|
||||
DWORD flags = bShowSeconds == false ? TIME_NOSECONDS : 0;
|
||||
SYSTEMTIME systemTime;
|
||||
@@ -2657,14 +2685,14 @@ void CLocalizedStringsManager::LocalizeTime(time_t t, bool bMakeLocalTime, bool
|
||||
if (len > 0)
|
||||
{
|
||||
// len includes terminating null!
|
||||
CryFixedWStringT<256> tmpString;
|
||||
AZStd::fixed_wstring<256> tmpString;
|
||||
tmpString.resize(len);
|
||||
::GetTimeFormatW(lcID, flags, &systemTime, 0, (wchar_t*) tmpString.c_str(), len);
|
||||
Unicode::Convert(outTimeString, tmpString);
|
||||
AZStd::to_string(outTimeString, tmpString.data());
|
||||
}
|
||||
}
|
||||
|
||||
void CLocalizedStringsManager::LocalizeDate(time_t t, bool bMakeLocalTime, bool bShort, bool bIncludeWeekday, string& outDateString)
|
||||
void CLocalizedStringsManager::LocalizeDate(time_t t, bool bMakeLocalTime, bool bShort, bool bIncludeWeekday, AZStd::string& outDateString)
|
||||
{
|
||||
if (bMakeLocalTime)
|
||||
{
|
||||
@@ -2678,7 +2706,7 @@ void CLocalizedStringsManager::LocalizeDate(time_t t, bool bMakeLocalTime, bool
|
||||
UnixTimeToSystemTime(t, &systemTime);
|
||||
|
||||
// len includes terminating null!
|
||||
CryFixedWStringT<256> tmpString;
|
||||
AZStd::fixed_wstring<256> tmpString;
|
||||
|
||||
if (bIncludeWeekday)
|
||||
{
|
||||
@@ -2689,8 +2717,8 @@ void CLocalizedStringsManager::LocalizeDate(time_t t, bool bMakeLocalTime, bool
|
||||
// len includes terminating null!
|
||||
tmpString.resize(len);
|
||||
::GetDateFormatW(lcID, 0, &systemTime, L"ddd", (wchar_t*) tmpString.c_str(), len);
|
||||
string utf8;
|
||||
Unicode::Convert(utf8, tmpString);
|
||||
AZStd::string utf8;
|
||||
AZStd::to_string(utf8, tmpString.data());
|
||||
outDateString.append(utf8);
|
||||
outDateString.append(" ");
|
||||
}
|
||||
@@ -2702,15 +2730,15 @@ void CLocalizedStringsManager::LocalizeDate(time_t t, bool bMakeLocalTime, bool
|
||||
// len includes terminating null!
|
||||
tmpString.resize(len);
|
||||
::GetDateFormatW(lcID, flags, &systemTime, 0, (wchar_t*) tmpString.c_str(), len);
|
||||
string utf8;
|
||||
Unicode::Convert(utf8, tmpString);
|
||||
AZStd::string utf8;
|
||||
AZStd::to_string(utf8, tmpString.data());
|
||||
outDateString.append(utf8);
|
||||
}
|
||||
}
|
||||
|
||||
#else // #if defined (WIN32) || defined(WIN64)
|
||||
|
||||
void CLocalizedStringsManager::LocalizeTime(time_t t, bool bMakeLocalTime, bool bShowSeconds, string& outTimeString)
|
||||
void CLocalizedStringsManager::LocalizeTime(time_t t, bool bMakeLocalTime, bool bShowSeconds, AZStd::string& outTimeString)
|
||||
{
|
||||
struct tm theTime;
|
||||
if (bMakeLocalTime)
|
||||
@@ -2734,10 +2762,10 @@ void CLocalizedStringsManager::LocalizeTime(time_t t, bool bMakeLocalTime, bool
|
||||
const size_t bufSize = sizeof(buf) / sizeof(buf[0]);
|
||||
wcsftime(buf, bufSize, bShowSeconds ? L"%#X" : L"%X", &theTime);
|
||||
buf[bufSize - 1] = 0;
|
||||
Unicode::Convert(outTimeString, buf);
|
||||
AZStd::to_string(outTimeString, buf);
|
||||
}
|
||||
|
||||
void CLocalizedStringsManager::LocalizeDate(time_t t, bool bMakeLocalTime, bool bShort, bool bIncludeWeekday, string& outDateString)
|
||||
void CLocalizedStringsManager::LocalizeDate(time_t t, bool bMakeLocalTime, bool bShort, bool bIncludeWeekday, AZStd::string& outDateString)
|
||||
{
|
||||
struct tm theTime;
|
||||
if (bMakeLocalTime)
|
||||
@@ -2762,7 +2790,7 @@ void CLocalizedStringsManager::LocalizeDate(time_t t, bool bMakeLocalTime, bool
|
||||
const wchar_t* format = bShort ? (bIncludeWeekday ? L"%a %x" : L"%x") : L"%#x"; // long format always contains Weekday name
|
||||
wcsftime(buf, bufSize, format, &theTime);
|
||||
buf[bufSize - 1] = 0;
|
||||
Unicode::Convert(outDateString, buf);
|
||||
AZStd::to_string(outDateString, buf);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class CLocalizedStringsManager
|
||||
, public ISystemEventListener
|
||||
{
|
||||
public:
|
||||
typedef std::vector<string> TLocalizationTagVec;
|
||||
typedef std::vector<AZStd::string> TLocalizationTagVec;
|
||||
|
||||
constexpr const static size_t LOADING_FIXED_STRING_LENGTH = 2048;
|
||||
constexpr const static size_t COMPRESSION_FIXED_BUFFER_LENGTH = 6144;
|
||||
@@ -56,11 +56,11 @@ public:
|
||||
void ReloadData() override;
|
||||
void FreeData();
|
||||
|
||||
bool LocalizeString_s(const string& sString, string& outLocalizedString, bool bEnglish = false) override;
|
||||
bool LocalizeString_ch(const char* sString, string& outLocalizedString, bool bEnglish = false) override;
|
||||
bool LocalizeString_s(const AZStd::string& sString, AZStd::string& outLocalizedString, bool bEnglish = false) override;
|
||||
bool LocalizeString_ch(const char* sString, AZStd::string& outLocalizedString, bool bEnglish = false) override;
|
||||
|
||||
void LocalizeAndSubstituteInternal(AZStd::string& locString, const AZStd::vector<AZStd::string>& keys, const AZStd::vector<AZStd::string>& values) override;
|
||||
bool LocalizeLabel(const char* sLabel, string& outLocalizedString, bool bEnglish = false) override;
|
||||
bool LocalizeLabel(const char* sLabel, AZStd::string& outLocalizedString, bool bEnglish = false) override;
|
||||
bool IsLocalizedInfoFound(const char* sKey);
|
||||
bool GetLocalizedInfoByKey(const char* sKey, SLocalizedInfoGame& outGameInfo);
|
||||
bool GetLocalizedInfoByKey(const char* sKey, SLocalizedSoundInfoGame* pOutSoundInfoGame);
|
||||
@@ -68,17 +68,17 @@ public:
|
||||
bool GetLocalizedInfoByIndex(int nIndex, SLocalizedInfoGame& outGameInfo);
|
||||
bool GetLocalizedInfoByIndex(int nIndex, SLocalizedInfoEditor& outEditorInfo);
|
||||
|
||||
bool GetEnglishString(const char* sKey, string& sLocalizedString) override;
|
||||
bool GetSubtitle(const char* sKeyOrLabel, string& outSubtitle, bool bForceSubtitle = false) override;
|
||||
bool GetEnglishString(const char* sKey, AZStd::string& sLocalizedString) override;
|
||||
bool GetSubtitle(const char* sKeyOrLabel, AZStd::string& outSubtitle, bool bForceSubtitle = false) override;
|
||||
|
||||
void FormatStringMessage_List(string& outString, const string& sString, const char** sParams, int nParams) override;
|
||||
void FormatStringMessage(string& outString, const string& sString, const char* param1, const char* param2 = 0, const char* param3 = 0, const char* param4 = 0) override;
|
||||
void FormatStringMessage_List(AZStd::string& outString, const AZStd::string& sString, const char** sParams, int nParams) override;
|
||||
void FormatStringMessage(AZStd::string& outString, const AZStd::string& sString, const char* param1, const char* param2 = 0, const char* param3 = 0, const char* param4 = 0) override;
|
||||
|
||||
void LocalizeTime(time_t t, bool bMakeLocalTime, bool bShowSeconds, string& outTimeString) override;
|
||||
void LocalizeDate(time_t t, bool bMakeLocalTime, bool bShort, bool bIncludeWeekday, string& outDateString) override;
|
||||
void LocalizeDuration(int seconds, string& outDurationString) override;
|
||||
void LocalizeNumber(int number, string& outNumberString) override;
|
||||
void LocalizeNumber_Decimal(float number, int decimals, string& outNumberString) override;
|
||||
void LocalizeTime(time_t t, bool bMakeLocalTime, bool bShowSeconds, AZStd::string& outTimeString) override;
|
||||
void LocalizeDate(time_t t, bool bMakeLocalTime, bool bShort, bool bIncludeWeekday, AZStd::string& outDateString) override;
|
||||
void LocalizeDuration(int seconds, AZStd::string& outDurationString) override;
|
||||
void LocalizeNumber(int number, AZStd::string& outNumberString) override;
|
||||
void LocalizeNumber_Decimal(float number, int decimals, AZStd::string& outNumberString) override;
|
||||
|
||||
bool ProjectUsesLocalization() const override;
|
||||
// ~ILocalizationManager
|
||||
@@ -95,7 +95,7 @@ public:
|
||||
private:
|
||||
void SetAvailableLocalizationsBitfield(const ILocalizationManager::TLocalizationBitfield availableLocalizations);
|
||||
|
||||
bool LocalizeStringInternal(const char* pStr, size_t len, string& outLocalizedString, bool bEnglish);
|
||||
bool LocalizeStringInternal(const char* pStr, size_t len, AZStd::string& outLocalizedString, bool bEnglish);
|
||||
|
||||
bool DoLoadExcelXmlSpreadsheet(const char* sFileName, uint8 tagID, bool bReload);
|
||||
typedef bool(CLocalizedStringsManager::*LoadFunc)(const char*, uint8, bool);
|
||||
@@ -104,11 +104,11 @@ private:
|
||||
|
||||
struct SLocalizedStringEntryEditorExtension
|
||||
{
|
||||
string sKey; // Map key text equivalent (without @)
|
||||
string sOriginalActorLine; // english text
|
||||
string sUtf8TranslatedActorLine; // localized text
|
||||
string sOriginalText; // subtitle. if empty, uses English text
|
||||
string sOriginalCharacterName; // english character name speaking via XML asset
|
||||
AZStd::string sKey; // Map key text equivalent (without @)
|
||||
AZStd::string sOriginalActorLine; // english text
|
||||
AZStd::string sUtf8TranslatedActorLine; // localized text
|
||||
AZStd::string sOriginalText; // subtitle. if empty, uses English text
|
||||
AZStd::string sOriginalCharacterName; // english character name speaking via XML asset
|
||||
|
||||
unsigned int nRow; // Number of row in XML file
|
||||
|
||||
@@ -141,15 +141,15 @@ private:
|
||||
|
||||
union trans_text
|
||||
{
|
||||
string* psUtf8Uncompressed;
|
||||
AZStd::string* psUtf8Uncompressed;
|
||||
uint8* szCompressed; // Note that no size information is stored. This is for struct size optimization and unfortunately renders the size info inaccurate.
|
||||
};
|
||||
|
||||
string sCharacterName; // character name speaking via XML asset
|
||||
AZStd::string sCharacterName; // character name speaking via XML asset
|
||||
trans_text TranslatedText; // Subtitle of this line
|
||||
|
||||
// audio specific part
|
||||
string sPrototypeSoundEvent; // associated sound event prototype (radio, ...)
|
||||
AZStd::string sPrototypeSoundEvent; // associated sound event prototype (radio, ...)
|
||||
CryHalf fVolume;
|
||||
CryHalf fRadioRatio;
|
||||
// SoundMoods
|
||||
@@ -191,7 +191,7 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
string GetTranslatedText(const SLanguage* pLanguage) const;
|
||||
AZStd::string GetTranslatedText(const SLanguage* pLanguage) const;
|
||||
|
||||
void GetMemoryUsage(ICrySizer* pSizer) const
|
||||
{
|
||||
@@ -224,7 +224,7 @@ private:
|
||||
typedef std::vector<SLocalizedStringEntry*> TLocalizedStringEntries;
|
||||
typedef std::vector<HuffmanCoder*> THuffmanCoders;
|
||||
|
||||
string sLanguage;
|
||||
AZStd::string sLanguage;
|
||||
StringsKeyMap m_keysMap;
|
||||
TLocalizedStringEntries m_vLocalizedStrings;
|
||||
THuffmanCoders m_vEncoders;
|
||||
@@ -246,7 +246,7 @@ private:
|
||||
};
|
||||
|
||||
#ifndef _RELEASE
|
||||
std::map<string, bool> m_warnedAboutLabels;
|
||||
std::map<AZStd::string, bool> m_warnedAboutLabels;
|
||||
bool m_haveWarnedAboutAtLeastOneLabel;
|
||||
|
||||
void LocalizedStringsManagerWarning(const char* label, const char* message);
|
||||
@@ -259,45 +259,45 @@ private:
|
||||
void AddLocalizedString(SLanguage* pLanguage, SLocalizedStringEntry* pEntry, const uint32 keyCRC32);
|
||||
void AddControl(int nKey);
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void ParseFirstLine(IXmlTableReader* pXmlTableReader, char* nCellIndexToType, std::map<int, string>& SoundMoodIndex, std::map<int, string>& EventParameterIndex);
|
||||
void ParseFirstLine(IXmlTableReader* pXmlTableReader, char* nCellIndexToType, std::map<int, AZStd::string>& SoundMoodIndex, std::map<int, AZStd::string>& EventParameterIndex);
|
||||
void InternalSetCurrentLanguage(SLanguage* pLanguage);
|
||||
ISystem* m_pSystem;
|
||||
// Pointer to the current language.
|
||||
SLanguage* m_pLanguage;
|
||||
|
||||
// all loaded Localization Files
|
||||
typedef std::pair<string, SFileInfo> pairFileName;
|
||||
typedef std::map<string, SFileInfo> tmapFilenames;
|
||||
typedef std::pair<AZStd::string, SFileInfo> pairFileName;
|
||||
typedef std::map<AZStd::string, SFileInfo> tmapFilenames;
|
||||
tmapFilenames m_loadedTables;
|
||||
|
||||
|
||||
// filenames per tag
|
||||
typedef std::vector<string> TStringVec;
|
||||
typedef std::vector<AZStd::string> TStringVec;
|
||||
struct STag
|
||||
{
|
||||
TStringVec filenames;
|
||||
uint8 id;
|
||||
bool loaded;
|
||||
};
|
||||
typedef std::map<string, STag> TTagFileNames;
|
||||
typedef std::map<AZStd::string, STag> TTagFileNames;
|
||||
TTagFileNames m_tagFileNames;
|
||||
TStringVec m_tagLoadRequests;
|
||||
|
||||
// Array of loaded languages.
|
||||
std::vector<SLanguage*> m_languages;
|
||||
|
||||
typedef std::set<string> PrototypeSoundEvents;
|
||||
typedef std::set<AZStd::string> PrototypeSoundEvents;
|
||||
PrototypeSoundEvents m_prototypeEvents; // this set is purely used for clever string/string assigning to save memory
|
||||
|
||||
struct less_strcmp
|
||||
{
|
||||
bool operator()(const string& left, const string& right) const
|
||||
bool operator()(const AZStd::string& left, const AZStd::string& right) const
|
||||
{
|
||||
return strcmp(left.c_str(), right.c_str()) < 0;
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::set<string, less_strcmp> CharacterNameSet;
|
||||
typedef std::set<AZStd::string, less_strcmp> CharacterNameSet;
|
||||
CharacterNameSet m_characterNameSet; // this set is purely used for clever string/string assigning to save memory
|
||||
|
||||
// CVARs
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include <ISystem.h>
|
||||
#include "System.h"
|
||||
#include "CryPath.h" // PathUtil::ReplaceExtension()
|
||||
#include "UnicodeFunctions.h"
|
||||
|
||||
#include <AzFramework/IO/FileOperations.h>
|
||||
#include <AzCore/IO/FileIO.h>
|
||||
@@ -466,7 +465,7 @@ void CLog::LogV(const ELogType type, [[maybe_unused]]int flags, const char* szFo
|
||||
{
|
||||
case eWarning:
|
||||
case eWarningAlways:
|
||||
cry_strcpy(szString, MAX_WARNING_LENGTH, "$6[Warning] ");
|
||||
azstrcpy(szString, MAX_WARNING_LENGTH, "$6[Warning] ");
|
||||
szString += 12; // strlen("$6[Warning] ");
|
||||
szAfterColour += 2;
|
||||
prefixSize = 12;
|
||||
@@ -474,7 +473,7 @@ void CLog::LogV(const ELogType type, [[maybe_unused]]int flags, const char* szFo
|
||||
|
||||
case eError:
|
||||
case eErrorAlways:
|
||||
cry_strcpy(szString, MAX_WARNING_LENGTH, "$4[Error] ");
|
||||
azstrcpy(szString, MAX_WARNING_LENGTH, "$4[Error] ");
|
||||
szString += 10; // strlen("$4[Error] ");
|
||||
szAfterColour += 2;
|
||||
prefixSize = 10;
|
||||
@@ -509,7 +508,7 @@ void CLog::LogV(const ELogType type, [[maybe_unused]]int flags, const char* szFo
|
||||
stack_string s = szBuffer;
|
||||
s += "\t<Scope> ";
|
||||
s += sAssetScope;
|
||||
cry_strcpy(szBuffer, s.c_str());
|
||||
azstrcpy(szBuffer, AZ_ARRAY_SIZE(szBuffer), s.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -532,7 +531,7 @@ void CLog::LogV(const ELogType type, [[maybe_unused]]int flags, const char* szFo
|
||||
}
|
||||
}
|
||||
i = m_iLastHistoryItem = m_iLastHistoryItem + 1 & sz - 1;
|
||||
cry_strcpy(m_history[i].str, m_history[i].ptr = szSpamCheck);
|
||||
azstrcpy(m_history[i].str, AZ_ARRAY_SIZE(m_history[i].str), m_history[i].ptr = szSpamCheck);
|
||||
m_history[i].type = type;
|
||||
m_history[i].time = time;
|
||||
}
|
||||
@@ -863,7 +862,7 @@ bool CLog::LogToMainThread(const char* szString, ELogType logType, bool bAdd, SL
|
||||
{
|
||||
// When logging from other thread then main, push all log strings to queue.
|
||||
SLogMsg msg;
|
||||
cry_strcpy(msg.msg, szString);
|
||||
azstrcpy(msg.msg, AZ_ARRAY_SIZE(msg.msg), szString);
|
||||
msg.bAdd = bAdd;
|
||||
msg.destination = destination;
|
||||
msg.logType = logType;
|
||||
@@ -956,7 +955,7 @@ void CLog::LogStringToFile(const char* szString, ELogType logType, bool bAdd, [[
|
||||
{
|
||||
timeStr.clear();
|
||||
uint32 dwMs = (uint32)((currenttime - lasttime).GetMilliSeconds());
|
||||
timeStr.Format("<%3d.%.3d>: ", dwMs / 1000, dwMs % 1000);
|
||||
timeStr = AZStd::string::format("<%3d.%.3d>: ", dwMs / 1000, dwMs % 1000);
|
||||
tempString = timeStr + tempString;
|
||||
}
|
||||
lasttime = currenttime;
|
||||
@@ -983,7 +982,7 @@ void CLog::LogStringToFile(const char* szString, ELogType logType, bool bAdd, [[
|
||||
{
|
||||
timeStr.clear();
|
||||
uint32 dwMs = (uint32)((currenttime - lasttime).GetMilliSeconds());
|
||||
timeStr.Format("<%3d.%.3d>: ", dwMs / 1000, dwMs % 1000);
|
||||
timeStr = AZStd::string::format("<%3d.%.3d>: ", dwMs / 1000, dwMs % 1000);
|
||||
tempString = timeStr + tempString;
|
||||
}
|
||||
lasttime = currenttime;
|
||||
@@ -1000,7 +999,7 @@ void CLog::LogStringToFile(const char* szString, ELogType logType, bool bAdd, [[
|
||||
{
|
||||
timeStr.clear();
|
||||
uint32 dwMs = (uint32)((currenttime - lasttime).GetMilliSeconds());
|
||||
timeStr.Format("<%3d.%.3d>: ", dwMs / 1000, dwMs % 1000);
|
||||
timeStr = AZStd::string::format("<%3d.%.3d>: ", dwMs / 1000, dwMs % 1000);
|
||||
tempString = timeStr + tempString;
|
||||
}
|
||||
if (bFirst)
|
||||
@@ -1052,13 +1051,7 @@ void CLog::LogStringToFile(const char* szString, ELogType logType, bool bAdd, [[
|
||||
#if !defined(_RELEASE)
|
||||
if (queueState == MessageQueueState::NotQueued)
|
||||
{
|
||||
// Note: OutputDebugString(A) only accepts current ANSI code-page, and the W variant will call the A variant internally.
|
||||
// Here we replace non-ASCII characters with '?', which is the same as OutputDebugStringW will do for non-ANSI.
|
||||
// Thus, we discard slightly more characters (ie, those inside the current ANSI code-page, but outside ASCII).
|
||||
// In exchange, we save double-converting that would have happened otherwise (UTF-8 -> UTF-16 -> ANSI).
|
||||
LogStringType asciiString;
|
||||
Unicode::ConvertSafe<Unicode::EErrorRecovery::eErrorRecovery_FallbackLatin1ThenDiscard, Unicode::eEncoding_ASCII, Unicode::eEncoding_UTF8>(asciiString, tempString);
|
||||
OutputDebugString(asciiString.c_str());
|
||||
AZ::Debug::Platform::OutputToDebugger(nullptr, tempString.c_str());
|
||||
}
|
||||
|
||||
if (!bIsMainThread)
|
||||
@@ -1218,14 +1211,14 @@ void CLog::CreateBackupFile() const
|
||||
|
||||
// boswej: only create a backup if logging to the engine root, otherwise the
|
||||
// log output has been overridden and the user is responsible
|
||||
string logDir = PathUtil::RemoveSlash(PathUtil::ToUnixPath(PathUtil::GetParentDirectory(m_szFilename)));
|
||||
AZStd::string logDir = PathUtil::RemoveSlash(PathUtil::ToUnixPath(PathUtil::GetParentDirectory(m_szFilename)));
|
||||
|
||||
string sExt = PathUtil::GetExt(m_szFilename);
|
||||
string sFileWithoutExt = PathUtil::GetFileName(m_szFilename);
|
||||
AZStd::string sExt = PathUtil::GetExt(m_szFilename);
|
||||
AZStd::string sFileWithoutExt = PathUtil::GetFileName(m_szFilename);
|
||||
|
||||
{
|
||||
assert(::strstr(sFileWithoutExt, ":") == 0);
|
||||
assert(::strstr(sFileWithoutExt, "\\") == 0);
|
||||
assert(::strstr(sFileWithoutExt.c_str(), ":") == 0);
|
||||
assert(::strstr(sFileWithoutExt.c_str(), "\\") == 0);
|
||||
}
|
||||
|
||||
PathUtil::RemoveExtension(sFileWithoutExt);
|
||||
@@ -1234,14 +1227,14 @@ void CLog::CreateBackupFile() const
|
||||
AZ::IO::HandleType inFileHandle = AZ::IO::InvalidHandle;
|
||||
fileSystem->Open(m_szFilename, AZ::IO::OpenMode::ModeRead | AZ::IO::OpenMode::ModeBinary, inFileHandle);
|
||||
|
||||
string sBackupNameAttachment;
|
||||
AZStd::string sBackupNameAttachment;
|
||||
|
||||
// parse backup name attachment
|
||||
// e.g. BackupNameAttachment="attachment name"
|
||||
if (inFileHandle != AZ::IO::InvalidHandle)
|
||||
{
|
||||
bool bKeyFound = false;
|
||||
string sName;
|
||||
AZStd::string sName;
|
||||
|
||||
while (!fileSystem->Eof(inFileHandle))
|
||||
{
|
||||
@@ -1253,13 +1246,11 @@ void CLog::CreateBackupFile() const
|
||||
{
|
||||
bKeyFound = true;
|
||||
|
||||
if (sName.find("BackupNameAttachment=") == string::npos)
|
||||
if (sName.find("BackupNameAttachment=") == AZStd::string::npos)
|
||||
{
|
||||
#ifdef WIN32
|
||||
OutputDebugString("Log::CreateBackupFile ERROR '");
|
||||
OutputDebugString(sName.c_str());
|
||||
OutputDebugString("' not recognized \n");
|
||||
#endif
|
||||
AZ::Debug::Platform::OutputToDebugger("CrySystem Log", "Log::CreateBackupFile ERROR '");
|
||||
AZ::Debug::Platform::OutputToDebugger(nullptr, sName.c_str());
|
||||
AZ::Debug::Platform::OutputToDebugger(nullptr, "' not recognized \n");
|
||||
assert(0); // broken log file? - first line should include this name - written by LogVersion()
|
||||
return;
|
||||
}
|
||||
@@ -1284,12 +1275,12 @@ void CLog::CreateBackupFile() const
|
||||
fileSystem->Close(inFileHandle);
|
||||
}
|
||||
|
||||
string bakdest = PathUtil::Make(LOG_BACKUP_PATH, sFileWithoutExt + sBackupNameAttachment + "." + sExt);
|
||||
AZStd::string bakdest = PathUtil::Make(LOG_BACKUP_PATH, sFileWithoutExt + sBackupNameAttachment + "." + sExt);
|
||||
fileSystem->CreatePath(LOG_BACKUP_PATH);
|
||||
cry_strcpy(m_sBackupFilename, bakdest.c_str());
|
||||
azstrcpy(m_sBackupFilename, AZ_ARRAY_SIZE(m_sBackupFilename), bakdest.c_str());
|
||||
// Remove any existing backup file with the same name first since the copy will fail otherwise.
|
||||
fileSystem->Remove(m_sBackupFilename);
|
||||
fileSystem->Copy(m_szFilename, bakdest);
|
||||
fileSystem->Copy(m_szFilename, bakdest.c_str());
|
||||
#endif // AZ_LEGACY_CRYSYSTEM_TRAIT_ALLOW_CREATE_BACKUP_LOG_FILE
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class CLog
|
||||
{
|
||||
public:
|
||||
typedef std::list<ILogCallback*> Callbacks;
|
||||
typedef CryStackStringT<char, MAX_TEMP_LENGTH_SIZE> LogStringType;
|
||||
typedef AZStd::fixed_string<MAX_TEMP_LENGTH_SIZE> LogStringType;
|
||||
|
||||
// constructor
|
||||
CLog(ISystem* pSystem);
|
||||
|
||||
@@ -88,14 +88,7 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
|
||||
// Handle with the default procedure
|
||||
#if defined(UNICODE) || defined(_UNICODE)
|
||||
assert(IsWindowUnicode(hWnd) && "Window should be Unicode when compiling with UNICODE");
|
||||
#else
|
||||
if (!IsWindowUnicode(hWnd))
|
||||
{
|
||||
return DefWindowProcA(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
#endif
|
||||
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
#endif
|
||||
@@ -138,7 +131,6 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
#include "RemoteConsole/RemoteConsole.h"
|
||||
|
||||
#include <PNoise3.h>
|
||||
#include <StringUtils.h>
|
||||
|
||||
#include <LyShine/Bus/UiCursorBus.h>
|
||||
#include <AzFramework/Asset/AssetSystemBus.h>
|
||||
@@ -1156,7 +1148,7 @@ void CSystem::WarningV(EValidatorModule module, EValidatorSeverity severity, int
|
||||
if (sModuleFilter && *sModuleFilter != 0)
|
||||
{
|
||||
const char* sModule = ValidatorModuleToString(module);
|
||||
if (strlen(sModule) > 1 || CryStringUtils::stristr(sModule, sModuleFilter) == 0)
|
||||
if (strlen(sModule) > 1 || AZ::StringFunc::Find(sModule, sModuleFilter) == AZStd::string::npos)
|
||||
{
|
||||
// Filter out warnings from other modules.
|
||||
return;
|
||||
@@ -1190,7 +1182,7 @@ void CSystem::WarningV(EValidatorModule module, EValidatorSeverity severity, int
|
||||
|
||||
if (file && *file)
|
||||
{
|
||||
CryFixedStringT<MAX_WARNING_LENGTH> fmt = szBuffer;
|
||||
AZStd::fixed_string<MAX_WARNING_LENGTH> fmt = szBuffer;
|
||||
fmt += " [File=";
|
||||
fmt += file;
|
||||
fmt += "]";
|
||||
@@ -1209,10 +1201,11 @@ void CSystem::WarningV(EValidatorModule module, EValidatorSeverity severity, int
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CSystem::GetLocalizedPath(const char* sLanguage, string& sLocalizedPath)
|
||||
void CSystem::GetLocalizedPath(const char* sLanguage, AZStd::string& sLocalizedPath)
|
||||
{
|
||||
// Omit the trailing slash!
|
||||
string sLocalizationFolder(string().assign(PathUtil::GetLocalizationFolder(), 0, PathUtil::GetLocalizationFolder().size() - 1));
|
||||
AZStd::string sLocalizationFolder(PathUtil::GetLocalizationFolder());
|
||||
sLocalizationFolder.pop_back();
|
||||
|
||||
int locFormat = 0;
|
||||
LocalizationManagerRequestBus::BroadcastResult(locFormat, &LocalizationManagerRequestBus::Events::GetLocalizationFormat);
|
||||
@@ -1222,37 +1215,38 @@ void CSystem::GetLocalizedPath(const char* sLanguage, string& sLocalizedPath)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sLocalizationFolder.compareNoCase("Languages") != 0)
|
||||
{
|
||||
sLocalizedPath = sLocalizationFolder + "/" + sLanguage + "_xml.pak";
|
||||
}
|
||||
else
|
||||
{
|
||||
sLocalizedPath = string("Localized/") + sLanguage + "_xml.pak";
|
||||
if (AZ::StringFunc::Equal(sLocalizationFolder, "Languages", false))
|
||||
{
|
||||
sLocalizedPath = sLocalizationFolder + "/" + sLanguage + "_xml.pak";
|
||||
}
|
||||
else
|
||||
{
|
||||
sLocalizedPath = AZStd::string("Localized/") + sLanguage + "_xml.pak";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CSystem::GetLocalizedAudioPath(const char* sLanguage, string& sLocalizedPath)
|
||||
void CSystem::GetLocalizedAudioPath(const char* sLanguage, AZStd::string& sLocalizedPath)
|
||||
{
|
||||
// Omit the trailing slash!
|
||||
string sLocalizationFolder(string().assign(PathUtil::GetLocalizationFolder(), 0, PathUtil::GetLocalizationFolder().size() - 1));
|
||||
AZStd::string sLocalizationFolder(PathUtil::GetLocalizationFolder());
|
||||
sLocalizationFolder.pop_back();
|
||||
|
||||
if (sLocalizationFolder.compareNoCase("Languages") != 0)
|
||||
if (AZ::StringFunc::Equal(sLocalizationFolder, "Languages", false))
|
||||
{
|
||||
sLocalizedPath = sLocalizationFolder + "/" + sLanguage + ".pak";
|
||||
}
|
||||
else
|
||||
{
|
||||
sLocalizedPath = string("Localized/") + sLanguage + ".pak";
|
||||
sLocalizedPath = AZStd::string("Localized/") + sLanguage + ".pak";
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CSystem::CloseLanguagePak(const char* sLanguage)
|
||||
{
|
||||
string sLocalizedPath;
|
||||
AZStd::string sLocalizedPath;
|
||||
GetLocalizedPath(sLanguage, sLocalizedPath);
|
||||
m_env.pCryPak->ClosePacks({ sLocalizedPath.c_str(), sLocalizedPath.size() });
|
||||
}
|
||||
@@ -1260,7 +1254,7 @@ void CSystem::CloseLanguagePak(const char* sLanguage)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CSystem::CloseLanguageAudioPak(const char* sLanguage)
|
||||
{
|
||||
string sLocalizedPath;
|
||||
AZStd::string sLocalizedPath;
|
||||
GetLocalizedAudioPath(sLanguage, sLocalizedPath);
|
||||
m_env.pCryPak->ClosePacks({ sLocalizedPath.c_str(), sLocalizedPath.size() });
|
||||
}
|
||||
@@ -1334,11 +1328,11 @@ void CSystem::ExecuteCommandLine(bool deferred)
|
||||
|
||||
if (pCmd->GetType() == eCLAT_Post)
|
||||
{
|
||||
string sLine = pCmd->GetName();
|
||||
AZStd::string sLine = pCmd->GetName();
|
||||
{
|
||||
if (pCmd->GetValue())
|
||||
{
|
||||
sLine += string(" ") + pCmd->GetValue();
|
||||
sLine += AZStd::string(" ") + pCmd->GetValue();
|
||||
}
|
||||
|
||||
GetILog()->Log("Executing command from command line: \n%s\n", sLine.c_str()); // - the actual command might be executed much later (e.g. level load pause)
|
||||
|
||||
@@ -450,7 +450,7 @@ private:
|
||||
bool ReLaunchMediaCenter();
|
||||
void UpdateAudioSystems();
|
||||
|
||||
void AddCVarGroupDirectory(const string& sPath);
|
||||
void AddCVarGroupDirectory(const AZStd::string& sPath);
|
||||
|
||||
AZStd::unique_ptr<AZ::DynamicModuleHandle> LoadDynamiclibrary(const char* dllName) const;
|
||||
|
||||
@@ -619,7 +619,7 @@ private: // ------------------------------------------------------
|
||||
// ICVar *m_sys_filecache;
|
||||
ICVar* m_gpu_particle_physics;
|
||||
|
||||
string m_sSavedRDriver; //!< to restore the driver when quitting the dedicated server
|
||||
AZStd::string m_sSavedRDriver; //!< to restore the driver when quitting the dedicated server
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! User define callback for system events.
|
||||
@@ -668,8 +668,8 @@ public:
|
||||
void OpenBasicPaks();
|
||||
void OpenLanguagePak(const char* sLanguage);
|
||||
void OpenLanguageAudioPak(const char* sLanguage);
|
||||
void GetLocalizedPath(const char* sLanguage, string& sLocalizedPath);
|
||||
void GetLocalizedAudioPath(const char* sLanguage, string& sLocalizedPath);
|
||||
void GetLocalizedPath(const char* sLanguage, AZStd::string& sLocalizedPath);
|
||||
void GetLocalizedAudioPath(const char* sLanguage, AZStd::string& sLocalizedPath);
|
||||
void CloseLanguagePak(const char* sLanguage);
|
||||
void CloseLanguageAudioPak(const char* sLanguage);
|
||||
void UpdateMovieSystem(const int updateFlags, const float fFrameTime, const bool bPreUpdate);
|
||||
@@ -714,14 +714,14 @@ protected: // -------------------------------------------------------------
|
||||
|
||||
CCmdLine* m_pCmdLine;
|
||||
|
||||
string m_currentLanguageAudio;
|
||||
string m_systemConfigName; // computed from system_(hardwareplatform)_(assetsPlatform) - eg, system_android_android.cfg or system_windows_pc.cfg
|
||||
AZStd::string m_currentLanguageAudio;
|
||||
AZStd::string m_systemConfigName; // computed from system_(hardwareplatform)_(assetsPlatform) - eg, system_android_android.cfg or system_windows_pc.cfg
|
||||
|
||||
std::vector< std::pair<CTimeValue, float> > m_updateTimes;
|
||||
|
||||
struct SErrorMessage
|
||||
{
|
||||
string m_Message;
|
||||
AZStd::string m_Message;
|
||||
float m_fTimeToShow;
|
||||
float m_Color[4];
|
||||
bool m_HardFailure;
|
||||
|
||||
@@ -114,20 +114,22 @@ void CSystem::QueryVersionInfo()
|
||||
|
||||
char ver[1024 * 8];
|
||||
|
||||
GetModuleFileName(NULL, moduleName, _MAX_PATH); //retrieves the PATH for the current module
|
||||
AZ::Utils::GetExecutablePath(moduleName, _MAX_PATH); //retrieves the PATH for the current module
|
||||
|
||||
#ifdef AZ_MONOLITHIC_BUILD
|
||||
GetModuleFileName(NULL, moduleName, _MAX_PATH); //retrieves the PATH for the current module
|
||||
AZ::Utils::GetExecutablePath(moduleName, _MAX_PATH); //retrieves the PATH for the current module
|
||||
#else // AZ_MONOLITHIC_BUILD
|
||||
azstrcpy(moduleName, AZ_ARRAY_SIZE(moduleName), "CrySystem.dll"); // we want to version from the system dll
|
||||
#endif // AZ_MONOLITHIC_BUILD
|
||||
|
||||
int verSize = GetFileVersionInfoSize(moduleName, &dwHandle);
|
||||
AZStd::wstring moduleNameW;
|
||||
AZStd::to_wstring(moduleNameW, moduleName);
|
||||
int verSize = GetFileVersionInfoSizeW(moduleNameW.c_str(), &dwHandle);
|
||||
if (verSize > 0)
|
||||
{
|
||||
GetFileVersionInfo(moduleName, dwHandle, 1024 * 8, ver);
|
||||
GetFileVersionInfoW(moduleNameW.c_str(), dwHandle, 1024 * 8, ver);
|
||||
VS_FIXEDFILEINFO* vinfo;
|
||||
VerQueryValue(ver, "\\", (void**)&vinfo, &len);
|
||||
VerQueryValueW(ver, L"\\", (void**)&vinfo, &len);
|
||||
|
||||
const uint32 verIndices[4] = {0, 1, 2, 3};
|
||||
m_fileVersion.v[verIndices[0]] = m_productVersion.v[verIndices[0]] = vinfo->dwFileVersionLS & 0xFFFF;
|
||||
@@ -143,14 +145,14 @@ void CSystem::QueryVersionInfo()
|
||||
}* lpTranslate;
|
||||
|
||||
UINT count = 0;
|
||||
char path[256];
|
||||
wchar_t path[256];
|
||||
char* version = NULL;
|
||||
|
||||
VerQueryValue(ver, "\\VarFileInfo\\Translation", (LPVOID*)&lpTranslate, &count);
|
||||
VerQueryValueW(ver, L"\\VarFileInfo\\Translation", (LPVOID*)&lpTranslate, &count);
|
||||
if (lpTranslate != NULL)
|
||||
{
|
||||
azsnprintf(path, sizeof(path), "\\StringFileInfo\\%04x%04x\\InternalName", lpTranslate[0].wLanguage, lpTranslate[0].wCodePage);
|
||||
VerQueryValue(ver, path, (LPVOID*)&version, &count);
|
||||
azsnwprintf(path, sizeof(path), L"\\StringFileInfo\\%04x%04x\\InternalName", lpTranslate[0].wLanguage, lpTranslate[0].wCodePage);
|
||||
VerQueryValueW(ver, path, (LPVOID*)&version, &count);
|
||||
if (version)
|
||||
{
|
||||
m_buildVersion.Set(version);
|
||||
@@ -211,7 +213,7 @@ void CSystem::LogVersion()
|
||||
CryLogAlways("Running 64 bit Mac version");
|
||||
#endif
|
||||
#if AZ_LEGACY_CRYSYSTEM_TRAIT_SYSTEMCFG_MODULENAME
|
||||
GetModuleFileName(NULL, s, sizeof(s));
|
||||
AZ::Utils::GetExecutablePath(s, sizeof(s));
|
||||
|
||||
// Log EXE filename only if possible (not full EXE path which could contain sensitive info)
|
||||
AZStd::string exeName;
|
||||
@@ -279,7 +281,7 @@ public:
|
||||
int nFlags = pCVar->GetFlags();
|
||||
if (((nFlags & VF_DUMPTODISK) && (nFlags & VF_MODIFIED)) || (nFlags & VF_WASINCONFIG))
|
||||
{
|
||||
string szValue = pCVar->GetString();
|
||||
AZStd::string szValue = pCVar->GetString();
|
||||
int pos;
|
||||
|
||||
pos = 1;
|
||||
@@ -287,7 +289,7 @@ public:
|
||||
{
|
||||
pos = static_cast<int>(szValue.find_first_of("\\", pos));
|
||||
|
||||
if (pos == string::npos)
|
||||
if (pos == AZStd::string::npos)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -302,7 +304,7 @@ public:
|
||||
{
|
||||
pos = static_cast<int>(szValue.find_first_of("\"", pos));
|
||||
|
||||
if (pos == string::npos)
|
||||
if (pos == AZStd::string::npos)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -311,7 +313,7 @@ public:
|
||||
pos += 2;
|
||||
}
|
||||
|
||||
string szLine = pCVar->GetName();
|
||||
AZStd::string szLine = pCVar->GetName();
|
||||
|
||||
if (pCVar->GetType() == CVAR_STRING)
|
||||
{
|
||||
@@ -344,7 +346,7 @@ void CSystem::SaveConfiguration()
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// system cfg
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CSystemConfiguration::CSystemConfiguration(const string& strSysConfigFilePath, CSystem* pSystem, ILoadConfigurationEntrySink* pSink, bool warnIfMissing)
|
||||
CSystemConfiguration::CSystemConfiguration(const AZStd::string& strSysConfigFilePath, CSystem* pSystem, ILoadConfigurationEntrySink* pSink, bool warnIfMissing)
|
||||
: m_strSysConfigFilePath(strSysConfigFilePath)
|
||||
, m_bError(false)
|
||||
, m_pSink(pSink)
|
||||
@@ -364,14 +366,14 @@ CSystemConfiguration::~CSystemConfiguration()
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CSystemConfiguration::ParseSystemConfig()
|
||||
{
|
||||
string filename = m_strSysConfigFilePath;
|
||||
if (strlen(PathUtil::GetExt(filename)) == 0)
|
||||
AZStd::string filename = m_strSysConfigFilePath;
|
||||
if (strlen(PathUtil::GetExt(filename.c_str())) == 0)
|
||||
{
|
||||
filename = PathUtil::ReplaceExtension(filename, "cfg");
|
||||
}
|
||||
|
||||
CCryFile file;
|
||||
string filenameLog;
|
||||
AZStd::string filenameLog;
|
||||
{
|
||||
int flags = AZ::IO::IArchive::FOPEN_HINT_QUIET | AZ::IO::IArchive::FOPEN_ONDISK;
|
||||
|
||||
@@ -380,7 +382,7 @@ bool CSystemConfiguration::ParseSystemConfig()
|
||||
// this is used when theres a very specific file to read, like @user@/game.cfg which is read
|
||||
// IN ADDITION to the one in the game folder, and afterwards to override values in it.
|
||||
// if the file is missing and its already prefixed with an alias, there is no need to look any further.
|
||||
if (!(file.Open(filename, "rb", flags)))
|
||||
if (!(file.Open(filename.c_str(), "rb", flags)))
|
||||
{
|
||||
if (m_warnIfMissing)
|
||||
{
|
||||
@@ -394,11 +396,11 @@ bool CSystemConfiguration::ParseSystemConfig()
|
||||
// otherwise, if the file isn't prefixed with an alias, then its likely one of the convenience mappings
|
||||
// to either root or assets/config. this is done so that code can just request a simple file name and get its data
|
||||
if (
|
||||
!(file.Open(filename, "rb", flags)) &&
|
||||
!(file.Open(string("@root@/") + filename, "rb", flags)) &&
|
||||
!(file.Open(string("@assets@/") + filename, "rb", flags)) &&
|
||||
!(file.Open(string("@assets@/config/") + filename, "rb", flags)) &&
|
||||
!(file.Open(string("@assets@/config/spec/") + filename, "rb", flags))
|
||||
!(file.Open(filename.c_str(), "rb", flags)) &&
|
||||
!(file.Open((AZStd::string("@root@/") + filename).c_str(), "rb", flags)) &&
|
||||
!(file.Open((AZStd::string("@assets@/") + filename).c_str(), "rb", flags)) &&
|
||||
!(file.Open((AZStd::string("@assets@/config/") + filename).c_str(), "rb", flags)) &&
|
||||
!(file.Open((AZStd::string("@assets@/config/spec/") + filename).c_str(), "rb", flags))
|
||||
)
|
||||
{
|
||||
if (m_warnIfMissing)
|
||||
@@ -429,7 +431,7 @@ bool CSystemConfiguration::ParseSystemConfig()
|
||||
sAllText[nLen] = '\0';
|
||||
sAllText[nLen + 1] = '\0';
|
||||
|
||||
string strGroup; // current group e.g. "[General]"
|
||||
AZStd::string strGroup; // current group e.g. "[General]"
|
||||
|
||||
char* strLast = sAllText + nLen;
|
||||
char* str = sAllText;
|
||||
@@ -447,26 +449,25 @@ bool CSystemConfiguration::ParseSystemConfig()
|
||||
str++;
|
||||
}
|
||||
|
||||
string strLine = s;
|
||||
AZStd::string strLine = s;
|
||||
AZ::StringFunc::TrimWhiteSpace(strLine, true, true);
|
||||
|
||||
// detect groups e.g. "[General]" should set strGroup="General"
|
||||
{
|
||||
string strTrimmedLine(RemoveWhiteSpaces(strLine));
|
||||
size_t size = strTrimmedLine.size();
|
||||
size_t size = strLine.size();
|
||||
|
||||
if (size >= 3)
|
||||
{
|
||||
if (strTrimmedLine[0] == '[' && strTrimmedLine[size - 1] == ']') // currently no comments are allowed to be behind groups
|
||||
if (strLine[0] == '[' && strLine[size - 1] == ']') // currently no comments are allowed to be behind groups
|
||||
{
|
||||
strGroup = &strTrimmedLine[1];
|
||||
strGroup.resize(size - 2); // remove [ and ]
|
||||
strGroup = &strLine[1];
|
||||
strGroup.resize(size - 2); // remove [ and ]
|
||||
continue; // next line
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//trim all whitespace characters at the beginning and the end of the current line and store its size
|
||||
strLine.Trim();
|
||||
size_t strLineSize = strLine.size();
|
||||
|
||||
//skip comments, comments start with ";" or "--" but may have preceding whitespace characters
|
||||
@@ -488,35 +489,36 @@ bool CSystemConfiguration::ParseSystemConfig()
|
||||
}
|
||||
|
||||
//if line contains a '=' try to read and assign console variable
|
||||
string::size_type posEq(strLine.find("=", 0));
|
||||
if (string::npos != posEq)
|
||||
AZStd::string::size_type posEq(strLine.find("=", 0));
|
||||
if (AZStd::string::npos != posEq)
|
||||
{
|
||||
string stemp(strLine, 0, posEq);
|
||||
string strKey(RemoveWhiteSpaces(stemp));
|
||||
AZStd::string stemp;
|
||||
AZStd::string strKey(strLine, 0, posEq);
|
||||
AZ::StringFunc::TrimWhiteSpace(strKey, true, true);
|
||||
|
||||
{
|
||||
// extract value
|
||||
string::size_type posValueStart(strLine.find("\"", posEq + 1) + 1);
|
||||
string::size_type posValueEnd(strLine.rfind('\"'));
|
||||
AZStd::string::size_type posValueStart(strLine.find("\"", posEq + 1) + 1);
|
||||
AZStd::string::size_type posValueEnd(strLine.rfind('\"'));
|
||||
|
||||
string strValue;
|
||||
AZStd::string strValue;
|
||||
|
||||
if (string::npos != posValueStart && string::npos != posValueEnd)
|
||||
if (AZStd::string::npos != posValueStart && AZStd::string::npos != posValueEnd)
|
||||
{
|
||||
strValue = string(strLine, posValueStart, posValueEnd - posValueStart);
|
||||
strValue = AZStd::string(strLine, posValueStart, posValueEnd - posValueStart);
|
||||
}
|
||||
else
|
||||
{
|
||||
string strTmp(strLine, posEq + 1, strLine.size() - (posEq + 1));
|
||||
strValue = RemoveWhiteSpaces(strTmp);
|
||||
strValue = AZStd::string(strLine, posEq + 1, strLine.size() - (posEq + 1));
|
||||
AZ::StringFunc::TrimWhiteSpace(strValue, true, true);
|
||||
}
|
||||
|
||||
{
|
||||
// replace '\\\\' with '\\' and '\\\"' with '\"'
|
||||
strValue.replace("\\\\", "\\");
|
||||
strValue.replace("\\\"", "\"");
|
||||
AZ::StringFunc::Replace(strValue, "\\\\", "\\");
|
||||
AZ::StringFunc::Replace(strValue, "\\\"", "\"");
|
||||
|
||||
m_pSink->OnLoadConfigurationEntry(strKey, strValue, strGroup);
|
||||
m_pSink->OnLoadConfigurationEntry(strKey.c_str(), strValue.c_str(), strGroup.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,22 +15,16 @@
|
||||
#include <math.h>
|
||||
#include <map>
|
||||
|
||||
typedef string SysConfigKey;
|
||||
typedef string SysConfigValue;
|
||||
typedef AZStd::string SysConfigKey;
|
||||
typedef AZStd::string SysConfigValue;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class CSystemConfiguration
|
||||
{
|
||||
public:
|
||||
CSystemConfiguration(const string& strSysConfigFilePath, CSystem* pSystem, ILoadConfigurationEntrySink* pSink, bool warnIfMissing = true);
|
||||
CSystemConfiguration(const AZStd::string& strSysConfigFilePath, CSystem* pSystem, ILoadConfigurationEntrySink* pSink, bool warnIfMissing = true);
|
||||
~CSystemConfiguration();
|
||||
|
||||
string RemoveWhiteSpaces(string& s)
|
||||
{
|
||||
s.Trim();
|
||||
return s;
|
||||
}
|
||||
|
||||
bool IsError() const { return m_bError; }
|
||||
|
||||
private: // ----------------------------------------
|
||||
@@ -39,10 +33,10 @@ private: // ----------------------------------------
|
||||
// success
|
||||
bool ParseSystemConfig();
|
||||
|
||||
CSystem* m_pSystem;
|
||||
string m_strSysConfigFilePath;
|
||||
bool m_bError;
|
||||
ILoadConfigurationEntrySink* m_pSink; // never 0
|
||||
CSystem* m_pSystem;
|
||||
AZStd::string m_strSysConfigFilePath;
|
||||
bool m_bError;
|
||||
ILoadConfigurationEntrySink* m_pSink; // never 0
|
||||
bool m_warnIfMissing;
|
||||
};
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
|
||||
#include "CryLibrary.h"
|
||||
#include "CryPath.h"
|
||||
#include <StringUtils.h>
|
||||
|
||||
#include <AzFramework/Input/Devices/Mouse/InputDeviceMouse.h>
|
||||
#include <AzFramework/IO/LocalFileIO.h>
|
||||
@@ -452,7 +451,7 @@ AZStd::unique_ptr<AZ::DynamicModuleHandle> CSystem::LoadDLL(const char* dllName)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// After loading DLL initialize it by calling ModuleInitISystem
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
string moduleName = PathUtil::GetFileName(dllName);
|
||||
AZStd::string moduleName = PathUtil::GetFileName(dllName);
|
||||
|
||||
typedef void*(*PtrFunc_ModuleInitISystem)(ISystem* pSystem, const char* moduleName);
|
||||
PtrFunc_ModuleInitISystem pfnModuleInitISystem = handle->GetFunction<PtrFunc_ModuleInitISystem>(DLL_MODULE_INIT_ISYSTEM);
|
||||
@@ -524,7 +523,7 @@ void CSystem::ShutdownModuleLibraries()
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if defined(WIN32) || defined(WIN64)
|
||||
wstring GetErrorStringUnsupportedGPU(const char* gpuName, unsigned int gpuVendorId, unsigned int gpuDeviceId)
|
||||
AZStd::wstring GetErrorStringUnsupportedGPU(const char* gpuName, unsigned int gpuVendorId, unsigned int gpuDeviceId)
|
||||
{
|
||||
const size_t fullLangID = (size_t) GetKeyboardLayout(0);
|
||||
const size_t primLangID = fullLangID & 0x3FF;
|
||||
@@ -878,19 +877,19 @@ void CSystem::InitLocalization()
|
||||
languageID = ILocalizationManager::EPlatformIndependentLanguageID::ePILID_English_US;
|
||||
}
|
||||
|
||||
string language = m_pLocalizationManager->LangNameFromPILID(languageID);
|
||||
AZStd::string language = m_pLocalizationManager->LangNameFromPILID(languageID);
|
||||
m_pLocalizationManager->SetLanguage(language.c_str());
|
||||
if (m_pLocalizationManager->GetLocalizationFormat() == 1)
|
||||
{
|
||||
string translationsListXML = LOCALIZATION_TRANSLATIONS_LIST_FILE_NAME;
|
||||
m_pLocalizationManager->InitLocalizationData(translationsListXML);
|
||||
AZStd::string translationsListXML = LOCALIZATION_TRANSLATIONS_LIST_FILE_NAME;
|
||||
m_pLocalizationManager->InitLocalizationData(translationsListXML.c_str());
|
||||
|
||||
m_pLocalizationManager->LoadAllLocalizationData();
|
||||
}
|
||||
else
|
||||
{
|
||||
// if the language value cannot be found, let's default to the english pak
|
||||
OpenLanguagePak(language);
|
||||
OpenLanguagePak(language.c_str());
|
||||
}
|
||||
|
||||
if (auto console = AZ::Interface<AZ::IConsole>::Get(); console != nullptr)
|
||||
@@ -906,7 +905,7 @@ void CSystem::InitLocalization()
|
||||
language.assign(languageAudio.data(), languageAudio.size());
|
||||
}
|
||||
}
|
||||
OpenLanguageAudioPak(language);
|
||||
OpenLanguageAudioPak(language.c_str());
|
||||
}
|
||||
|
||||
void CSystem::OpenBasicPaks()
|
||||
@@ -970,10 +969,10 @@ void CSystem::OpenLanguagePak(const char* sLanguage)
|
||||
// Initialize languages.
|
||||
|
||||
// Omit the trailing slash!
|
||||
string sLocalizationFolder = PathUtil::GetLocalizationFolder();
|
||||
AZStd::string sLocalizationFolder = PathUtil::GetLocalizationFolder();
|
||||
|
||||
// load xml pak with full filenames to perform wildcard searches.
|
||||
string sLocalizedPath;
|
||||
AZStd::string sLocalizedPath;
|
||||
GetLocalizedPath(sLanguage, sLocalizedPath);
|
||||
if (!m_env.pCryPak->OpenPacks({ sLocalizationFolder.c_str(), sLocalizationFolder.size() }, { sLocalizedPath.c_str(), sLocalizedPath.size() }, 0))
|
||||
{
|
||||
@@ -1000,15 +999,15 @@ void CSystem::OpenLanguageAudioPak([[maybe_unused]] const char* sLanguage)
|
||||
int nPakFlags = 0;
|
||||
|
||||
// Omit the trailing slash!
|
||||
string sLocalizationFolder(string().assign(PathUtil::GetLocalizationFolder(), 0, PathUtil::GetLocalizationFolder().size() - 1));
|
||||
AZStd::string sLocalizationFolder(AZStd::string().assign(PathUtil::GetLocalizationFolder(), 0, PathUtil::GetLocalizationFolder().size() - 1));
|
||||
|
||||
if (sLocalizationFolder.compareNoCase("Languages") == 0)
|
||||
if (!AZ::StringFunc::Equal(sLocalizationFolder, "Languages", false))
|
||||
{
|
||||
sLocalizationFolder = "@assets@";
|
||||
}
|
||||
|
||||
// load localized pak with crc32 filenames on consoles to save memory.
|
||||
string sLocalizedPath = "loc.pak";
|
||||
AZStd::string sLocalizedPath = "loc.pak";
|
||||
|
||||
if (!m_env.pCryPak->OpenPacks(sLocalizationFolder.c_str(), sLocalizedPath.c_str(), nPakFlags))
|
||||
{
|
||||
@@ -1018,10 +1017,10 @@ void CSystem::OpenLanguageAudioPak([[maybe_unused]] const char* sLanguage)
|
||||
}
|
||||
|
||||
|
||||
string GetUniqueLogFileName(string logFileName)
|
||||
AZStd::string GetUniqueLogFileName(AZStd::string logFileName)
|
||||
{
|
||||
string logFileNamePrefix = logFileName;
|
||||
if ((logFileNamePrefix[0] != '@') && (AzFramework::StringFunc::Path::IsRelative(logFileNamePrefix)))
|
||||
AZStd::string logFileNamePrefix = logFileName;
|
||||
if ((logFileNamePrefix[0] != '@') && (AzFramework::StringFunc::Path::IsRelative(logFileNamePrefix.c_str())))
|
||||
{
|
||||
logFileNamePrefix = "@log@/";
|
||||
logFileNamePrefix += logFileName;
|
||||
@@ -1037,9 +1036,9 @@ string GetUniqueLogFileName(string logFileName)
|
||||
return logFileNamePrefix;
|
||||
}
|
||||
|
||||
string logFileExtension;
|
||||
AZStd::string logFileExtension;
|
||||
size_t extensionIndex = logFileName.find_last_of('.');
|
||||
if (extensionIndex != string::npos)
|
||||
if (extensionIndex != AZStd::string::npos)
|
||||
{
|
||||
logFileExtension = logFileName.substr(extensionIndex, logFileName.length() - extensionIndex);
|
||||
logFileNamePrefix = logFileName.substr(0, extensionIndex);
|
||||
@@ -1213,7 +1212,7 @@ bool CSystem::Init(const SSystemInitParams& startupParams)
|
||||
|
||||
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||
AZ_PUSH_DISABLE_WARNING(4996, "-Wunknown-warning-option")
|
||||
GetVersionExA(&osvi);
|
||||
GetVersionExW(&osvi);
|
||||
AZ_POP_DISABLE_WARNING
|
||||
|
||||
bool bIsWindowsXPorLater = osvi.dwMajorVersion > 5 || (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion >= 1);
|
||||
@@ -1308,7 +1307,7 @@ AZ_POP_DISABLE_WARNING
|
||||
}
|
||||
else if (startupParams.sLogFileName) //otherwise see if the startup params has a log file name, if so use it
|
||||
{
|
||||
const string sUniqueLogFileName = GetUniqueLogFileName(startupParams.sLogFileName);
|
||||
const AZStd::string sUniqueLogFileName = GetUniqueLogFileName(startupParams.sLogFileName);
|
||||
m_env.pLog->SetFileName(sUniqueLogFileName.c_str(), startupParams.autoBackupLogs);
|
||||
}
|
||||
else//use the default log name
|
||||
@@ -1656,20 +1655,20 @@ static void LoadConfigurationCmd(IConsoleCmdArgs* pParams)
|
||||
return;
|
||||
}
|
||||
|
||||
GetISystem()->LoadConfiguration(string("Config/") + pParams->GetArg(1));
|
||||
GetISystem()->LoadConfiguration((AZStd::string("Config/") + pParams->GetArg(1)).c_str());
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
static string ConcatPath(const char* szPart1, const char* szPart2)
|
||||
static AZStd::string ConcatPath(const char* szPart1, const char* szPart2)
|
||||
{
|
||||
if (szPart1[0] == 0)
|
||||
{
|
||||
return szPart2;
|
||||
}
|
||||
|
||||
string ret;
|
||||
AZStd::string ret;
|
||||
|
||||
ret.reserve(strlen(szPart1) + 1 + strlen(szPart2));
|
||||
|
||||
@@ -2133,12 +2132,12 @@ void CSystem::CreateAudioVars()
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
void CSystem::AddCVarGroupDirectory(const string& sPath)
|
||||
void CSystem::AddCVarGroupDirectory(const AZStd::string& sPath)
|
||||
{
|
||||
CryLog("creating CVarGroups from directory '%s' ...", sPath.c_str());
|
||||
INDENT_LOG_DURING_SCOPE();
|
||||
|
||||
AZ::IO::ArchiveFileIterator handle = gEnv->pCryPak->FindFirst(ConcatPath(sPath, "*.cfg").c_str());
|
||||
AZ::IO::ArchiveFileIterator handle = gEnv->pCryPak->FindFirst(ConcatPath(sPath.c_str(), "*.cfg").c_str());
|
||||
|
||||
if (!handle)
|
||||
{
|
||||
@@ -2151,16 +2150,9 @@ void CSystem::AddCVarGroupDirectory(const string& sPath)
|
||||
{
|
||||
if (handle.m_filename != "." && handle.m_filename != "..")
|
||||
{
|
||||
AddCVarGroupDirectory(ConcatPath(sPath, handle.m_filename.data()));
|
||||
AddCVarGroupDirectory(ConcatPath(sPath.c_str(), handle.m_filename.data()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string sFilePath = ConcatPath(sPath, handle.m_filename.data());
|
||||
|
||||
string sCVarName = sFilePath;
|
||||
PathUtil::RemoveExtension(sCVarName);
|
||||
}
|
||||
} while (handle = gEnv->pCryPak->FindNext(handle));
|
||||
|
||||
gEnv->pCryPak->FindClose(handle);
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include <IMovieSystem.h>
|
||||
#include <ILog.h>
|
||||
#include <CryLibrary.h>
|
||||
#include <StringUtils.h>
|
||||
#include <AzCore/Debug/StackTracer.h>
|
||||
#include <AzCore/IO/SystemFile.h> // for AZ_MAX_PATH_LEN
|
||||
#include <AzCore/std/allocator_stack.h>
|
||||
@@ -127,7 +126,7 @@ const char* CSystem::GetUserName()
|
||||
DWORD dwSize = iNameBufferSize;
|
||||
wchar_t nameW[iNameBufferSize];
|
||||
::GetUserNameW(nameW, &dwSize);
|
||||
cry_strcpy(szNameBuffer, CryStringUtils::WStrToUTF8(nameW));
|
||||
AZStd::to_string(szNameBuffer, iNameBufferSize, { nameW, dwSize });
|
||||
return szNameBuffer;
|
||||
#else
|
||||
#if defined(LINUX)
|
||||
@@ -171,12 +170,12 @@ int CSystem::GetApplicationInstance()
|
||||
// this code below essentially "locks" an instance of the USER folder to a specific running application
|
||||
if (m_iApplicationInstance == -1)
|
||||
{
|
||||
string suffix;
|
||||
AZStd::wstring suffix;
|
||||
for (int instance = 0;; ++instance)
|
||||
{
|
||||
suffix.Format("(%d)", instance);
|
||||
suffix = AZStd::wstring::format(L"O3DEApplication(%d)", instance);
|
||||
|
||||
CreateMutex(NULL, TRUE, "LumberyardApplication" + suffix);
|
||||
CreateMutexW(NULL, TRUE, suffix.c_str());
|
||||
// search for duplicates
|
||||
if (GetLastError() != ERROR_ALREADY_EXISTS)
|
||||
{
|
||||
@@ -195,13 +194,13 @@ int CSystem::GetApplicationInstance()
|
||||
int CSystem::GetApplicationLogInstance([[maybe_unused]] const char* logFilePath)
|
||||
{
|
||||
#if AZ_TRAIT_OS_USE_WINDOWS_MUTEX
|
||||
string suffix;
|
||||
AZStd::wstring suffix;
|
||||
int instance = 0;
|
||||
for (;; ++instance)
|
||||
{
|
||||
suffix.Format("(%d)", instance);
|
||||
suffix = AZStd::wstring::format(L"%s(%d)", logFilePath, instance);
|
||||
|
||||
CreateMutex(NULL, TRUE, logFilePath + suffix);
|
||||
CreateMutexW(NULL, TRUE, suffix.c_str());
|
||||
if (GetLastError() != ERROR_ALREADY_EXISTS)
|
||||
{
|
||||
break;
|
||||
@@ -218,30 +217,11 @@ struct CryDbgModule
|
||||
{
|
||||
HANDLE heap;
|
||||
WIN_HMODULE handle;
|
||||
string name;
|
||||
AZStd::string name;
|
||||
DWORD dwSize;
|
||||
};
|
||||
|
||||
#ifdef WIN32
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class CStringOrder
|
||||
{
|
||||
public:
|
||||
bool operator () (const char* szLeft, const char* szRight) const {return azstricmp(szLeft, szRight) < 0; }
|
||||
};
|
||||
typedef std::map<const char*, unsigned, CStringOrder> StringToSizeMap;
|
||||
void AddSize (StringToSizeMap& mapSS, const char* szString, unsigned nSize)
|
||||
{
|
||||
StringToSizeMap::iterator it = mapSS.find (szString);
|
||||
if (it == mapSS.end())
|
||||
{
|
||||
mapSS.insert (StringToSizeMap::value_type(szString, nSize));
|
||||
}
|
||||
else
|
||||
{
|
||||
it->second += nSize;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
const char* GetModuleGroup (const char* szString)
|
||||
@@ -283,7 +263,7 @@ static const char* GetLastSystemErrorMessage()
|
||||
0,
|
||||
NULL))
|
||||
{
|
||||
cry_strcpy(szBuffer, (char*)lpMsgBuf);
|
||||
azstrcpy(szBuffer, AZ_ARRAY_SIZE(szBuffer), (char*)lpMsgBuf);
|
||||
LocalFree(lpMsgBuf);
|
||||
}
|
||||
else
|
||||
@@ -343,12 +323,15 @@ void CSystem::FatalError(const char* format, ...)
|
||||
assert(szBuffer[0] >= ' ');
|
||||
// strcpy(szBuffer,szBuffer+1); // remove verbosity tag since it is not supported by ::MessageBox
|
||||
|
||||
OutputDebugString(szBuffer);
|
||||
AZ::Debug::Platform::OutputToDebugger("CrySystem", szBuffer);
|
||||
|
||||
#ifdef WIN32
|
||||
OnFatalError(szBuffer);
|
||||
if (!g_cvars.sys_no_crash_dialog)
|
||||
{
|
||||
::MessageBox(NULL, szBuffer, "Open 3D Engine Error", MB_OK | MB_ICONERROR | MB_SYSTEMMODAL);
|
||||
AZStd::wstring szBufferW;
|
||||
AZStd::to_wstring(szBufferW, szBuffer);
|
||||
::MessageBoxW(NULL, szBufferW.c_str(), L"Open 3D Engine Error", MB_OK | MB_ICONERROR | MB_SYSTEMMODAL);
|
||||
}
|
||||
|
||||
// Dump callstack.
|
||||
@@ -454,20 +437,20 @@ bool CSystem::ReLaunchMediaCenter()
|
||||
}
|
||||
|
||||
// Get the path to Media Center
|
||||
char szExpandedPath[AZ_MAX_PATH_LEN];
|
||||
if (!ExpandEnvironmentStrings("%SystemRoot%\\ehome\\ehshell.exe", szExpandedPath, AZ_MAX_PATH_LEN))
|
||||
wchar_t szExpandedPath[AZ_MAX_PATH_LEN];
|
||||
if (!ExpandEnvironmentStringsW(L"%SystemRoot%\\ehome\\ehshell.exe", szExpandedPath, AZ_MAX_PATH_LEN))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Skip if ehshell.exe doesn't exist
|
||||
if (GetFileAttributes(szExpandedPath) == 0xFFFFFFFF)
|
||||
if (GetFileAttributesW(szExpandedPath) == 0xFFFFFFFF)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Launch ehshell.exe
|
||||
INT_PTR result = (INT_PTR)ShellExecute(NULL, TEXT("open"), szExpandedPath, NULL, NULL, SW_SHOWNORMAL);
|
||||
INT_PTR result = (INT_PTR)ShellExecuteW(NULL, TEXT("open"), szExpandedPath, NULL, NULL, SW_SHOWNORMAL);
|
||||
return (result > 32);
|
||||
}
|
||||
#else
|
||||
@@ -484,7 +467,7 @@ bool CSystem::GetWinGameFolder(char* szMyDocumentsPath, int maxPathSize)
|
||||
bool bSucceeded = false;
|
||||
// check Vista and later OS first
|
||||
|
||||
HMODULE shell32 = LoadLibraryA("Shell32.dll");
|
||||
HMODULE shell32 = LoadLibraryW(L"Shell32.dll");
|
||||
if (shell32)
|
||||
{
|
||||
typedef long (__stdcall * T_SHGetKnownFolderPath)(REFKNOWNFOLDERID rfid, unsigned long dwFlags, void* hToken, wchar_t** ppszPath);
|
||||
@@ -498,7 +481,7 @@ bool CSystem::GetWinGameFolder(char* szMyDocumentsPath, int maxPathSize)
|
||||
if (bSucceeded)
|
||||
{
|
||||
// Convert from UNICODE to UTF-8
|
||||
cry_strcpy(szMyDocumentsPath, maxPathSize, CryStringUtils::WStrToUTF8(wMyDocumentsPath));
|
||||
AZStd::to_string(szMyDocumentsPath, maxPathSize, wMyDocumentsPath);
|
||||
CoTaskMemFree(wMyDocumentsPath);
|
||||
}
|
||||
}
|
||||
@@ -512,7 +495,7 @@ bool CSystem::GetWinGameFolder(char* szMyDocumentsPath, int maxPathSize)
|
||||
bSucceeded = SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_PERSONAL | CSIDL_FLAG_CREATE, NULL, 0, wMyDocumentsPath));
|
||||
if (bSucceeded)
|
||||
{
|
||||
cry_strcpy(szMyDocumentsPath, maxPathSize, CryStringUtils::WStrToUTF8(wMyDocumentsPath));
|
||||
AZStd::to_string(szMyDocumentsPath, maxPathSize, wMyDocumentsPath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -540,7 +523,7 @@ void CSystem::DetectGameFolderAccessRights()
|
||||
BOOL bAccessStatus = FALSE;
|
||||
|
||||
// Get a pointer to the existing DACL.
|
||||
dwRes = GetNamedSecurityInfo(".", SE_FILE_OBJECT,
|
||||
dwRes = GetNamedSecurityInfoW(L".", SE_FILE_OBJECT,
|
||||
DACL_SECURITY_INFORMATION | OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION,
|
||||
NULL, NULL, &pDACL, NULL, &pSD);
|
||||
|
||||
|
||||
@@ -66,7 +66,9 @@ LONG WINAPI CryEngineExceptionFilterMiniDump(struct _EXCEPTION_POINTERS* pExcept
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
}
|
||||
|
||||
HANDLE hFile = ::CreateFile(szDumpPath, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
AZStd::wstring szDumpPathW;
|
||||
AZStd::to_wstring(szDumpPathW, szDumpPath);
|
||||
HANDLE hFile = ::CreateFileW(szDumpPathW.c_str(), GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
CryLogAlways("Failed to record DMP file: could not open file '%s' for writing - error code: %d", szDumpPath, GetLastError());
|
||||
|
||||
+108
-179
@@ -15,9 +15,6 @@
|
||||
#include "XConsoleVariable.h"
|
||||
#include "System.h"
|
||||
#include "ConsoleBatchFile.h"
|
||||
#include "StringUtils.h"
|
||||
#include "UnicodeFunctions.h"
|
||||
#include "UnicodeIterator.h"
|
||||
|
||||
#include <ITimer.h>
|
||||
#include <IRenderer.h>
|
||||
@@ -87,33 +84,6 @@ inline int GetCharPrio(char x)
|
||||
return x;
|
||||
}
|
||||
}
|
||||
// case sensitive
|
||||
inline bool less_CVar(const char* left, const char* right)
|
||||
{
|
||||
for (;; )
|
||||
{
|
||||
uint32 l = GetCharPrio(*left), r = GetCharPrio(*right);
|
||||
|
||||
if (l < r)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (l > r)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (*left == 0 || *right == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
++left;
|
||||
++right;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Command_SetWaitSeconds(IConsoleCmdArgs* pCmd)
|
||||
{
|
||||
@@ -149,7 +119,7 @@ void Bind(IConsoleCmdArgs* cmdArgs)
|
||||
{
|
||||
if (cmdArgs->GetArgCount() >= 3)
|
||||
{
|
||||
string arg;
|
||||
AZStd::string arg;
|
||||
for (int i = 2; i < cmdArgs->GetArgCount(); ++i)
|
||||
{
|
||||
arg += cmdArgs->GetArg(i);
|
||||
@@ -348,28 +318,6 @@ void CXConsole::Init(ISystem* pSystem)
|
||||
con_restricted = 0;
|
||||
}
|
||||
|
||||
// test cases -----------------------------------------------
|
||||
assert(GetCVar("con_debug") != 0); // should be registered a few lines above
|
||||
assert(GetCVar("Con_Debug") == GetCVar("con_debug")); // different case
|
||||
|
||||
// editor
|
||||
assert(strcmp(AutoComplete("con_"), "con_debug") == 0);
|
||||
assert(strcmp(AutoComplete("CON_"), "con_debug") == 0);
|
||||
assert(strcmp(AutoComplete("con_debug"), "con_display_last_messages") == 0); // actually we should reconsider this behavior
|
||||
assert(strcmp(AutoComplete("Con_Debug"), "con_display_last_messages") == 0); // actually we should reconsider this behavior
|
||||
|
||||
// game
|
||||
assert(strcmp(ProcessCompletion("con_"), "con_debug ") == 0);
|
||||
ResetAutoCompletion();
|
||||
assert(strcmp(ProcessCompletion("CON_"), "con_debug ") == 0);
|
||||
ResetAutoCompletion();
|
||||
assert(strcmp(ProcessCompletion("con_debug"), "con_debug ") == 0);
|
||||
ResetAutoCompletion();
|
||||
assert(strcmp(ProcessCompletion("Con_Debug"), "con_debug ") == 0);
|
||||
ResetAutoCompletion();
|
||||
|
||||
// ----------------------------------------------------------
|
||||
|
||||
m_nLoadingBackTexID = -1;
|
||||
|
||||
if (gEnv->IsDedicated())
|
||||
@@ -414,9 +362,7 @@ void CXConsole::Init(ISystem* pSystem)
|
||||
void CXConsole::LogChangeMessage(const char* name, const bool isConst, const bool isCheat, const bool isReadOnly, const bool isDeprecated,
|
||||
const char* oldValue, const char* newValue, [[maybe_unused]] const bool isProcessingGroup, const bool allowChange)
|
||||
{
|
||||
string logMessage;
|
||||
|
||||
logMessage.Format
|
||||
AZStd::string logMessage = AZStd::string::format
|
||||
("[CVARS]: [%s] variable [%s] from [%s] to [%s]%s; Marked as%s%s%s%s",
|
||||
(allowChange) ? "CHANGED" : "IGNORED CHANGE",
|
||||
name,
|
||||
@@ -452,7 +398,7 @@ void CXConsole::RegisterVar(ICVar* pCVar, ConsoleVarFunc pChangeFunc)
|
||||
bool isReadOnly = ((pCVar->GetFlags() & VF_READONLY) != 0);
|
||||
bool isDeprecated = ((pCVar->GetFlags() & VF_DEPRECATED) != 0);
|
||||
|
||||
ConfigVars::iterator it = m_configVars.find(CONST_TEMP_STRING(pCVar->GetName()));
|
||||
ConfigVars::iterator it = m_configVars.find(pCVar->GetName());
|
||||
if (it != m_configVars.end())
|
||||
{
|
||||
SConfigVar& var = it->second;
|
||||
@@ -906,7 +852,7 @@ void CXConsole::DumpKeyBinds(IKeyBindDumpSink* pCallback)
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
const char* CXConsole::FindKeyBind(const char* sCmd) const
|
||||
{
|
||||
ConsoleBindsMap::const_iterator it = m_mapBinds.find(CONST_TEMP_STRING(sCmd));
|
||||
ConsoleBindsMap::const_iterator it = m_mapBinds.find(sCmd);
|
||||
|
||||
if (it != m_mapBinds.end())
|
||||
{
|
||||
@@ -1263,9 +1209,7 @@ bool CXConsole::ProcessInput(const AzFramework::InputChannel& inputChannel)
|
||||
if (m_nCursorPos)
|
||||
{
|
||||
const char* pCursor = m_sInputBuffer.c_str() + m_nCursorPos;
|
||||
Unicode::CIterator<const char*, false> pUnicode(pCursor);
|
||||
--pUnicode; // Note: This moves back one UCS code-point, but doesn't necessarily match one displayed character (ie, combining diacritics)
|
||||
pCursor = pUnicode.GetPosition();
|
||||
pCursor -= Utf8::Internal::sequence_length(pCursor); // Note: This moves back one UCS code-point, but doesn't necessarily match one displayed character (ie, combining diacritics)
|
||||
m_nCursorPos = pCursor - m_sInputBuffer.c_str();
|
||||
}
|
||||
return true;
|
||||
@@ -1275,9 +1219,7 @@ bool CXConsole::ProcessInput(const AzFramework::InputChannel& inputChannel)
|
||||
if (m_nCursorPos < (int)(m_sInputBuffer.length()))
|
||||
{
|
||||
const char* pCursor = m_sInputBuffer.c_str() + m_nCursorPos;
|
||||
Unicode::CIterator<const char*, false> pUnicode(pCursor);
|
||||
++pUnicode; // Note: This moves forward one UCS code-point, but doesn't necessarily match one displayed character (ie, combining diacritics)
|
||||
pCursor = pUnicode.GetPosition();
|
||||
pCursor += Utf8::Internal::sequence_length(pCursor); // Note: This moves forward one UCS code-point, but doesn't necessarily match one displayed character (ie, combining diacritics)
|
||||
m_nCursorPos = pCursor - m_sInputBuffer.c_str();
|
||||
}
|
||||
return true;
|
||||
@@ -1446,7 +1388,7 @@ bool CXConsole::GetLineNo(const int indwLineNo, char* outszBuffer, const int ind
|
||||
{
|
||||
buf++; // to jump over verbosity level character
|
||||
}
|
||||
cry_strcpy(outszBuffer, indwBufferSize, buf);
|
||||
azstrcpy(outszBuffer, indwBufferSize, buf);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1552,33 +1494,33 @@ const char* CXConsole::GetFlagsString(const uint32 dwFlags)
|
||||
static char sFlags[256];
|
||||
|
||||
// hiding this makes it a bit more difficult for cheaters
|
||||
// if(dwFlags&VF_CHEAT) cry_strcat( sFlags,"CHEAT, ");
|
||||
// if(dwFlags&VF_CHEAT) azstrcat( sFlags,"CHEAT, ");
|
||||
|
||||
cry_strcpy(sFlags, "");
|
||||
azstrcpy(sFlags, AZ_ARRAY_SIZE(sFlags), "");
|
||||
|
||||
if (dwFlags & VF_READONLY)
|
||||
{
|
||||
cry_strcat(sFlags, "READONLY, ");
|
||||
azstrcat(sFlags, AZ_ARRAY_SIZE(sFlags), "READONLY, ");
|
||||
}
|
||||
if (dwFlags & VF_DEPRECATED)
|
||||
{
|
||||
cry_strcat(sFlags, "DEPRECATED, ");
|
||||
azstrcat(sFlags, AZ_ARRAY_SIZE(sFlags), "DEPRECATED, ");
|
||||
}
|
||||
if (dwFlags & VF_DUMPTODISK)
|
||||
{
|
||||
cry_strcat(sFlags, "DUMPTODISK, ");
|
||||
azstrcat(sFlags, AZ_ARRAY_SIZE(sFlags), "DUMPTODISK, ");
|
||||
}
|
||||
if (dwFlags & VF_REQUIRE_LEVEL_RELOAD)
|
||||
{
|
||||
cry_strcat(sFlags, "REQUIRE_LEVEL_RELOAD, ");
|
||||
azstrcat(sFlags, AZ_ARRAY_SIZE(sFlags), "REQUIRE_LEVEL_RELOAD, ");
|
||||
}
|
||||
if (dwFlags & VF_REQUIRE_APP_RESTART)
|
||||
{
|
||||
cry_strcat(sFlags, "REQUIRE_APP_RESTART, ");
|
||||
azstrcat(sFlags, AZ_ARRAY_SIZE(sFlags), "REQUIRE_APP_RESTART, ");
|
||||
}
|
||||
if (dwFlags & VF_RESTRICTEDMODE)
|
||||
{
|
||||
cry_strcat(sFlags, "RESTRICTEDMODE, ");
|
||||
azstrcat(sFlags, AZ_ARRAY_SIZE(sFlags), "RESTRICTEDMODE, ");
|
||||
}
|
||||
|
||||
if (sFlags[0] != 0)
|
||||
@@ -1794,7 +1736,7 @@ void CXConsole::DisplayHelp(const char* help, const char* name)
|
||||
char* start, * pos;
|
||||
for (pos = strstr((char*)help, "\n"), start = (char*)help; pos; start = ++pos)
|
||||
{
|
||||
string s = start;
|
||||
AZStd::string s = start;
|
||||
s.resize(pos - start);
|
||||
ConsoleLogInputResponse(" $3%s", s.c_str());
|
||||
pos = strstr(pos, "\n");
|
||||
@@ -1816,11 +1758,12 @@ void CXConsole::ExecuteString(const char* command, const bool bSilentMode, const
|
||||
|
||||
// Store the string commands into a list and defer the execution for later.
|
||||
// The commands will be processed in CXConsole::Update()
|
||||
string str(command);
|
||||
str.TrimLeft();
|
||||
AZStd::string str(command);
|
||||
AZ::StringFunc::TrimWhiteSpace(str, true, false);
|
||||
|
||||
// Unroll the exec command
|
||||
bool unroll = (0 == str.Left(strlen("exec")).compareNoCase("exec"));
|
||||
|
||||
bool unroll = (0 == AZ::StringFunc::Find(str, "exec", 0, false, false));
|
||||
|
||||
if (unroll)
|
||||
{
|
||||
@@ -1858,10 +1801,10 @@ void CXConsole::ResetCVarsToDefaults()
|
||||
|
||||
}
|
||||
|
||||
void CXConsole::SplitCommands(const char* line, std::list<string>& split)
|
||||
void CXConsole::SplitCommands(const char* line, std::list<AZStd::string>& split)
|
||||
{
|
||||
const char* start = line;
|
||||
string working;
|
||||
AZStd::string working;
|
||||
|
||||
while (true)
|
||||
{
|
||||
@@ -1881,7 +1824,7 @@ void CXConsole::SplitCommands(const char* line, std::list<string>& split)
|
||||
case '\0':
|
||||
{
|
||||
working.assign(start, line - 1);
|
||||
working.Trim();
|
||||
AZ::StringFunc::TrimWhiteSpace(working, true, true);
|
||||
|
||||
if (!working.empty())
|
||||
{
|
||||
@@ -1931,15 +1874,15 @@ void CXConsole::ExecuteStringInternal(const char* command, const bool bFromConso
|
||||
ConsoleCommandsMapItor itrCmd;
|
||||
ConsoleVariablesMapItor itrVar;
|
||||
|
||||
std::list<string> lineCommands;
|
||||
std::list<AZStd::string> lineCommands;
|
||||
SplitCommands(command, lineCommands);
|
||||
|
||||
string sTemp;
|
||||
string sCommand, sLineCommand;
|
||||
AZStd::string sTemp;
|
||||
AZStd::string sCommand, sLineCommand;
|
||||
|
||||
while (!lineCommands.empty())
|
||||
{
|
||||
string::size_type nPos;
|
||||
AZStd::string::size_type nPos;
|
||||
|
||||
{
|
||||
sTemp = lineCommands.front();
|
||||
@@ -1951,17 +1894,17 @@ void CXConsole::ExecuteStringInternal(const char* command, const bool bFromConso
|
||||
{
|
||||
if (GetStatus())
|
||||
{
|
||||
AddLine(sTemp);
|
||||
AddLine(sTemp.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
nPos = sTemp.find_first_of('=');
|
||||
|
||||
if (nPos != string::npos)
|
||||
if (nPos != AZStd::string::npos)
|
||||
{
|
||||
sCommand = sTemp.substr(0, nPos);
|
||||
}
|
||||
else if ((nPos = sTemp.find_first_of(' ')) != string::npos)
|
||||
else if ((nPos = sTemp.find_first_of(' ')) != AZStd::string::npos)
|
||||
{
|
||||
sCommand = sTemp.substr(0, nPos);
|
||||
}
|
||||
@@ -1970,7 +1913,7 @@ void CXConsole::ExecuteStringInternal(const char* command, const bool bFromConso
|
||||
sCommand = sTemp;
|
||||
}
|
||||
|
||||
sCommand.Trim();
|
||||
AZ::StringFunc::TrimWhiteSpace(sCommand, true, true);
|
||||
|
||||
//////////////////////////////////////////
|
||||
// Search for CVars
|
||||
@@ -2005,7 +1948,7 @@ void CXConsole::ExecuteStringInternal(const char* command, const bool bFromConso
|
||||
|
||||
//////////////////////////////////////////
|
||||
//Check if is a variable
|
||||
itrVar = m_mapVariables.find(sCommand);
|
||||
itrVar = m_mapVariables.find(sCommand.c_str());
|
||||
if (itrVar != m_mapVariables.end())
|
||||
{
|
||||
ICVar* pCVar = itrVar->second;
|
||||
@@ -2017,10 +1960,10 @@ void CXConsole::ExecuteStringInternal(const char* command, const bool bFromConso
|
||||
m_blockCounter++;
|
||||
}
|
||||
|
||||
if (nPos != string::npos)
|
||||
if (nPos != AZStd::string::npos)
|
||||
{
|
||||
sTemp = sTemp.substr(nPos + 1); // remove the command from sTemp
|
||||
sTemp.Trim(" \t\r\n\"\'");
|
||||
AZ::StringFunc::StripEnds(sTemp, " \t\r\n\"\'");
|
||||
|
||||
if (sTemp == "?")
|
||||
{
|
||||
@@ -2094,12 +2037,12 @@ void CXConsole::ExecuteDeferredCommands()
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CXConsole::ExecuteCommand(CConsoleCommand& cmd, string& str, bool bIgnoreDevMode)
|
||||
void CXConsole::ExecuteCommand(CConsoleCommand& cmd, AZStd::string& str, bool bIgnoreDevMode)
|
||||
{
|
||||
CryLog ("[CONSOLE] Executing console command '%s'", str.c_str());
|
||||
INDENT_LOG_DURING_SCOPE();
|
||||
|
||||
std::vector<string> args;
|
||||
std::vector<AZStd::string> args;
|
||||
size_t t;
|
||||
|
||||
{
|
||||
@@ -2118,7 +2061,7 @@ void CXConsole::ExecuteCommand(CConsoleCommand& cmd, string& str, bool bIgnoreDe
|
||||
{
|
||||
;
|
||||
}
|
||||
args.push_back(string(start + 1, commandLine - 1));
|
||||
args.push_back(AZStd::string(start + 1, commandLine - 1));
|
||||
start = commandLine;
|
||||
break;
|
||||
}
|
||||
@@ -2129,7 +2072,7 @@ void CXConsole::ExecuteCommand(CConsoleCommand& cmd, string& str, bool bIgnoreDe
|
||||
{
|
||||
if ((*commandLine == ' ') || !*commandLine)
|
||||
{
|
||||
args.push_back(string(start, commandLine));
|
||||
args.push_back(AZStd::string(start, commandLine));
|
||||
start = commandLine + 1;
|
||||
}
|
||||
}
|
||||
@@ -2139,7 +2082,7 @@ void CXConsole::ExecuteCommand(CConsoleCommand& cmd, string& str, bool bIgnoreDe
|
||||
|
||||
if (args.size() >= 2 && args[1] == "?")
|
||||
{
|
||||
DisplayHelp(cmd.m_sHelp, cmd.m_sName.c_str());
|
||||
DisplayHelp(cmd.m_sHelp.c_str(), cmd.m_sName.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2166,13 +2109,13 @@ void CXConsole::ExecuteCommand(CConsoleCommand& cmd, string& str, bool bIgnoreDe
|
||||
return;
|
||||
}
|
||||
|
||||
string buf;
|
||||
AZStd::string buf;
|
||||
{
|
||||
// only do this for commands with script implementation
|
||||
for (;; )
|
||||
{
|
||||
t = str.find_first_of("\\", t);
|
||||
if (t == string::npos)
|
||||
if (t == AZStd::string::npos)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -2183,7 +2126,7 @@ void CXConsole::ExecuteCommand(CConsoleCommand& cmd, string& str, bool bIgnoreDe
|
||||
for (t = 1;; )
|
||||
{
|
||||
t = str.find_first_of("\"", t);
|
||||
if (t == string::npos)
|
||||
if (t == AZStd::string::npos)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -2194,9 +2137,9 @@ void CXConsole::ExecuteCommand(CConsoleCommand& cmd, string& str, bool bIgnoreDe
|
||||
buf = cmd.m_sCommand;
|
||||
|
||||
size_t pp = buf.find("%%");
|
||||
if (pp != string::npos)
|
||||
if (pp != AZStd::string::npos)
|
||||
{
|
||||
string list = "";
|
||||
AZStd::string list = "";
|
||||
for (unsigned int i = 1; i < args.size(); i++)
|
||||
{
|
||||
list += "\"" + args[i] + "\"";
|
||||
@@ -2207,9 +2150,9 @@ void CXConsole::ExecuteCommand(CConsoleCommand& cmd, string& str, bool bIgnoreDe
|
||||
}
|
||||
buf.replace(pp, 2, list);
|
||||
}
|
||||
else if ((pp = buf.find("%line")) != string::npos)
|
||||
else if ((pp = buf.find("%line")) != AZStd::string::npos)
|
||||
{
|
||||
string tmp = "\"" + str.substr(str.find(" ") + 1) + "\"";
|
||||
AZStd::string tmp = "\"" + str.substr(str.find(" ") + 1) + "\"";
|
||||
if (args.size() > 1)
|
||||
{
|
||||
buf.replace(pp, 5, tmp);
|
||||
@@ -2226,7 +2169,7 @@ void CXConsole::ExecuteCommand(CConsoleCommand& cmd, string& str, bool bIgnoreDe
|
||||
char pat[10];
|
||||
azsprintf(pat, "%%%d", i);
|
||||
size_t pos = buf.find(pat);
|
||||
if (pos == string::npos)
|
||||
if (pos == AZStd::string::npos)
|
||||
{
|
||||
if (i != args.size())
|
||||
{
|
||||
@@ -2241,7 +2184,7 @@ void CXConsole::ExecuteCommand(CConsoleCommand& cmd, string& str, bool bIgnoreDe
|
||||
ConsoleWarning("Not enough arguments for: %s", cmd.m_sName.c_str());
|
||||
return;
|
||||
}
|
||||
string arg = "\"" + args[i] + "\"";
|
||||
AZStd::string arg = "\"" + args[i] + "\"";
|
||||
buf.replace(pos, strlen(pat), arg);
|
||||
}
|
||||
}
|
||||
@@ -2340,15 +2283,15 @@ const char* CXConsole::ProcessCompletion(const char* szInputBuffer)
|
||||
}
|
||||
//try to search in command list
|
||||
bool bArgumentAutoComplete = false;
|
||||
std::vector<string> matches;
|
||||
std::vector<AZStd::string> matches;
|
||||
|
||||
if (m_sPrevTab.find(' ') != string::npos)
|
||||
if (m_sPrevTab.find(' ') != AZStd::string::npos)
|
||||
{
|
||||
bool bProcessAutoCompl = true;
|
||||
|
||||
// Find command.
|
||||
string sVar = m_sPrevTab.substr(0, m_sPrevTab.find(' '));
|
||||
ICVar* pCVar = GetCVar(sVar);
|
||||
AZStd::string sVar = m_sPrevTab.substr(0, m_sPrevTab.find(' '));
|
||||
ICVar* pCVar = GetCVar(sVar.c_str());
|
||||
if (pCVar)
|
||||
{
|
||||
if (!(pCVar->GetFlags() & VF_RESTRICTEDMODE) && con_restricted) // in restricted mode we allow only VF_RESTRICTEDMODE CVars&CCmd
|
||||
@@ -2376,7 +2319,7 @@ const char* CXConsole::ProcessCompletion(const char* szInputBuffer)
|
||||
int nMatches = pArgumentAutoComplete->GetCount();
|
||||
for (int i = 0; i < nMatches; i++)
|
||||
{
|
||||
string cmd = string(sVar) + " " + pArgumentAutoComplete->GetValue(i);
|
||||
AZStd::string cmd = AZStd::string(sVar) + " " + pArgumentAutoComplete->GetValue(i);
|
||||
if (_strnicmp(m_sPrevTab.c_str(), cmd.c_str(), m_sPrevTab.length()) == 0)
|
||||
{
|
||||
{
|
||||
@@ -2430,16 +2373,16 @@ const char* CXConsole::ProcessCompletion(const char* szInputBuffer)
|
||||
|
||||
if (!matches.empty())
|
||||
{
|
||||
std::sort(matches.begin(), matches.end(), less_CVar); // to sort commands with variables
|
||||
std::sort(matches.begin(), matches.end()); // to sort commands with variables
|
||||
}
|
||||
if (showlist && !matches.empty())
|
||||
{
|
||||
ConsoleLogInput(" "); // empty line before auto completion
|
||||
|
||||
for (std::vector<string>::iterator i = matches.begin(); i != matches.end(); ++i)
|
||||
for (std::vector<AZStd::string>::iterator i = matches.begin(); i != matches.end(); ++i)
|
||||
{
|
||||
// List matching variables
|
||||
const char* sVar = *i;
|
||||
const char* sVar = i->c_str();
|
||||
ICVar* pVar = GetCVar(sVar);
|
||||
|
||||
if (pVar)
|
||||
@@ -2453,7 +2396,7 @@ const char* CXConsole::ProcessCompletion(const char* szInputBuffer)
|
||||
}
|
||||
}
|
||||
|
||||
for (std::vector<string>::iterator i = matches.begin(); i != matches.end(); ++i)
|
||||
for (std::vector<AZStd::string>::iterator i = matches.begin(); i != matches.end(); ++i)
|
||||
{
|
||||
if (m_nTabCount <= nMatch)
|
||||
{
|
||||
@@ -2485,8 +2428,8 @@ void CXConsole::DisplayVarValue(ICVar* pVar)
|
||||
|
||||
const char* sFlagsString = GetFlagsString(pVar->GetFlags());
|
||||
|
||||
string sValue = (pVar->GetFlags() & VF_INVISIBLE) ? "" : pVar->GetString();
|
||||
string sVar = pVar->GetName();
|
||||
AZStd::string sValue = (pVar->GetFlags() & VF_INVISIBLE) ? "" : pVar->GetString();
|
||||
AZStd::string sVar = pVar->GetName();
|
||||
|
||||
char szRealState[40] = "";
|
||||
|
||||
@@ -2623,12 +2566,8 @@ void CXConsole::AddLine(const char* inputStr)
|
||||
|
||||
void CXConsole::PostLine(const char* lineOfText, size_t len)
|
||||
{
|
||||
string line;
|
||||
|
||||
{
|
||||
line = string(lineOfText, len);
|
||||
m_dqConsoleBuffer.push_back(line);
|
||||
}
|
||||
AZStd::string line = AZStd::string(lineOfText, len);
|
||||
m_dqConsoleBuffer.push_back(line);
|
||||
|
||||
int nBufferSize = con_line_buffer_size;
|
||||
|
||||
@@ -2701,7 +2640,7 @@ void CXConsole::RemoveOutputPrintSink(IOutputPrintSink* inpSink)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CXConsole::AddLinePlus(const char* inputStr)
|
||||
{
|
||||
string str, tmpStr;
|
||||
AZStd::string str, tmpStr;
|
||||
|
||||
{
|
||||
if (!m_dqConsoleBuffer.size())
|
||||
@@ -2717,13 +2656,13 @@ void CXConsole::AddLinePlus(const char* inputStr)
|
||||
str.resize(str.size() - 1);
|
||||
}
|
||||
|
||||
string::size_type nPos;
|
||||
while ((nPos = str.find('\n')) != string::npos)
|
||||
AZStd::string::size_type nPos;
|
||||
while ((nPos = str.find('\n')) != AZStd::string::npos)
|
||||
{
|
||||
str.replace(nPos, 1, 1, ' ');
|
||||
}
|
||||
|
||||
while ((nPos = str.find('\r')) != string::npos)
|
||||
while ((nPos = str.find('\r')) != AZStd::string::npos)
|
||||
{
|
||||
str.replace(nPos, 1, 1, ' ');
|
||||
}
|
||||
@@ -2783,7 +2722,7 @@ void CXConsole::AddInputUTF8(const AZStd::string& textUTF8)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CXConsole::ExecuteInputBuffer()
|
||||
{
|
||||
string sTemp = m_sInputBuffer;
|
||||
AZStd::string sTemp = m_sInputBuffer;
|
||||
if (m_sInputBuffer.empty())
|
||||
{
|
||||
return;
|
||||
@@ -2814,9 +2753,7 @@ void CXConsole::RemoveInputChar(bool bBackSpace)
|
||||
const char* const pBase = m_sInputBuffer.c_str();
|
||||
const char* pCursor = pBase + m_nCursorPos;
|
||||
const char* const pEnd = pCursor;
|
||||
Unicode::CIterator<const char*, false> pUnicode(pCursor);
|
||||
pUnicode--; // Remove one UCS code-point, doesn't account for combining diacritics
|
||||
pCursor = pUnicode.GetPosition();
|
||||
pCursor -= Utf8::Internal::sequence_length(pCursor); // Remove one UCS code-point, doesn't account for combining diacritics
|
||||
size_t length = pEnd - pCursor;
|
||||
m_sInputBuffer.erase(pCursor - pBase, length);
|
||||
m_nCursorPos -= length;
|
||||
@@ -2829,9 +2766,7 @@ void CXConsole::RemoveInputChar(bool bBackSpace)
|
||||
const char* const pBase = m_sInputBuffer.c_str();
|
||||
const char* pCursor = pBase + m_nCursorPos;
|
||||
const char* const pBegin = pCursor;
|
||||
Unicode::CIterator<const char*, false> pUnicode(pCursor);
|
||||
pUnicode--; // Remove one UCS code-point, doesn't account for combining diacritics
|
||||
pCursor = pUnicode.GetPosition();
|
||||
pCursor -= Utf8::Internal::sequence_length(pCursor); // Remove one UCS code-point, doesn't account for combining diacritics
|
||||
size_t length = pCursor - pBegin;
|
||||
m_sInputBuffer.erase(pBegin - pBase, length);
|
||||
}
|
||||
@@ -2905,29 +2840,29 @@ void CXConsole::Paste()
|
||||
#if defined(AZ_PLATFORM_WINDOWS)
|
||||
if (OpenClipboard(NULL) != 0)
|
||||
{
|
||||
wstring data;
|
||||
AZStd::string data;
|
||||
const HANDLE wideData = GetClipboardData(CF_UNICODETEXT);
|
||||
if (wideData)
|
||||
{
|
||||
const LPCWSTR pWideData = (LPCWSTR)GlobalLock(wideData);
|
||||
if (pWideData)
|
||||
{
|
||||
// Note: This conversion is just to make sure we discard malicious or malformed data
|
||||
Unicode::ConvertSafe<Unicode::eErrorRecovery_Discard>(data, pWideData);
|
||||
AZStd::to_string(data, pWideData);
|
||||
GlobalUnlock(wideData);
|
||||
}
|
||||
}
|
||||
CloseClipboard();
|
||||
|
||||
for (Unicode::CIterator<wstring::const_iterator> it(data.begin(), data.end()); it != data.end(); ++it)
|
||||
Utf8::Unchecked::octet_iterator end(data.end());
|
||||
for (Utf8::Unchecked::octet_iterator it(data.begin()); it != end; ++it)
|
||||
{
|
||||
const uint32 cp = *it;
|
||||
const wchar_t cp = *it;
|
||||
if (cp != '\r')
|
||||
{
|
||||
// Convert UCS code-point into UTF-8 string
|
||||
char utf8_buf[5];
|
||||
Unicode::Convert(utf8_buf, cp);
|
||||
AddInputUTF8(utf8_buf);
|
||||
AZStd::fixed_string<5> utf8_buf = {0};
|
||||
AZStd::to_string(utf8_buf.data(), 5, { &cp, 1 });
|
||||
AddInputUTF8(utf8_buf.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3030,7 +2965,7 @@ void CXConsole::AddCVarsToHash(ConsoleVariablesVector::const_iterator begin, Con
|
||||
{
|
||||
// add name & variable to string. We add both since adding only the value could cause
|
||||
// many collisions with variables all having value 0 or all 1.
|
||||
string hashStr = it->first;
|
||||
AZStd::string hashStr = it->first;
|
||||
|
||||
runningNameCrc32.Add(hashStr.c_str(), hashStr.length());
|
||||
hashStr += it->second->GetDataProbeString();
|
||||
@@ -3195,7 +3130,7 @@ char* CXConsole::GetCheatVarAt(uint32 nOffset)
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
size_t CXConsole::GetSortedVars(const char** pszArray, size_t numItems, const char* szPrefix)
|
||||
size_t CXConsole::GetSortedVars(AZStd::vector<AZStd::string_view>& pszArray, const char* szPrefix)
|
||||
{
|
||||
size_t i = 0;
|
||||
size_t iPrefixLen = szPrefix ? strlen(szPrefix) : 0;
|
||||
@@ -3205,7 +3140,7 @@ size_t CXConsole::GetSortedVars(const char** pszArray, size_t numItems, const ch
|
||||
ConsoleVariablesMap::const_iterator it, end = m_mapVariables.end();
|
||||
for (it = m_mapVariables.begin(); it != end; ++it)
|
||||
{
|
||||
if (pszArray && i >= numItems)
|
||||
if (i >= pszArray.size())
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -3223,10 +3158,7 @@ size_t CXConsole::GetSortedVars(const char** pszArray, size_t numItems, const ch
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pszArray)
|
||||
{
|
||||
pszArray[i] = it->first;
|
||||
}
|
||||
pszArray[i] = it->first;
|
||||
|
||||
i++;
|
||||
}
|
||||
@@ -3237,7 +3169,7 @@ size_t CXConsole::GetSortedVars(const char** pszArray, size_t numItems, const ch
|
||||
ConsoleCommandsMap::iterator it, end = m_mapCommands.end();
|
||||
for (it = m_mapCommands.begin(); it != end; ++it)
|
||||
{
|
||||
if (pszArray && i >= numItems)
|
||||
if (i >= pszArray.size())
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -3255,18 +3187,15 @@ size_t CXConsole::GetSortedVars(const char** pszArray, size_t numItems, const ch
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pszArray)
|
||||
{
|
||||
pszArray[i] = it->first.c_str();
|
||||
}
|
||||
pszArray[i] = it->first.c_str();
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if (i != 0 && pszArray)
|
||||
if (i != 0)
|
||||
{
|
||||
std::sort(pszArray, pszArray + i, less_CVar);
|
||||
std::sort(pszArray.begin(), pszArray.end());
|
||||
}
|
||||
|
||||
return i;
|
||||
@@ -3275,22 +3204,22 @@ size_t CXConsole::GetSortedVars(const char** pszArray, size_t numItems, const ch
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CXConsole::FindVar(const char* substr)
|
||||
{
|
||||
std::vector<const char*> cmds;
|
||||
AZStd::vector<AZStd::string_view> cmds;
|
||||
cmds.resize(GetNumVars() + m_mapCommands.size());
|
||||
size_t cmdCount = GetSortedVars(&cmds[0], cmds.size());
|
||||
size_t cmdCount = GetSortedVars(cmds);
|
||||
|
||||
for (size_t i = 0; i < cmdCount; i++)
|
||||
{
|
||||
if (CryStringUtils::stristr(cmds[i], substr))
|
||||
if (AZ::StringFunc::Find(cmds[i], substr) != AZStd::string::npos)
|
||||
{
|
||||
ICVar* pCvar = gEnv->pConsole->GetCVar(cmds[i]);
|
||||
ICVar* pCvar = gEnv->pConsole->GetCVar(cmds[i].data());
|
||||
if (pCvar)
|
||||
{
|
||||
DisplayVarValue(pCvar);
|
||||
}
|
||||
else
|
||||
{
|
||||
ConsoleLogInputResponse(" $3%s $6(Command)", cmds[i]);
|
||||
ConsoleLogInputResponse(" $3%.*s $6(Command)", aznumeric_cast<int>(cmds[i].size()), cmds[i].data());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3301,22 +3230,22 @@ const char* CXConsole::AutoComplete(const char* substr)
|
||||
{
|
||||
// following code can be optimized
|
||||
|
||||
std::vector<const char*> cmds;
|
||||
AZStd::vector<AZStd::string_view> cmds;
|
||||
cmds.resize(GetNumVars() + m_mapCommands.size());
|
||||
size_t cmdCount = GetSortedVars(&cmds[0], cmds.size());
|
||||
size_t cmdCount = GetSortedVars(cmds);
|
||||
|
||||
size_t substrLen = strlen(substr);
|
||||
|
||||
// If substring is empty return first command.
|
||||
if (substrLen == 0 && cmdCount > 0)
|
||||
{
|
||||
return cmds[0];
|
||||
return cmds[0].data();
|
||||
}
|
||||
|
||||
// find next
|
||||
for (size_t i = 0; i < cmdCount; i++)
|
||||
{
|
||||
const char* szCmd = cmds[i];
|
||||
const char* szCmd = cmds[i].data();
|
||||
size_t cmdlen = strlen(szCmd);
|
||||
if (cmdlen >= substrLen && memcmp(szCmd, substr, substrLen) == 0)
|
||||
{
|
||||
@@ -3325,32 +3254,32 @@ const char* CXConsole::AutoComplete(const char* substr)
|
||||
i++;
|
||||
if (i < cmdCount)
|
||||
{
|
||||
return cmds[i];
|
||||
return cmds[i].data();
|
||||
}
|
||||
return cmds[i - 1];
|
||||
return cmds[i - 1].data();
|
||||
}
|
||||
return cmds[i];
|
||||
return cmds[i].data();
|
||||
}
|
||||
}
|
||||
|
||||
// then first matching case insensitive
|
||||
for (size_t i = 0; i < cmdCount; i++)
|
||||
{
|
||||
const char* szCmd = cmds[i];
|
||||
const char* szCmd = cmds[i].data();
|
||||
|
||||
size_t cmdlen = strlen(szCmd);
|
||||
if (cmdlen >= substrLen && azmemicmp(szCmd, substr, substrLen) == 0)
|
||||
if (cmdlen >= substrLen && azstrnicmp(szCmd, substr, substrLen) == 0)
|
||||
{
|
||||
if (substrLen == cmdlen)
|
||||
{
|
||||
i++;
|
||||
if (i < cmdCount)
|
||||
{
|
||||
return cmds[i];
|
||||
return cmds[i].data();
|
||||
}
|
||||
return cmds[i - 1];
|
||||
return cmds[i - 1].data();
|
||||
}
|
||||
return cmds[i];
|
||||
return cmds[i].data();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3371,27 +3300,27 @@ void CXConsole::SetInputLine(const char* szLine)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
const char* CXConsole::AutoCompletePrev(const char* substr)
|
||||
{
|
||||
std::vector<const char*> cmds;
|
||||
AZStd::vector<AZStd::string_view> cmds;
|
||||
cmds.resize(GetNumVars() + m_mapCommands.size());
|
||||
size_t cmdCount = GetSortedVars(&cmds[0], cmds.size());
|
||||
size_t cmdCount = GetSortedVars(cmds);
|
||||
|
||||
// If substring is empty return last command.
|
||||
if (strlen(substr) == 0 && cmds.size() > 0)
|
||||
{
|
||||
return cmds[cmdCount - 1];
|
||||
return cmds[cmdCount - 1].data();
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < cmdCount; i++)
|
||||
{
|
||||
if (azstricmp(substr, cmds[i]) == 0)
|
||||
if (azstricmp(substr, cmds[i].data()) == 0)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
return cmds[i - 1];
|
||||
return cmds[i - 1].data();
|
||||
}
|
||||
else
|
||||
{
|
||||
return cmds[0];
|
||||
return cmds[0].data();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3399,7 +3328,7 @@ const char* CXConsole::AutoCompletePrev(const char* substr)
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
inline size_t sizeOf (const string& str)
|
||||
inline size_t sizeOf (const AZStd::string& str)
|
||||
{
|
||||
return str.capacity() + 1;
|
||||
}
|
||||
|
||||
@@ -42,11 +42,11 @@ enum ScrollDir
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
struct CConsoleCommand
|
||||
{
|
||||
string m_sName; // Console command name
|
||||
string m_sCommand; // lua code that is executed when this command is invoked
|
||||
string m_sHelp; // optional help string - can be shown in the console with "<commandname> ?"
|
||||
int m_nFlags; // bitmask consist of flag starting with VF_ e.g. VF_CHEAT
|
||||
ConsoleCommandFunc m_func; // Pointer to console command.
|
||||
AZStd::string m_sName; // Console command name
|
||||
AZStd::string m_sCommand; // lua code that is executed when this command is invoked
|
||||
AZStd::string m_sHelp; // optional help string - can be shown in the console with "<commandname> ?"
|
||||
int m_nFlags; // bitmask consist of flag starting with VF_ e.g. VF_CHEAT
|
||||
ConsoleCommandFunc m_func; // Pointer to console command.
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CConsoleCommand()
|
||||
@@ -67,7 +67,7 @@ struct CConsoleCommand
|
||||
struct CConsoleCommandArgs
|
||||
: public IConsoleCmdArgs
|
||||
{
|
||||
CConsoleCommandArgs(string& line, std::vector<string>& args)
|
||||
CConsoleCommandArgs(AZStd::string& line, std::vector<AZStd::string>& args)
|
||||
: m_line(line)
|
||||
, m_args(args) {};
|
||||
virtual int GetArgCount() const { return static_cast<int>(m_args.size()); };
|
||||
@@ -87,34 +87,20 @@ struct CConsoleCommandArgs
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<string>& m_args;
|
||||
string& m_line;
|
||||
std::vector<AZStd::string>& m_args;
|
||||
AZStd::string& m_line;
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct string_nocase_lt
|
||||
{
|
||||
bool operator()(const char* s1, const char* s2) const
|
||||
bool operator()(const AZStd::string& s1, const AZStd::string& s2) const
|
||||
{
|
||||
return azstricmp(s1, s2) < 0;
|
||||
return azstricmp(s1.c_str(), s2.c_str()) < 0;
|
||||
}
|
||||
};
|
||||
|
||||
/* - very dangerous to use with STL containers
|
||||
struct string_nocase_lt
|
||||
{
|
||||
bool operator()( const char *s1,const char *s2 ) const
|
||||
{
|
||||
return _stricmp(s1,s2) < 0;
|
||||
}
|
||||
bool operator()( const string &s1,const string &s2 ) const
|
||||
{
|
||||
return _stricmp(s1.c_str(),s2.c_str()) < 0;
|
||||
}
|
||||
};
|
||||
*/
|
||||
|
||||
//forward declarations
|
||||
class ITexture;
|
||||
struct IRenderer;
|
||||
@@ -132,7 +118,7 @@ class CXConsole
|
||||
, public AzFramework::CommandRegistrationBus::Handler
|
||||
{
|
||||
public:
|
||||
typedef std::deque<string> ConsoleBuffer;
|
||||
typedef std::deque<AZStd::string> ConsoleBuffer;
|
||||
typedef ConsoleBuffer::iterator ConsoleBufferItor;
|
||||
typedef ConsoleBuffer::reverse_iterator ConsoleBufferRItor;
|
||||
|
||||
@@ -195,7 +181,7 @@ public:
|
||||
virtual bool IsOpened();
|
||||
virtual int GetNumVars();
|
||||
virtual int GetNumVisibleVars();
|
||||
virtual size_t GetSortedVars(const char** pszArray, size_t numItems, const char* szPrefix = 0);
|
||||
virtual size_t GetSortedVars(AZStd::vector<AZStd::string_view>& pszArray, const char* szPrefix = 0);
|
||||
virtual int GetNumCheatVars();
|
||||
virtual void SetCheatVarHashRange(size_t firstVar, size_t lastVar);
|
||||
virtual void CalcCheatVarHash();
|
||||
@@ -262,7 +248,7 @@ protected: // ------------------------------------------------------------------
|
||||
void AddInputUTF8(const AZStd::string& textUTF8);
|
||||
void RemoveInputChar(bool bBackSpace);
|
||||
void ExecuteInputBuffer();
|
||||
void ExecuteCommand(CConsoleCommand& cmd, string& params, bool bIgnoreDevMode = false);
|
||||
void ExecuteCommand(CConsoleCommand& cmd, AZStd::string& params, bool bIgnoreDevMode = false);
|
||||
|
||||
void ScrollConsole();
|
||||
|
||||
@@ -294,7 +280,7 @@ protected: // ------------------------------------------------------------------
|
||||
|
||||
// Arguments:
|
||||
// bFromConsole - true=from console, false=from outside
|
||||
void SplitCommands(const char* line, std::list<string>& split);
|
||||
void SplitCommands(const char* line, std::list<AZStd::string>& split);
|
||||
void ExecuteStringInternal(const char* command, const bool bFromConsole, const bool bSilentMode = false);
|
||||
void ExecuteDeferredCommands();
|
||||
|
||||
@@ -320,27 +306,27 @@ private: // ----------------------------------------------------------
|
||||
|
||||
void PostLine(const char* lineOfText, size_t len);
|
||||
|
||||
typedef std::map<string, CConsoleCommand, string_nocase_lt> ConsoleCommandsMap;
|
||||
typedef std::map<AZStd::string, CConsoleCommand, string_nocase_lt> ConsoleCommandsMap;
|
||||
typedef ConsoleCommandsMap::iterator ConsoleCommandsMapItor;
|
||||
|
||||
typedef std::map<string, string> ConsoleBindsMap;
|
||||
typedef std::map<AZStd::string, AZStd::string> ConsoleBindsMap;
|
||||
typedef ConsoleBindsMap::iterator ConsoleBindsMapItor;
|
||||
|
||||
typedef std::map<string, IConsoleArgumentAutoComplete*, stl::less_stricmp<string> > ArgumentAutoCompleteMap;
|
||||
typedef std::map<AZStd::string, IConsoleArgumentAutoComplete*, stl::less_stricmp<AZStd::string> > ArgumentAutoCompleteMap;
|
||||
|
||||
struct SConfigVar
|
||||
{
|
||||
string m_value;
|
||||
AZStd::string m_value;
|
||||
bool m_partOfGroup;
|
||||
};
|
||||
typedef std::map<string, SConfigVar, string_nocase_lt> ConfigVars;
|
||||
typedef std::map<AZStd::string, SConfigVar, string_nocase_lt> ConfigVars;
|
||||
|
||||
struct SDeferredCommand
|
||||
{
|
||||
string command;
|
||||
AZStd::string command;
|
||||
bool silentMode;
|
||||
|
||||
SDeferredCommand(const string& _command, bool _silentMode)
|
||||
SDeferredCommand(const AZStd::string& _command, bool _silentMode)
|
||||
: command(_command)
|
||||
, silentMode(_silentMode)
|
||||
{}
|
||||
@@ -359,10 +345,10 @@ private: // ----------------------------------------------------------
|
||||
int m_nProgress;
|
||||
int m_nProgressRange;
|
||||
|
||||
string m_sInputBuffer;
|
||||
string m_sReturnString;
|
||||
AZStd::string m_sInputBuffer;
|
||||
AZStd::string m_sReturnString;
|
||||
|
||||
string m_sPrevTab;
|
||||
AZStd::string m_sPrevTab;
|
||||
int m_nTabCount;
|
||||
|
||||
ConsoleCommandsMap m_mapCommands; //
|
||||
|
||||
@@ -286,7 +286,7 @@ void CXConsoleVariableCVarGroup::OnLoadConfigurationEntry_End()
|
||||
{
|
||||
if (!m_sDefaultValue.empty())
|
||||
{
|
||||
gEnv->pConsole->LoadConfigVar(GetName(), m_sDefaultValue);
|
||||
gEnv->pConsole->LoadConfigVar(GetName(), m_sDefaultValue.c_str());
|
||||
m_sDefaultValue.clear();
|
||||
}
|
||||
}
|
||||
@@ -299,9 +299,9 @@ CXConsoleVariableCVarGroup::CXConsoleVariableCVarGroup(CXConsole* pConsole, cons
|
||||
}
|
||||
|
||||
|
||||
string CXConsoleVariableCVarGroup::GetDetailedInfo() const
|
||||
AZStd::string CXConsoleVariableCVarGroup::GetDetailedInfo() const
|
||||
{
|
||||
string sRet = GetName();
|
||||
AZStd::string sRet = GetName();
|
||||
|
||||
sRet += " [";
|
||||
|
||||
@@ -326,11 +326,11 @@ string CXConsoleVariableCVarGroup::GetDetailedInfo() const
|
||||
sRet += "/default] [current]:\n";
|
||||
|
||||
|
||||
std::map<string, string>::const_iterator it, end = m_CVarGroupDefault.m_KeyValuePair.end();
|
||||
std::map<AZStd::string, AZStd::string>::const_iterator it, end = m_CVarGroupDefault.m_KeyValuePair.end();
|
||||
|
||||
for (it = m_CVarGroupDefault.m_KeyValuePair.begin(); it != end; ++it)
|
||||
{
|
||||
const string& rKey = it->first;
|
||||
const AZStd::string& rKey = it->first;
|
||||
|
||||
sRet += " ... ";
|
||||
sRet += rKey;
|
||||
@@ -344,7 +344,7 @@ string CXConsoleVariableCVarGroup::GetDetailedInfo() const
|
||||
sRet += "/";
|
||||
}
|
||||
sRet += GetValueSpec(rKey);
|
||||
ICVar* pCVar = gEnv->pConsole->GetCVar(rKey);
|
||||
ICVar* pCVar = gEnv->pConsole->GetCVar(rKey.c_str());
|
||||
if (pCVar)
|
||||
{
|
||||
sRet += " [";
|
||||
@@ -369,7 +369,7 @@ const char* CXConsoleVariableCVarGroup::GetHelp()
|
||||
}
|
||||
|
||||
// create help on demand
|
||||
string sRet = "Console variable group to apply settings to multiple variables\n\n";
|
||||
AZStd::string sRet = "Console variable group to apply settings to multiple variables\n\n";
|
||||
|
||||
sRet += GetDetailedInfo();
|
||||
|
||||
@@ -545,12 +545,12 @@ bool CXConsoleVariableCVarGroup::TestCVars(const SCVarGroup* pGroup, const ICVar
|
||||
bool CXConsoleVariableCVarGroup::TestCVars(const SCVarGroup& rGroup, const ICVar::EConsoleLogMode mode, const SCVarGroup* pExclude) const
|
||||
{
|
||||
bool bRet = true;
|
||||
std::map<string, string>::const_iterator it, end = rGroup.m_KeyValuePair.end();
|
||||
std::map<AZStd::string, AZStd::string>::const_iterator it, end = rGroup.m_KeyValuePair.end();
|
||||
|
||||
for (it = rGroup.m_KeyValuePair.begin(); it != end; ++it)
|
||||
{
|
||||
const string& rKey = it->first;
|
||||
const string& rValue = it->second;
|
||||
const AZStd::string& rKey = it->first;
|
||||
const AZStd::string& rValue = it->second;
|
||||
|
||||
if (pExclude)
|
||||
{
|
||||
@@ -674,7 +674,7 @@ bool CXConsoleVariableCVarGroup::TestCVars(const SCVarGroup& rGroup, const ICVar
|
||||
|
||||
|
||||
|
||||
string CXConsoleVariableCVarGroup::GetValueSpec(const string& sKey, const int* pSpec) const
|
||||
AZStd::string CXConsoleVariableCVarGroup::GetValueSpec(const AZStd::string& sKey, const int* pSpec) const
|
||||
{
|
||||
if (pSpec)
|
||||
{
|
||||
@@ -685,7 +685,7 @@ string CXConsoleVariableCVarGroup::GetValueSpec(const string& sKey, const int* p
|
||||
const SCVarGroup* pGrp = itGrp->second;
|
||||
|
||||
// check in spec
|
||||
std::map<string, string>::const_iterator it = pGrp->m_KeyValuePair.find(sKey);
|
||||
std::map<AZStd::string, AZStd::string>::const_iterator it = pGrp->m_KeyValuePair.find(sKey);
|
||||
|
||||
if (it != pGrp->m_KeyValuePair.end())
|
||||
{
|
||||
@@ -695,7 +695,7 @@ string CXConsoleVariableCVarGroup::GetValueSpec(const string& sKey, const int* p
|
||||
}
|
||||
|
||||
// check in default
|
||||
std::map<string, string>::const_iterator it = m_CVarGroupDefault.m_KeyValuePair.find(sKey);
|
||||
std::map<AZStd::string, AZStd::string>::const_iterator it = m_CVarGroupDefault.m_KeyValuePair.find(sKey);
|
||||
|
||||
if (it != m_CVarGroupDefault.m_KeyValuePair.end())
|
||||
{
|
||||
@@ -708,14 +708,14 @@ string CXConsoleVariableCVarGroup::GetValueSpec(const string& sKey, const int* p
|
||||
|
||||
void CXConsoleVariableCVarGroup::ApplyCVars(const SCVarGroup& rGroup, const SCVarGroup* pExclude)
|
||||
{
|
||||
std::map<string, string>::const_iterator it, end = rGroup.m_KeyValuePair.end();
|
||||
std::map<AZStd::string, AZStd::string>::const_iterator it, end = rGroup.m_KeyValuePair.end();
|
||||
|
||||
bool wasProcessingGroup = m_pConsole->GetIsProcessingGroup();
|
||||
m_pConsole->SetProcessingGroup(true);
|
||||
|
||||
for (it = rGroup.m_KeyValuePair.begin(); it != end; ++it)
|
||||
{
|
||||
const string& rKey = it->first;
|
||||
const AZStd::string& rKey = it->first;
|
||||
|
||||
if (pExclude)
|
||||
{
|
||||
@@ -728,7 +728,7 @@ void CXConsoleVariableCVarGroup::ApplyCVars(const SCVarGroup& rGroup, const SCVa
|
||||
// Useful for debugging cvar groups
|
||||
//CryLogAlways("[CVARS]: [APPLY] ([%s]) [%s] = [%s]", GetName(), rKey.c_str(), it->second.c_str());
|
||||
|
||||
m_pConsole->LoadConfigVar(rKey, it->second);
|
||||
m_pConsole->LoadConfigVar(rKey.c_str(), it->second.c_str());
|
||||
}
|
||||
|
||||
m_pConsole->SetProcessingGroup(wasProcessingGroup);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "SFunctor.h"
|
||||
|
||||
class CXConsole;
|
||||
typedef AZStd::fixed_string<512> stack_string;
|
||||
|
||||
inline int64 TextToInt64(const char* s, int64 nCurrent, bool bBitfield)
|
||||
{
|
||||
@@ -178,19 +179,22 @@ public:
|
||||
CXConsoleVariableString(CXConsole* pConsole, const char* sName, const char* szDefault, int nFlags, const char* help)
|
||||
: CXConsoleVariableBase(pConsole, sName, nFlags, help)
|
||||
{
|
||||
m_sValue = szDefault;
|
||||
m_sDefault = szDefault;
|
||||
if (szDefault)
|
||||
{
|
||||
m_sValue = szDefault;
|
||||
m_sDefault = szDefault;
|
||||
}
|
||||
}
|
||||
|
||||
// interface ICVar --------------------------------------------------------------------------------------
|
||||
|
||||
virtual int GetIVal() const { return atoi(m_sValue); }
|
||||
virtual int64 GetI64Val() const { return _atoi64(m_sValue); }
|
||||
virtual float GetFVal() const { return (float)atof(m_sValue); }
|
||||
virtual const char* GetString() const { return m_sValue; }
|
||||
virtual int GetIVal() const { return atoi(m_sValue.c_str()); }
|
||||
virtual int64 GetI64Val() const { return _atoi64(m_sValue.c_str()); }
|
||||
virtual float GetFVal() const { return (float)atof(m_sValue.c_str()); }
|
||||
virtual const char* GetString() const { return m_sValue.c_str(); }
|
||||
virtual void ResetImpl()
|
||||
{
|
||||
Set(m_sDefault);
|
||||
Set(m_sDefault.c_str());
|
||||
}
|
||||
virtual void Set(const char* s)
|
||||
{
|
||||
@@ -219,8 +223,7 @@ public:
|
||||
|
||||
virtual void Set(float f)
|
||||
{
|
||||
stack_string s;
|
||||
s.Format("%g", f);
|
||||
stack_string s = stack_string::format("%g", f);
|
||||
|
||||
if ((m_sValue == s.c_str()) && (m_nFlags & VF_ALWAYSONCHANGE) == 0)
|
||||
{
|
||||
@@ -233,8 +236,7 @@ public:
|
||||
|
||||
virtual void Set(int i)
|
||||
{
|
||||
stack_string s;
|
||||
s.Format("%d", i);
|
||||
stack_string s = stack_string::format("%d", i);
|
||||
|
||||
if ((m_sValue == s.c_str()) && (m_nFlags & VF_ALWAYSONCHANGE) == 0)
|
||||
{
|
||||
@@ -248,8 +250,8 @@ public:
|
||||
|
||||
virtual void GetMemoryUsage(class ICrySizer* pSizer) const { pSizer->AddObject(this, sizeof(*this)); }
|
||||
private: // --------------------------------------------------------------------------------------------
|
||||
string m_sValue;
|
||||
string m_sDefault; //!<
|
||||
AZStd::string m_sValue;
|
||||
AZStd::string m_sDefault; //!<
|
||||
};
|
||||
|
||||
|
||||
@@ -296,8 +298,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
stack_string s;
|
||||
s.Format("%d", i);
|
||||
stack_string s = stack_string::format("%d", i);
|
||||
|
||||
if (m_pConsole->OnBeforeVarChange(this, s.c_str()))
|
||||
{
|
||||
@@ -364,8 +365,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
stack_string s;
|
||||
s.Format("%lld", i);
|
||||
stack_string s = stack_string::format("%lld", i);
|
||||
|
||||
if (m_pConsole->OnBeforeVarChange(this, s.c_str()))
|
||||
{
|
||||
@@ -442,8 +442,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
stack_string s;
|
||||
s.Format("%g", f);
|
||||
stack_string s = stack_string::format("%g", f);
|
||||
|
||||
if (m_pConsole->OnBeforeVarChange(this, s.c_str()))
|
||||
{
|
||||
@@ -718,7 +717,7 @@ public:
|
||||
{
|
||||
return m_sValue.c_str();
|
||||
}
|
||||
virtual void ResetImpl() { Set(m_sDefault); }
|
||||
virtual void ResetImpl() { Set(m_sDefault.c_str()); }
|
||||
virtual void Set(const char* s)
|
||||
{
|
||||
if ((m_sValue == s) && (m_nFlags & VF_ALWAYSONCHANGE) == 0)
|
||||
@@ -740,14 +739,12 @@ public:
|
||||
}
|
||||
virtual void Set(float f)
|
||||
{
|
||||
stack_string s;
|
||||
s.Format("%g", f);
|
||||
stack_string s = stack_string::format("%g", f);
|
||||
Set(s.c_str());
|
||||
}
|
||||
virtual void Set(int i)
|
||||
{
|
||||
stack_string s;
|
||||
s.Format("%d", i);
|
||||
stack_string s = stack_string::format("%d", i);
|
||||
Set(s.c_str());
|
||||
}
|
||||
virtual int GetType() { return CVAR_STRING; }
|
||||
@@ -755,8 +752,8 @@ public:
|
||||
virtual void GetMemoryUsage(class ICrySizer* pSizer) const { pSizer->AddObject(this, sizeof(*this)); }
|
||||
private: // --------------------------------------------------------------------------------------------
|
||||
|
||||
string m_sValue;
|
||||
string m_sDefault;
|
||||
AZStd::string m_sValue;
|
||||
AZStd::string m_sDefault;
|
||||
const char*& m_userPtr; //!<
|
||||
};
|
||||
|
||||
@@ -778,7 +775,7 @@ public:
|
||||
|
||||
// Returns:
|
||||
// part of the help string - useful to log out detailed description without additional help text
|
||||
string GetDetailedInfo() const;
|
||||
AZStd::string GetDetailedInfo() const;
|
||||
|
||||
// interface ICVar -----------------------------------------------------------------------------------
|
||||
|
||||
@@ -809,7 +806,7 @@ private: // --------------------------------------------------------------------
|
||||
|
||||
struct SCVarGroup
|
||||
{
|
||||
std::map<string, string> m_KeyValuePair; // e.g. m_KeyValuePair["r_fullscreen"]="0"
|
||||
std::map<AZStd::string, AZStd::string> m_KeyValuePair; // e.g. m_KeyValuePair["r_fullscreen"]="0"
|
||||
void GetMemoryUsage(class ICrySizer* pSizer) const
|
||||
{
|
||||
pSizer->AddObject(m_KeyValuePair);
|
||||
@@ -818,15 +815,15 @@ private: // --------------------------------------------------------------------
|
||||
|
||||
SCVarGroup m_CVarGroupDefault;
|
||||
typedef std::map<int, SCVarGroup*> TCVarGroupStateMap;
|
||||
TCVarGroupStateMap m_CVarGroupStates;
|
||||
string m_sDefaultValue; // used by OnLoadConfigurationEntry_End()
|
||||
TCVarGroupStateMap m_CVarGroupStates;
|
||||
AZStd::string m_sDefaultValue; // used by OnLoadConfigurationEntry_End()
|
||||
|
||||
void ApplyCVars(const SCVarGroup& rGroup, const SCVarGroup* pExclude = 0);
|
||||
|
||||
// Arguments:
|
||||
// sKey - must exist, at least in default
|
||||
// pSpec - can be 0
|
||||
string GetValueSpec(const string& sKey, const int* pSpec = 0) const;
|
||||
AZStd::string GetValueSpec(const AZStd::string& sKey, const int* pSpec = 0) const;
|
||||
|
||||
// should only be used by TestCVars()
|
||||
// Returns:
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
ELSE_LOAD_PROPERTY(Vec3); \
|
||||
ELSE_LOAD_PROPERTY(int); \
|
||||
ELSE_LOAD_PROPERTY(float); \
|
||||
ELSE_LOAD_PROPERTY(string); \
|
||||
ELSE_LOAD_PROPERTY(AZStd::string); \
|
||||
ELSE_LOAD_PROPERTY(bool);
|
||||
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <ISystem.h>
|
||||
#include <stack>
|
||||
|
||||
typedef std::map<string, XmlNodeRef> IdTable;
|
||||
typedef std::map<AZStd::string, XmlNodeRef> IdTable;
|
||||
struct SParseParams
|
||||
{
|
||||
IdTable idTable;
|
||||
@@ -98,7 +98,7 @@ struct ReadPropertyTyped
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ReadPropertyTyped<string>
|
||||
struct ReadPropertyTyped<AZStd::string>
|
||||
{
|
||||
static bool Load(const SParseParams& parseParams, const char* name, XmlNodeRef& definition, XmlNodeRef& data, IReadXMLSink* pSink)
|
||||
{
|
||||
@@ -235,8 +235,9 @@ bool LoadProperty(const SParseParams& parseParams, XmlNodeRef& definition, XmlNo
|
||||
|
||||
dataToRead = GetISystem()->CreateXmlNode(data->getTag());
|
||||
|
||||
string content = childRef->getContent();
|
||||
dataToRead->setAttr(name, content.Trim().c_str());
|
||||
AZStd::string content = childRef->getContent();
|
||||
AZ::StringFunc::TrimWhiteSpace(content, true, true);
|
||||
dataToRead->setAttr(name, content.c_str());
|
||||
}
|
||||
|
||||
if (!dataToRead->haveAttr(name))
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#define TAG_SCRIPT_TYPE "t"
|
||||
#define TAG_SCRIPT_NAME "n"
|
||||
|
||||
//#define LOG_SERIALIZE_STACK(tag,szName) CryLogAlways( "<%s> %s/%s",tag,GetStackInfo(),szName );
|
||||
//#define LOG_SERIALIZE_STACK(tag,szName) CryLogAlways( "<%s> %s/%s",tag,GetStackInfo().c_str(), szName);
|
||||
#define LOG_SERIALIZE_STACK(tag, szName)
|
||||
|
||||
CSerializeXMLReaderImpl::CSerializeXMLReaderImpl(const XmlNodeRef& nodeRef)
|
||||
@@ -49,7 +49,7 @@ bool CSerializeXMLReaderImpl::Value(const char* name, int8& value)
|
||||
return bResult;
|
||||
}
|
||||
|
||||
bool CSerializeXMLReaderImpl::Value(const char* name, string& value)
|
||||
bool CSerializeXMLReaderImpl::Value(const char* name, AZStd::string& value)
|
||||
{
|
||||
DefaultValue(value); // Set input value to default.
|
||||
if (m_nErrors)
|
||||
@@ -175,10 +175,9 @@ void CSerializeXMLReaderImpl::EndGroup()
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
const char* CSerializeXMLReaderImpl::GetStackInfo() const
|
||||
AZStd::string CSerializeXMLReaderImpl::GetStackInfo() const
|
||||
{
|
||||
static string str;
|
||||
str.assign("");
|
||||
AZStd::string str;
|
||||
for (int i = 0; i < (int)m_nodeStack.size(); i++)
|
||||
{
|
||||
const char* name = m_nodeStack[i].m_node->getAttr(TAG_SCRIPT_NAME);
|
||||
@@ -195,7 +194,7 @@ const char* CSerializeXMLReaderImpl::GetStackInfo() const
|
||||
str += "/";
|
||||
}
|
||||
}
|
||||
return str.c_str();
|
||||
return str;
|
||||
}
|
||||
|
||||
void CSerializeXMLReaderImpl::GetMemoryUsage(ICrySizer* pSizer) const
|
||||
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
g_pXmlStrCmp = pPrevCmpFunc;
|
||||
return bReturn;
|
||||
}
|
||||
ILINE bool GetAttr([[maybe_unused]] XmlNodeRef& node, [[maybe_unused]] const char* name, [[maybe_unused]] const string& value)
|
||||
ILINE bool GetAttr([[maybe_unused]] XmlNodeRef& node, [[maybe_unused]] const char* name, [[maybe_unused]] const AZStd::string& value)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
}
|
||||
|
||||
bool Value(const char* name, int8& value);
|
||||
bool Value(const char* name, string& value);
|
||||
bool Value(const char* name, AZStd::string& value);
|
||||
bool Value(const char* name, CTimeValue& value);
|
||||
bool Value(const char* name, XmlNodeRef& value);
|
||||
|
||||
@@ -88,7 +88,7 @@ public:
|
||||
void BeginGroup(const char* szName);
|
||||
bool BeginOptionalGroup(const char* szName, bool condition);
|
||||
void EndGroup();
|
||||
const char* GetStackInfo() const;
|
||||
AZStd::string GetStackInfo() const;
|
||||
|
||||
void GetMemoryUsage(ICrySizer* pSizer) const;
|
||||
|
||||
@@ -172,8 +172,8 @@ private:
|
||||
void DefaultValue(Quat& v) const { v.w = 1.0f; v.v.x = 0; v.v.y = 0; v.v.z = 0; }
|
||||
void DefaultValue(CTimeValue& v) const { v.SetValue(0); }
|
||||
//void DefaultValue( char *str ) const { if (str) str[0] = 0; }
|
||||
void DefaultValue(string& str) const { str = ""; }
|
||||
void DefaultValue([[maybe_unused]] const string& str) const {}
|
||||
void DefaultValue(AZStd::string& str) const { str = ""; }
|
||||
void DefaultValue([[maybe_unused]] const AZStd::string& str) const {}
|
||||
void DefaultValue([[maybe_unused]] SNetObjectID& id) const {}
|
||||
void DefaultValue([[maybe_unused]] SSerializeString& str) const {}
|
||||
void DefaultValue(XmlNodeRef& ref) const { ref = NULL; }
|
||||
|
||||
@@ -64,14 +64,14 @@ void CSerializeXMLWriterImpl::BeginGroup(const char* szName)
|
||||
if (strchr(szName, ' ') != 0)
|
||||
{
|
||||
assert(0 && "Spaces in group name not supported");
|
||||
CryWarning(VALIDATOR_MODULE_SYSTEM, VALIDATOR_WARNING, "!Spaces in group name not supported: %s/%s", GetStackInfo(), szName);
|
||||
CryWarning(VALIDATOR_MODULE_SYSTEM, VALIDATOR_WARNING, "!Spaces in group name not supported: %s/%s", GetStackInfo().c_str(), szName);
|
||||
}
|
||||
XmlNodeRef node = CreateNodeNamed(szName);
|
||||
CurNode()->addChild(node);
|
||||
m_nodeStack.push_back(node);
|
||||
if (m_nodeStack.size() > MAX_NODE_STACK_DEPTH)
|
||||
{
|
||||
CryWarning(VALIDATOR_MODULE_SYSTEM, VALIDATOR_WARNING, "!Too Deep Node Stack:\r\n%s", GetStackInfo());
|
||||
CryWarning(VALIDATOR_MODULE_SYSTEM, VALIDATOR_WARNING, "!Too Deep Node Stack:\r\n%s", GetStackInfo().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,10 +112,9 @@ void CSerializeXMLWriterImpl::GetMemoryUsage(ICrySizer* pSizer) const
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
const char* CSerializeXMLWriterImpl::GetStackInfo() const
|
||||
AZStd::string CSerializeXMLWriterImpl::GetStackInfo() const
|
||||
{
|
||||
static string str;
|
||||
str.assign("");
|
||||
AZStd::string str;
|
||||
for (int i = 0; i < (int)m_nodeStack.size(); i++)
|
||||
{
|
||||
const char* name = m_nodeStack[i]->getAttr(TAG_SCRIPT_NAME);
|
||||
@@ -132,14 +131,13 @@ const char* CSerializeXMLWriterImpl::GetStackInfo() const
|
||||
str += "/";
|
||||
}
|
||||
}
|
||||
return str.c_str();
|
||||
return str;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
const char* CSerializeXMLWriterImpl::GetLuaStackInfo() const
|
||||
AZStd::string CSerializeXMLWriterImpl::GetLuaStackInfo() const
|
||||
{
|
||||
static string str;
|
||||
str.assign("");
|
||||
AZStd::string str;
|
||||
for (int i = 0; i < (int)m_luaSaveStack.size(); i++)
|
||||
{
|
||||
const char* name = m_luaSaveStack[i];
|
||||
@@ -149,5 +147,5 @@ const char* CSerializeXMLWriterImpl::GetLuaStackInfo() const
|
||||
str += ".";
|
||||
}
|
||||
}
|
||||
return str.c_str();
|
||||
return str;
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ private:
|
||||
if (strchr(name, ' ') != 0)
|
||||
{
|
||||
assert(0 && "Spaces in Value name not supported");
|
||||
CryWarning(VALIDATOR_MODULE_SYSTEM, VALIDATOR_WARNING, "!Spaces in Value name not supported: %s in Group %s", name, GetStackInfo());
|
||||
CryWarning(VALIDATOR_MODULE_SYSTEM, VALIDATOR_WARNING, "!Spaces in Value name not supported: %s in Group %s", name, GetStackInfo().c_str());
|
||||
return;
|
||||
}
|
||||
if (GetISystem()->IsDevMode() && CurNode())
|
||||
@@ -86,7 +86,7 @@ private:
|
||||
if (CurNode()->haveAttr(name))
|
||||
{
|
||||
assert(0);
|
||||
CryWarning(VALIDATOR_MODULE_SYSTEM, VALIDATOR_WARNING, "!Duplicate tag Value( \"%s\" ) in Group %s", name, GetStackInfo());
|
||||
CryWarning(VALIDATOR_MODULE_SYSTEM, VALIDATOR_WARNING, "!Duplicate tag Value( \"%s\" ) in Group %s", name, GetStackInfo().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,8 +115,8 @@ private:
|
||||
}
|
||||
|
||||
// Used for printing currebnt stack info for warnings.
|
||||
const char* GetStackInfo() const;
|
||||
const char* GetLuaStackInfo() const;
|
||||
AZStd::string GetStackInfo() const;
|
||||
AZStd::string GetLuaStackInfo() const;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Check For Defaults.
|
||||
@@ -138,7 +138,7 @@ private:
|
||||
bool IsDefaultValue(const Quat& v) const { return v.w == 1.0f && v.v.x == 0 && v.v.y == 0 && v.v.z == 0; };
|
||||
bool IsDefaultValue(const CTimeValue& v) const { return v.GetValue() == 0; };
|
||||
bool IsDefaultValue(const char* str) const { return !str || !*str; };
|
||||
bool IsDefaultValue(const string& str) const { return str.empty(); };
|
||||
bool IsDefaultValue(const AZStd::string& str) const { return str.empty(); };
|
||||
bool IsDefaultValue(const SSerializeString& str) const { return str.empty(); };
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
#include <stack>
|
||||
|
||||
typedef std::map<string, XmlNodeRef> IdTable;
|
||||
typedef std::map<AZStd::string, XmlNodeRef> IdTable;
|
||||
|
||||
static bool IsOptionalWriteXML(XmlNodeRef& definition);
|
||||
|
||||
@@ -66,7 +66,7 @@ struct WritePropertyTyped
|
||||
};
|
||||
|
||||
template <>
|
||||
struct WritePropertyTyped<string>
|
||||
struct WritePropertyTyped<AZStd::string>
|
||||
: public WritePropertyTyped<const char*>
|
||||
{
|
||||
};
|
||||
|
||||
@@ -189,8 +189,6 @@ public:
|
||||
bool getAttr(const char* key, Vec3d& value) const;
|
||||
bool getAttr(const char* key, Quat& value) const;
|
||||
bool getAttr(const char* key, ColorB& value) const;
|
||||
// bool getAttr( const char *key,CString &value ) const { XmlString v; if (getAttr(key,v)) { value = (const char*)v; return true; } else return false; }
|
||||
|
||||
|
||||
private:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -32,7 +32,7 @@ const char* XMLBinary::XMLBinaryReader::GetErrorDescription() const
|
||||
|
||||
void XMLBinary::XMLBinaryReader::SetErrorDescription(const char* text)
|
||||
{
|
||||
cry_strcpy(m_errorDescription, text);
|
||||
azstrcpy(m_errorDescription, AZ_ARRAY_SIZE(m_errorDescription), text);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ static void write(XMLBinary::IDataWriter* const pFile, size_t& nPosition, const
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool XMLBinary::CXMLBinaryWriter::WriteNode(IDataWriter* pFile, XmlNodeRef node, bool bNeedSwapEndian, XMLBinary::IFilter* pFilter, string& error)
|
||||
bool XMLBinary::CXMLBinaryWriter::WriteNode(IDataWriter* pFile, XmlNodeRef node, bool bNeedSwapEndian, XMLBinary::IFilter* pFilter, AZStd::string& error)
|
||||
{
|
||||
error = "";
|
||||
|
||||
@@ -99,7 +99,7 @@ bool XMLBinary::CXMLBinaryWriter::WriteNode(IDataWriter* pFile, XmlNodeRef node,
|
||||
static const uint nMaxNodeCount = (NodeIndex) ~0;
|
||||
if (m_nodes.size() > nMaxNodeCount)
|
||||
{
|
||||
error.Format("XMLBinary: Too many nodes: %d (max is %i)", m_nodes.size(), nMaxNodeCount);
|
||||
error = AZStd::string::format("XMLBinary: Too many nodes: %zu (max is %i)", m_nodes.size(), nMaxNodeCount);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ bool XMLBinary::CXMLBinaryWriter::WriteNode(IDataWriter* pFile, XmlNodeRef node,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool XMLBinary::CXMLBinaryWriter::CompileTables(XmlNodeRef node, XMLBinary::IFilter* pFilter, string& error)
|
||||
bool XMLBinary::CXMLBinaryWriter::CompileTables(XmlNodeRef node, XMLBinary::IFilter* pFilter, AZStd::string& error)
|
||||
{
|
||||
bool ok = CompileTablesForNode(node, -1, pFilter, error);
|
||||
ok = ok && CompileChildTable(node, pFilter, error);
|
||||
@@ -200,7 +200,7 @@ bool XMLBinary::CXMLBinaryWriter::CompileTables(XmlNodeRef node, XMLBinary::IFil
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool XMLBinary::CXMLBinaryWriter::CompileTablesForNode(XmlNodeRef node, int nParentIndex, XMLBinary::IFilter* pFilter, string& error)
|
||||
bool XMLBinary::CXMLBinaryWriter::CompileTablesForNode(XmlNodeRef node, int nParentIndex, XMLBinary::IFilter* pFilter, AZStd::string& error)
|
||||
{
|
||||
// Add the tag to the string table.
|
||||
int nTagStringOffset = AddString(node->getTag());
|
||||
@@ -231,7 +231,7 @@ bool XMLBinary::CXMLBinaryWriter::CompileTablesForNode(XmlNodeRef node, int nPar
|
||||
static const int nMaxAttributeCount = (uint16) ~0;
|
||||
if (nAttributeCount > nMaxAttributeCount)
|
||||
{
|
||||
error.Format("XMLBinary: Too many attributes in a node: %d (max is %i)", nAttributeCount, nMaxAttributeCount);
|
||||
error = AZStd::string::format("XMLBinary: Too many attributes in a node: %d (max is %i)", nAttributeCount, nMaxAttributeCount);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ bool XMLBinary::CXMLBinaryWriter::CompileTablesForNode(XmlNodeRef node, int nPar
|
||||
{
|
||||
if (++nChildCount > nMaxChildCount)
|
||||
{
|
||||
error.Format("XMLBinary: Too many children in node '%s': %d (max is %i)", childNode->getTag(), nChildCount, nMaxChildCount);
|
||||
error = AZStd::string::format("XMLBinary: Too many children in node '%s': %d (max is %i)", childNode->getTag(), nChildCount, nMaxChildCount);
|
||||
return false;
|
||||
}
|
||||
if (!CompileTablesForNode(childNode, nIndex, pFilter, error))
|
||||
@@ -277,7 +277,7 @@ bool XMLBinary::CXMLBinaryWriter::CompileTablesForNode(XmlNodeRef node, int nPar
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool XMLBinary::CXMLBinaryWriter::CompileChildTable(XmlNodeRef node, XMLBinary::IFilter* pFilter, string& error)
|
||||
bool XMLBinary::CXMLBinaryWriter::CompileChildTable(XmlNodeRef node, XMLBinary::IFilter* pFilter, AZStd::string& error)
|
||||
{
|
||||
const int nIndex = m_nodesMap.find(node)->second; // Assume node always exist in map.
|
||||
const int nFirstChildIndex = (int)m_childs.size();
|
||||
@@ -298,7 +298,7 @@ bool XMLBinary::CXMLBinaryWriter::CompileChildTable(XmlNodeRef node, XMLBinary::
|
||||
}
|
||||
if (nChildCount != nd.nChildCount)
|
||||
{
|
||||
error.Format("XMLBinary: Internal error in CompileChildTable()");
|
||||
error = AZStd::string::format("XMLBinary: Internal error in CompileChildTable()");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,25 +25,25 @@ namespace XMLBinary
|
||||
{
|
||||
public:
|
||||
CXMLBinaryWriter();
|
||||
bool WriteNode(IDataWriter* pFile, XmlNodeRef node, bool bNeedSwapEndian, XMLBinary::IFilter* pFilter, string& error);
|
||||
bool WriteNode(IDataWriter* pFile, XmlNodeRef node, bool bNeedSwapEndian, XMLBinary::IFilter* pFilter, AZStd::string & error);
|
||||
|
||||
private:
|
||||
bool CompileTables(XmlNodeRef node, XMLBinary::IFilter* pFilter, string& error);
|
||||
bool CompileTables(XmlNodeRef node, XMLBinary::IFilter* pFilter, AZStd::string& error);
|
||||
|
||||
bool CompileTablesForNode(XmlNodeRef node, int nParentIndex, XMLBinary::IFilter* pFilter, string& error);
|
||||
bool CompileChildTable(XmlNodeRef node, XMLBinary::IFilter* pFilter, string& error);
|
||||
bool CompileTablesForNode(XmlNodeRef node, int nParentIndex, XMLBinary::IFilter* pFilter, AZStd::string& error);
|
||||
bool CompileChildTable(XmlNodeRef node, XMLBinary::IFilter* pFilter, AZStd::string& error);
|
||||
int AddString(const XmlString& sString);
|
||||
|
||||
private:
|
||||
// tables.
|
||||
typedef std::map<IXmlNode*, int> NodesMap;
|
||||
typedef std::map<string, uint> StringMap;
|
||||
typedef std::map<AZStd::string, uint> StringMap;
|
||||
|
||||
std::vector<Node> m_nodes;
|
||||
NodesMap m_nodesMap;
|
||||
std::vector<Attribute> m_attributes;
|
||||
std::vector<NodeIndex> m_childs;
|
||||
std::vector<string> m_strings;
|
||||
std::vector<AZStd::string> m_strings;
|
||||
StringMap m_stringMap;
|
||||
|
||||
uint m_nStringDataSize;
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#include "CrySystem_precompiled.h"
|
||||
#include "XMLPatcher.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
CXMLPatcher::CXMLPatcher(XmlNodeRef& patchXML)
|
||||
{
|
||||
@@ -84,7 +83,7 @@ XmlNodeRef CXMLPatcher::FindPatchForFile(
|
||||
{
|
||||
const char* pForFile = child->getAttr("forfile");
|
||||
|
||||
if (pForFile && CryStringUtils::stristr(pForFile, pInFileToPatch) != 0)
|
||||
if (pForFile && AZ::StringFunc::Find(pForFile, pInFileToPatch) != AZStd::string::npos)
|
||||
{
|
||||
result = child;
|
||||
break;
|
||||
@@ -345,7 +344,7 @@ void CXMLPatcher::DumpXMLNodes(
|
||||
AZ::IO::HandleType inFileHandle,
|
||||
int inIndent,
|
||||
const XmlNodeRef& inNode,
|
||||
CryFixedStringT<512>* ioTempString)
|
||||
AZStd::fixed_string<512>* ioTempString)
|
||||
{
|
||||
auto pPak = gEnv->pCryPak;
|
||||
|
||||
@@ -353,7 +352,7 @@ void CXMLPatcher::DumpXMLNodes(
|
||||
|
||||
INDENT();
|
||||
|
||||
ioTempString->Format("<%s ", inNode->getTag());
|
||||
*ioTempString = AZStd::fixed_string<512>::format("<%s ", inNode->getTag());
|
||||
|
||||
pPak->FWrite(ioTempString->c_str(), ioTempString->length(), inFileHandle);
|
||||
|
||||
@@ -361,7 +360,7 @@ void CXMLPatcher::DumpXMLNodes(
|
||||
{
|
||||
const char* pKey, * pVal;
|
||||
inNode->getAttributeByIndex(i, &pKey, &pVal);
|
||||
ioTempString->Format("%s=\"%s\" ", pKey, pVal);
|
||||
*ioTempString = AZStd::fixed_string<512>::format("%s=\"%s\" ", pKey, pVal);
|
||||
pPak->FWrite(ioTempString->c_str(), ioTempString->length(), inFileHandle);
|
||||
}
|
||||
pPak->FWrite(">\n", 2, inFileHandle);
|
||||
@@ -372,7 +371,7 @@ void CXMLPatcher::DumpXMLNodes(
|
||||
}
|
||||
|
||||
INDENT();
|
||||
ioTempString->Format("</%s>\n", inNode->getTag());
|
||||
*ioTempString = AZStd::fixed_string<512>::format("</%s>\n", inNode->getTag());
|
||||
pPak->FWrite(ioTempString->c_str(), ioTempString->length(), inFileHandle);
|
||||
}
|
||||
|
||||
@@ -391,12 +390,12 @@ void CXMLPatcher::DumpFiles(
|
||||
{
|
||||
pOrigFileName++;
|
||||
|
||||
DumpXMLFile(string().Format("PATCH_%s", pOrigFileName), inBefore);
|
||||
DumpXMLFile(AZStd::string::format("PATCH_%s", pOrigFileName).c_str(), inBefore);
|
||||
|
||||
CryFixedStringT<128> newFileName(pOrigFileName);
|
||||
newFileName.replace(".xml", "_patched.xml");
|
||||
AZStd::string newFileName(pOrigFileName);
|
||||
AZ::StringFunc::Replace(newFileName, ".xml", "_patched.xml");
|
||||
|
||||
DumpXMLFile(string().Format("PATCH_%s", newFileName.c_str()), inAfter);
|
||||
DumpXMLFile(AZStd::string::format("PATCH_%s", newFileName.c_str()).c_str(), inAfter);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -414,7 +413,7 @@ void CXMLPatcher::DumpXMLFile(
|
||||
|
||||
if (fileHandle != AZ::IO::InvalidHandle)
|
||||
{
|
||||
CryFixedStringT<512> tempStr;
|
||||
AZStd::fixed_string<512> tempStr;
|
||||
|
||||
DumpXMLNodes(fileHandle, 0, inNode, &tempStr);
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ protected:
|
||||
AZ::IO::HandleType inFileHandle,
|
||||
int inIndent,
|
||||
const XmlNodeRef& inNode,
|
||||
CryFixedStringT<512>* ioTempString);
|
||||
AZStd::fixed_string<512>* ioTempString);
|
||||
void DumpFiles(
|
||||
const char* pInXMLFileName,
|
||||
const XmlNodeRef& inBefore,
|
||||
|
||||
@@ -313,7 +313,7 @@ bool CXmlUtils::SaveBinaryXmlFile(const char* filename, XmlNodeRef root)
|
||||
return false;
|
||||
}
|
||||
XMLBinary::CXMLBinaryWriter writer;
|
||||
string error;
|
||||
AZStd::string error;
|
||||
return writer.WriteNode(&fileSink, root, false, 0, error);
|
||||
}
|
||||
|
||||
|
||||
@@ -984,13 +984,13 @@ XmlString CXmlNode::MakeValidXmlString(const XmlString& instr) const
|
||||
XmlString str = instr;
|
||||
|
||||
// check if str contains any invalid characters
|
||||
str.replace("&", "&");
|
||||
str.replace("\"", """);
|
||||
str.replace("\'", "'");
|
||||
str.replace("<", "<");
|
||||
str.replace(">", ">");
|
||||
str.replace("...", ">");
|
||||
str.replace("\n", " ");
|
||||
AZ::StringFunc::Replace(str, "&", "&");
|
||||
AZ::StringFunc::Replace(str, "\"", """);
|
||||
AZ::StringFunc::Replace(str, "\'", "'");
|
||||
AZ::StringFunc::Replace(str, "<", "<");
|
||||
AZ::StringFunc::Replace(str, ">", ">");
|
||||
AZ::StringFunc::Replace(str, "...", ">");
|
||||
AZ::StringFunc::Replace(str, "\n", " ");
|
||||
|
||||
return str;
|
||||
}
|
||||
@@ -1691,8 +1691,8 @@ XmlNodeRef XmlParserImp::ParseFile(const char* filename, XmlString& errorString,
|
||||
|
||||
char str[1024];
|
||||
|
||||
CryStackStringT<char, 256> adjustedFilename;
|
||||
CryStackStringT<char, 256> pakPath;
|
||||
AZStd::fixed_string<256> adjustedFilename;
|
||||
AZStd::fixed_string<256> pakPath;
|
||||
if (fileSize <= 0)
|
||||
{
|
||||
CCryFile xmlFile;
|
||||
@@ -1732,9 +1732,9 @@ XmlNodeRef XmlParserImp::ParseFile(const char* filename, XmlString& errorString,
|
||||
return 0;
|
||||
}
|
||||
adjustedFilename = xmlFile.GetAdjustedFilename();
|
||||
adjustedFilename.replace('\\', '/');
|
||||
AZStd::replace(adjustedFilename.begin(), adjustedFilename.end(), '\\', '/');
|
||||
pakPath = xmlFile.GetPakPath();
|
||||
pakPath.replace('\\', '/');
|
||||
AZStd::replace(pakPath.begin(), pakPath.end(), '\\', '/');
|
||||
}
|
||||
|
||||
if (g_bEnableBinaryXmlLoading)
|
||||
@@ -1761,7 +1761,7 @@ XmlNodeRef XmlParserImp::ParseFile(const char* filename, XmlString& errorString,
|
||||
// not binary XML - refuse to load if in scripts dir and not in bin xml to help reduce hacking
|
||||
// wish we could compile the text xml parser out, but too much work to get everything moved over
|
||||
static const char SCRIPTS_DIR[] = "Scripts/";
|
||||
CryFixedStringT<32> strScripts("S");
|
||||
AZStd::fixed_string<32> strScripts("S");
|
||||
strScripts += "c";
|
||||
strScripts += "r";
|
||||
strScripts += "i";
|
||||
@@ -1770,7 +1770,7 @@ XmlNodeRef XmlParserImp::ParseFile(const char* filename, XmlString& errorString,
|
||||
strScripts += "s";
|
||||
strScripts += "/";
|
||||
// exclude files and PAKs from Mods folder
|
||||
CryFixedStringT<8> modsStr("M");
|
||||
AZStd::fixed_string<8> modsStr("M");
|
||||
modsStr += "o";
|
||||
modsStr += "d";
|
||||
modsStr += "s";
|
||||
|
||||
Reference in New Issue
Block a user