More string fixes

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
Esteban Papp
2021-07-29 15:53:32 -07:00
parent 95c6fd83ea
commit 99bf5e54c4
43 changed files with 439 additions and 432 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ public:
ELSE_LOAD_PROPERTY(Vec3); \
ELSE_LOAD_PROPERTY(int); \
ELSE_LOAD_PROPERTY(float); \
ELSE_LOAD_PROPERTY(string); \
ELSE_LOAD_PROPERTY(AZStd::string); \
ELSE_LOAD_PROPERTY(bool);
+5 -4
View File
@@ -13,7 +13,7 @@
#include <ISystem.h>
#include <stack>
typedef std::map<string, XmlNodeRef> IdTable;
typedef std::map<AZStd::string, XmlNodeRef> IdTable;
struct SParseParams
{
IdTable idTable;
@@ -98,7 +98,7 @@ struct ReadPropertyTyped
};
template <>
struct ReadPropertyTyped<string>
struct ReadPropertyTyped<AZStd::string>
{
static bool Load(const SParseParams& parseParams, const char* name, XmlNodeRef& definition, XmlNodeRef& data, IReadXMLSink* pSink)
{
@@ -235,8 +235,9 @@ bool LoadProperty(const SParseParams& parseParams, XmlNodeRef& definition, XmlNo
dataToRead = GetISystem()->CreateXmlNode(data->getTag());
string content = childRef->getContent();
dataToRead->setAttr(name, content.Trim().c_str());
AZStd::string content = childRef->getContent();
AZ::StringFunc::TrimWhiteSpace(content, true, true);
dataToRead->setAttr(name, content.c_str());
}
if (!dataToRead->haveAttr(name))
@@ -114,7 +114,7 @@ void CSerializeXMLWriterImpl::GetMemoryUsage(ICrySizer* pSizer) const
//////////////////////////////////////////////////////////////////////////
const char* CSerializeXMLWriterImpl::GetStackInfo() const
{
static string str;
static AZStd::string str;
str.assign("");
for (int i = 0; i < (int)m_nodeStack.size(); i++)
{
@@ -138,7 +138,7 @@ const char* CSerializeXMLWriterImpl::GetStackInfo() const
//////////////////////////////////////////////////////////////////////////
const char* CSerializeXMLWriterImpl::GetLuaStackInfo() const
{
static string str;
static AZStd::string str;
str.assign("");
for (int i = 0; i < (int)m_luaSaveStack.size(); i++)
{
@@ -138,7 +138,7 @@ private:
bool IsDefaultValue(const Quat& v) const { return v.w == 1.0f && v.v.x == 0 && v.v.y == 0 && v.v.z == 0; };
bool IsDefaultValue(const CTimeValue& v) const { return v.GetValue() == 0; };
bool IsDefaultValue(const char* str) const { return !str || !*str; };
bool IsDefaultValue(const string& str) const { return str.empty(); };
bool IsDefaultValue(const AZStd::string& str) const { return str.empty(); };
bool IsDefaultValue(const SSerializeString& str) const { return str.empty(); };
//////////////////////////////////////////////////////////////////////////
+2 -2
View File
@@ -12,7 +12,7 @@
#include <stack>
typedef std::map<string, XmlNodeRef> IdTable;
typedef std::map<AZStd::string, XmlNodeRef> IdTable;
static bool IsOptionalWriteXML(XmlNodeRef& definition);
@@ -66,7 +66,7 @@ struct WritePropertyTyped
};
template <>
struct WritePropertyTyped<string>
struct WritePropertyTyped<AZStd::string>
: public WritePropertyTyped<const char*>
{
};
+6 -6
View File
@@ -25,25 +25,25 @@ namespace XMLBinary
{
public:
CXMLBinaryWriter();
bool WriteNode(IDataWriter* pFile, XmlNodeRef node, bool bNeedSwapEndian, XMLBinary::IFilter* pFilter, string& error);
bool WriteNode(IDataWriter* pFile, XmlNodeRef node, bool bNeedSwapEndian, XMLBinary::IFilter* pFilter, AZStd::string & error);
private:
bool CompileTables(XmlNodeRef node, XMLBinary::IFilter* pFilter, string& error);
bool CompileTables(XmlNodeRef node, XMLBinary::IFilter* pFilter, AZStd::string& error);
bool CompileTablesForNode(XmlNodeRef node, int nParentIndex, XMLBinary::IFilter* pFilter, string& error);
bool CompileChildTable(XmlNodeRef node, XMLBinary::IFilter* pFilter, string& error);
bool CompileTablesForNode(XmlNodeRef node, int nParentIndex, XMLBinary::IFilter* pFilter, AZStd::string& error);
bool CompileChildTable(XmlNodeRef node, XMLBinary::IFilter* pFilter, AZStd::string& error);
int AddString(const XmlString& sString);
private:
// tables.
typedef std::map<IXmlNode*, int> NodesMap;
typedef std::map<string, uint> StringMap;
typedef std::map<AZStd::string, uint> StringMap;
std::vector<Node> m_nodes;
NodesMap m_nodesMap;
std::vector<Attribute> m_attributes;
std::vector<NodeIndex> m_childs;
std::vector<string> m_strings;
std::vector<AZStd::string> m_strings;
StringMap m_stringMap;
uint m_nStringDataSize;
+8 -9
View File
@@ -9,7 +9,6 @@
#include "CrySystem_precompiled.h"
#include "XMLPatcher.h"
#include "StringUtils.h"
CXMLPatcher::CXMLPatcher(XmlNodeRef& patchXML)
{
@@ -84,7 +83,7 @@ XmlNodeRef CXMLPatcher::FindPatchForFile(
{
const char* pForFile = child->getAttr("forfile");
if (pForFile && CryStringUtils::stristr(pForFile, pInFileToPatch) != 0)
if (pForFile && AZ::StringFunc::Find(pForFile, pInFileToPatch) != AZStd::string::npos)
{
result = child;
break;
@@ -353,7 +352,7 @@ void CXMLPatcher::DumpXMLNodes(
INDENT();
ioTempString->Format("<%s ", inNode->getTag());
*ioTempString = AZStd::fixed_string<512>::format("<%s ", inNode->getTag());
pPak->FWrite(ioTempString->c_str(), ioTempString->length(), inFileHandle);
@@ -361,7 +360,7 @@ void CXMLPatcher::DumpXMLNodes(
{
const char* pKey, * pVal;
inNode->getAttributeByIndex(i, &pKey, &pVal);
ioTempString->Format("%s=\"%s\" ", pKey, pVal);
*ioTempString = AZStd::fixed_string<512>::format("%s=\"%s\" ", pKey, pVal);
pPak->FWrite(ioTempString->c_str(), ioTempString->length(), inFileHandle);
}
pPak->FWrite(">\n", 2, inFileHandle);
@@ -372,7 +371,7 @@ void CXMLPatcher::DumpXMLNodes(
}
INDENT();
ioTempString->Format("</%s>\n", inNode->getTag());
*ioTempString = AZStd::fixed_string<512>::format("</%s>\n", inNode->getTag());
pPak->FWrite(ioTempString->c_str(), ioTempString->length(), inFileHandle);
}
@@ -391,12 +390,12 @@ void CXMLPatcher::DumpFiles(
{
pOrigFileName++;
DumpXMLFile(string().Format("PATCH_%s", pOrigFileName), inBefore);
DumpXMLFile(AZStd::string::format("PATCH_%s", pOrigFileName).c_str(), inBefore);
AZStd::fixed_string<128> newFileName(pOrigFileName);
newFileName.replace(".xml", "_patched.xml");
AZStd::string newFileName(pOrigFileName);
AZ::StringFunc::Replace(newFileName, ".xml", "_patched.xml");
DumpXMLFile(string().Format("PATCH_%s", newFileName.c_str()), inAfter);
DumpXMLFile(AZStd::string::format("PATCH_%s", newFileName.c_str()).c_str(), inAfter);
}
else
{
+1 -1
View File
@@ -313,7 +313,7 @@ bool CXmlUtils::SaveBinaryXmlFile(const char* filename, XmlNodeRef root)
return false;
}
XMLBinary::CXMLBinaryWriter writer;
string error;
AZStd::string error;
return writer.WriteNode(&fileSink, root, false, 0, error);
}
+9 -9
View File
@@ -984,13 +984,13 @@ XmlString CXmlNode::MakeValidXmlString(const XmlString& instr) const
XmlString str = instr;
// check if str contains any invalid characters
str.replace("&", "&amp;");
str.replace("\"", "&quot;");
str.replace("\'", "&apos;");
str.replace("<", "&lt;");
str.replace(">", "&gt;");
str.replace("...", "&gt;");
str.replace("\n", "&#10;");
AZ::StringFunc::Replace(str, "&", "&amp;");
AZ::StringFunc::Replace(str, "\"", "&quot;");
AZ::StringFunc::Replace(str, "\'", "&apos;");
AZ::StringFunc::Replace(str, "<", "&lt;");
AZ::StringFunc::Replace(str, ">", "&gt;");
AZ::StringFunc::Replace(str, "...", "&gt;");
AZ::StringFunc::Replace(str, "\n", "&#10;");
return str;
}
@@ -1732,9 +1732,9 @@ XmlNodeRef XmlParserImp::ParseFile(const char* filename, XmlString& errorString,
return 0;
}
adjustedFilename = xmlFile.GetAdjustedFilename();
adjustedFilename.replace('\\', '/');
AZStd::replace(adjustedFilename.begin(), adjustedFilename.end(), '\\', '/');
pakPath = xmlFile.GetPakPath();
pakPath.replace('\\', '/');
AZStd::replace(pakPath.begin(), pakPath.end(), '\\', '/');
}
if (g_bEnableBinaryXmlLoading)