NzString::Clear now takes an optional argument
Fixed NzString::ToDouble rejecting legal strings NzString::Clear can now keep the internal buffer to improve performances NzStringToNumber now takes an optional argument to check if the conversion went well Optimized NzString::ToInteger
This commit is contained in:
@@ -22,6 +22,7 @@ inline unsigned int nzPow2(unsigned int n)
|
||||
{
|
||||
unsigned int x = 1;
|
||||
|
||||
// Tant que x est plus petit que n, on décale ses bits vers la gauche, ce qui revient à multiplier par deux
|
||||
while(x <= n)
|
||||
x <<= 1;
|
||||
|
||||
@@ -265,9 +266,17 @@ NzString& NzString::Append(const NzString& string)
|
||||
return *this;
|
||||
}
|
||||
|
||||
void NzString::Clear()
|
||||
void NzString::Clear(bool keepBuffer)
|
||||
{
|
||||
ReleaseString();
|
||||
if (keepBuffer)
|
||||
{
|
||||
ReleaseString();
|
||||
|
||||
m_sharedString->size = 0;
|
||||
m_sharedString->string = nullptr;
|
||||
}
|
||||
else
|
||||
ReleaseString();
|
||||
}
|
||||
|
||||
bool NzString::Contains(char character, int start, nzUInt32 flags) const
|
||||
@@ -3842,7 +3851,7 @@ bool NzString::ToBool(bool* value, nzUInt32 flags) const
|
||||
|
||||
bool NzString::ToDouble(double* value) const
|
||||
{
|
||||
if (m_sharedString->size)
|
||||
if (m_sharedString->size == 0)
|
||||
return false;
|
||||
|
||||
if (value)
|
||||
@@ -3853,13 +3862,15 @@ bool NzString::ToDouble(double* value) const
|
||||
|
||||
bool NzString::ToInteger(long long* value, nzUInt8 base) const
|
||||
{
|
||||
if (!IsNumber(base))
|
||||
return false;
|
||||
|
||||
if (value)
|
||||
*value = NzStringToNumber(*this, base);
|
||||
{
|
||||
bool ok;
|
||||
*value = NzStringToNumber(*this, base, &ok);
|
||||
|
||||
return true;
|
||||
return ok;
|
||||
}
|
||||
else
|
||||
return IsNumber(base);
|
||||
}
|
||||
|
||||
NzString NzString::ToLower(nzUInt32 flags) const
|
||||
|
||||
@@ -98,6 +98,7 @@ bool NzGLSLShader::Compile()
|
||||
glGetProgramiv(m_program, GL_INFO_LOG_LENGTH, &length);
|
||||
if (length > 1)
|
||||
{
|
||||
m_log.Clear(true);
|
||||
m_log.Reserve(length+19-1); // La taille retournée est celle du buffer (Avec caractère de fin)
|
||||
m_log.Prepend("Linkage error: ");
|
||||
m_log.Resize(length+19-1); // Extension du buffer d'écriture pour ajouter le log
|
||||
@@ -129,7 +130,7 @@ bool NzGLSLShader::Create()
|
||||
glBindAttribLocation(m_program, attribIndex[nzElementUsage_Diffuse], "Diffuse");
|
||||
glBindAttribLocation(m_program, attribIndex[nzElementUsage_Tangent], "Tangent");
|
||||
|
||||
NzString uniformName = "TexCoordi";
|
||||
NzString uniformName = "TexCoord*";
|
||||
for (unsigned int i = 0; i < 8; ++i)
|
||||
{
|
||||
uniformName[8] = '0'+i;
|
||||
@@ -242,6 +243,7 @@ bool NzGLSLShader::Load(nzShaderType type, const NzString& source)
|
||||
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &length);
|
||||
if (length > 1)
|
||||
{
|
||||
m_log.Clear(true);
|
||||
m_log.Reserve(length+19-1); // La taille retournée est celle du buffer (Avec caractère de fin)
|
||||
m_log.Prepend("Compilation error: ");
|
||||
m_log.Resize(length+19-1); // Extension du buffer d'écriture pour ajouter le log
|
||||
|
||||
Reference in New Issue
Block a user