Remove Nz::String and Nz::StringStream
This commit is contained in:
@@ -99,7 +99,7 @@ namespace Nz
|
||||
|
||||
if (byteStream.Read(ptr, byteCount) != byteCount)
|
||||
{
|
||||
NazaraError("Failed to read level #" + String::Number(i));
|
||||
NazaraError("Failed to read level #" + NumberToString(i));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -245,7 +245,7 @@ namespace Nz
|
||||
buf[3] = (header.format.fourCC >> 24) & 255;
|
||||
buf[4] = '\0';
|
||||
|
||||
NazaraError("Unhandled format \"" + String(buf) + "\"");
|
||||
NazaraError("Unhandled format \"" + std::string(buf) + "\"");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <Nazara/Utility/FontGlyph.hpp>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
@@ -243,12 +244,12 @@ namespace Nz
|
||||
return true;
|
||||
}
|
||||
|
||||
String GetFamilyName() const override
|
||||
std::string GetFamilyName() const override
|
||||
{
|
||||
return m_face->family_name;
|
||||
}
|
||||
|
||||
String GetStyleName() const override
|
||||
std::string GetStyleName() const override
|
||||
{
|
||||
return m_face->style_name;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <Nazara/Utility/Formats/MD5AnimParser.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/StringExt.hpp>
|
||||
#include <Nazara/Utility/Config.hpp>
|
||||
#include <cstdio>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
@@ -81,13 +82,13 @@ namespace Nz
|
||||
{
|
||||
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
|
||||
case 'M': // MD5Version
|
||||
if (m_currentLine.GetWord(0) != "MD5Version")
|
||||
if (GetWord(m_currentLine, 0) != "MD5Version")
|
||||
UnrecognizedLine();
|
||||
break;
|
||||
#endif
|
||||
|
||||
case 'b': // baseframe/bounds
|
||||
if (m_currentLine.StartsWith("baseframe {"))
|
||||
if (StartsWith(m_currentLine, "baseframe {"))
|
||||
{
|
||||
if (!ParseBaseframe())
|
||||
{
|
||||
@@ -95,7 +96,7 @@ namespace Nz
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (m_currentLine.StartsWith("bounds {"))
|
||||
else if (StartsWith(m_currentLine, "bounds {"))
|
||||
{
|
||||
if (!ParseBounds())
|
||||
{
|
||||
@@ -111,7 +112,7 @@ namespace Nz
|
||||
|
||||
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
|
||||
case 'c': // commandline
|
||||
if (m_currentLine.GetWord(0) != "commandline")
|
||||
if (GetWord(m_currentLine, 0) != "commandline")
|
||||
UnrecognizedLine();
|
||||
break;
|
||||
#endif
|
||||
@@ -123,7 +124,7 @@ namespace Nz
|
||||
{
|
||||
if (m_frameIndex != index)
|
||||
{
|
||||
Error("Unexpected frame index (expected " + String::Number(m_frameIndex) + ", got " + String::Number(index) + ')');
|
||||
Error("Unexpected frame index (expected " + NumberToString(m_frameIndex) + ", got " + NumberToString(index) + ')');
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -145,7 +146,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
case 'h': // hierarchy
|
||||
if (m_currentLine.StartsWith("hierarchy {"))
|
||||
if (StartsWith(m_currentLine, "hierarchy {"))
|
||||
{
|
||||
if (!ParseHierarchy())
|
||||
{
|
||||
@@ -220,7 +221,7 @@ namespace Nz
|
||||
|
||||
if (m_frameIndex != frameCount)
|
||||
{
|
||||
NazaraError("Missing frame infos: [" + String::Number(m_frameIndex) + ',' + String::Number(frameCount) + ']');
|
||||
NazaraError("Missing frame infos: [" + NumberToString(m_frameIndex) + ',' + NumberToString(frameCount) + ']');
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -250,13 +251,10 @@ namespace Nz
|
||||
m_lineCount++;
|
||||
|
||||
m_currentLine = m_stream.ReadLine();
|
||||
if (m_currentLine.IsEmpty())
|
||||
continue;
|
||||
|
||||
m_currentLine = m_currentLine.SubStringTo("//"); // On ignore les commentaires
|
||||
m_currentLine.Simplify(); // Pour un traitement plus simple
|
||||
if (std::size_t pos = m_currentLine.find("//"); pos != std::string::npos)
|
||||
m_currentLine.resize(pos);
|
||||
}
|
||||
while (m_currentLine.IsEmpty());
|
||||
while (m_currentLine.empty());
|
||||
}
|
||||
else
|
||||
m_keepLastLine = false;
|
||||
@@ -264,9 +262,9 @@ namespace Nz
|
||||
return true;
|
||||
}
|
||||
|
||||
void MD5AnimParser::Error(const String& message)
|
||||
void MD5AnimParser::Error(const std::string& message)
|
||||
{
|
||||
NazaraError(message + " at line #" + String::Number(m_lineCount));
|
||||
NazaraError(message + " at line #" + NumberToString(m_lineCount));
|
||||
}
|
||||
|
||||
bool MD5AnimParser::ParseBaseframe()
|
||||
@@ -295,7 +293,7 @@ namespace Nz
|
||||
if (!Advance())
|
||||
return false;
|
||||
|
||||
if (m_currentLine != '}')
|
||||
if (m_currentLine != "}")
|
||||
{
|
||||
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
|
||||
Warning("Bounds braces closing not found");
|
||||
@@ -336,7 +334,7 @@ namespace Nz
|
||||
if (!Advance())
|
||||
return false;
|
||||
|
||||
if (m_currentLine != '}')
|
||||
if (m_currentLine != "}")
|
||||
{
|
||||
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
|
||||
Warning("Bounds braces closing not found");
|
||||
@@ -365,7 +363,7 @@ namespace Nz
|
||||
return false;
|
||||
}
|
||||
|
||||
String line;
|
||||
std::string line;
|
||||
|
||||
std::size_t count = 0;
|
||||
do
|
||||
@@ -374,7 +372,7 @@ namespace Nz
|
||||
return false;
|
||||
|
||||
std::size_t index = 0;
|
||||
std::size_t size = m_currentLine.GetSize();
|
||||
std::size_t size = m_currentLine.size();
|
||||
do
|
||||
{
|
||||
float f;
|
||||
@@ -430,7 +428,7 @@ namespace Nz
|
||||
if (!Advance(false))
|
||||
return true;
|
||||
|
||||
if (m_currentLine != '}')
|
||||
if (m_currentLine != "}")
|
||||
{
|
||||
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
|
||||
Warning("Hierarchy braces closing not found");
|
||||
@@ -457,8 +455,8 @@ namespace Nz
|
||||
if (!Advance())
|
||||
return false;
|
||||
|
||||
std::size_t pos = m_currentLine.Find(' ');
|
||||
if (pos == String::npos)
|
||||
std::size_t pos = m_currentLine.find(' ');
|
||||
if (pos == std::string::npos)
|
||||
{
|
||||
UnrecognizedLine(true);
|
||||
return false;
|
||||
@@ -477,15 +475,14 @@ namespace Nz
|
||||
return false;
|
||||
}
|
||||
|
||||
m_joints[i].name = name;
|
||||
m_joints[i].name.Trim('"');
|
||||
m_joints[i].name = Trim(name, '"');
|
||||
|
||||
Int32 parent = m_joints[i].parent;
|
||||
if (parent >= 0)
|
||||
{
|
||||
if (static_cast<UInt32>(parent) >= jointCount)
|
||||
{
|
||||
Error("Joint's parent is out of bounds (" + String::Number(parent) + " >= " + String::Number(jointCount) + ')');
|
||||
Error("Joint's parent is out of bounds (" + NumberToString(parent) + " >= " + NumberToString(jointCount) + ')');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -494,7 +491,7 @@ namespace Nz
|
||||
if (!Advance())
|
||||
return false;
|
||||
|
||||
if (m_currentLine != '}')
|
||||
if (m_currentLine != "}")
|
||||
{
|
||||
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
|
||||
Warning("Hierarchy braces closing not found");
|
||||
@@ -507,14 +504,14 @@ namespace Nz
|
||||
return true;
|
||||
}
|
||||
|
||||
void MD5AnimParser::Warning(const String& message)
|
||||
void MD5AnimParser::Warning(const std::string& message)
|
||||
{
|
||||
NazaraWarning(message + " at line #" + String::Number(m_lineCount));
|
||||
NazaraWarning(message + " at line #" + NumberToString(m_lineCount));
|
||||
}
|
||||
|
||||
void MD5AnimParser::UnrecognizedLine(bool error)
|
||||
{
|
||||
String message = "Unrecognized \"" + m_currentLine + '"';
|
||||
std::string message = "Unrecognized \"" + m_currentLine + '"';
|
||||
|
||||
if (error)
|
||||
Error(message);
|
||||
|
||||
@@ -229,7 +229,7 @@ namespace Nz
|
||||
return false;
|
||||
|
||||
std::size_t pos = m_currentLine.find(' ');
|
||||
if (pos == String::npos)
|
||||
if (pos == std::string::npos)
|
||||
{
|
||||
UnrecognizedLine(true);
|
||||
return false;
|
||||
@@ -250,8 +250,7 @@ namespace Nz
|
||||
return false;
|
||||
}
|
||||
|
||||
m_joints[i].name = name;
|
||||
m_joints[i].name.Trim('"');
|
||||
m_joints[i].name = Trim(name, '"');
|
||||
|
||||
Int32 parent = m_joints[i].parent;
|
||||
if (parent >= 0)
|
||||
|
||||
@@ -499,7 +499,7 @@ namespace Nz
|
||||
});
|
||||
}
|
||||
|
||||
m_outputStream.Clear();
|
||||
m_outputStream.str({});
|
||||
|
||||
EmitLine("# Exported by Nazara Engine");
|
||||
EmitLine();
|
||||
@@ -510,7 +510,7 @@ namespace Nz
|
||||
|
||||
for (auto& pair : m_materials)
|
||||
{
|
||||
const String& matName = pair.first;
|
||||
const std::string& matName = pair.first;
|
||||
const Material& mat = pair.second;
|
||||
|
||||
Emit("newmtl ");
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace Nz
|
||||
return false;
|
||||
}
|
||||
|
||||
std::unordered_map<String, ParameterList> materialCache;
|
||||
std::unordered_map<std::string, ParameterList> materialCache;
|
||||
std::filesystem::path baseDir = file.GetDirectory();
|
||||
for (std::size_t i = 0; i < meshCount; ++i)
|
||||
{
|
||||
|
||||
@@ -503,7 +503,7 @@ namespace Nz
|
||||
});
|
||||
}
|
||||
|
||||
m_outputStream.Clear();
|
||||
m_outputStream.str({});
|
||||
|
||||
EmitLine("# Exported by Nazara Engine");
|
||||
EmitLine();
|
||||
|
||||
@@ -101,11 +101,8 @@ namespace Nz
|
||||
{
|
||||
const ParameterList& matData = mesh.GetMaterialData(i);
|
||||
|
||||
String nzname;
|
||||
std::string name;
|
||||
if (matData.GetStringParameter(MaterialData::Name, &nzname))
|
||||
name = nzname.ToStdString();
|
||||
else
|
||||
if (!matData.GetStringParameter(MaterialData::Name, &name))
|
||||
name = "material_" + std::to_string(i);
|
||||
|
||||
// Makes sure we only have one material of that name
|
||||
@@ -117,10 +114,7 @@ namespace Nz
|
||||
|
||||
MTLParser::Material* material = mtlFormat.AddMaterial(name);
|
||||
|
||||
String strVal;
|
||||
if (matData.GetStringParameter(MaterialData::FilePath, &strVal))
|
||||
material->diffuseMap = strVal.ToStdString();
|
||||
else
|
||||
if (!matData.GetStringParameter(MaterialData::FilePath, &material->diffuseMap))
|
||||
{
|
||||
Color colorVal;
|
||||
double dValue;
|
||||
@@ -137,14 +131,9 @@ namespace Nz
|
||||
if (matData.GetDoubleParameter(MaterialData::Shininess, &dValue))
|
||||
material->shininess = float(dValue);
|
||||
|
||||
if (matData.GetStringParameter(MaterialData::AlphaTexturePath, &strVal))
|
||||
material->alphaMap = strVal.ToStdString();
|
||||
|
||||
if (matData.GetStringParameter(MaterialData::DiffuseTexturePath, &strVal))
|
||||
material->diffuseMap = strVal.ToStdString();
|
||||
|
||||
if (matData.GetStringParameter(MaterialData::SpecularTexturePath, &strVal))
|
||||
material->specularMap = strVal.ToStdString();
|
||||
matData.GetStringParameter(MaterialData::AlphaTexturePath, &material->alphaMap);
|
||||
matData.GetStringParameter(MaterialData::DiffuseTexturePath, &material->diffuseMap);
|
||||
matData.GetStringParameter(MaterialData::SpecularTexturePath, &material->specularMap);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace Nz
|
||||
{
|
||||
if (!stream.Read(&rle_value, 1))
|
||||
{
|
||||
NazaraError("Failed to read stream (byte " + String::Number(stream.GetCursorPos()) + ')');
|
||||
NazaraError("Failed to read stream (byte " + NumberToString(stream.GetCursorPos()) + ')');
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace Nz
|
||||
rle_count = rle_value - 0xc0;
|
||||
if (!stream.Read(&rle_value, 1))
|
||||
{
|
||||
NazaraError("Failed to read stream (byte " + String::Number(stream.GetCursorPos()) + ')');
|
||||
NazaraError("Failed to read stream (byte " + NumberToString(stream.GetCursorPos()) + ')');
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
@@ -174,7 +174,7 @@ namespace Nz
|
||||
{
|
||||
if (!stream.Read(&rle_value, 1))
|
||||
{
|
||||
NazaraError("Failed to read stream (byte " + String::Number(stream.GetCursorPos()) + ')');
|
||||
NazaraError("Failed to read stream (byte " + NumberToString(stream.GetCursorPos()) + ')');
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ namespace Nz
|
||||
rle_count = rle_value - 0xc0;
|
||||
if (!stream.Read(&rle_value, 1))
|
||||
{
|
||||
NazaraError("Failed to read stream (byte " + String::Number(stream.GetCursorPos()) + ')');
|
||||
NazaraError("Failed to read stream (byte " + NumberToString(stream.GetCursorPos()) + ')');
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
@@ -225,14 +225,14 @@ namespace Nz
|
||||
UInt8 magic;
|
||||
if (!stream.Read(&magic, 1))
|
||||
{
|
||||
NazaraError("Failed to read stream (byte " + String::Number(stream.GetCursorPos()) + ')');
|
||||
NazaraError("Failed to read stream (byte " + NumberToString(stream.GetCursorPos()) + ')');
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* first byte must be equal to 0x0c (12) */
|
||||
if (magic != 0x0c)
|
||||
{
|
||||
NazaraError("Colormap's first byte must be 0x0c (0x" + String::Number(magic, 16) + ')');
|
||||
NazaraError("Colormap's first byte must be 0x0c (0x" + NumberToString(magic, 16) + ')');
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ namespace Nz
|
||||
{
|
||||
if (!stream.Read(&rle_value, 1))
|
||||
{
|
||||
NazaraError("Failed to read stream (byte " + String::Number(stream.GetCursorPos()) + ')');
|
||||
NazaraError("Failed to read stream (byte " + NumberToString(stream.GetCursorPos()) + ')');
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -269,7 +269,7 @@ namespace Nz
|
||||
rle_count = rle_value - 0xc0;
|
||||
if (!stream.Read(&rle_value, 1))
|
||||
{
|
||||
NazaraError("Failed to read stream (byte " + String::Number(stream.GetCursorPos()) + ')');
|
||||
NazaraError("Failed to read stream (byte " + NumberToString(stream.GetCursorPos()) + ')');
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
@@ -302,7 +302,7 @@ namespace Nz
|
||||
{
|
||||
if (!stream.Read(&rle_value, 1))
|
||||
{
|
||||
NazaraError("Failed to read stream (byte " + String::Number(stream.GetCursorPos()) + ')');
|
||||
NazaraError("Failed to read stream (byte " + NumberToString(stream.GetCursorPos()) + ')');
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -313,7 +313,7 @@ namespace Nz
|
||||
rle_count = rle_value - 0xc0;
|
||||
if (!stream.Read(&rle_value, 1))
|
||||
{
|
||||
NazaraError("Failed to read stream (byte " + String::Number(stream.GetCursorPos()) + ')');
|
||||
NazaraError("Failed to read stream (byte " + NumberToString(stream.GetCursorPos()) + ')');
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
@@ -329,7 +329,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
default:
|
||||
NazaraError("Unsupported " + String::Number(bitCount) + " bitcount for pcx files");
|
||||
NazaraError("Unsupported " + NumberToString(bitCount) + " bitcount for pcx files");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/Stream.hpp>
|
||||
#include <Nazara/Utility/Image.hpp>
|
||||
#include <set>
|
||||
#include <unordered_set>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
@@ -38,7 +38,7 @@ namespace Nz
|
||||
|
||||
bool IsSupported(const std::string& extension)
|
||||
{
|
||||
static std::set<String> supportedExtensions = {"bmp", "gif", "hdr", "jpg", "jpeg", "pic", "png", "ppm", "pgm", "psd", "tga"};
|
||||
static std::unordered_set<std::string> supportedExtensions = {"bmp", "gif", "hdr", "jpg", "jpeg", "pic", "png", "ppm", "pgm", "psd", "tga"};
|
||||
return supportedExtensions.find(extension) != supportedExtensions.end();
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace Nz
|
||||
UInt8* ptr = stbi_load_from_callbacks(&callbacks, &stream, &width, &height, &bpp, STBI_rgb_alpha);
|
||||
if (!ptr)
|
||||
{
|
||||
NazaraError("Failed to load image: " + String(stbi_failure_reason()));
|
||||
NazaraError("Failed to load image: " + std::string(stbi_failure_reason()));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace Nz
|
||||
ImageType type = image.GetType();
|
||||
if (type != ImageType_1D && type != ImageType_2D)
|
||||
{
|
||||
NazaraError("Image type 0x" + String::Number(type, 16) + " is not in a supported format");
|
||||
NazaraError("Image type 0x" + NumberToString(type, 16) + " is not in a supported format");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ namespace Nz
|
||||
{
|
||||
if (imageQuality <= 0 || imageQuality > 100)
|
||||
{
|
||||
NazaraError("NativeJPEGSaver_Quality value (" + Nz::String::Number(imageQuality) + ") does not fit in bounds ]0, 100], clamping...");
|
||||
NazaraError("NativeJPEGSaver_Quality value (" + Nz::NumberToString(imageQuality) + ") does not fit in bounds ]0, 100], clamping...");
|
||||
imageQuality = Nz::Clamp(imageQuality, 1LL, 100LL);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user