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 ||