Core/String: Replace implicit operator std::string by ToStd::String

This commit is contained in:
Lynix 2017-12-14 19:50:06 +01:00
parent 5aab9b248d
commit fd8306f17f
13 changed files with 40 additions and 43 deletions

View File

@ -134,7 +134,7 @@ namespace Ndk
Nz::Vector3f textBox = m_textSprite->GetBoundingVolume().obb.localBox.GetLengths();
m_textEntity->GetComponent<NodeComponent>().SetPosition(origin.x + checkboxSize.x + (m_adaptativeMargin ? checkboxSize.x / 2.f : m_textMargin),
origin.y + checkboxSize.y / 2.f - textBox.y / 2.f);
origin.y + checkboxSize.y / 2.f - textBox.y / 2.f);
}
void CheckboxWidget::OnMouseButtonRelease(int x, int y, Nz::Mouse::Button button)

View File

@ -168,6 +168,7 @@ namespace Nz
bool ToDouble(double* value) const;
bool ToInteger(long long* value, UInt8 radix = 10) const;
String ToLower(UInt32 flags = None) const;
std::string ToStdString() const;
String ToUpper(UInt32 flags = None) const;
String& Trim(UInt32 flags = None);
@ -193,8 +194,6 @@ namespace Nz
typedef char value_type;
// Méthodes STD
operator std::string() const;
char& operator[](std::size_t pos);
char operator[](std::size_t pos) const;

View File

@ -238,7 +238,7 @@ namespace Nz
String error("Column out of range: (" + String::Number(column) + ") > 3");
NazaraError(error);
throw std::out_of_range(error);
throw std::out_of_range(error.ToStdString());
}
#endif
@ -632,7 +632,7 @@ namespace Nz
String error("Row out of range: (" + String::Number(row) + ") > 3");
NazaraError(error);
throw std::out_of_range(error);
throw std::out_of_range(error.ToStdString());
}
#endif
@ -1347,7 +1347,7 @@ namespace Nz
String error("Index out of range: (" + String::Number(x) + ", " + String::Number(y) +") > (3, 3)");
NazaraError(error);
throw std::out_of_range(error);
throw std::out_of_range(error.ToStdString());
}
#endif
@ -1371,7 +1371,7 @@ namespace Nz
String error("Index out of range: (" + String::Number(x) + ", " + String::Number(y) +") > (3, 3)");
NazaraError(error);
throw std::out_of_range(error);
throw std::out_of_range(error.ToStdString());
}
#endif

View File

@ -304,7 +304,7 @@ namespace Nz
ss << "Index out of range: (" << i << " >= " << BoxCorner_Max << ")";
NazaraError(ss);
throw std::out_of_range(ss.ToString());
throw std::out_of_range(ss.ToString().ToStdString());
}
#endif

View File

@ -579,7 +579,7 @@ namespace Nz
String error("Planes are parallel");
NazaraError(error);
throw std::domain_error(error);
throw std::domain_error(error.ToStdString());
}
#endif

View File

@ -607,7 +607,7 @@ namespace Nz
String error("Division by zero");
NazaraError(error);
throw std::domain_error(error);
throw std::domain_error(error.ToStdString());
}
#endif
@ -633,7 +633,7 @@ namespace Nz
String error("Division by zero");
NazaraError(error);
throw std::domain_error(error);
throw std::domain_error(error.ToStdString());
}
#endif
@ -723,7 +723,7 @@ namespace Nz
String error("Division by zero");
NazaraError(error);
throw std::domain_error(error);
throw std::domain_error(error.ToStdString());
}
#endif
@ -752,7 +752,7 @@ namespace Nz
String error("Division by zero");
NazaraError(error);
throw std::domain_error(error);
throw std::domain_error(error.ToStdString());
}
#endif
@ -1050,7 +1050,7 @@ Nz::Vector2<T> operator/(T scale, const Nz::Vector2<T>& vec)
Nz::String error("Division by zero");
NazaraError(error);
throw std::domain_error(error);
throw std::domain_error(error.ToStdString());
}
#endif

View File

@ -142,7 +142,7 @@ namespace Nz
String error("Division by zero");
NazaraError(error);
throw std::domain_error(error);
throw std::domain_error(error.ToStdString());
}
#endif
@ -726,7 +726,7 @@ namespace Nz
String error("Division by zero");
NazaraError(error);
throw std::domain_error(error);
throw std::domain_error(error.ToStdString());
}
#endif
@ -751,7 +751,7 @@ namespace Nz
String error("Division by zero");
NazaraError(error);
throw std::domain_error(error);
throw std::domain_error(error.ToStdString());
}
#endif
@ -839,7 +839,7 @@ namespace Nz
String error("Division by zero");
NazaraError(error);
throw std::domain_error(error);
throw std::domain_error(error.ToStdString());
}
x /= vec.x;
@ -866,7 +866,7 @@ namespace Nz
String error("Division by zero");
NazaraError(error);
throw std::domain_error(error);
throw std::domain_error(error.ToStdString());
}
x /= scale;
@ -1340,7 +1340,7 @@ Nz::Vector3<T> operator/(T scale, const Nz::Vector3<T>& vec)
Nz::String error("Division by zero");
NazaraError(error);
throw std::domain_error(error);
throw std::domain_error(error.ToStdString());
}
#endif

