Revised String class
Renamed String::Substr to SubString Former-commit-id: 6aa925799e71af6916f7808368a3faa26efbe1bc
This commit is contained in:
parent
c1e57c829c
commit
b0c46b2384
|
|
@ -29,7 +29,7 @@ class NAZARA_API NzByteArray : public NzHashable
|
|||
|
||||
NzByteArray& Append(nzUInt8 byte);
|
||||
NzByteArray& Append(const nzUInt8* buffer, unsigned int length);
|
||||
NzByteArray& Append(const NzByteArray& byteArray);
|
||||
NzByteArray& Append(const NzByteArray& array);
|
||||
|
||||
void Clear(bool keepBuffer = false);
|
||||
|
||||
|
|
@ -78,13 +78,13 @@ class NAZARA_API NzByteArray : public NzHashable
|
|||
nzUInt8& operator[](unsigned int pos);
|
||||
nzUInt8 operator[](unsigned int pos) const;
|
||||
|
||||
NzByteArray& operator=(const NzByteArray& byteArray);
|
||||
NzByteArray& operator=(NzByteArray&& byteArray) noexcept;
|
||||
NzByteArray& operator=(const NzByteArray& array);
|
||||
NzByteArray& operator=(NzByteArray&& array) noexcept;
|
||||
|
||||
NzByteArray operator+(nzUInt8 byte) const;
|
||||
NzByteArray operator+(const NzByteArray& byteArray) const;
|
||||
NzByteArray operator+(const NzByteArray& array) const;
|
||||
NzByteArray& operator+=(nzUInt8 byte);
|
||||
NzByteArray& operator+=(const NzByteArray& byteArray);
|
||||
NzByteArray& operator+=(const NzByteArray& array);
|
||||
|
||||
static int Compare(const NzByteArray& first, const NzByteArray& second);
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ bool NzResourceLoader<Type, Parameters>::LoadFromFile(Type* resource, const NzSt
|
|||
#endif
|
||||
|
||||
NzString path = NzFile::NormalizePath(filePath);
|
||||
NzString ext = path.SubstrFrom('.', -1, true);
|
||||
NzString ext = path.SubStringFrom('.', -1, true);
|
||||
if (ext.IsEmpty())
|
||||
{
|
||||
NazaraError("Failed to get file extension from \"" + filePath + '"');
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ class NAZARA_API NzString : public NzHashable
|
|||
NzString();
|
||||
explicit NzString(char character);
|
||||
NzString(const char* string);
|
||||
NzString(const char* string, unsigned int length);
|
||||
NzString(const std::string& string);
|
||||
NzString(const NzString& string);
|
||||
NzString(NzString&& string) noexcept;
|
||||
|
|
@ -59,6 +60,7 @@ class NAZARA_API NzString : public NzHashable
|
|||
|
||||
bool EndsWith(char character, nzUInt32 flags = None) const;
|
||||
bool EndsWith(const char* string, nzUInt32 flags = None) const;
|
||||
bool EndsWith(const char* string, unsigned int length, nzUInt32 flags = None) const;
|
||||
bool EndsWith(const NzString& string, nzUInt32 flags = None) const;
|
||||
|
||||
unsigned int Find(char character, int start = 0, nzUInt32 flags = None) const;
|
||||
|
|
@ -90,6 +92,7 @@ class NAZARA_API NzString : public NzHashable
|
|||
|
||||
NzString& Insert(int pos, char character);
|
||||
NzString& Insert(int pos, const char* string);
|
||||
NzString& Insert(int pos, const char* string, unsigned int length);
|
||||
NzString& Insert(int pos, const NzString& string);
|
||||
|
||||
bool IsEmpty() const;
|
||||
|
|
@ -101,10 +104,12 @@ class NAZARA_API NzString : public NzHashable
|
|||
|
||||
NzString& Prepend(char character);
|
||||
NzString& Prepend(const char* string);
|
||||
NzString& Prepend(const char* string, unsigned int length);
|
||||
NzString& Prepend(const NzString& string);
|
||||
|
||||
unsigned int Replace(char oldCharacter, char newCharacter, int start = 0, nzUInt32 flags = None);
|
||||
unsigned int Replace(const char* oldString, const char* replaceString, int start = 0, nzUInt32 flags = None);
|
||||
unsigned int Replace(const char* oldString, unsigned int oldLength, const char* replaceString, unsigned int replaceLength, int start = 0, nzUInt32 flags = None);
|
||||
unsigned int Replace(const NzString& oldString, const NzString& replaceString, int start = 0, nzUInt32 flags = None);
|
||||
unsigned int ReplaceAny(const char* oldCharacters, char replaceCharacter, int start = 0, nzUInt32 flags = None);
|
||||
//unsigned int ReplaceAny(const char* oldCharacters, const char* replaceString, int start = 0, nzUInt32 flags = None);
|
||||
|
|
@ -123,6 +128,7 @@ class NAZARA_API NzString : public NzHashable
|
|||
|
||||
unsigned int Split(std::vector<NzString>& result, char separation = ' ', int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int Split(std::vector<NzString>& result, const char* separation, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int Split(std::vector<NzString>& result, const char* separation, unsigned int length, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int Split(std::vector<NzString>& result, const NzString& separation, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int SplitAny(std::vector<NzString>& result, const char* separations, int start = 0, nzUInt32 flags = None) const;
|
||||
unsigned int SplitAny(std::vector<NzString>& result, const NzString& separations, int start = 0, nzUInt32 flags = None) const;
|
||||
|
|
@ -131,13 +137,15 @@ class NAZARA_API NzString : public NzHashable
|
|||
bool StartsWith(const char* string, nzUInt32 flags = None) const;
|
||||
bool StartsWith(const NzString& string, nzUInt32 flags = None) const;
|
||||
|
||||
NzString Substr(int startPos, int endPos = -1) const;
|
||||
NzString SubstrFrom(char character, int startPos = 0, bool fromLast = false, bool include = false, nzUInt32 flags = None) const;
|
||||
NzString SubstrFrom(const char *string, int startPos = 0, bool fromLast = false, bool include = false, nzUInt32 flags = None) const;
|
||||
NzString SubstrFrom(const NzString& string, int startPos = 0, bool fromLast = false, bool include = false, nzUInt32 flags = None) const;
|
||||
NzString SubstrTo(char character, int startPos = 0, bool toLast = false, bool include = false, nzUInt32 flags = None) const;
|
||||
NzString SubstrTo(const char *string, int startPos = 0, bool toLast = false, bool include = false, nzUInt32 flags = None) const;
|
||||
NzString SubstrTo(const NzString& string, int startPos = 0, bool toLast = false, bool include = false, nzUInt32 flags = None) const;
|
||||
NzString SubString(int startPos, int endPos = -1) const;
|
||||
NzString SubStringFrom(char character, int startPos = 0, bool fromLast = false, bool include = false, nzUInt32 flags = None) const;
|
||||
NzString SubStringFrom(const char *string, int startPos = 0, bool fromLast = false, bool include = false, nzUInt32 flags = None) const;
|
||||
NzString SubStringFrom(const char *string, unsigned int length, int startPos = 0, bool fromLast = false, bool include = false, nzUInt32 flags = None) const;
|
||||
NzString SubStringFrom(const NzString& string, int startPos = 0, bool fromLast = false, bool include = false, nzUInt32 flags = None) const;
|
||||
NzString SubStringTo(char character, int startPos = 0, bool toLast = false, bool include = false, nzUInt32 flags = None) const;
|
||||
NzString SubStringTo(const char *string, int startPos = 0, bool toLast = false, bool include = false, nzUInt32 flags = None) const;
|
||||
NzString SubStringTo(const char *string, unsigned int length, int startPos = 0, bool toLast = false, bool include = false, nzUInt32 flags = None) const;
|
||||
NzString SubStringTo(const NzString& string, int startPos = 0, bool toLast = false, bool include = false, nzUInt32 flags = None) const;
|
||||
|
||||
void Swap(NzString& str);
|
||||
|
||||
|
|
|
|||
|
|
@ -262,9 +262,9 @@ bool NzDirectory::Create(const NzString& dirPath, bool recursive)
|
|||
|
||||
do
|
||||
{
|
||||
NzString p = path.Substr(0, foundPos);
|
||||
NzString p = path.SubString(0, foundPos);
|
||||
if (p.EndsWith(NAZARA_DIRECTORY_SEPARATOR))
|
||||
p = p.Substr(0, -2);
|
||||
p = p.SubString(0, -2);
|
||||
|
||||
if (!NzDirectoryImpl::Exists(p) && !NzDirectoryImpl::Create(p))
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -162,14 +162,14 @@ NzString NzFile::GetDirectory() const
|
|||
{
|
||||
NazaraLock(m_mutex)
|
||||
|
||||
return m_filePath.SubstrTo(NAZARA_DIRECTORY_SEPARATOR, -1, true, true);
|
||||
return m_filePath.SubStringTo(NAZARA_DIRECTORY_SEPARATOR, -1, true, true);
|
||||
}
|
||||
|
||||
NzString NzFile::GetFileName() const
|
||||
{
|
||||
NazaraLock(m_mutex)
|
||||
|
||||
return m_filePath.SubstrFrom(NAZARA_DIRECTORY_SEPARATOR, -1, true);
|
||||
return m_filePath.SubStringFrom(NAZARA_DIRECTORY_SEPARATOR, -1, true);
|
||||
}
|
||||
|
||||
time_t NzFile::GetLastAccessTime() const
|
||||
|
|
@ -501,8 +501,8 @@ NzString NzFile::AbsolutePath(const NzString& filePath)
|
|||
}
|
||||
else if (path.StartsWith('\\')) // Spécial : '\' fait référence au disque racine
|
||||
{
|
||||
NzString drive = NzDirectory::GetCurrent().SubstrTo('\\');
|
||||
NzString end = path.Substr(1, -1);
|
||||
NzString drive = NzDirectory::GetCurrent().SubStringTo('\\');
|
||||
NzString end = path.SubString(1, -1);
|
||||
if (end.IsEmpty())
|
||||
path = drive;
|
||||
else
|
||||
|
|
@ -604,7 +604,7 @@ time_t NzFile::GetCreationTime(const NzString& filePath)
|
|||
|
||||
NzString NzFile::GetDirectory(const NzString& filePath)
|
||||
{
|
||||
return filePath.SubstrTo(NAZARA_DIRECTORY_SEPARATOR, -1, true, true);
|
||||
return filePath.SubStringTo(NAZARA_DIRECTORY_SEPARATOR, -1, true, true);
|
||||
}
|
||||
|
||||
time_t NzFile::GetLastAccessTime(const NzString& filePath)
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -151,7 +151,7 @@ bool NzMTLParser::Parse()
|
|||
}
|
||||
else if (keyword == "map_ka")
|
||||
{
|
||||
NzString map = m_currentLine.Substr(m_currentLine.GetWordPosition(1));
|
||||
NzString map = m_currentLine.SubString(m_currentLine.GetWordPosition(1));
|
||||
if (!map.IsEmpty())
|
||||
{
|
||||
if (!currentMaterial)
|
||||
|
|
@ -166,7 +166,7 @@ bool NzMTLParser::Parse()
|
|||
}
|
||||
else if (keyword == "map_kd")
|
||||
{
|
||||
NzString map = m_currentLine.Substr(m_currentLine.GetWordPosition(1));
|
||||
NzString map = m_currentLine.SubString(m_currentLine.GetWordPosition(1));
|
||||
if (!map.IsEmpty())
|
||||
{
|
||||
if (!currentMaterial)
|
||||
|
|
@ -181,7 +181,7 @@ bool NzMTLParser::Parse()
|
|||
}
|
||||
else if (keyword == "map_ks")
|
||||
{
|
||||
NzString map = m_currentLine.Substr(m_currentLine.GetWordPosition(1));
|
||||
NzString map = m_currentLine.SubString(m_currentLine.GetWordPosition(1));
|
||||
if (!map.IsEmpty())
|
||||
{
|
||||
if (!currentMaterial)
|
||||
|
|
@ -196,7 +196,7 @@ bool NzMTLParser::Parse()
|
|||
}
|
||||
else if (keyword == "map_bump" || keyword == "bump")
|
||||
{
|
||||
NzString map = m_currentLine.Substr(m_currentLine.GetWordPosition(1));
|
||||
NzString map = m_currentLine.SubString(m_currentLine.GetWordPosition(1));
|
||||
if (!map.IsEmpty())
|
||||
{
|
||||
if (!currentMaterial)
|
||||
|
|
@ -211,7 +211,7 @@ bool NzMTLParser::Parse()
|
|||
}
|
||||
else if (keyword == "map_d")
|
||||
{
|
||||
NzString map = m_currentLine.Substr(m_currentLine.GetWordPosition(1));
|
||||
NzString map = m_currentLine.SubString(m_currentLine.GetWordPosition(1));
|
||||
if (!map.IsEmpty())
|
||||
{
|
||||
if (!currentMaterial)
|
||||
|
|
@ -226,7 +226,7 @@ bool NzMTLParser::Parse()
|
|||
}
|
||||
else if (keyword == "map_decal" || keyword == "decal")
|
||||
{
|
||||
NzString map = m_currentLine.Substr(m_currentLine.GetWordPosition(1));
|
||||
NzString map = m_currentLine.SubString(m_currentLine.GetWordPosition(1));
|
||||
if (!map.IsEmpty())
|
||||
{
|
||||
if (!currentMaterial)
|
||||
|
|
@ -241,7 +241,7 @@ bool NzMTLParser::Parse()
|
|||
}
|
||||
else if (keyword == "map_disp" || keyword == "disp")
|
||||
{
|
||||
NzString map = m_currentLine.Substr(m_currentLine.GetWordPosition(1));
|
||||
NzString map = m_currentLine.SubString(m_currentLine.GetWordPosition(1));
|
||||
if (!map.IsEmpty())
|
||||
{
|
||||
if (!currentMaterial)
|
||||
|
|
@ -256,7 +256,7 @@ bool NzMTLParser::Parse()
|
|||
}
|
||||
else if (keyword == "map_refl" || keyword == "refl")
|
||||
{
|
||||
NzString map = m_currentLine.Substr(m_currentLine.GetWordPosition(1));
|
||||
NzString map = m_currentLine.SubString(m_currentLine.GetWordPosition(1));
|
||||
if (!map.IsEmpty())
|
||||
{
|
||||
if (!currentMaterial)
|
||||
|
|
@ -271,7 +271,7 @@ bool NzMTLParser::Parse()
|
|||
}
|
||||
else if (keyword == "newmtl")
|
||||
{
|
||||
NzString materialName = m_currentLine.Substr(m_currentLine.GetWordPosition(1));
|
||||
NzString materialName = m_currentLine.SubString(m_currentLine.GetWordPosition(1));
|
||||
if (!materialName.IsEmpty())
|
||||
currentMaterial = &m_materials[materialName];
|
||||
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
|
||||
|
|
@ -305,7 +305,7 @@ bool NzMTLParser::Advance(bool required)
|
|||
m_lineCount++;
|
||||
|
||||
m_currentLine = m_stream.ReadLine();
|
||||
m_currentLine = m_currentLine.SubstrTo("#"); // On ignore les commentaires
|
||||
m_currentLine = m_currentLine.SubStringTo("#"); // On ignore les commentaires
|
||||
m_currentLine.Simplify(); // Pour un traitement plus simple
|
||||
}
|
||||
while (m_currentLine.IsEmpty());
|
||||
|
|
|
|||
|
|
@ -237,7 +237,7 @@ bool NzOBJParser::Parse()
|
|||
UnrecognizedLine();
|
||||
#endif
|
||||
|
||||
m_mtlLib = m_currentLine.Substr(m_currentLine.GetWordPosition(1));
|
||||
m_mtlLib = m_currentLine.SubString(m_currentLine.GetWordPosition(1));
|
||||
break;
|
||||
|
||||
case 'g':
|
||||
|
|
@ -251,7 +251,7 @@ bool NzOBJParser::Parse()
|
|||
break;
|
||||
}
|
||||
|
||||
NzString objectName = m_currentLine.Substr(m_currentLine.GetWordPosition(1));
|
||||
NzString objectName = m_currentLine.SubString(m_currentLine.GetWordPosition(1));
|
||||
if (objectName.IsEmpty())
|
||||
{
|
||||
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
|
||||
|
|
@ -269,7 +269,7 @@ bool NzOBJParser::Parse()
|
|||
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
|
||||
if (m_currentLine[1] == ' ')
|
||||
{
|
||||
NzString param = m_currentLine.Substr(2);
|
||||
NzString param = m_currentLine.SubString(2);
|
||||
if (param != "all" && param != "on" && param != "off" && !param.IsNumber())
|
||||
UnrecognizedLine();
|
||||
}
|
||||
|
|
@ -284,7 +284,7 @@ bool NzOBJParser::Parse()
|
|||
UnrecognizedLine();
|
||||
#endif
|
||||
|
||||
matName = m_currentLine.Substr(m_currentLine.GetWordPosition(1));
|
||||
matName = m_currentLine.SubString(m_currentLine.GetWordPosition(1));
|
||||
if (matName.IsEmpty())
|
||||
{
|
||||
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
|
||||
|
|
@ -405,7 +405,7 @@ bool NzOBJParser::Advance(bool required)
|
|||
m_lineCount++;
|
||||
|
||||
m_currentLine = m_stream.ReadLine();
|
||||
m_currentLine = m_currentLine.SubstrTo("#"); // On ignore les commentaires
|
||||
m_currentLine = m_currentLine.SubStringTo("#"); // On ignore les commentaires
|
||||
m_currentLine.Simplify(); // Pour un traitement plus simple
|
||||
}
|
||||
while (m_currentLine.IsEmpty());
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ bool NzMD5AnimParser::Parse(NzAnimation* animation)
|
|||
sequence.firstFrame = 0;
|
||||
sequence.frameCount = m_frames.size();
|
||||
sequence.frameRate = m_frameRate;
|
||||
sequence.name = m_stream.GetPath().SubstrFrom(NAZARA_DIRECTORY_SEPARATOR, -1, true);
|
||||
sequence.name = m_stream.GetPath().SubStringFrom(NAZARA_DIRECTORY_SEPARATOR, -1, true);
|
||||
if (!animation->AddSequence(sequence))
|
||||
NazaraWarning("Failed to add sequence");
|
||||
|
||||
|
|
@ -265,7 +265,7 @@ bool NzMD5AnimParser::Advance(bool required)
|
|||
m_lineCount++;
|
||||
|
||||
m_currentLine = m_stream.ReadLine();
|
||||
m_currentLine = m_currentLine.SubstrTo("//"); // On ignore les commentaires
|
||||
m_currentLine = m_currentLine.SubStringTo("//"); // On ignore les commentaires
|
||||
m_currentLine.Simplify(); // Pour un traitement plus simple
|
||||
}
|
||||
while (m_currentLine.IsEmpty());
|
||||
|
|
|
|||
|
|
@ -390,7 +390,7 @@ bool NzMD5MeshParser::Advance(bool required)
|
|||
m_lineCount++;
|
||||
|
||||
m_currentLine = m_stream.ReadLine();
|
||||
m_currentLine = m_currentLine.SubstrTo("//"); // On ignore les commentaires
|
||||
m_currentLine = m_currentLine.SubStringTo("//"); // On ignore les commentaires
|
||||
m_currentLine.Simplify(); // Pour un traitement plus simple
|
||||
}
|
||||
while (m_currentLine.IsEmpty());
|
||||
|
|
@ -494,7 +494,7 @@ bool NzMD5MeshParser::ParseMesh()
|
|||
}
|
||||
#endif
|
||||
|
||||
m_meshes[m_meshIndex].shader = m_currentLine.Substr(7);
|
||||
m_meshes[m_meshIndex].shader = m_currentLine.SubString(7);
|
||||
m_meshes[m_meshIndex].shader.Trim('"');
|
||||
break;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue