|
@@ -15,6 +15,7 @@
|
|
|
#include "xml.h"
|
|
|
#include <algorithm>
|
|
|
#include <stdio.h>
|
|
|
+#include <AzCore/Serialization/Locale.h>
|
|
|
#include <AzFramework/Archive/IArchive.h>
|
|
|
#include <CryCommon/Cry_Color.h>
|
|
|
#include "XMLBinaryReader.h"
|
|
@@ -26,31 +27,6 @@
|
|
|
|
|
|
#include "System.h"
|
|
|
|
|
|
-#if AZ_TRAIT_OS_PLATFORM_APPLE || defined(AZ_PLATFORM_LINUX)
|
|
|
-#include <clocale>
|
|
|
-#include <locale>
|
|
|
-
|
|
|
-class LocaleResetter
|
|
|
-{
|
|
|
-public:
|
|
|
- LocaleResetter()
|
|
|
- {
|
|
|
- m_oldLocale = std::setlocale(LC_NUMERIC, "C");
|
|
|
- }
|
|
|
- ~LocaleResetter()
|
|
|
- {
|
|
|
- std::setlocale(LC_NUMERIC, m_oldLocale);
|
|
|
- }
|
|
|
-
|
|
|
-private:
|
|
|
- char* m_oldLocale;
|
|
|
-};
|
|
|
-#define SCOPED_LOCALE_RESETTER LocaleResetter l
|
|
|
-#else
|
|
|
-// noop on Windows
|
|
|
-#define SCOPED_LOCALE_RESETTER
|
|
|
-#endif
|
|
|
-
|
|
|
// Global counter for memory allocated in XML string pools.
|
|
|
size_t CSimpleStringPool::g_nTotalAllocInXmlStringPools = 0;
|
|
|
|
|
@@ -296,7 +272,7 @@ void CXmlNode::setAttr(const char* key, unsigned int value)
|
|
|
void CXmlNode::setAttr(const char* key, float value)
|
|
|
{
|
|
|
char str[128];
|
|
|
- SCOPED_LOCALE_RESETTER;
|
|
|
+ AZ::Locale::ScopedSerializationLocale localeResetter;
|
|
|
sprintf_s(str, FLOAT_FMT, value);
|
|
|
setAttr(key, str);
|
|
|
}
|
|
@@ -304,7 +280,7 @@ void CXmlNode::setAttr(const char* key, float value)
|
|
|
void CXmlNode::setAttr(const char* key, double value)
|
|
|
{
|
|
|
char str[128];
|
|
|
- SCOPED_LOCALE_RESETTER;
|
|
|
+ AZ::Locale::ScopedSerializationLocale localeResetter;
|
|
|
sprintf_s(str, DOUBLE_FMT, value);
|
|
|
setAttr(key, str);
|
|
|
}
|
|
@@ -335,21 +311,21 @@ void CXmlNode::setAttr(const char* key, uint64 value, bool useHexFormat)
|
|
|
void CXmlNode::setAttr(const char* key, const Ang3& value)
|
|
|
{
|
|
|
char str[128];
|
|
|
- SCOPED_LOCALE_RESETTER;
|
|
|
+ AZ::Locale::ScopedSerializationLocale localeResetter;
|
|
|
sprintf_s(str, FLOAT_FMT "," FLOAT_FMT "," FLOAT_FMT, value.x, value.y, value.z);
|
|
|
setAttr(key, str);
|
|
|
}
|
|
|
void CXmlNode::setAttr(const char* key, const Vec3& value)
|
|
|
{
|
|
|
char str[128];
|
|
|
- SCOPED_LOCALE_RESETTER;
|
|
|
+ AZ::Locale::ScopedSerializationLocale localeResetter;
|
|
|
sprintf_s(str, FLOAT_FMT "," FLOAT_FMT "," FLOAT_FMT, value.x, value.y, value.z);
|
|
|
setAttr(key, str);
|
|
|
}
|
|
|
void CXmlNode::setAttr(const char* key, const Vec4& value)
|
|
|
{
|
|
|
char str[128];
|
|
|
- SCOPED_LOCALE_RESETTER;
|
|
|
+ AZ::Locale::ScopedSerializationLocale localeResetter;
|
|
|
sprintf_s(str, FLOAT_FMT "," FLOAT_FMT "," FLOAT_FMT "," FLOAT_FMT, value.x, value.y, value.z, value.w);
|
|
|
setAttr(key, str);
|
|
|
}
|
|
@@ -357,7 +333,7 @@ void CXmlNode::setAttr(const char* key, const Vec4& value)
|
|
|
void CXmlNode::setAttr(const char* key, const Vec2& value)
|
|
|
{
|
|
|
char str[128];
|
|
|
- SCOPED_LOCALE_RESETTER;
|
|
|
+ AZ::Locale::ScopedSerializationLocale localeResetter;
|
|
|
sprintf_s(str, FLOAT_FMT "," FLOAT_FMT, value.x, value.y);
|
|
|
setAttr(key, str);
|
|
|
}
|
|
@@ -365,7 +341,7 @@ void CXmlNode::setAttr(const char* key, const Vec2& value)
|
|
|
void CXmlNode::setAttr(const char* key, const Quat& value)
|
|
|
{
|
|
|
char str[128];
|
|
|
- SCOPED_LOCALE_RESETTER;
|
|
|
+ AZ::Locale::ScopedSerializationLocale localeResetter;
|
|
|
sprintf_s(str, FLOAT_FMT "," FLOAT_FMT "," FLOAT_FMT "," FLOAT_FMT, value.w, value.v.x, value.v.y, value.v.z);
|
|
|
setAttr(key, str);
|
|
|
}
|
|
@@ -444,6 +420,7 @@ bool CXmlNode::getAttr(const char* key, float& value) const
|
|
|
const char* svalue = GetValue(key);
|
|
|
if (svalue)
|
|
|
{
|
|
|
+ AZ::Locale::ScopedSerializationLocale localeResetter;
|
|
|
value = (float)atof(svalue);
|
|
|
return true;
|
|
|
}
|
|
@@ -455,6 +432,7 @@ bool CXmlNode::getAttr(const char* key, double& value) const
|
|
|
const char* svalue = GetValue(key);
|
|
|
if (svalue)
|
|
|
{
|
|
|
+ AZ::Locale::ScopedSerializationLocale localeResetter;
|
|
|
value = atof(svalue);
|
|
|
return true;
|
|
|
}
|
|
@@ -466,7 +444,7 @@ bool CXmlNode::getAttr(const char* key, Ang3& value) const
|
|
|
const char* svalue = GetValue(key);
|
|
|
if (svalue)
|
|
|
{
|
|
|
- SCOPED_LOCALE_RESETTER;
|
|
|
+ AZ::Locale::ScopedSerializationLocale localeResetter;
|
|
|
float x, y, z;
|
|
|
if (azsscanf(svalue, "%f,%f,%f", &x, &y, &z) == 3)
|
|
|
{
|
|
@@ -483,7 +461,7 @@ bool CXmlNode::getAttr(const char* key, Vec3& value) const
|
|
|
const char* svalue = GetValue(key);
|
|
|
if (svalue)
|
|
|
{
|
|
|
- SCOPED_LOCALE_RESETTER;
|
|
|
+ AZ::Locale::ScopedSerializationLocale localeResetter;
|
|
|
float x, y, z;
|
|
|
if (azsscanf(svalue, "%f,%f,%f", &x, &y, &z) == 3)
|
|
|
{
|
|
@@ -500,7 +478,7 @@ bool CXmlNode::getAttr(const char* key, Vec4& value) const
|
|
|
const char* svalue = GetValue(key);
|
|
|
if (svalue)
|
|
|
{
|
|
|
- SCOPED_LOCALE_RESETTER;
|
|
|
+ AZ::Locale::ScopedSerializationLocale localeResetter;
|
|
|
float x, y, z, w;
|
|
|
if (azsscanf(svalue, "%f,%f,%f,%f", &x, &y, &z, &w) == 4)
|
|
|
{
|
|
@@ -518,7 +496,7 @@ bool CXmlNode::getAttr(const char* key, Vec2& value) const
|
|
|
const char* svalue = GetValue(key);
|
|
|
if (svalue)
|
|
|
{
|
|
|
- SCOPED_LOCALE_RESETTER;
|
|
|
+ AZ::Locale::ScopedSerializationLocale localeResetter;
|
|
|
float x, y;
|
|
|
if (azsscanf(svalue, "%f,%f", &x, &y) == 2)
|
|
|
{
|
|
@@ -535,7 +513,7 @@ bool CXmlNode::getAttr(const char* key, Quat& value) const
|
|
|
const char* svalue = GetValue(key);
|
|
|
if (svalue)
|
|
|
{
|
|
|
- SCOPED_LOCALE_RESETTER;
|
|
|
+ AZ::Locale::ScopedSerializationLocale localeResetter;
|
|
|
float w, x, y, z;
|
|
|
if (azsscanf(svalue, "%f,%f,%f,%f", &w, &x, &y, &z) == 4)
|
|
|
{
|
|
@@ -557,6 +535,7 @@ bool CXmlNode::getAttr(const char* key, ColorB& value) const
|
|
|
const char* svalue = GetValue(key);
|
|
|
if (svalue)
|
|
|
{
|
|
|
+ AZ::Locale::ScopedSerializationLocale localeResetter;
|
|
|
unsigned int r, g, b, a = 255;
|
|
|
int numFound = azsscanf(svalue, "%u,%u,%u,%u", &r, &g, &b, &a);
|
|
|
if (numFound == 3 || numFound == 4)
|