Core/String: Replace manual memory management/COW by smart pointers

Former-commit-id: 27cab7f0642619ab47d53ed59c737992534f2979
This commit is contained in:
Lynix
2015-09-13 12:07:31 +02:00
parent 44e99bce3d
commit 9f1c190985
3 changed files with 342 additions and 447 deletions

View File

@@ -4,6 +4,31 @@
#include <Nazara/Core/Debug.hpp>
inline NzString::NzString(std::shared_ptr<SharedString>&& sharedString) :
m_sharedString(std::move(sharedString))
{
}
inline void NzString::ReleaseString()
{
m_sharedString = std::move(GetEmptyString());
}
inline NzString::SharedString::SharedString() : // Special case: empty string
capacity(0),
size(0)
{
}
inline NzString::SharedString::SharedString(unsigned int strSize) :
capacity(strSize),
size(strSize),
string(new char[strSize + 1])
{
string[strSize] = '\0';
}
namespace std
{
template<>