Index: src/libchcore/TString.cpp =================================================================== diff -u -rb8d323f736b7a2d3e85a6420f330f139db5964cf -r3d37945a5eaceb8e104154588d429f3eb52a90ab --- src/libchcore/TString.cpp (.../TString.cpp) (revision b8d323f736b7a2d3e85a6420f330f139db5964cf) +++ src/libchcore/TString.cpp (.../TString.cpp) (revision 3d37945a5eaceb8e104154588d429f3eb52a90ab) @@ -181,7 +181,6 @@ if(this != &rSrc) { Release(); - m_pszStringData = rSrc.m_pszStringData; AddRef(); } @@ -207,7 +206,7 @@ * \param[in] src - TString object that will be appended * \return A new TString object with concatenated strings. */ -const TString TString::operator+(const TString& src) const +TString TString::operator+(const TString& src) const { TString str(*this); str.Append(src); @@ -220,7 +219,7 @@ * \param[in] pszSrc - unicode TString that will be appended * \return A new TString object with concatenated strings. */ -const TString TString::operator+(const wchar_t* pszSrc) const +TString TString::operator+(const wchar_t* pszSrc) const { TString str(*this); str.Append(pszSrc); @@ -750,6 +749,8 @@ TInternalStringData* pInternalStringData = GetInternalStringData(); if(!pInternalStringData) { + BOOST_ASSERT(m_pszStringData == NULL); + pInternalStringData = TInternalStringData::Allocate(stRequestedSize); m_pszStringData = pInternalStringData->GetData(); AddRef(); @@ -762,7 +763,6 @@ if(bCloned) { Release(); - m_pszStringData = pNewData->GetData(); AddRef(); } @@ -771,13 +771,39 @@ { // need to resize TInternalStringData* pNewData = pInternalStringData->CloneWithResize(stRequestedSize); - Release(); + Release(); m_pszStringData = pNewData->GetData(); AddRef(); } } +void TString::AddRef() +{ + if(m_pszStringData) + { + details::TInternalStringData* pInternalStringData = details::TInternalStringData::GetStringDataFromTextPointer(m_pszStringData); + pInternalStringData->AddRef(); + } +} + +void TString::Release() +{ + details::TInternalStringData* pInternalStringData = details::TInternalStringData::GetStringDataFromTextPointer(m_pszStringData); + if(pInternalStringData && pInternalStringData->Release()) + details::TInternalStringData::Free(pInternalStringData); + m_pszStringData = NULL; +} + +size_t TString::GetCurrentBufferSize() const +{ + const details::TInternalStringData* pData = GetInternalStringData(); + if(pData) + return pData->GetBufferSize(); + else + return 0; +} + END_CHCORE_NAMESPACE chcore::TString operator+(const wchar_t* pszString, chcore::TString& str) Index: src/libchcore/TString.h =================================================================== diff -u -r5fd6beaad9f1eccb664b997d151acb59961e4827 -r3d37945a5eaceb8e104154588d429f3eb52a90ab --- src/libchcore/TString.h (.../TString.h) (revision 5fd6beaad9f1eccb664b997d151acb59961e4827) +++ src/libchcore/TString.h (.../TString.h) (revision 3d37945a5eaceb8e104154588d429f3eb52a90ab) @@ -127,11 +127,11 @@ /**@{*/ // assignment const TString& operator=(const TString& src); ///< Assign operator for TString objects - const TString operator+(const TString& src) const; ///< Concatenate operator for TString objects + TString operator+(const TString& src) const; ///< Concatenate operator for TString objects const TString& operator+=(const TString& src); ///< Merge operator for TString objects const TString& operator=(const wchar_t* pszSrc); ///< Assign operator from unicode strings - const TString operator+(const wchar_t* pszSrc) const; ///< Concatenate operator for unicode strings + TString operator+(const wchar_t* pszSrc) const; ///< Concatenate operator for unicode strings const TString& operator+=(const wchar_t* pszSrc); ///< Merge operator for unicode strings /// Makes case sensitive comparison to the unicode TString ( see Compare(const wchar_t* psz) ) @@ -220,32 +220,11 @@ void EnsureWritable(size_t stRequestedSize); - void AddRef() - { - if(m_pszStringData) - { - details::TInternalStringData* pInternalStringData = details::TInternalStringData::GetStringDataFromTextPointer(m_pszStringData); - pInternalStringData->AddRef(); - } - } + void AddRef(); + void Release(); - void Release() - { - details::TInternalStringData* pInternalStringData = details::TInternalStringData::GetStringDataFromTextPointer(m_pszStringData); - if(pInternalStringData && pInternalStringData->Release()) - details::TInternalStringData::Free(pInternalStringData); - m_pszStringData = NULL; - } + size_t GetCurrentBufferSize() const; - size_t GetCurrentBufferSize() const - { - const details::TInternalStringData* pData = GetInternalStringData(); - if(pData) - return pData->GetBufferSize(); - else - return 0; - } - details::TInternalStringData* GetInternalStringData() { return details::TInternalStringData::GetStringDataFromTextPointer(m_pszStringData); } const details::TInternalStringData* GetInternalStringData() const { return details::TInternalStringData::GetStringDataFromTextPointer(m_pszStringData); }