Merge branch 'development' into redcode/crythread-2nd-pass

Signed-off-by: AMZN-ScottR <24445312+AMZN-ScottR@users.noreply.github.com>
This commit is contained in:
AMZN-ScottR
2021-08-11 20:31:58 -07:00
1650 changed files with 39333 additions and 62370 deletions
-14
View File
@@ -30,16 +30,6 @@
#define MOBILE
#endif
// Force all allocations to be aligned to TARGET_DEFAULT_ALIGN.
// This is because malloc on Android 32 bit returns memory that is not aligned
// to what some structs/classes need.
#define CRY_FORCE_MALLOC_NEW_ALIGN
#define DEBUG_BREAK raise(SIGTRAP)
#define RC_EXECUTABLE "rc"
#define USE_CRT 1
#define SIZEOF_PTR 4
//////////////////////////////////////////////////////////////////////////
// Standard includes.
//////////////////////////////////////////////////////////////////////////
@@ -121,10 +111,6 @@ typedef unsigned char byte;
#define DEFINE_ALIGNED_DATA(type, name, alignment) \
type __attribute__ ((aligned(alignment))) name;
#define DEFINE_ALIGNED_DATA_STATIC(type, name, alignment) \
static type __attribute__ ((aligned(alignment))) name;
#define DEFINE_ALIGNED_DATA_CONST(type, name, alignment) \
const type __attribute__ ((aligned(alignment))) name;
#include "LinuxSpecific.h"
// these functions do not exist int the wchar.h header
-83
View File
@@ -17,10 +17,6 @@
#pragma diagnostic ignore "-W#pragma-messages"
#endif
#define DEBUG_BREAK __builtin_trap()
#define RC_EXECUTABLE "rc"
//////////////////////////////////////////////////////////////////////////
// Standard includes.
//////////////////////////////////////////////////////////////////////////
@@ -52,12 +48,6 @@
#define __COUNTER__ __LINE__
#endif
#ifdef __FUNC__
#undef __FUNC__
#endif
#define __FUNC__ __func__
typedef void* LPVOID;
#define VOID void
#define PVOID void*
@@ -192,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)))
@@ -267,10 +252,6 @@ typedef uint64 __uint64;
#define DEFINE_ALIGNED_DATA(type, name, alignment) \
type __attribute__ ((aligned(alignment))) name;
#define DEFINE_ALIGNED_DATA_STATIC(type, name, alignment) \
static type __attribute__ ((aligned(alignment))) name;
#define DEFINE_ALIGNED_DATA_CONST(type, name, alignment) \
const type __attribute__ ((aligned(alignment))) name;
#define BST_UNCHECKED 0x0000
@@ -303,17 +284,6 @@ enum
IDCONTINUE = 11
};
#define ES_MULTILINE 0x0004L
#define ES_AUTOVSCROLL 0x0040L
#define ES_AUTOHSCROLL 0x0080L
#define ES_WANTRETURN 0x1000L
#define LB_ERR (-1)
#define LB_ADDSTRING 0x0180
#define LB_GETCOUNT 0x018B
#define LB_SETTOPINDEX 0x0197
#define MB_OK 0x00000000L
#define MB_OKCANCEL 0x00000001L
#define MB_ABORTRETRYIGNORE 0x00000002L
@@ -333,22 +303,16 @@ enum
#define MB_APPLMODAL 0x00000000L
#define MF_STRING 0x00000000L
#define MK_LBUTTON 0x0001
#define MK_RBUTTON 0x0002
#define MK_SHIFT 0x0004
#define MK_CONTROL 0x0008
#define MK_MBUTTON 0x0010
#define MK_ALT ( 0x20 )
#define SM_MOUSEPRESENT 0x00000000L
#define SM_CMOUSEBUTTONS 43
#define USER_TIMER_MINIMUM 0x0000000A
#define VK_TAB 0x09
#define VK_SHIFT 0x10
#define VK_MENU 0x12
@@ -356,11 +320,6 @@ enum
#define VK_SPACE 0x20
#define VK_DELETE 0x2E
#define VK_NUMPAD1 0x61
#define VK_NUMPAD2 0x62
#define VK_NUMPAD3 0x63
#define VK_NUMPAD4 0x64
#define VK_OEM_COMMA 0xBC // ',' any country
#define VK_OEM_PERIOD 0xBE // '.' any country
#define VK_OEM_3 0xC0 // '`~' for US
@@ -391,13 +350,9 @@ enum
#define wcsnicmp wcsncasecmp
//#define memcpy_s(dest,bytes,src,n) memcpy(dest,src,n)
#define _isnan ISNAN
#define _wtof(str) wcstod(str, 0)
#define TARGET_DEFAULT_ALIGN (0x8U)
#define _msize malloc_size
@@ -503,36 +458,6 @@ typedef HANDLE HMENU;
#endif //__cplusplus
inline char* _fullpath(char* absPath, const char* relPath, size_t maxLength)
{
char path[PATH_MAX];
if (realpath(relPath, path) == NULL)
{
return NULL;
}
const size_t len = std::min(strlen(path), maxLength - 1);
memcpy(absPath, path, len);
absPath[len] = 0;
return absPath;
}
typedef union _LARGE_INTEGER
{
struct
{
DWORD LowPart;
LONG HighPart;
};
struct
{
DWORD LowPart;
LONG HighPart;
} u;
long long QuadPart;
} LARGE_INTEGER;
extern bool QueryPerformanceCounter(LARGE_INTEGER*);
extern bool QueryPerformanceFrequency(LARGE_INTEGER* frequency);
@@ -573,14 +498,6 @@ inline int closesocket(int s)
return ::close(s);
}
inline int WSAGetLastError()
{
return errno;
}
//we take the definition of the pthread_t type directly from the pthread file
#define THREADID_NULL 0
template <typename T, size_t N>
char (*RtlpNumberOf( T (&)[N] ))[N];
+22 -25
View File
@@ -11,12 +11,9 @@
#define CRYINCLUDE_CRYCOMMON_BASETYPES_H
#pragma once
#include "CompileTimeAssert.h"
COMPILE_TIME_ASSERT(sizeof(char) == 1);
COMPILE_TIME_ASSERT(sizeof(float) == 4);
COMPILE_TIME_ASSERT(sizeof(int) >= 4);
static_assert(sizeof(char) == 1);
static_assert(sizeof(float) == 4);
static_assert(sizeof(int) >= 4);
typedef unsigned char uchar;
@@ -36,35 +33,35 @@ typedef signed long slong;
typedef unsigned long long ulonglong;
typedef signed long long slonglong;
COMPILE_TIME_ASSERT(sizeof(uchar) == sizeof(schar));
COMPILE_TIME_ASSERT(sizeof(ushort) == sizeof(sshort));
COMPILE_TIME_ASSERT(sizeof(uint) == sizeof(sint));
COMPILE_TIME_ASSERT(sizeof(ulong) == sizeof(slong));
COMPILE_TIME_ASSERT(sizeof(ulonglong) == sizeof(slonglong));
static_assert(sizeof(uchar) == sizeof(schar));
static_assert(sizeof(ushort) == sizeof(sshort));
static_assert(sizeof(uint) == sizeof(sint));
static_assert(sizeof(ulong) == sizeof(slong));
static_assert(sizeof(ulonglong) == sizeof(slonglong));
COMPILE_TIME_ASSERT(sizeof(uchar) <= sizeof(ushort));
COMPILE_TIME_ASSERT(sizeof(ushort) <= sizeof(uint));
COMPILE_TIME_ASSERT(sizeof(uint) <= sizeof(ulong));
COMPILE_TIME_ASSERT(sizeof(ulong) <= sizeof(ulonglong));
static_assert(sizeof(uchar) <= sizeof(ushort));
static_assert(sizeof(ushort) <= sizeof(uint));
static_assert(sizeof(uint) <= sizeof(ulong));
static_assert(sizeof(ulong) <= sizeof(ulonglong));
typedef schar int8;
typedef schar sint8;
typedef uchar uint8;
COMPILE_TIME_ASSERT(sizeof(uint8) == 1);
COMPILE_TIME_ASSERT(sizeof(sint8) == 1);
static_assert(sizeof(uint8) == 1);
static_assert(sizeof(sint8) == 1);
typedef sshort int16;
typedef sshort sint16;
typedef ushort uint16;
COMPILE_TIME_ASSERT(sizeof(uint16) == 2);
COMPILE_TIME_ASSERT(sizeof(sint16) == 2);
static_assert(sizeof(uint16) == 2);
static_assert(sizeof(sint16) == 2);
typedef sint int32;
typedef sint sint32;
typedef uint uint32;
COMPILE_TIME_ASSERT(sizeof(uint32) == 4);
COMPILE_TIME_ASSERT(sizeof(sint32) == 4);
static_assert(sizeof(uint32) == 4);
static_assert(sizeof(sint32) == 4);
typedef slonglong int64;
@@ -72,14 +69,14 @@ typedef slonglong int64;
#define O3DE_INT64_DEFINED
typedef slonglong sint64;
typedef ulonglong uint64;
COMPILE_TIME_ASSERT(sizeof(uint64) == 8);
COMPILE_TIME_ASSERT(sizeof(sint64) == 8);
static_assert(sizeof(uint64) == 8);
static_assert(sizeof(sint64) == 8);
#endif
typedef float f32;
typedef double f64;
COMPILE_TIME_ASSERT(sizeof(f32) == 4);
COMPILE_TIME_ASSERT(sizeof(f64) == 8);
static_assert(sizeof(f32) == 4);
static_assert(sizeof(f64) == 8);
#endif // CRYINCLUDE_CRYCOMMON_BASETYPES_H
-51
View File
@@ -12,7 +12,6 @@
#pragma once
#include "CompileTimeAssert.h"
#include <AzCore/Casting/numeric_cast.h>
// Section dictionary
@@ -36,7 +35,6 @@ ILINE uint32 countLeadingZeros32(uint32 x)
{
DWORD result = 32 ^ 31; // assumes result is unmodified if _BitScanReverse returns 0
_BitScanReverse(&result, x);
PREFAST_SUPPRESS_WARNING(6102);
result ^= 31; // needed because the index is from LSB (whereas all other implementations are from MSB)
return result;
}
@@ -73,16 +71,6 @@ inline bool IsPowerOfTwo(TInteger x)
return (x & (x - 1)) == 0;
}
// compile time version of IsPowerOfTwo, useful for STATIC_CHECK
template <int nValue>
struct IsPowerOfTwoCompileTime
{
enum
{
IsPowerOfTwo = ((nValue & (nValue - 1)) == 0)
};
};
inline uint32 NextPower2(uint32 n)
{
n--;
@@ -199,45 +187,6 @@ ILINE int32 Isel32(int32 v, int32 alt)
return ((static_cast<int32>(v) >> 31) & alt) | ((static_cast<int32>(~v) >> 31) & v);
}
template <uint32 ILOG>
struct CompileTimeIntegerLog2
{
static const uint32 result = 1 + CompileTimeIntegerLog2<(ILOG >> 1)>::result;
};
template <>
struct CompileTimeIntegerLog2<1>
{
static const uint32 result = 0;
};
template <>
struct CompileTimeIntegerLog2<0>; // keep it undefined, we cannot represent "minus infinity" result
COMPILE_TIME_ASSERT(CompileTimeIntegerLog2<1>::result == 0);
COMPILE_TIME_ASSERT(CompileTimeIntegerLog2<2>::result == 1);
COMPILE_TIME_ASSERT(CompileTimeIntegerLog2<3>::result == 1);
COMPILE_TIME_ASSERT(CompileTimeIntegerLog2<4>::result == 2);
COMPILE_TIME_ASSERT(CompileTimeIntegerLog2<5>::result == 2);
COMPILE_TIME_ASSERT(CompileTimeIntegerLog2<255>::result == 7);
COMPILE_TIME_ASSERT(CompileTimeIntegerLog2<256>::result == 8);
COMPILE_TIME_ASSERT(CompileTimeIntegerLog2<257>::result == 8);
template <uint32 ILOG>
struct CompileTimeIntegerLog2_RoundUp
{
static const uint32 result = CompileTimeIntegerLog2<ILOG>::result + ((ILOG & (ILOG - 1)) != 0);
};
template <>
struct CompileTimeIntegerLog2_RoundUp<0>; // we can return 0, but let's keep it undefined (same as CompileTimeIntegerLog2<0>)
COMPILE_TIME_ASSERT(CompileTimeIntegerLog2_RoundUp<1>::result == 0);
COMPILE_TIME_ASSERT(CompileTimeIntegerLog2_RoundUp<2>::result == 1);
COMPILE_TIME_ASSERT(CompileTimeIntegerLog2_RoundUp<3>::result == 2);
COMPILE_TIME_ASSERT(CompileTimeIntegerLog2_RoundUp<4>::result == 2);
COMPILE_TIME_ASSERT(CompileTimeIntegerLog2_RoundUp<5>::result == 3);
COMPILE_TIME_ASSERT(CompileTimeIntegerLog2_RoundUp<255>::result == 8);
COMPILE_TIME_ASSERT(CompileTimeIntegerLog2_RoundUp<256>::result == 8);
COMPILE_TIME_ASSERT(CompileTimeIntegerLog2_RoundUp<257>::result == 9);
// Character-to-bitfield mapping
inline uint32 AlphaBit(char c)
-56
View File
@@ -1,56 +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
*
*/
// Inspired by the Boost library's BOOST_STATIC_ASSERT(),
// see http://www.boost.org/doc/libs/1_49_0/doc/html/boost_staticassert/how.html
// or http://www.boost.org/libs/static_assert
#ifndef CRYINCLUDE_CRYCOMMON_COMPILETIMEASSERT_H
#define CRYINCLUDE_CRYCOMMON_COMPILETIMEASSERT_H
#pragma once
#if defined(__cplusplus)
/*
template <bool b>
struct COMPILE_TIME_ASSERT_FAIL;
template <>
struct COMPILE_TIME_ASSERT_FAIL<true>
{
};
template <int i>
struct COMPILE_TIME_ASSERT_TEST
{
enum { dummy = i };
};
#define COMPILE_TIME_ASSERT_BUILD_NAME2(x, y) x##y
#define COMPILE_TIME_ASSERT_BUILD_NAME1(x, y) COMPILE_TIME_ASSERT_BUILD_NAME2(x, y)
#define COMPILE_TIME_ASSERT_BUILD_NAME(x, y) COMPILE_TIME_ASSERT_BUILD_NAME1(x, y)
#ifndef __RECODE__
#define COMPILE_TIME_ASSERT(expr) \
typedef COMPILE_TIME_ASSERT_TEST<sizeof(COMPILE_TIME_ASSERT_FAIL<(bool)(expr)>)> \
COMPILE_TIME_ASSERT_BUILD_NAME(compile_time_assert_test_, __LINE__)
// note: for MS Visual Studio we could use __COUNTER__ instead of __LINE__
#else
#define COMPILE_TIME_ASSERT(expr)
#endif // __RECODE__
#else
#define COMPILE_TIME_ASSERT(expr)
*/
#endif
#define COMPILE_TIME_ASSERT_MSG(expr, msg) static_assert(expr, msg)
#define COMPILE_TIME_ASSERT(expr) COMPILE_TIME_ASSERT_MSG(expr, "Compile Time Assert")
#endif // CRYINCLUDE_CRYCOMMON_COMPILETIMEASSERT_H
+4 -29
View File
@@ -12,27 +12,14 @@
#pragma once
#include <CryLegacyAllocator.h>
#include <AzCore/std/string/string.h>
//---------------------------------------------------------------------------
// Convenient iteration macros
#define for_iter(IT, it, b, e) for (IT it = (b), _e = (e); it != _e; ++it)
#define for_container(CT, it, cont) for_iter (CT::iterator, it, (cont).begin(), (cont).end())
#define for_ptr(T, it, b, e) for (T* it = (b), * _e = (e); it != _e; ++it)
#define for_array_ptr(T, it, arr) for_ptr (T, it, (arr).begin(), (arr).end())
#define for_array(i, arr) for (int i = 0, _e = (arr).size(); i < _e; i++)
#define for_all(cont) for_array (_i, cont) cont[_i]
//---------------------------------------------------------------------------
// Stack array helper
#define ALIGNED_STACK_ARRAY(T, name, size, alignment) \
PREFAST_SUPPRESS_WARNING(6255) \
T * name = (T*) alloca((size) * sizeof(T) + alignment - 1); \
name = Align(name, alignment);
#define STACK_ARRAY(T, name, size) \
ALIGNED_STACK_ARRAY(T, name, size, alignof(T)) \
#define for_array_ptr(T, it, arr) for_ptr (T, it, (arr).begin(), (arr).end())
#define for_array(i, arr) for (int i = 0, _e = (arr).size(); i < _e; i++)
//---------------------------------------------------------------------------
// Specify semantics for moving objects.
@@ -58,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.
@@ -785,7 +760,7 @@ namespace NArray
AP& allocator()
{
COMPILE_TIME_ASSERT(sizeof(AP) == sizeof(A));
static_assert(sizeof(AP) == sizeof(A));
return *(AP*)this;
}
const AP& allocator() const
+1 -2
View File
@@ -71,7 +71,6 @@
#if defined(USE_CRY_ASSERT) && CRYASSERT_H_TRAIT_USE_CRY_ASSERT_MESSAGE
void CryAssertTrace(const char*, ...);
bool CryAssert(const char*, const char*, unsigned int, bool*);
void CryDebugBreak();
#define CRY_ASSERT(condition) CRY_ASSERT_MESSAGE(condition, NULL)
@@ -86,7 +85,7 @@ void CryDebugBreak();
CryAssertTrace parenthese_message; \
if (CryAssert(#condition, __FILE__, __LINE__, &s_bIgnoreAssert)) \
{ \
DEBUG_BREAK; \
AZ::Debug::Trace::Break(); \
} \
} \
} while (0)
+25 -25
View File
@@ -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);
@@ -708,8 +708,8 @@ protected:
static inline S FromFloat(float fIn)
{
COMPILE_TIME_ASSERT(sizeof(S) <= 4);
COMPILE_TIME_ASSERT(nEXP_BITS > 0 && nEXP_BITS <= 8 && nEXP_BITS < sizeof(S) * 8 - 4);
static_assert(sizeof(S) <= 4);
static_assert(nEXP_BITS > 0 && nEXP_BITS <= 8 && nEXP_BITS < sizeof(S) * 8 - 4);
// Clamp to allowed range.
float fClamped = clamp_tpl(fIn * fROUNDER(), fMIN(), fMAX());
@@ -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
+5 -6
View File
@@ -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
+1 -1
View File
@@ -17,7 +17,7 @@
#ifdef MAX_SUB_MATERIALS
// This checks that the values are in sync in the different files.
COMPILE_TIME_ASSERT(MAX_SUB_MATERIALS == 128);
static_assert(MAX_SUB_MATERIALS == 128);
#else
#define MAX_SUB_MATERIALS 128
#endif
-1
View File
@@ -63,7 +63,6 @@ using DetachEnvironmentFunction = void(*)();
#if !defined(WIN32_LEAN_AND_MEAN)
#define WIN32_LEAN_AND_MEAN
#endif
#include <CryWindows.h>
HMODULE CryLoadLibrary(const char* libName);
+2 -2
View File
@@ -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
+8 -8
View File
@@ -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)
+73 -66
View File
@@ -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)
{
+13 -14
View File
@@ -13,7 +13,6 @@
#include <limits> // std::numeric_limits
#include <type_traits> // std::make_unsigned
#include "BaseTypes.h" // uint32, uint64
#include "CompileTimeAssert.h"
#include "Cry_Vector2.h"
#include "Cry_Vector3.h"
#include "Cry_Vector4.h"
@@ -24,10 +23,10 @@ namespace CryRandom_Internal
template <class R, class T, size_t size>
struct BoundedRandomUint
{
COMPILE_TIME_ASSERT(std::numeric_limits<T>::is_integer);
COMPILE_TIME_ASSERT(!std::numeric_limits<T>::is_signed);
COMPILE_TIME_ASSERT(sizeof(T) == size);
COMPILE_TIME_ASSERT(sizeof(T) <= sizeof(uint32));
static_assert(std::numeric_limits<T>::is_integer);
static_assert(!std::numeric_limits<T>::is_signed);
static_assert(sizeof(T) == size);
static_assert(sizeof(T) <= sizeof(uint32));
inline static T Get(R& randomGenerator, const T maxValue)
{
@@ -41,9 +40,9 @@ namespace CryRandom_Internal
template <class R, class T>
struct BoundedRandomUint<R, T, 8>
{
COMPILE_TIME_ASSERT(std::numeric_limits<T>::is_integer);
COMPILE_TIME_ASSERT(!std::numeric_limits<T>::is_signed);
COMPILE_TIME_ASSERT(sizeof(T) == sizeof(uint64));
static_assert(std::numeric_limits<T>::is_integer);
static_assert(!std::numeric_limits<T>::is_signed);
static_assert(sizeof(T) == sizeof(uint64));
inline static T Get(R& randomGenerator, const T maxValue)
{
@@ -65,11 +64,11 @@ namespace CryRandom_Internal
template <class R, class T>
struct BoundedRandom<R, T, true>
{
COMPILE_TIME_ASSERT(std::numeric_limits<T>::is_integer);
static_assert(std::numeric_limits<T>::is_integer);
typedef typename std::make_unsigned<T>::type UT;
COMPILE_TIME_ASSERT(sizeof(T) == sizeof(UT));
COMPILE_TIME_ASSERT(std::numeric_limits<UT>::is_integer);
COMPILE_TIME_ASSERT(!std::numeric_limits<UT>::is_signed);
static_assert(sizeof(T) == sizeof(UT));
static_assert(std::numeric_limits<UT>::is_integer);
static_assert(!std::numeric_limits<UT>::is_signed);
inline static T Get(R& randomGenerator, T minValue, T maxValue)
{
@@ -84,7 +83,7 @@ namespace CryRandom_Internal
template <class R, class T>
struct BoundedRandom<R, T, false>
{
COMPILE_TIME_ASSERT(!std::numeric_limits<T>::is_integer);
static_assert(!std::numeric_limits<T>::is_integer);
inline static T Get(R& randomGenerator, const T minValue, const T maxValue)
{
@@ -139,7 +138,7 @@ namespace CryRandom_Internal
inline VT GetRandomUnitVector(R& randomGenerator)
{
typedef typename VT::value_type T;
COMPILE_TIME_ASSERT(!std::numeric_limits<T>::is_integer);
static_assert(!std::numeric_limits<T>::is_integer);
VT res;
T lenSquared;
+5 -6
View File
@@ -30,6 +30,7 @@
#include <Cry_Quat.h>
#include <Cry_Color.h>
#include <smartptr.h>
#include <AzCore/std/smart_ptr/shared_ptr.h>
// forward declarations for overloads
struct AABB;
@@ -208,9 +209,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 +426,7 @@ public:
#endif
#ifndef NOT_USE_CRY_STRING
bool Add (const string& strText)
bool Add (const AZStd::string& strText)
{
AddString(strText);
return true;
@@ -581,7 +580,7 @@ protected:
// use this to push (and automatically pop) the sizer component name at the beginning of the
// getSize() function
#define SIZER_COMPONENT_NAME(pSizerPointer, szComponentName) PREFAST_SUPPRESS_WARNING(6246) CrySizerComponentNameHelper AZ_JOIN(sizerHelper, __LINE__)(pSizerPointer, szComponentName, false)
#define SIZER_SUBCOMPONENT_NAME(pSizerPointer, szComponentName) PREFAST_SUPPRESS_WARNING(6246) CrySizerComponentNameHelper AZ_JOIN(sizerHelper, __LINE__)(pSizerPointer, szComponentName, true)
#define SIZER_COMPONENT_NAME(pSizerPointer, szComponentName) CrySizerComponentNameHelper AZ_JOIN(sizerHelper, __LINE__)(pSizerPointer, szComponentName, false)
#define SIZER_SUBCOMPONENT_NAME(pSizerPointer, szComponentName) CrySizerComponentNameHelper AZ_JOIN(sizerHelper, __LINE__)(pSizerPointer, szComponentName, true)
#endif // CRYINCLUDE_CRYCOMMON_CRYSIZER_H
File diff suppressed because it is too large Load Diff
+43 -40
View File
@@ -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.
+4 -5
View File
@@ -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;
-19
View File
@@ -1,19 +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 : Specific header to handle Windows.h include
#ifndef CRYINCLUDE_CRYCOMMON_CRYWINDOWS_H
#define CRYINCLUDE_CRYCOMMON_CRYWINDOWS_H
#pragma once
#include <AzCore/PlatformIncl.h>
#endif // CRYINCLUDE_CRYCOMMON_CRYWINDOWS_H
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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:
+3 -4
View File
@@ -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;
+1
View File
@@ -14,6 +14,7 @@
#define CRYINCLUDE_CRYCOMMON_IFUNCTORBASE_H
#pragma once
#include <CryCommon/CryThread.h>
#include <AzCore/std/parallel/atomic.h>
+15 -15
View File
@@ -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.
-2
View File
@@ -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)
+2 -1
View File
@@ -37,10 +37,11 @@ struct IRenderMesh;
#include <IXml.h>
#include <smartptr.h>
#include <AzCore/EBus/EBus.h>
#include <CryThread.h>
#ifdef MAX_SUB_MATERIALS
// This checks that the values are in sync in the different files.
COMPILE_TIME_ASSERT(MAX_SUB_MATERIALS == 128);
static_assert(MAX_SUB_MATERIALS == 128);
#else
#define MAX_SUB_MATERIALS 128
#endif
+3 -8
View File
@@ -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);
+1 -2
View File
@@ -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;
+11 -113
View File
@@ -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;
};
+18 -19
View File
@@ -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();
+6 -6
View File
@@ -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
+7 -7
View File
@@ -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;
+43 -47
View File
@@ -24,7 +24,6 @@
#endif
#include "CryAssert.h"
#include "CompileTimeAssert.h"
#include <AzCore/IO/SystemFile.h>
@@ -900,9 +899,6 @@ struct ISystem
// Retrieves access to XML utilities interface.
virtual IXmlUtils* GetXmlUtils() = 0;
virtual void SetViewCamera(CCamera& Camera) = 0;
virtual CCamera& GetViewCamera() = 0;
// Description:
// When ignore update sets to true, system will ignore and updates and render calls.
virtual void IgnoreUpdates(bool bIgnore) = 0;
@@ -946,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.
@@ -1419,7 +1415,7 @@ namespace Detail
} DummyStaticInstance; \
if (!(gEnv->pConsole != 0 ? gEnv->pConsole->Register(&DummyStaticInstance) : 0)) \
{ \
DEBUG_BREAK; \
AZ::Debug::Trace::Break(); \
CryFatalError("Can not register dummy CVar"); \
} \
} while (0)
@@ -1428,10 +1424,10 @@ namespace Detail
# define DeclareConstIntCVar(name, defaultValue) enum : int { name = (defaultValue) }
# define DeclareStaticConstIntCVar(name, defaultValue) enum : int { name = (defaultValue) }
# define DefineConstIntCVarName(strname, name, defaultValue, flags, help) { COMPILE_TIME_ASSERT((int)(defaultValue) == (int)(name)); REGISTER_DUMMY_CVAR(int, strname, defaultValue); }
# define DefineConstIntCVar(name, defaultValue, flags, help) { COMPILE_TIME_ASSERT((int)(defaultValue) == (int)(name)); REGISTER_DUMMY_CVAR(int, (#name), defaultValue); }
# define DefineConstIntCVarName(strname, name, defaultValue, flags, help) { static_assert((int)(defaultValue) == (int)(name)); REGISTER_DUMMY_CVAR(int, strname, defaultValue); }
# define DefineConstIntCVar(name, defaultValue, flags, help) { static_assert((int)(defaultValue) == (int)(name)); REGISTER_DUMMY_CVAR(int, (#name), defaultValue); }
// DefineConstIntCVar2 is deprecated, any such instance can be converted to the 3 variant by removing the quotes around the first parameter
# define DefineConstIntCVar3(name, _var_, defaultValue, flags, help) { COMPILE_TIME_ASSERT((int)(defaultValue) == (int)(_var_)); REGISTER_DUMMY_CVAR(int, name, defaultValue); }
# define DefineConstIntCVar3(name, _var_, defaultValue, flags, help) { static_assert((int)(defaultValue) == (int)(_var_)); REGISTER_DUMMY_CVAR(int, name, defaultValue); }
# define AllocateConstIntCVar(scope, name)
# define DefineConstFloatCVar(name, flags, help) { REGISTER_DUMMY_CVAR(float, (#name), name ## Default); }
@@ -1543,33 +1539,33 @@ static void AssertConsoleExists(void)
#define ILLEGAL_DEV_FLAGS (VF_NET_SYNCED | VF_CHEAT | VF_CHEAT_ALWAYS_CHECK | VF_CHEAT_NOCHECK | VF_READONLY | VF_CONST_CVAR)
#if defined(_RELEASE)
#define REGISTER_CVAR_DEV_ONLY(_var, _def_val, _flags, _comment) NULL; COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0); _var = _def_val
#define REGISTER_CVAR_CB_DEV_ONLY(_var, _def_val, _flags, _comment, _onchangefunction) NULL; COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0); _var = _def_val /* _onchangefunction consumed; callback not available */
#define REGISTER_STRING_DEV_ONLY(_name, _def_val, _flags, _comment) NULL; COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0) /* consumed; pure cvar not available */
#define REGISTER_STRING_CB_DEV_ONLY(_name, _def_val, _flags, _comment, _onchangefunction) NULL; COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0) /* consumed; pure cvar not available */
#define REGISTER_INT_DEV_ONLY(_name, _def_val, _flags, _comment) NULL; COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0) /* consumed; pure cvar not available */
#define REGISTER_INT_CB_DEV_ONLY(_name, _def_val, _flags, _comment, _onchangefunction) NULL; COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0) /* consumed; pure cvar not available */
#define REGISTER_INT64_DEV_ONLY(_name, _def_val, _flags, _comment) NULL; COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0) /* consumed; pure cvar not available */
#define REGISTER_FLOAT_DEV_ONLY(_name, _def_val, _flags, _comment) NULL; COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0) /* consumed; pure cvar not available */
#define REGISTER_CVAR2_DEV_ONLY(_name, _var, _def_val, _flags, _comment) NULL; COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0); *(_var) = _def_val
#define REGISTER_CVAR2_CB_DEV_ONLY(_name, _var, _def_val, _flags, _comment, _onchangefunction) NULL; COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0); *(_var) = _def_val
#define REGISTER_CVAR3_DEV_ONLY(_name, _var, _def_val, _flags, _comment) NULL; COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0); _var = _def_val
#define REGISTER_CVAR3_CB_DEV_ONLY(_name, _var, _def_val, _flags, _comment, _onchangefunction) NULL; COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0); _var = _def_val
#define REGISTER_CVAR_DEV_ONLY(_var, _def_val, _flags, _comment) NULL; static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0); _var = _def_val
#define REGISTER_CVAR_CB_DEV_ONLY(_var, _def_val, _flags, _comment, _onchangefunction) NULL; static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0); _var = _def_val /* _onchangefunction consumed; callback not available */
#define REGISTER_STRING_DEV_ONLY(_name, _def_val, _flags, _comment) NULL; static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0) /* consumed; pure cvar not available */
#define REGISTER_STRING_CB_DEV_ONLY(_name, _def_val, _flags, _comment, _onchangefunction) NULL; static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0) /* consumed; pure cvar not available */
#define REGISTER_INT_DEV_ONLY(_name, _def_val, _flags, _comment) NULL; static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0) /* consumed; pure cvar not available */
#define REGISTER_INT_CB_DEV_ONLY(_name, _def_val, _flags, _comment, _onchangefunction) NULL; static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0) /* consumed; pure cvar not available */
#define REGISTER_INT64_DEV_ONLY(_name, _def_val, _flags, _comment) NULL; static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0) /* consumed; pure cvar not available */
#define REGISTER_FLOAT_DEV_ONLY(_name, _def_val, _flags, _comment) NULL; static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0) /* consumed; pure cvar not available */
#define REGISTER_CVAR2_DEV_ONLY(_name, _var, _def_val, _flags, _comment) NULL; static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0); *(_var) = _def_val
#define REGISTER_CVAR2_CB_DEV_ONLY(_name, _var, _def_val, _flags, _comment, _onchangefunction) NULL; static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0); *(_var) = _def_val
#define REGISTER_CVAR3_DEV_ONLY(_name, _var, _def_val, _flags, _comment) NULL; static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0); _var = _def_val
#define REGISTER_CVAR3_CB_DEV_ONLY(_name, _var, _def_val, _flags, _comment, _onchangefunction) NULL; static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0); _var = _def_val
#define REGISTER_COMMAND_DEV_ONLY(_name, _func, _flags, _comment) /* consumed; command not available */
#else
#define REGISTER_CVAR_DEV_ONLY(_var, _def_val, _flags, _comment) REGISTER_CVAR(_var, _def_val, ((_flags) | VF_DEV_ONLY), _comment); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_CVAR_CB_DEV_ONLY(_var, _def_val, _flags, _comment, _onchangefunction) REGISTER_CVAR_CB(_var, _def_val, ((_flags) | VF_DEV_ONLY), _comment, _onchangefunction); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_STRING_DEV_ONLY(_name, _def_val, _flags, _comment) REGISTER_STRING(_name, _def_val, ((_flags) | VF_DEV_ONLY), _comment); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_STRING_CB_DEV_ONLY(_name, _def_val, _flags, _comment, _onchangefunction) REGISTER_STRING_CB(_name, _def_val, ((_flags) | VF_DEV_ONLY), _comment, _onchangefunction); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_INT_DEV_ONLY(_name, _def_val, _flags, _comment) REGISTER_INT(_name, _def_val, ((_flags) | VF_DEV_ONLY), _comment); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_INT_CB_DEV_ONLY(_name, _def_val, _flags, _comment, _onchangefunction) REGISTER_INT_CB(_name, _def_val, ((_flags) | VF_DEV_ONLY), _comment, _onchangefunction); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_INT64_DEV_ONLY(_name, _def_val, _flags, _comment) REGISTER_INT64(_name, _def_val, ((_flags) | VF_DEV_ONLY), _comment); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_FLOAT_DEV_ONLY(_name, _def_val, _flags, _comment) REGISTER_FLOAT(_name, _def_val, ((_flags) | VF_DEV_ONLY), _comment); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_CVAR2_DEV_ONLY(_name, _var, _def_val, _flags, _comment) REGISTER_CVAR2(_name, _var, _def_val, ((_flags) | VF_DEV_ONLY), _comment); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_CVAR2_CB_DEV_ONLY(_name, _var, _def_val, _flags, _comment, _onchangefunction) REGISTER_CVAR2_CB(_name, _var, _def_val, ((_flags) | VF_DEV_ONLY), _comment, _onchangefunction); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_CVAR3_DEV_ONLY(_name, _var, _def_val, _flags, _comment) REGISTER_CVAR3(_name, _var, _def_val, ((_flags) | VF_DEV_ONLY), _comment); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_CVAR3_CB_DEV_ONLY(_name, _var, _def_val, _flags, _comment, _onchangefunction) REGISTER_CVAR3_CB(_name, _var, _def_val, ((_flags) | VF_DEV_ONLY), _comment, _onchangefunction); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_COMMAND_DEV_ONLY(_name, _func, _flags, _comment) REGISTER_COMMAND(_name, _func, ((_flags) | VF_DEV_ONLY), _comment); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_CVAR_DEV_ONLY(_var, _def_val, _flags, _comment) REGISTER_CVAR(_var, _def_val, ((_flags) | VF_DEV_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_CVAR_CB_DEV_ONLY(_var, _def_val, _flags, _comment, _onchangefunction) REGISTER_CVAR_CB(_var, _def_val, ((_flags) | VF_DEV_ONLY), _comment, _onchangefunction); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_STRING_DEV_ONLY(_name, _def_val, _flags, _comment) REGISTER_STRING(_name, _def_val, ((_flags) | VF_DEV_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_STRING_CB_DEV_ONLY(_name, _def_val, _flags, _comment, _onchangefunction) REGISTER_STRING_CB(_name, _def_val, ((_flags) | VF_DEV_ONLY), _comment, _onchangefunction); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_INT_DEV_ONLY(_name, _def_val, _flags, _comment) REGISTER_INT(_name, _def_val, ((_flags) | VF_DEV_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_INT_CB_DEV_ONLY(_name, _def_val, _flags, _comment, _onchangefunction) REGISTER_INT_CB(_name, _def_val, ((_flags) | VF_DEV_ONLY), _comment, _onchangefunction); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_INT64_DEV_ONLY(_name, _def_val, _flags, _comment) REGISTER_INT64(_name, _def_val, ((_flags) | VF_DEV_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_FLOAT_DEV_ONLY(_name, _def_val, _flags, _comment) REGISTER_FLOAT(_name, _def_val, ((_flags) | VF_DEV_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_CVAR2_DEV_ONLY(_name, _var, _def_val, _flags, _comment) REGISTER_CVAR2(_name, _var, _def_val, ((_flags) | VF_DEV_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_CVAR2_CB_DEV_ONLY(_name, _var, _def_val, _flags, _comment, _onchangefunction) REGISTER_CVAR2_CB(_name, _var, _def_val, ((_flags) | VF_DEV_ONLY), _comment, _onchangefunction); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_CVAR3_DEV_ONLY(_name, _var, _def_val, _flags, _comment) REGISTER_CVAR3(_name, _var, _def_val, ((_flags) | VF_DEV_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_CVAR3_CB_DEV_ONLY(_name, _var, _def_val, _flags, _comment, _onchangefunction) REGISTER_CVAR3_CB(_name, _var, _def_val, ((_flags) | VF_DEV_ONLY), _comment, _onchangefunction); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_COMMAND_DEV_ONLY(_name, _func, _flags, _comment) REGISTER_COMMAND(_name, _func, ((_flags) | VF_DEV_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#endif // defined(_RELEASE)
//
////////////////////////////////////////////////////////////////////////////////
@@ -1586,19 +1582,19 @@ static void AssertConsoleExists(void)
// TODO Registering all cvars for Dedicated server as well. Currently CrySystems have no concept of Dedicated server with cmake.
// If we introduce server specific targets for CrySystems, we can add DEDICATED_SERVER flags to those and add the flag back in here.
#if defined(_RELEASE)
#define REGISTER_CVAR_DEDI_ONLY(_var, _def_val, _flags, _comment) REGISTER_CVAR(_var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_CVAR_CB_DEDI_ONLY(_var, _def_val, _flags, _comment, _onchangefunction) REGISTER_CVAR_CB(_var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment, _onchangefunction); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_STRING_DEDI_ONLY(_name, _def_val, _flags, _comment) REGISTER_STRING(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_STRING_CB_DEDI_ONLY(_name, _def_val, _flags, _comment, _onchangefunction) REGISTER_STRING_CB(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment, _onchangefunction); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_INT_DEDI_ONLY(_name, _def_val, _flags, _comment) REGISTER_INT(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_INT_CB_DEDI_ONLY(_name, _def_val, _flags, _comment, _onchangefunction) REGISTER_INT_CB(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment, _onchangefunction); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_INT64_DEDI_ONLY(_name, _def_val, _flags, _comment) REGISTER_INT64(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_FLOAT_DEDI_ONLY(_name, _def_val, _flags, _comment) REGISTER_FLOAT(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_CVAR2_DEDI_ONLY(_name, _var, _def_val, _flags, _comment) REGISTER_CVAR2(_name, _var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_CVAR2_CB_DEDI_ONLY(_name, _var, _def_val, _flags, _comment, _onchangefunction) REGISTER_CVAR2_CB(_name, _var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment, _onchangefunction); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_CVAR3_DEDI_ONLY(_name, _var, _def_val, _flags, _comment) REGISTER_CVAR3(_name, _var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_CVAR3_CB_DEDI_ONLY(_name, _var, _def_val, _flags, _comment, _onchangefunction) REGISTER_CVAR3_CB(_name, _var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment, _onchangefunction); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_COMMAND_DEDI_ONLY(_name, _func, _flags, _comment) REGISTER_COMMAND(_name, _func, ((_flags) | VF_DEDI_ONLY), _comment); COMPILE_TIME_ASSERT(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_CVAR_DEDI_ONLY(_var, _def_val, _flags, _comment) REGISTER_CVAR(_var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_CVAR_CB_DEDI_ONLY(_var, _def_val, _flags, _comment, _onchangefunction) REGISTER_CVAR_CB(_var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment, _onchangefunction); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_STRING_DEDI_ONLY(_name, _def_val, _flags, _comment) REGISTER_STRING(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_STRING_CB_DEDI_ONLY(_name, _def_val, _flags, _comment, _onchangefunction) REGISTER_STRING_CB(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment, _onchangefunction); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_INT_DEDI_ONLY(_name, _def_val, _flags, _comment) REGISTER_INT(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_INT_CB_DEDI_ONLY(_name, _def_val, _flags, _comment, _onchangefunction) REGISTER_INT_CB(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment, _onchangefunction); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_INT64_DEDI_ONLY(_name, _def_val, _flags, _comment) REGISTER_INT64(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_FLOAT_DEDI_ONLY(_name, _def_val, _flags, _comment) REGISTER_FLOAT(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_CVAR2_DEDI_ONLY(_name, _var, _def_val, _flags, _comment) REGISTER_CVAR2(_name, _var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_CVAR2_CB_DEDI_ONLY(_name, _var, _def_val, _flags, _comment, _onchangefunction) REGISTER_CVAR2_CB(_name, _var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment, _onchangefunction); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_CVAR3_DEDI_ONLY(_name, _var, _def_val, _flags, _comment) REGISTER_CVAR3(_name, _var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_CVAR3_CB_DEDI_ONLY(_name, _var, _def_val, _flags, _comment, _onchangefunction) REGISTER_CVAR3_CB(_name, _var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment, _onchangefunction); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_COMMAND_DEDI_ONLY(_name, _func, _flags, _comment) REGISTER_COMMAND(_name, _func, ((_flags) | VF_DEDI_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#else
#define REGISTER_CVAR_DEDI_ONLY(_var, _def_val, _flags, _comment) REGISTER_CVAR_DEV_ONLY(_var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment)
#define REGISTER_CVAR_CB_DEDI_ONLY(_var, _def_val, _flags, _comment, _onchangefunction) REGISTER_CVAR_CB_DEV_ONLY(_var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment, _onchangefunction)
+2 -2
View File
@@ -314,8 +314,8 @@ public:
void GetMemoryUsage([[maybe_unused]] ICrySizer* pSizer) const
{
COMPILE_TIME_ASSERT(eTT_MaxTexType <= 255);
COMPILE_TIME_ASSERT(eTF_MaxFormat <= 255);
static_assert(eTT_MaxTexType <= 255);
static_assert(eTF_MaxFormat <= 255);
/*LATER*/
}
+9 -13
View File
@@ -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
-9
View File
@@ -18,11 +18,6 @@
#define _CPU_X86
//#define _CPU_SSE
#define DEBUG_BREAK raise(SIGTRAP)
#define RC_EXECUTABLE "rc"
#define USE_CRT 1
#define SIZEOF_PTR 4
//////////////////////////////////////////////////////////////////////////
// Standard includes.
//////////////////////////////////////////////////////////////////////////
@@ -98,10 +93,6 @@ typedef unsigned char byte;
#define DEFINE_ALIGNED_DATA(type, name, alignment) \
type __attribute__ ((aligned(alignment))) name;
#define DEFINE_ALIGNED_DATA_STATIC(type, name, alignment) \
static type __attribute__ ((aligned(alignment))) name;
#define DEFINE_ALIGNED_DATA_CONST(type, name, alignment) \
const type __attribute__ ((aligned(alignment))) name;
#include "LinuxSpecific.h"
-9
View File
@@ -20,11 +20,6 @@
#define _CPU_AMD64
#define _CPU_SSE
#define DEBUG_BREAK ::raise(SIGTRAP)
#define RC_EXECUTABLE "rc"
#define USE_CRT 1
#define SIZEOF_PTR 8
//////////////////////////////////////////////////////////////////////////
// Standard includes.
//////////////////////////////////////////////////////////////////////////
@@ -104,10 +99,6 @@ typedef uint8 byte;
#define DEFINE_ALIGNED_DATA(type, name, alignment) \
type __attribute__ ((aligned(alignment))) name;
#define DEFINE_ALIGNED_DATA_STATIC(type, name, alignment) \
static type __attribute__ ((aligned(alignment))) name;
#define DEFINE_ALIGNED_DATA_CONST(type, name, alignment) \
const type __attribute__ ((aligned(alignment))) name;
#include "LinuxSpecific.h"
-94
View File
@@ -42,23 +42,6 @@
#include <vector>
#include <string>
#ifdef __FUNC__
#undef __FUNC__
#endif
#if defined(__GNUC__) || defined(__clang__)
#define __FUNC__ __func__
#else
#define __FUNC__ \
({ \
static char __f[sizeof(__PRETTY_FUNCTION__) + 1]; \
strcpy(__f, __PRETTY_FUNCTION__); \
char* __p = (char*)strchr(__f, '('); \
*__p = 0; \
while (*(__p) != ' ' && __p != (__f - 1)) {--__p; } \
(__p + 1); \
})
#endif
typedef void* LPVOID;
#define VOID void
#define PVOID void*
@@ -156,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;
@@ -199,7 +177,6 @@ typedef int64 __int64;
typedef uint64 __uint64;
#endif
#define THREADID_NULL -1
typedef unsigned long int threadID;
#define TRUE 1
@@ -227,14 +204,6 @@ typedef unsigned long int threadID;
#define wcsicmp wcscasecmp
#define wcsnicmp wcsncasecmp
#define _wtof(str) wcstod(str, 0)
/*static unsigned char toupper(unsigned char c)
{
return c & ~0x40;
}
*/
typedef union _LARGE_INTEGER
{
struct
@@ -250,7 +219,6 @@ typedef union _LARGE_INTEGER
long long QuadPart;
} LARGE_INTEGER;
// stdlib.h stuff
#define _MAX_DRIVE 3 // max. length of drive component
#define _MAX_DIR 256 // max. length of path component
@@ -274,21 +242,6 @@ typedef union _LARGE_INTEGER
#define _O_SEQUENTIAL 0x0020 /* file access is primarily sequential */
#define _O_RANDOM 0x0010 /* file access is primarily random */
// curses.h stubs for PDcurses keys
#define PADENTER KEY_MAX + 1
#define CTL_HOME KEY_MAX + 2
#define CTL_END KEY_MAX + 3
#define CTL_PGDN KEY_MAX + 4
#define CTL_PGUP KEY_MAX + 5
// stubs for virtual keys, isn't used on Linux
#define VK_UP 0
#define VK_DOWN 0
#define VK_RIGHT 0
#define VK_LEFT 0
#define VK_CONTROL 0
#define VK_SCROLL 0
enum
{
IDOK = 1,
@@ -302,17 +255,6 @@ enum
IDCONTINUE = 11
};
#define ES_MULTILINE 0x0004L
#define ES_AUTOVSCROLL 0x0040L
#define ES_AUTOHSCROLL 0x0080L
#define ES_WANTRETURN 0x1000L
#define LB_ERR (-1)
#define LB_ADDSTRING 0x0180
#define LB_GETCOUNT 0x018B
#define LB_SETTOPINDEX 0x0197
#define MB_OK 0x00000000L
#define MB_OKCANCEL 0x00000001L
#define MB_ABORTRETRYIGNORE 0x00000002L
@@ -332,22 +274,16 @@ enum
#define MB_APPLMODAL 0x00000000L
#define MF_STRING 0x00000000L
#define MK_LBUTTON 0x0001
#define MK_RBUTTON 0x0002
#define MK_SHIFT 0x0004
#define MK_CONTROL 0x0008
#define MK_MBUTTON 0x0010
#define MK_ALT ( 0x20 )
#define SM_MOUSEPRESENT 0x00000000L
#define SM_CMOUSEBUTTONS 43
#define USER_TIMER_MINIMUM 0x0000000A
#define VK_TAB 0x09
#define VK_SHIFT 0x10
#define VK_MENU 0x12
@@ -355,11 +291,6 @@ enum
#define VK_SPACE 0x20
#define VK_DELETE 0x2E
#define VK_NUMPAD1 0x61
#define VK_NUMPAD2 0x62
#define VK_NUMPAD3 0x63
#define VK_NUMPAD4 0x64
#define VK_OEM_COMMA 0xBC // ',' any country
#define VK_OEM_PERIOD 0xBE // '.' any country
#define VK_OEM_3 0xC0 // '`~' for US
@@ -546,36 +477,11 @@ inline int64 CryGetTicksPerSec()
inline int _CrtCheckMemory() { return 1; };
inline char* _fullpath(char* absPath, const char* relPath, size_t maxLength)
{
char path[PATH_MAX];
if (realpath(relPath, path) == NULL)
{
return NULL;
}
const size_t len = std::min(strlen(path), maxLength - 1);
memcpy(absPath, path, len);
absPath[len] = 0;
return absPath;
}
typedef void* HGLRC;
typedef void* HDC;
typedef void* PROC;
typedef void* PIXELFORMATDESCRIPTOR;
#define SCOPED_ENABLE_FLOAT_EXCEPTIONS
// Linux_Win32Wrapper.h now included directly by platform.h
//#include "Linux_Win32Wrapper.h"
#define closesocket close
inline int WSAGetLastError()
{
return errno;
}
template <typename T, size_t N>
char (*RtlpNumberOf( T (&)[N] ))[N];
+4 -9
View File
@@ -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,11 +326,6 @@ inline uint32 GetTickCount()
#define _strlwr_s(BUF, SIZE) strlwr(BUF)
#define _strups strupr
#define _wtof(str) wcstod(str, 0)
// 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
@@ -344,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()
@@ -376,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);
@@ -490,8 +487,6 @@ extern void adaptFilenameToLinux(char* rAdjustedFilename);
extern const int comparePathNames(const char* cpFirst, const char* cpSecond, unsigned int len);//returns 0 if identical
extern void replaceDoublePathFilename(char* szFileName);//removes "\.\" to "\" and "/./" to "/"
//////////////////////////////////////////////////////////////////////////
extern char* _fullpath(char* absPath, const char* relPath, size_t maxLength);
//////////////////////////////////////////////////////////////////////////
extern void _makepath(char* path, const char* drive, const char* dir, const char* filename, const char* ext);
+13 -13
View File
@@ -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
+5 -5
View File
@@ -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;
+3 -4
View File
@@ -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;
};
+1 -1
View File
@@ -7,7 +7,7 @@
*/
#pragma once
#include <AzCore/RTTI/TypeInfo.h>
#include <AzCore/RTTI/TypeInfoSimple.h>
#include <AzFramework/Asset/SimpleAsset.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
-1
View File
@@ -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
+1 -1
View File
@@ -63,7 +63,7 @@ void CMTRand_int32::seed(const uint32* array, int size) // init by array
}
for (int k = n - 1; k; --k)
{
PREFAST_SUPPRESS_WARNING(6385) PREFAST_SUPPRESS_WARNING(6386) m_nState[i] = (m_nState[i] ^ ((m_nState[i - 1] ^ (m_nState[i - 1] >> 30)) * 1566083941UL)) - i;
m_nState[i] = (m_nState[i] ^ ((m_nState[i - 1] ^ (m_nState[i - 1] >> 30)) * 1566083941UL)) - i;
if ((++i) == n)
{
m_nState[0] = m_nState[n - 1];
-34
View File
@@ -24,40 +24,6 @@
#define _CPU_SSE
#define PLATFORM_64BIT
#define USE_CRT 1
#define SIZEOF_PTR 8
typedef uint64_t threadID;
// curses.h stubs for PDcurses keys
#define PADENTER KEY_MAX + 1
#define CTL_HOME KEY_MAX + 2
#define CTL_END KEY_MAX + 3
#define CTL_PGDN KEY_MAX + 4
#define CTL_PGUP KEY_MAX + 5
// stubs for virtual keys, isn't used on Mac
#define VK_UP 0
#define VK_DOWN 0
#define VK_RIGHT 0
#define VK_LEFT 0
#define VK_CONTROL 0
#define VK_SCROLL 0
#define MAC_NOT_IMPLEMENTED assert(false);
typedef enum
{
eDAContinue,
eDAIgnore,
eDAIgnoreAll,
eDABreak,
eDAStop,
eDAReportAsBug
} EDialogAction;
extern EDialogAction MacOSXHandleAssert(const char* condition, const char* file, int line, const char* reason, bool);
#endif // CRYINCLUDE_CRYCOMMON_MACSPECIFIC_H
+1 -1
View File
@@ -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));
+1 -1
View File
@@ -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,
+1 -5
View File
@@ -100,10 +100,6 @@ public:
XmlNodeRef(const char*, bool));
MOCK_METHOD0(GetXmlUtils,
IXmlUtils * ());
MOCK_METHOD1(SetViewCamera,
void(CCamera & Camera));
MOCK_METHOD0(GetViewCamera,
CCamera & ());
MOCK_METHOD1(IgnoreUpdates,
void(bool bIgnore));
MOCK_METHOD1(SetIProcess,
@@ -122,7 +118,7 @@ public:
const SFileVersion&());
MOCK_METHOD1(AddCVarGroupDirectory,
void(const string&));
void(const AZStd::string&));
MOCK_METHOD0(SaveConfiguration,
void());
MOCK_METHOD3(LoadConfiguration,
+1 -1
View File
@@ -80,7 +80,7 @@ private:
typedef Struc TThis; typedef Int TInt; \
TInt Mask() const { return *(const TInt*)this; } \
TInt& Mask() { return *(TInt*)this; } \
Struc(TInt init = 0) { COMPILE_TIME_ASSERT(sizeof(TThis) == sizeof(TInt)); Mask() = init; } \
Struc(TInt init = 0) { static_assert(sizeof(TThis) == sizeof(TInt)); Mask() = init; } \
#define BIT_VAR(Var) \
TInt _##Var : 1; \
+53 -136
View File
@@ -16,10 +16,6 @@
#include "BaseTypes.h"
#include <AzCore/PlatformDef.h>
#if defined(_RELEASE) && !defined(RELEASE)
#define RELEASE
#endif
// Section dictionary
#if defined(AZ_RESTRICTED_PLATFORM)
#define PROJECTDEFINES_H_SECTION_STATS_AGENT 1
@@ -31,57 +27,48 @@
#define AZ_RESTRICTED_SECTION PROJECTDEFINES_H_SECTION_STATS_AGENT
#include AZ_RESTRICTED_FILE(ProjectDefines_h)
#elif defined(WIN32) || defined(WIN64)
#if !defined(_RELEASE) || defined(PERFORMANCE_BUILD)
#define ENABLE_STATS_AGENT
#endif
#if !defined(_RELEASE) || defined(PERFORMANCE_BUILD)
#define ENABLE_STATS_AGENT
#endif
#endif
// The following definitions are used by Sandbox and RC to determine which platform support is needed
#define TOOLS_SUPPORT_POWERVR
#define TOOLS_SUPPORT_ETC2COMP
// 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)
typedef uint16 vtx_idx;
#define AZ_RESTRICTED_SECTION_IMPLEMENTED
#if defined(MOBILE)
typedef uint16 vtx_idx;
#define AZ_RESTRICTED_SECTION_IMPLEMENTED
#elif defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION PROJECTDEFINES_H_SECTION_VTX_IDX
#include AZ_RESTRICTED_FILE(ProjectDefines_h)
#endif
#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
#else
// Uncomment one of the two following typedefs:
typedef uint32 vtx_idx;
//typedef uint16 vtx_idx;
// Uncomment one of the two following typedefs:
typedef uint32 vtx_idx;
//typedef uint16 vtx_idx;
#endif
// 0=off, 1=on
#define TERRAIN_USE_CIE_COLORSPACE 0
// When non-zero, const cvar accesses (by name) are logged in release-mode on consoles.
// This can be used to find non-optimal usage scenario's, where the constant should be used directly instead.
// Since read accesses tend to be used in flow-control logic, constants allow for better optimization by the compiler.
#define LOG_CONST_CVAR_ACCESS 0
#if defined(WIN32) || defined(WIN64) || LOG_CONST_CVAR_ACCESS
#define RELEASE_LOGGING
#define RELEASE_LOGGING
#endif
#if defined(_RELEASE) && !defined(RELEASE_LOGGING)
#define EXCLUDE_NORMAL_LOG
#define EXCLUDE_NORMAL_LOG
#endif
// Add the "REMOTE_ASSET_PROCESSOR" define except in release
// this makes it so that asset processor functions. Without this, all assets must be present and on local media
// with this, the asset processor can be used to remotely process assets.
#if !defined(_RELEASE)
# define REMOTE_ASSET_PROCESSOR
#define REMOTE_ASSET_PROCESSOR
#endif
#if (!defined(_RELEASE) || defined(PERFORMANCE_BUILD))
@@ -93,132 +80,68 @@ typedef uint32 vtx_idx;
#define AZ_RESTRICTED_SECTION PROJECTDEFINES_H_SECTION_TRAITS
#include AZ_RESTRICTED_FILE(ProjectDefines_h)
#else
#define PROJECTDEFINES_H_TRAIT_DISABLE_MONOLITHIC_PROFILING_MARKERS 1
#if !defined(LINUX) && !defined(APPLE)
#define PROJECTDEFINES_H_TRAIT_ENABLE_SOFTCODE_SYSTEM 1
#endif
#if defined(WIN32) || defined(WIN64) || defined(LINUX) || defined(APPLE)
#define PROJECTDEFINES_H_TRAIT_USE_GPU_PARTICLES 1
#endif
#define PROJECTDEFINES_H_TRAIT_USE_MESH_TESSELLATION 1
#if defined(WIN32)
#define PROJECTDEFINES_H_TRAIT_USE_SVO_GI 1
#endif
#if defined(APPLE) || defined(LINUX)
#define AZ_LEGACY_CRYCOMMON_TRAIT_USE_PTHREADS 1
#define AZ_LEGACY_CRYCOMMON_TRAIT_USE_UNIX_PATHS 1
#endif
#define PROJECTDEFINES_H_TRAIT_DISABLE_MONOLITHIC_PROFILING_MARKERS 1
#if !defined(LINUX) && !defined(APPLE)
#define PROJECTDEFINES_H_TRAIT_ENABLE_SOFTCODE_SYSTEM 1
#endif
#if defined(WIN32) || defined(WIN64) || defined(LINUX) || defined(APPLE)
#define PROJECTDEFINES_H_TRAIT_USE_GPU_PARTICLES 1
#endif
#define PROJECTDEFINES_H_TRAIT_USE_MESH_TESSELLATION 1
#if defined(WIN32)
#define PROJECTDEFINES_H_TRAIT_USE_SVO_GI 1
#endif
#if defined(APPLE) || defined(LINUX)
#define AZ_LEGACY_CRYCOMMON_TRAIT_USE_PTHREADS 1
#define AZ_LEGACY_CRYCOMMON_TRAIT_USE_UNIX_PATHS 1
#endif
#endif
#define USE_GLOBAL_BUCKET_ALLOCATOR
#if (!defined(_RELEASE) || defined(PERFORMANCE_BUILD))
#ifndef ENABLE_PROFILING_CODE
#define ENABLE_PROFILING_CODE
#endif
#ifdef IS_PROSDK
# define USING_TAGES_SECURITY // Wrapper for TGVM security
# if defined(LINUX) || defined(APPLE)
# error LINUX and Mac does not support evaluation version
# endif
#endif
#ifdef USING_TAGES_SECURITY
# define TAGES_EXPORT __declspec(dllexport)
#else
# define TAGES_EXPORT
#endif // USING_TAGES_SECURITY
// test -------------------------------------
#define _DATAPROBE
//This feature allows automatic crash submission to JIRA, but does not work outside of O3DE
//Note: This #define will be commented out during code export
#define ENABLE_CRASH_HANDLER
#if !defined(PHYSICS_STACK_SIZE)
# define PHYSICS_STACK_SIZE (128U << 10)
#endif
#if (!defined(_RELEASE) || defined(PERFORMANCE_BUILD)) && !defined(RESOURCE_COMPILER)
#ifndef ENABLE_PROFILING_CODE
#define ENABLE_PROFILING_CODE
#endif
#if !(defined(SANDBOX_EXPORTS) || defined(PLUGIN_EXPORTS) || (defined(AZ_MONOLITHIC_BUILD) && PROJECTDEFINES_H_TRAIT_DISABLE_MONOLITHIC_PROFILING_MARKERS))
#define ENABLE_PROFILING_MARKERS
#endif
//lightweight profilers, disable for submissions, disables displayinfo inside 3dengine as well
#ifndef ENABLE_LW_PROFILERS
#define ENABLE_LW_PROFILERS
#endif
#endif
#if defined(ENABLE_PROFILING_CODE)
#define ENABLE_ART_RT_TIME_ESTIMATE
#endif
#if defined(ENABLE_PROFILING_CODE) && !defined(_RELEASE)
#define FMOD_STREAMING_DEBUGGING 1
#endif
#if defined(WIN32) || defined(WIN64) || defined(APPLE) || defined(AZ_PLATFORM_LINUX)
#define FLARES_SUPPORT_EDITING
//lightweight profilers, disable for submissions, disables displayinfo inside 3dengine as well
#ifndef ENABLE_LW_PROFILERS
#define ENABLE_LW_PROFILERS
#endif
#endif
// Reflect texture slot information - only used in the editor
#if defined(WIN32) || defined(WIN64) || defined(AZ_PLATFORM_MAC)
#define SHADER_REFLECT_TEXTURE_SLOTS 1
#define SHADER_REFLECT_TEXTURE_SLOTS 1
#else
#define SHADER_REFLECT_TEXTURE_SLOTS 0
#define SHADER_REFLECT_TEXTURE_SLOTS 0
#endif
// these enable and disable certain net features to give compatibility between PCs and consoles / profile and performance builds
#define PC_CONSOLE_NET_COMPATIBLE 0
#define PROFILE_PERFORMANCE_NET_COMPATIBLE 0
#if (!defined(_RELEASE) || defined(PERFORMANCE_BUILD)) && !PROFILE_PERFORMANCE_NET_COMPATIBLE
#define USE_LAGOMETER (1)
#else
#define USE_LAGOMETER (0)
#endif
// enable this in order to support old style material names in old data ("engine/material.mtl" or "mygame/material.mtl" as opposed to just "material.mtl")
// previously, material names could have the game folder in it, but this is not necessary anymore and would not work with things like gems
// note that if you use any older projects such as GameSDK this should remain enabled
#define SUPPORT_LEGACY_MATERIAL_NAMES
// Enable additional structures and code for sprite motion blur. Currently non-functional and disabled
// #define PARTICLE_MOTION_BLUR
// a special ticker thread to run during load and unload of levels
#define USE_NETWORK_STALL_TICKER_THREAD
#if !defined(MOBILE)
//---------------------------------------------------------------------
// Enable Tessellation Features
// (displacement mapping, subdivision, water tessellation)
//---------------------------------------------------------------------
// Modules : 3DEngine, Renderer
// Depends on: DX11
//---------------------------------------------------------------------
// Enable Tessellation Features
// (displacement mapping, subdivision, water tessellation)
//---------------------------------------------------------------------
// Modules : 3DEngine, Renderer
// Depends on: DX11
// Global tessellation feature flag
// Global tessellation feature flag
#define TESSELLATION
#ifdef TESSELLATION
// Specific features flags
// Specific features flags
#define WATER_TESSELLATION
#define PARTICLES_TESSELLATION
#if PROJECTDEFINES_H_TRAIT_USE_MESH_TESSELLATION
// Mesh tessellation (displacement, smoothing, subd)
// Mesh tessellation (displacement, smoothing, subd)
#define MESH_TESSELLATION
// Mesh tessellation also in motion blur passes
// Mesh tessellation also in motion blur passes
#define MOTIONBLUR_TESSELLATION
#endif
// Dependencies
// Dependencies
#ifdef MESH_TESSELLATION
#define MESH_TESSELLATION_ENGINE
#endif
#ifndef NULL_RENDERER
#ifndef NULL_RENDERER
#ifdef WATER_TESSELLATION
#define WATER_TESSELLATION_RENDERER
#endif
@@ -230,7 +153,7 @@ typedef uint32 vtx_idx;
#endif
#if defined(WATER_TESSELLATION_RENDERER) || defined(PARTICLES_TESSELLATION_RENDERER) || defined(MESH_TESSELLATION_RENDERER)
// Common tessellation flag enabling tessellation stages in renderer
// Common tessellation flag enabling tessellation stages in renderer
#define TESSELLATION_RENDERER
#endif
#endif // !NULL_RENDERER
@@ -249,14 +172,8 @@ typedef uint32 vtx_idx;
#endif
#if defined(ENABLE_PROFILING_CODE)
# define USE_DISK_PROFILER
# define ENABLE_LOADING_PROFILER // requires AZ_PROFILE_TELEMETRY to also be defined
#endif
#if PROJECTDEFINES_H_TRAIT_USE_GPU_PARTICLES && !defined(NULL_RENDERER)
#define GPU_PARTICLES 1
#else
#define GPU_PARTICLES 0
#define USE_DISK_PROFILER
#define ENABLE_LOADING_PROFILER // requires AZ_PROFILE_TELEMETRY to also be defined
#endif
// The maximum number of joints in an animation
+1 -1
View File
@@ -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
+3 -2
View File
@@ -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();
-986
View File
@@ -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;
COMPILE_TIME_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;
COMPILE_TIME_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>
{
COMPILE_TIME_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.
COMPILE_TIME_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
{
COMPILE_TIME_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;
COMPILE_TIME_ASSERT(is_integral<SourceChar>::value && is_integral<TargetChar>::value);
COMPILE_TIME_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;
COMPILE_TIME_ASSERT(is_integral<TargetChar>::value);
COMPILE_TIME_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>)
{
COMPILE_TIME_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>)
{
COMPILE_TIME_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>)
{
COMPILE_TIME_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>)
{
COMPILE_TIME_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>)
{
COMPILE_TIME_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>)
{
COMPILE_TIME_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>)
{
COMPILE_TIME_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>)
{
COMPILE_TIME_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>)
{
COMPILE_TIME_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>)
{
COMPILE_TIME_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>)
{
COMPILE_TIME_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>)
{
COMPILE_TIME_ASSERT(is_arithmetic<InputCharType>::value);
return &in; // 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;
};
}
}
-767
View File
@@ -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
#include "CompileTimeAssert.h" // For COMPILE_TIME_ASSERT macro
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
COMPILE_TIME_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
-615
View File
@@ -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>)
{
COMPILE_TIME_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>)
{
COMPILE_TIME_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());
}
}
+1 -1
View File
@@ -14,7 +14,7 @@
#define CRYINCLUDE_CRYCOMMON_VECTORMAP_H
#pragma once
#include <StlUtils.h> // for stl::free_container
#include <CryCommon/StlUtils.h>
//--------------------------------------------------------------------------
// VectorMap
-9
View File
@@ -23,11 +23,7 @@
#define ILINE __forceinline
#endif
#define DEBUG_BREAK _asm { int 3 }
#define RC_EXECUTABLE "rc.exe"
#define DEPRECATED __declspec(deprecated)
#define TYPENAME(x) typeid(x).name()
#define SIZEOF_PTR 4
#ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x501
@@ -55,8 +51,6 @@
//////////////////////////////////////////////////////////////////////////
#include "BaseTypes.h"
#define THREADID_NULL -1
typedef unsigned char BYTE;
typedef unsigned int threadID;
typedef unsigned long DWORD;
@@ -112,14 +106,11 @@ int64 CryGetTicksPerSec();
__declspec(align(num))
#define DEFINE_ALIGNED_DATA(type, name, alignment) _declspec(align(alignment)) type name;
#define DEFINE_ALIGNED_DATA_STATIC(type, name, alignment) static _declspec(align(alignment)) type name;
#define DEFINE_ALIGNED_DATA_CONST(type, name, alignment) const _declspec(align(alignment)) type name;
#ifndef FILE_ATTRIBUTE_NORMAL
#define FILE_ATTRIBUTE_NORMAL 0x00000080
#endif
#define FP16_TERRAIN
#define TARGET_DEFAULT_ALIGN (0x4U)
-9
View File
@@ -19,11 +19,7 @@
#define _CPU_SSE
#define ILINE __forceinline
#define DEBUG_BREAK CryDebugBreak()
#define RC_EXECUTABLE "rc.exe"
#define DEPRECATED __declspec(deprecated)
#define TYPENAME(x) typeid(x).name()
#define SIZEOF_PTR 8
#ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x501
@@ -52,7 +48,6 @@
//////////////////////////////////////////////////////////////////////////
#include "BaseTypes.h"
#define THREADID_NULL -1
typedef long LONG;
typedef unsigned char BYTE;
typedef unsigned long threadID;
@@ -94,10 +89,6 @@ int64 CryGetTicksPerSec();
__declspec(align(num))
#define DEFINE_ALIGNED_DATA(type, name, alignment) _declspec(align(alignment)) type name;
#define DEFINE_ALIGNED_DATA_STATIC(type, name, alignment) static _declspec(align(alignment)) type name;
#define DEFINE_ALIGNED_DATA_CONST(type, name, alignment) const _declspec(align(alignment)) type name;
#define SIZEOF_PTR 8
#ifndef FILE_ATTRIBUTE_NORMAL
#define FILE_ATTRIBUTE_NORMAL 0x00000080
+31 -70
View File
@@ -12,6 +12,7 @@
#include "platform.h" // Note: This should be first to get consistent debugging definitions
#include <CryCommon/ISystem.h>
#include <CryAssert.h>
#if defined(AZ_RESTRICTED_PLATFORM)
@@ -29,7 +30,7 @@
#include AZ_RESTRICTED_FILE(WinBase_cpp)
#endif
#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
#else
#include <signal.h>
#endif
@@ -38,6 +39,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 +79,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 +349,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 +486,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 +503,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 +521,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 +547,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 +779,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 +798,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 +817,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)
@@ -1127,20 +1127,6 @@ void CrySleep(unsigned int dwMilliseconds)
Sleep(dwMilliseconds);
}
//////////////////////////////////////////////////////////////////////////
void CryLowLatencySleep(unsigned int dwMilliseconds)
{
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION WINBASE_CPP_SECTION_6
#include AZ_RESTRICTED_FILE(WinBase_cpp)
#endif
#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
#else
CrySleep(dwMilliseconds);
#endif
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
int CryMessageBox(const char* lpText, const char* lpCaption, unsigned int uType)
@@ -1284,14 +1270,6 @@ int CryMessageBox(const char* lpText, const char* lpCaption, unsigned int uType)
#endif
}
//////////////////////////////////////////////////////////////////////////
short CryGetAsyncKeyState(int vKey)
{
//TODO: implement
CRY_ASSERT_MESSAGE(0, "CryGetAsyncKeyState not implemented yet");
return 0;
}
#if defined(LINUX) || defined(APPLE)
threadID CryGetCurrentThreadId()
@@ -1299,10 +1277,6 @@ threadID CryGetCurrentThreadId()
return GetCurrentThreadId();
}
void CryDebugBreak()
{
__builtin_trap();
}
#endif//LINUX APPLE
#if defined(APPLE) || defined(LINUX)
@@ -1315,11 +1289,6 @@ DLL_EXPORT void OutputDebugString(const char* outputString)
#endif
}
DLL_EXPORT void DebugBreak()
{
CryDebugBreak();
}
#endif
// This code does not have a long life span and will be replaced soon
@@ -1516,14 +1485,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;
@@ -1543,16 +1514,6 @@ DWORD GetFileAttributes(LPCSTR lpFileName)
return (ret == 0) ? FILE_ATTRIBUTE_NORMAL : ret;//return file attribute normal as the default value, must only be set if no other attributes have been found
}
uint32 CryGetFileAttributes(const char* lpFileName)
{
string fn = lpFileName;
adaptFilenameToLinux(fn);
const char* buffer = fn.c_str();
return GetFileAttributes(buffer);
}
__finddata64_t::~__finddata64_t()
{
if (m_Dir != FS_DIR_NULL)
@@ -68,7 +68,6 @@ set(FILES
LCGRandom.h
CryTypeInfo.cpp
BaseTypes.h
CompileTimeAssert.h
MemoryAccess.h
AnimKey.h
BitFiddling.h
@@ -78,7 +77,6 @@ set(FILES
CryCrc32.h
CryCustomTypes.h
CryFile.h
CryFixedString.h
CryHeaders.h
CryHeaders_info.cpp
CryListenerSet.h
@@ -87,7 +85,6 @@ set(FILES
CryPath.h
CryPodArray.h
CrySizer.h
CryString.h
CrySystemBus.h
CryTypeInfo.h
CryVersion.h
@@ -108,7 +105,6 @@ set(FILES
SimpleSerialize.h
smartptr.h
StlUtils.h
StringUtils.h
Synchronization.h
Tarray.h
Timer.h
@@ -116,10 +112,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
@@ -157,7 +149,6 @@ set(FILES
CryAssert_Mac.h
CryLibrary.cpp
CryLibrary.h
CryWindows.h
Linux32Specific.h
Linux64Specific.h
Linux_Win32Wrapper.h
-2
View File
@@ -47,11 +47,9 @@
#define VK_SCROLL 0
//#define USE_CRT 1
#if !defined(PLATFORM_64BIT)
#error "IOS build only supports the 64bit architecture"
#else
#define SIZEOF_PTR 8
typedef uint64_t threadID;
#endif
+39 -382
View File
@@ -7,22 +7,18 @@
*/
// Description : Platform dependend stuff.
// Description : Platform dependent stuff.
// Include this file instead of windows h
#pragma once
#if defined(AZ_RESTRICTED_PLATFORM)
#undef AZ_RESTRICTED_SECTION
#define PLATFORM_H_SECTION_1 1
#define PLATFORM_H_SECTION_2 2
#define PLATFORM_H_SECTION_3 3
#define PLATFORM_H_SECTION_4 4
#define PLATFORM_H_SECTION_5 5
#define PLATFORM_H_SECTION_6 6
#define PLATFORM_H_SECTION_7 7
#define PLATFORM_H_SECTION_8 8
#define PLATFORM_H_SECTION_9 9
#define PLATFORM_H_SECTION_10 10
#define PLATFORM_H_SECTION_11 11
#define PLATFORM_H_SECTION_12 12
@@ -31,112 +27,12 @@
#define PLATFORM_H_SECTION_15 15
#endif
// certain C++ features are not available in some compiler versions
// turn them off here:
// #define _ALLOW_KEYWORD_MACROS
// #define _DISALLOW_INITIALIZER_LISTS
// #define _DISALLOW_ENUM_CLASS
#if defined(_MSC_VER)
#define _ALLOW_KEYWORD_MACROS
#define alignof _alignof
#if !defined(_HAS_EXCEPTIONS)
#define _HAS_EXCEPTIONS 0
#endif
#elif defined(__GNUC__)
#define alignof __alignof__
#endif
// Alignment|InitializerList support.
#define _ALLOW_INITIALIZER_LISTS
#if (defined(LINUX) && !defined(ANDROID)) || defined(APPLE)
#define _FILE_OFFSET_BITS 64 // define large file support > 2GB
#define _FILE_OFFSET_BITS 64 // define large file support > 2GB
#endif
#include <AzCore/PlatformIncl.h>
#include <cstring>
#if defined(_MSC_VER) // We want the class name to be included, but __FUNCTION__ doesn't contain that on GCC/clang
#define __FUNC__ __FUNCTION__
#else
#define __FUNC__ __PRETTY_FUNCTION__
#endif
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION PLATFORM_H_SECTION_1
#include AZ_RESTRICTED_FILE(platform_h)
#endif
#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
#elif defined(_DEBUG) && !defined(LINUX) && !defined(APPLE)
#include <crtdbg.h>
#endif
#define RESTRICT_POINTER __restrict
// we have to use it because of VS doesn't support restrict reference variables
#if defined(APPLE) || defined(LINUX)
#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)
#define GCC411_OR_LATER
#endif
#define RESTRICT_REFERENCE __restrict
#else
#define RESTRICT_REFERENCE
#endif
#ifndef CHECK_REFERENCE_COUNTS //define that in your StdAfx.h to override per-project
# define CHECK_REFERENCE_COUNTS 0 //default value
#endif
#if CHECK_REFERENCE_COUNTS
# define CHECK_REFCOUNT_CRASH(x) { if (!(x)) {*((int*)0) = 0; } \
}
#else
# define CHECK_REFCOUNT_CRASH(x)
#endif
#ifndef GARBAGE_MEMORY_ON_FREE //define that in your StdAfx.h to override per-project
# define GARBAGE_MEMORY_ON_FREE 0 //default value
#endif
#if GARBAGE_MEMORY_ON_FREE
# ifndef GARBAGE_MEMORY_RANDOM //define that in your StdAfx.h to override per-project
# define GARBAGE_MEMORY_RANDOM 1 //0 to change it to progressive pattern
# endif
#endif
//////////////////////////////////////////////////////////////////////////
// Available predefined compiler macros for Visual C++.
// _MSC_VER // Indicates MS Visual C compiler version
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION PLATFORM_H_SECTION_2
#include AZ_RESTRICTED_FILE(platform_h)
#endif
#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
#else
// _WIN32, _WIN64 // Indicates target OS
#endif
// _M_IX86, _M_PPC // Indicates target processor
// _DEBUG // Building in Debug mode
// _DLL // Linking with DLL runtime libs
// _MT // Linking with multi-threaded runtime libs
//////////////////////////////////////////////////////////////////////////
//
// Translate some predefined macros.
//
// NDEBUG disables std asserts, etc.
// Define it automatically if not compiling with Debug libs, or with ADEBUG flag.
#if !defined(_DEBUG) && !defined(ADEBUG) && !defined(NDEBUG)
#define NDEBUG
#endif
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION PLATFORM_H_SECTION_3
#include AZ_RESTRICTED_FILE(platform_h)
@@ -147,44 +43,6 @@
#define CONSOLE
#endif
//render thread settings, as this is accessed inside 3dengine and renderer and needs to be compile time defined, we need to do it here
//enable this macro to strip out the overhead for render thread
// #define STRIP_RENDER_THREAD
#ifdef STRIP_RENDER_THREAD
#define RT_COMMAND_BUF_COUNT 1
#else
//can be enhanced to triple buffering, FlushFrame needs to be adjusted and RenderObj would become 132 bytes
#define RT_COMMAND_BUF_COUNT 2
#endif
// We use WIN macros without _.
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION PLATFORM_H_SECTION_4
#include AZ_RESTRICTED_FILE(platform_h)
#endif
#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
#else
#if defined(_WIN32) && !defined(LINUX32) && !defined(LINUX64) && !defined(APPLE) && !defined(WIN32)
#define WIN32
#endif
#if defined(_WIN64) && !defined(WIN64)
#define WIN64
#endif
#endif
// In Win32 Release we use static linkage
#ifdef WIN32
#if !defined(_RELEASE) || defined(RESOURCE_COMPILER) || defined(EDITOR) || defined(_FORCEDLL)
// All windows targets not in Release built as DLLs.
#ifndef _USRDLL
#define _USRDLL
#endif
#endif
#endif //WIN32
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION PLATFORM_H_SECTION_5
#include AZ_RESTRICTED_FILE(platform_h)
@@ -205,19 +63,17 @@
#define PRId64 "lld"
#define PRIu64 "llu"
#endif
#define PLATFORM_I64(x) x##ll
#else
#include <inttypes.h>
#define PLATFORM_I64(x) x##i64
#endif
#if !defined(PRISIZE_T)
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION PLATFORM_H_SECTION_6
#include AZ_RESTRICTED_FILE(platform_h)
#endif
#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION PLATFORM_H_SECTION_6
#include AZ_RESTRICTED_FILE(platform_h)
#endif
#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
#elif defined(WIN64)
#define PRISIZE_T "I64u" //size_t defined as unsigned __int64
#elif defined(WIN32) || defined(LINUX32)
@@ -228,13 +84,14 @@
#error "Please defined PRISIZE_T for this platform"
#endif
#endif
#if !defined(PRI_THREADID)
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION PLATFORM_H_SECTION_7
#include AZ_RESTRICTED_FILE(platform_h)
#endif
#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION PLATFORM_H_SECTION_7
#include AZ_RESTRICTED_FILE(platform_h)
#endif
#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
#elif defined(MAC) || defined(IOS) && defined(__LP64__) && defined(__LP64__)
#define PRI_THREADID "lld"
#elif defined(LINUX64) || defined(ANDROID)
@@ -243,6 +100,7 @@
#define PRI_THREADID "d"
#endif
#endif
#include "ProjectDefines.h" // to get some defines available in every CryEngine project
// Function attribute for printf/scanf-style parameters.
@@ -277,43 +135,13 @@
#define PRINTF_EMPTY_FORMAT ""
#endif
//////////////////////////////////////////////////////////////////////////
// define Read Write Barrier macro needed for lockless programming
//////////////////////////////////////////////////////////////////////////
#if defined(__arm__)
/**
* (ARMv7) Full memory barriar.
*
* None of GCC 4.6/4.8 or clang 3.3/3.4 have a builtin intrinsic for ARM's ldrex/strex or dmb
* instructions. This is a placeholder until supplied by the toolchain.
*/
inline void __dmb()
{
// The linux kernel uses "dmb ish" to only sync with local monitor (arch/arm/include/asm/barrier.h):
//#define dmb(option) __asm__ __volatile__ ("dmb " #option : : : "memory")
//#define smp_mb() dmb(ish)
__asm__ __volatile__ ("dmb ish" : : : "memory");
}
#define READ_WRITE_BARRIER {__dmb(); }
#else
#define READ_WRITE_BARRIER
#endif
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// define macro to prevent memory reoderings of reads/and writes
//TODO implement for all GCC platforms, else there are potential crashes with strict aliasing
#define MEMORY_RW_REORDERING_BARRIER do { /*not implemented*/} while (0)
//default stack size for threads, currently only used on pthread platforms
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION PLATFORM_H_SECTION_8
#include AZ_RESTRICTED_FILE(platform_h)
#endif
#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
#elif defined(LINUX) || defined(APPLE)
#if !defined(_DEBUG)
#define SIMPLE_THREAD_STACK_SIZE_KB (256)
@@ -350,22 +178,6 @@ inline void __dmb()
#else
#define _HELP(x) ""
#endif
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// Globally Used Defines.
//////////////////////////////////////////////////////////////////////////
// CPU Types: _CPU_X86,_CPU_AMD64,_CPU_G5
// Platform: WIN23,WIN64,LINUX32,LINUX64,MAC
// CPU supported functionality: _CPU_SSE
//////////////////////////////////////////////////////////////////////////
#if defined(_MSC_VER)
#define PREFAST_SUPPRESS_WARNING(W) __pragma(warning(suppress: W))
#else
#define PREFAST_SUPPRESS_WARNING(W)
#endif
#ifdef _PREFAST_
# define PREFAST_ASSUME(cond) __analysis_assume(cond)
@@ -373,47 +185,21 @@ inline void __dmb()
# define PREFAST_ASSUME(cond)
#endif
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION PLATFORM_H_SECTION_9
#include AZ_RESTRICTED_FILE(platform_h)
#endif
#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
#else
#if defined(WIN32) && !defined(WIN64)
#include "Win32specific.h"
#endif
#if defined(WIN64)
#include "Win64specific.h"
#endif
#endif
#if defined(LINUX64) && !defined(ANDROID)
#include "Linux64Specific.h"
#endif
#if defined(LINUX32) && !defined(ANDROID)
#include "Linux32Specific.h"
#endif
#if defined(ANDROID)
#include "AndroidSpecific.h"
#endif
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION PLATFORM_H_SECTION_10
#include AZ_RESTRICTED_FILE(platform_h)
#endif
#if defined(MAC)
#include "MacSpecific.h"
#endif
#if defined(IOS)
#include "iOSSpecific.h"
#else
#if defined(WIN64)
#include "Win64specific.h"
#elif defined(LINUX64) && !defined(ANDROID)
#include "Linux64Specific.h"
#elif defined(MAC)
#include "MacSpecific.h"
#elif defined(ANDROID)
#include "AndroidSpecific.h"
#elif defined(IOS)
#include "iOSSpecific.h"
#endif
#endif
@@ -468,12 +254,6 @@ ILINE DestinationType alias_cast(SourceType pPtr)
#define DEPRECATED
#endif
//////////////////////////////////////////////////////////////////////////
// compile time error stuff
//////////////////////////////////////////////////////////////////////////
#undef STATIC_CHECK
#define STATIC_CHECK(expr, msg) static_assert(expr, #msg)
// Assert dialog box macros
#include "CryAssert.h"
@@ -483,35 +263,12 @@ ILINE DestinationType alias_cast(SourceType pPtr)
#define assert CRY_ASSERT
#endif
#include "CompileTimeAssert.h"
//////////////////////////////////////////////////////////////////////////
// Platform dependent functions that emulate Win32 API.
// Mostly used only for debugging!
//////////////////////////////////////////////////////////////////////////
void CryDebugBreak();
void CrySleep(unsigned int dwMilliseconds);
void CryLowLatencySleep(unsigned int dwMilliseconds);
int CryMessageBox(const char* lpText, const char* lpCaption, unsigned int uType);
short CryGetAsyncKeyState(int vKey);
unsigned int CryGetFileAttributes(const char* lpFileName);
inline void CryHeapCheck()
{
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION PLATFORM_H_SECTION_11
#include AZ_RESTRICTED_FILE(platform_h)
#elif !defined(LINUX) && !defined(APPLE) // todo: this might be readded with later xdks?
#if !defined(NDEBUG)
int Result =
#endif
_heapchk();
assert(Result != _HEAPBADBEGIN);
assert(Result != _HEAPBADNODE);
assert(Result != _HEAPBADPTR);
assert(Result != _HEAPEMPTY);
assert(Result == _HEAPOK);
#endif
}
//---------------------------------------------------------------------------
// Useful function to clean the structure.
@@ -542,77 +299,6 @@ inline D check_cast(S const& s)
return d;
}
// Convert one type to another, asserting there is no conversion loss.
// Usage: DestType dest; check_convert(dest, src);
template<class D, class S>
inline D& check_convert(D& d, S const& s)
{
d = D(s);
assert(S(d) == s);
return d;
}
// Convert one type to another, asserting there is no conversion loss.
// Usage: DestType dest; check_convert(dest) = src;
template<class D>
struct CheckConvert
{
CheckConvert(D& d)
: dest(&d) {}
template<class S>
D& operator=(S const& s)
{
return check_convert(*dest, s);
}
protected:
D* dest;
};
template<class D>
inline CheckConvert<D> check_convert(D& d)
{
return d;
}
//---------------------------------------------------------------------------
// Use NoCopy as a base class to easily prevent copy init & assign for any class.
struct NoCopy
{
NoCopy() {}
private:
NoCopy(const NoCopy&);
NoCopy& operator =(const NoCopy&);
};
//---------------------------------------------------------------------------
// ZeroInit: base class to zero the memory of the derived class before initialization, so local objects initialize the same as static.
// Usage:
// class MyClass: ZeroInit<MyClass> {...}
// class MyChild: public MyClass, ZeroInit<MyChild> {...} // ZeroInit must be the last base class
template<class TDerived>
struct ZeroInit
{
#if defined(__clang__) || defined(__GNUC__)
bool __dummy; // Dummy var to create non-zero size, ensuring proper placement in TDerived
#endif
ZeroInit(bool bZero = true)
{
// Optional bool arg to selectively disable zeroing.
if (bZero)
{
// Infer offset of this base class by static casting to derived class.
// Zero only the additional memory of the derived class.
TDerived* struct_end = static_cast<TDerived*>(this) + 1;
size_t memory_size = (char*)struct_end - (char*)this;
memset(this, 0, memory_size);
}
}
};
//---------------------------------------------------------------------------
// Quick const-manipulation macros
@@ -675,9 +361,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"
@@ -687,35 +370,19 @@ 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"
#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
#define __PACKED __attribute__ ((packed))
#else
#define NO_INLINE _declspec(noinline)
#define NO_INLINE_WEAK _declspec(noinline) inline
#define __PACKED
#endif
// need this in a common header file and any other file would be too misleading
enum ETriState
{
eTS_false,
eTS_true,
eTS_maybe
};
#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
# define __PACKED __attribute__ ((packed))
#else
#define NO_INLINE _declspec(noinline)
# define NO_INLINE_WEAK _declspec(noinline) inline
# define __PACKED
#endif
// Fallback for Alignment macro of GCC/CLANG (must be after the class definition)
#if !defined(_ALIGN)
#define _ALIGN(num) AZ_POP_DISABLE_WARNING
#define _ALIGN(num) AZ_POP_DISABLE_WARNING
#endif
// Fallback for Alignment macro of MSVC (must be before the class definition)
@@ -727,7 +394,7 @@ enum ETriState
#define AZ_RESTRICTED_SECTION PLATFORM_H_SECTION_13
#include AZ_RESTRICTED_FILE(platform_h)
#elif !defined(LINUX) && !defined(APPLE)
typedef int socklen_t;
typedef int socklen_t;
#endif
// In RELEASE disable printf and fprintf
@@ -738,19 +405,9 @@ typedef int socklen_t;
#endif
#endif
#define _STRINGIFY(x) #x
#define STRINGIFY(x) _STRINGIFY(x)
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION PLATFORM_H_SECTION_15
#include AZ_RESTRICTED_FILE(platform_h)
#endif
#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
#elif defined(WIN32) || defined(WIN64)
#define MESSAGE(msg) message(__FILE__ "(" STRINGIFY(__LINE__) "): " msg)
#else
#define MESSAGE(msg)
#endif
void InitRootDir(char szExeFileName[] = nullptr, uint nExeSize = 0, char szExeRootName[] = nullptr, uint nRootSize = 0);
+23 -72
View File
@@ -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)
@@ -200,17 +200,6 @@ void __stl_debug_message(const char* format_str, ...)
#include "CryAssert_impl.h"
//////////////////////////////////////////////////////////////////////////
void CryDebugBreak()
{
#if defined(WIN32) && !defined(RELEASE)
if (IsDebuggerPresent())
#endif
{
DebugBreak();
}
}
//////////////////////////////////////////////////////////////////////////
void CrySleep(unsigned int dwMilliseconds)
{
@@ -218,47 +207,32 @@ void CrySleep(unsigned int dwMilliseconds)
Sleep(dwMilliseconds);
}
//////////////////////////////////////////////////////////////////////////
void CryLowLatencySleep(unsigned int dwMilliseconds)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::System);
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION PLATFORM_IMPL_H_SECTION_CRYLOWLATENCYSLEEP
#include AZ_RESTRICTED_FILE(platform_impl_h)
#endif
#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
#else
CrySleep(dwMilliseconds);
#endif
}
//////////////////////////////////////////////////////////////////////////
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;
@@ -273,58 +247,33 @@ 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;
}
}
}
}
//////////////////////////////////////////////////////////////////////////
short CryGetAsyncKeyState([[maybe_unused]] int vKey)
{
#ifdef WIN32
return GetAsyncKeyState(vKey);
#else
return 0;
#endif
}
//////////////////////////////////////////////////////////////////////////
uint32 CryGetFileAttributes(const char* lpFileName)
{
WIN32_FILE_ATTRIBUTE_DATA data;
BOOL res;
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION PLATFORM_IMPL_H_SECTION_CRYGETFILEATTRIBUTES
#include AZ_RESTRICTED_FILE(platform_impl_h)
#endif
#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
#else
res = GetFileAttributesEx(lpFileName, GetFileExInfoStandard, &data);
#endif
return res ? data.dwFileAttributes : -1;
}
//////////////////////////////////////////////////////////////////////////
bool CrySetFileAttributes(const char* lpFileName, uint32 dwFileAttributes)
{
@@ -335,7 +284,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
}
@@ -384,7 +335,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
*/
+7 -6
View File
@@ -13,6 +13,7 @@
#include <platform.h>
#include <type_traits>
#include <MultiThread.h>
void CryFatalError(const char*, ...) PRINTF_PARAMS(1, 2);
#if defined(APPLE)
@@ -174,13 +175,13 @@ public:
void AddRef()
{
CHECK_REFCOUNT_CRASH(m_nRefCounter >= 0);
AZ_Assert(m_nRefCounter >= 0, "Invalid ref count");
++m_nRefCounter;
}
void Release()
{
CHECK_REFCOUNT_CRASH(m_nRefCounter > 0);
AZ_Assert(m_nRefCounter > 0, "Invalid ref count");
if (--m_nRefCounter == 0)
{
delete static_cast<TDerived*>(this);
@@ -218,13 +219,13 @@ public:
void AddRef()
{
CHECK_REFCOUNT_CRASH(m_nRefCounter >= 0);
AZ_Assert(m_nRefCounter >= 0, "Invalid ref count");
++m_nRefCounter;
}
void Release()
{
CHECK_REFCOUNT_CRASH(m_nRefCounter > 0);
AZ_Assert(m_nRefCounter > 0, "Invalid ref count");
if (--m_nRefCounter == 0)
{
delete this;
@@ -275,13 +276,13 @@ public:
void AddRef()
{
CHECK_REFCOUNT_CRASH(m_nRefCounter >= 0);
AZ_Assert(m_nRefCounter >= 0, "Invalid ref count");
++m_nRefCounter;
}
void Release()
{
CHECK_REFCOUNT_CRASH(m_nRefCounter > 0);
AZ_Assert(m_nRefCounter > 0, "Invalid ref count");
if (--m_nRefCounter == 0)
{
assert(m_pDeleteFnc);
+2 -2
View File
@@ -66,9 +66,9 @@ private:
# if !defined(eLittleEndian)
# error eLittleEndian is not defined, please include CryEndian.h.
# endif
COMPILE_TIME_ASSERT(metautils::is_const<dtype>::value || !metautils::is_const<dtype1>::value);
static_assert(metautils::is_const<dtype>::value || !metautils::is_const<dtype1>::value);
// note: we allow xint32 -> xint16 converting
COMPILE_TIME_ASSERT(
static_assert(
(metautils::is_same<typename metautils::remove_const<dtype1>::type, typename metautils::remove_const<dtype>::type>::value ||
((metautils::is_same<typename metautils::remove_const<dtype1>::type, sint32>::value ||
metautils::is_same<typename metautils::remove_const<dtype1>::type, uint32>::value ||
+10 -10
View File
@@ -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();
}
+4 -4
View File
@@ -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;
};
+2 -2
View File
@@ -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
+13 -13
View File
@@ -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
+37 -37
View File
@@ -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);
}
+5 -5
View File
@@ -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);
@@ -68,7 +68,7 @@
#endif
#ifdef WIN32
#include <CryWindows.h>
#include <AzCore/PlatformIncl.h>
#include <tlhelp32.h>
#undef GetCharWidth
#undef GetUserName
+44 -35
View File
@@ -19,6 +19,7 @@
#include <AzCore/Debug/StackTracer.h>
#include <AzCore/Debug/EventTraceDrillerBus.h>
#include <AzCore/std/parallel/spin_mutex.h>
#include <AzCore/Utils/Utils.h>
#define VS_VERSION_INFO 1
#define IDD_CRITICAL_ERROR 101
@@ -349,7 +350,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();
@@ -365,7 +366,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@");
@@ -380,12 +381,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"));
@@ -400,8 +401,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);
}
}
@@ -415,8 +420,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];
@@ -431,18 +436,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);
@@ -472,9 +477,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];
@@ -482,9 +487,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)];
@@ -500,20 +505,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)
{
@@ -594,8 +599,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);
@@ -636,11 +645,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);
}
}
}
@@ -819,7 +828,7 @@ void DebugCallStack::ResetFPU(EXCEPTION_POINTERS* pex)
}
}
string DebugCallStack::GetModuleNameForAddr(void* addr)
AZStd::string DebugCallStack::GetModuleNameForAddr(void* addr)
{
if (m_modules.empty())
{
@@ -845,7 +854,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);
@@ -853,10 +862,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;
}
+5 -5
View File
@@ -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);
+3 -3
View File
@@ -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;
@@ -227,7 +227,7 @@ void IDebugCallStack::FatalError(const char* description)
#if defined(WIN32) || !defined(_RELEASE)
int* p = 0x0;
PREFAST_SUPPRESS_WARNING(6011) * p = 1; // we're intentionally crashing here
*p = 1; // we're intentionally crashing here
#endif
}
@@ -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);
+4 -8
View File
@@ -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();
@@ -33,10 +33,6 @@
#include <AzCore/Script/ScriptSystemBus.h>
#ifdef WIN32
#include <CryWindows.h>
#endif
namespace LegacyLevelSystem
{
static constexpr const char* ArchiveExtension = ".pak";
@@ -480,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);
}
@@ -567,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!!!
{
@@ -618,12 +614,6 @@ ILevel* CLevelSystem::LoadLevelInternal(const char* _levelName)
}
}
// Reset the camera to (1,1,1) (not (0,0,0) which is the invalid/uninitialised state,
// to avoid the hack in the renderer to not show anything if the camera is at the origin).
CCamera defaultCam;
defaultCam.SetPosition(Vec3(1.0f));
m_pSystem->SetViewCamera(defaultCam);
m_pLoadingLevelInfo = pLevelInfo;
OnLoadingStart(levelName);
@@ -952,10 +942,6 @@ void CLevelSystem::UnloadLevel()
oAudioRequestData.pData = &oAMData3;
Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequestBlocking, oAudioRequestData);
// Reset the camera to (0,0,0) which is the invalid/uninitialised state
CCamera defaultCam;
m_pSystem->SetViewCamera(defaultCam);
OnUnloadComplete(m_lastLevelName.c_str());
// -- kenzo: this will close all pack files for this level
@@ -268,12 +268,6 @@ namespace LegacyLevelSystem
// This is a workaround until the replacement for GameEntityContext is done
AzFramework::GameEntityContextEventBus::Broadcast(&AzFramework::GameEntityContextEventBus::Events::OnPreGameEntitiesStarted);
// Reset the camera to (1,1,1) (not (0,0,0) which is the invalid/uninitialised state,
// to avoid the hack in the renderer to not show anything if the camera is at the origin).
CCamera defaultCam;
defaultCam.SetPosition(Vec3(1.0f));
m_pSystem->SetViewCamera(defaultCam);
OnLoadingStart(levelName);
auto pPak = gEnv->pCryPak;
@@ -587,10 +581,6 @@ namespace LegacyLevelSystem
oAudioRequestData.pData = &oAMData3;
Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequestBlocking, oAudioRequestData);
// Reset the camera to (0,0,0) which is the invalid/uninitialised state
CCamera defaultCam;
m_pSystem->SetViewCamera(defaultCam);
OnUnloadComplete(m_lastLevelName.c_str());
AzFramework::RootSpawnableInterface::Get()->ReleaseRootSpawnable();
+147 -119
View File
@@ -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);
}
+33 -33
View File
@@ -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
+23 -32
View File
@@ -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>
@@ -455,7 +454,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;
@@ -463,7 +462,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;
@@ -498,7 +497,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());
}
}
@@ -521,7 +520,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;
}
@@ -852,7 +851,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;
@@ -945,7 +944,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;
@@ -972,7 +971,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;
@@ -989,7 +988,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)
@@ -1041,13 +1040,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)
@@ -1207,14 +1200,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);
@@ -1223,14 +1216,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))
{
@@ -1242,13 +1235,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;
}
@@ -1273,12 +1264,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
}
+1 -1
View File
@@ -35,7 +35,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);
+21 -27
View File
@@ -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)
+7 -11
View File
@@ -353,9 +353,6 @@ public:
virtual IXmlUtils* GetXmlUtils();
//////////////////////////////////////////////////////////////////////////
void SetViewCamera(CCamera& Camera){ m_ViewCamera = Camera; }
CCamera& GetViewCamera() { return m_ViewCamera; }
void IgnoreUpdates(bool bIgnore) { m_bIgnoreUpdates = bIgnore; };
void SetIProcess(IProcess* process);
@@ -453,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;
@@ -494,7 +491,6 @@ private: // ------------------------------------------------------
SSystemGlobalEnvironment m_env;
CTimer m_Time; //!<
CCamera m_ViewCamera; //!<
bool m_bInitializedSuccessfully; //!< true if the system completed all initialization steps
bool m_bRelaunch; //!< relaunching the app or not (true beforerelaunch)
int m_iLoadingMode; //!< Game is loading w/o changing context (0 not, 1 quickloading, 2 full loading)
@@ -623,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.
@@ -672,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);
@@ -718,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;
+48 -46
View File
@@ -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());
}
}
}
+7 -13
View File
@@ -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 -43
View File
@@ -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>
@@ -252,7 +251,7 @@ static void CmdCrashTest(IConsoleCmdArgs* pArgs)
case 1:
{
int* p = 0;
PREFAST_SUPPRESS_WARNING(6011) * p = 0xABCD;
*p = 0xABCD;
}
break;
case 2:
@@ -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,37 +877,35 @@ 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)
{
AZ::CVarFixedString languageAudio;
if (auto result = console->GetCvarValue("g_languageAudio", languageAudio); result == AZ::GetValueResult::Success)
console->GetCvarValue("g_languageAudio", languageAudio);
if (languageAudio.empty())
{
if (languageAudio.size() == 0)
{
console->PerformCommand(AZStd::string::format("g_languageAudio %s", language.c_str()).c_str());
}
else
{
language.assign(languageAudio.data(), languageAudio.size());
}
console->PerformCommand(AZStd::string::format("g_languageAudio %s", language.c_str()).c_str());
}
else
{
language.assign(languageAudio.data(), languageAudio.size());
}
}
OpenLanguageAudioPak(language);
OpenLanguageAudioPak(language.c_str());
}
void CSystem::OpenBasicPaks()
@@ -972,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))
{
@@ -1002,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))
{
@@ -1020,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;
@@ -1039,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);
@@ -1215,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);
@@ -1310,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
@@ -1658,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));
@@ -2135,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)
{
@@ -2153,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);
+39 -63
View File
@@ -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,44 +323,40 @@ 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.
IDebugCallStack::instance()->FatalError(szBuffer);
#endif
CryDebugBreak();
// app can not continue
AZ::Debug::Trace::Break();
#ifdef _DEBUG
#if defined(WIN32) || defined(WIN64)
_flushall();
// on windows, _exit does all sorts of things which can cause cleanup to fail during a crash, we need to terminate instead.
TerminateProcess(GetCurrentProcess(), 1);
#endif
#if defined(WIN32) && !defined(WIN64)
DEBUG_BREAK;
#endif
#else
#if defined(WIN32) || defined(WIN64)
_flushall();
// on windows, _exit does all sorts of things which can cause cleanup to fail during a crash, we need to terminate instead.
TerminateProcess(GetCurrentProcess(), 1);
#endif
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION SYSTEMWIN32_CPP_SECTION_2
#include AZ_RESTRICTED_FILE(SystemWin32_cpp)
#endif
#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
#else
_exit(1);
#endif
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION SYSTEMWIN32_CPP_SECTION_2
#include AZ_RESTRICTED_FILE(SystemWin32_cpp)
#endif
#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
#else
_exit(1);
#endif
#endif
}
@@ -410,7 +386,7 @@ void CSystem::debug_GetCallStack(const char** pFunctions, int& nCount)
unsigned int numFrames = StackRecorder::Record(frames, nMaxCount, 1);
SymbolStorage::StackLine* textLines = (SymbolStorage::StackLine*)AZ_ALLOCA(sizeof(SymbolStorage::StackLine)*nMaxCount);
SymbolStorage::DecodeFrames(frames, numFrames, textLines);
for (int i = 0; i < numFrames; i++)
for (unsigned int i = 0; i < numFrames; i++)
{
pFunctions[i] = textLines[i];
}
@@ -461,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
@@ -491,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);
@@ -505,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);
}
}
@@ -519,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);
}
}
@@ -547,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);
@@ -58,10 +58,10 @@ DebugCamera::~DebugCamera()
///////////////////////////////////////////////////////////////////////////////
void DebugCamera::OnEnable()
{
m_position = gEnv->pSystem->GetViewCamera().GetPosition();
m_position = Vec3_Zero;
m_moveInput = Vec3_Zero;
Ang3 cameraAngles = Ang3(gEnv->pSystem->GetViewCamera().GetMatrix());
Ang3 cameraAngles = Ang3(ZERO);
m_cameraYaw = RAD2DEG(cameraAngles.z);
m_cameraPitch = RAD2DEG(cameraAngles.x);
m_view = Matrix33(Ang3(DEG2RAD(m_cameraPitch), 0.0f, DEG2RAD(m_cameraYaw)));
@@ -126,13 +126,6 @@ void DebugCamera::Update()
///////////////////////////////////////////////////////////////////////////////
void DebugCamera::PostUpdate()
{
if (m_cameraMode == DebugCamera::ModeOff)
{
return;
}
CCamera& camera = gEnv->pSystem->GetViewCamera();
camera.SetMatrix(Matrix34(m_view, m_position));
}
///////////////////////////////////////////////////////////////////////////////
+2 -72
View File
@@ -55,79 +55,9 @@ void CView::Release()
}
//------------------------------------------------------------------------
void CView::Update(float frameTime, bool isActive)
void CView::Update([[maybe_unused]] float frameTime, [[maybe_unused]] bool isActive)
{
//FIXME:some cameras may need to be updated always
if (!isActive)
{
return;
}
if (m_azEntity)
{
m_viewParams.SaveLast();
CCamera* pSysCam = &m_pSystem->GetViewCamera();
//process screen shaking
ProcessShaking(frameTime);
//FIXME:to let the updateView implementation use the correct shakeVector
m_viewParams.currentShakeShift = m_viewParams.rotation * m_viewParams.currentShakeShift;
m_viewParams.frameTime = frameTime;
//update view position/rotation
if (m_azEntity != nullptr)
{
auto entityTransform = m_azEntity->GetTransform();
if (entityTransform != nullptr)
{
AZ::Transform transform = entityTransform->GetWorldTM();
m_viewParams.position = AZVec3ToLYVec3(transform.GetTranslation());
m_viewParams.rotation = AZQuaternionToLYQuaternion(transform.GetRotation());
}
}
ApplyFrameAdditiveAngles(m_viewParams.rotation);
const float fNearZ = gEnv->pSystem->GetIViewSystem()->GetDefaultZNear();
//see if the view have to use a custom near clipping plane
const float nearPlane = (m_viewParams.nearplane >= CAMERA_MIN_NEAR) ? (m_viewParams.nearplane) : fNearZ;
const float farPlane = (m_viewParams.farplane > 0.f) ? m_viewParams.farplane : DEFAULT_FAR;
float fov = (m_viewParams.fov < 0.001f) ? DEFAULT_FOV : m_viewParams.fov;
m_camera.SetFrustum(pSysCam->GetViewSurfaceX(), pSysCam->GetViewSurfaceZ(), fov, nearPlane, farPlane, pSysCam->GetPixelAspectRatio());
//apply shake & set the view matrix
m_viewParams.rotation *= m_viewParams.currentShakeQuat;
m_viewParams.rotation.NormalizeSafe();
m_viewParams.position += m_viewParams.currentShakeShift;
// Blending between cameras needs to happen after Camera space rendering calculations have been applied
// so that the m_viewParams.position is in World Space again
m_viewParams.UpdateBlending(frameTime);
// [VR] specific
// Add HMD's pose tracking on top of current camera pose
// Each game-title can decide whether to keep this functionality here or (most likely)
// move it somewhere else.
Quat q = m_viewParams.rotation;
Vec3 pos = m_viewParams.position;
Vec3 p = Vec3(ZERO);
Matrix34 viewMtx(q);
viewMtx.SetTranslation(pos + p);
m_camera.SetMatrix(viewMtx);
m_camera.SetEntityRotation(m_viewParams.rotation);
m_camera.SetEntityPos(pos);
}
else
{
m_linkedTo = AZ::EntityId(0);
}
AZ_ErrorOnce("CryLegacy", false, "CryLegacy view system no longer available (CView::Update)");
}
//-----------------------------------------------------------------------
@@ -26,7 +26,7 @@
if (count > 0) \
{ \
const size_t memSize = count * sizeof(IViewSystemListener*); \
PREFAST_SUPPRESS_WARNING(6255) IViewSystemListener * *pArray = (IViewSystemListener**) alloca(memSize); \
IViewSystemListener* *pArray = (IViewSystemListener**) alloca(memSize); \
memcpy(pArray, &*m_listeners.begin(), memSize); \
while (count--) \
{ \
@@ -253,7 +253,7 @@ void CViewSystem::Update(float frameTime)
}
}
m_pSystem->SetViewCamera(rCamera);
AZ_ErrorOnce("CryLegacy", false, "CryLegacy view system no longer available (CViewSystem::Update)");
}
}
@@ -557,23 +557,7 @@ void CViewSystem::SetOverrideCameraRotation(bool bOverride, Quat rotation)
//////////////////////////////////////////////////////////////////////////
void CViewSystem::UpdateSoundListeners()
{
assert(gEnv->IsEditor() && !gEnv->IsEditorGameMode());
// In Editor we may want to control global listeners outside of the game view.
if (m_bControlsAudioListeners)
{
IView* const pActiveView = static_cast<IView*>(GetActiveView());
TViewMap::const_iterator Iter(m_views.begin());
TViewMap::const_iterator const IterEnd(m_views.end());
for (; Iter != IterEnd; ++Iter)
{
IView* const pView = Iter->second;
bool const bIsActive = (pView == pActiveView);
CCamera const& rCamera = bIsActive ? gEnv->pSystem->GetViewCamera() : pView->GetCamera();
pView->UpdateAudioListener(rCamera.GetMatrix());
}
}
AZ_ErrorOnce("CryLegacy", false, "CryLegacy view system no longer available (CViewSystem::UpdateSoundListeners)");
}
//////////////////////////////////////////////////////////////////
@@ -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());

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