View File

@ -637,7 +637,7 @@ namespace Nz
String error("Division by zero");
NazaraError(error);
throw std::domain_error(error);
throw std::domain_error(error.ToStdString());
}
#endif
@ -663,7 +663,7 @@ namespace Nz
String error("Division by zero");
NazaraError(error);
throw std::domain_error(error);
throw std::domain_error(error.ToStdString());
}
#endif
@ -761,7 +761,7 @@ namespace Nz
String error("Division by zero");
NazaraError(error);
throw std::domain_error(error);
throw std::domain_error(error.ToStdString());
}
#endif
@ -792,7 +792,7 @@ namespace Nz
String error("Division by zero");
NazaraError(error);
throw std::domain_error(error);
throw std::domain_error(error.ToStdString());
}
#endif
@ -1113,7 +1113,7 @@ Nz::Vector4<T> operator/(T scale, const Nz::Vector4<T>& vec)
Nz::String error("Division by zero");
NazaraError(error);
throw std::domain_error(error);
throw std::domain_error(error.ToStdString());
}
#endif

View File

@ -31,7 +31,7 @@ namespace Nz
namespace
{
//FIXME: MinGW seems to dislike thread_local shared_ptr.. (using a std::string is a working hackfix)
thread_local std::string currentPath(DirectoryImpl::GetCurrent());
thread_local std::string currentPath(DirectoryImpl::GetCurrent().ToStdString());
}
/*!
@ -526,7 +526,7 @@ namespace Nz
String path = File::AbsolutePath(dirPath);
if (DirectoryImpl::Exists(path))
{
currentPath = path;
currentPath = path.ToStdString();
return true;
}
else

View File

@ -148,7 +148,7 @@ namespace Nz
if (type == ErrorType_AssertFailed || (type != ErrorType_Warning &&
(s_flags & ErrorFlag_ThrowException) != 0 && (s_flags & ErrorFlag_ThrowExceptionDisabled) == 0))
throw std::runtime_error(error);
throw std::runtime_error(error.ToStdString());
}
/*!
@ -183,7 +183,7 @@ namespace Nz
if (type == ErrorType_AssertFailed || (type != ErrorType_Warning &&
(s_flags & ErrorFlag_ThrowException) != 0 && (s_flags & ErrorFlag_ThrowExceptionDisabled) == 0))
throw std::runtime_error(error);
throw std::runtime_error(error.ToStdString());
}
UInt32 Error::s_flags = ErrorFlag_None;

View File

@ -4197,13 +4197,21 @@ namespace Nz
}
}
/*!
* \brief Converts the string to std::string
* \return std::string representation
*/
std::string String::ToStdString() const
{
return std::string(m_sharedString->string.get(), m_sharedString->size);
}
/*!
* \brief Converts the string to upper
* \return Upper string
*
* \param flags Flag for the look up
*/
String String::ToUpper(UInt32 flags) const
{
if (m_sharedString->size == 0)
@ -4481,16 +4489,6 @@ namespace Nz
}
*/
/*!
* \brief Converts the string to std::string
* \return std::string representation
*/
String::operator std::string() const
{
return std::string(m_sharedString->string.get(), m_sharedString->size);
}
/*!
* \brief Gets the ith character in the string
* \return A reference to the character

View File

@ -21,7 +21,7 @@ namespace Nz
{
String lastError(lua_tostring(internalState, -1));
throw std::runtime_error("Lua panic: " + lastError);
throw std::runtime_error("Lua panic: " + lastError.ToStdString());
}
}

View File

@ -89,7 +89,7 @@ namespace Nz
if (varPtr->type != type)
{
//TODO: AstParseError
throw std::runtime_error("Function uses parameter \"" + name + "\" with a different type than specified in the function arguments");
throw std::runtime_error("Function uses parameter \"" + name.ToStdString() + "\" with a different type than specified in the function arguments");
}
break;
@ -98,7 +98,7 @@ namespace Nz
if (!found)
//TODO: AstParseError
throw std::runtime_error("Function has no parameter \"" + name + "\"");
throw std::runtime_error("Function has no parameter \"" + name.ToStdString() + "\"");
}
break;