diff options
author | Karlson2k <k2k@narod.ru> | 2013-11-27 16:10:27 -0800 |
---|---|---|
committer | Karlson2k <k2k@narod.ru> | 2013-11-27 16:10:27 -0800 |
commit | 74e4e99b2897818310091a389feaff524ee96f0b (patch) | |
tree | a8fc09e638c782c2dacc07b1685727adfa9a0191 | |
parent | 81a9c0c598f9c3895e43c9d0fc53adbd6f32d72c (diff) | |
parent | fd6e16a6bdc9ec595c60f8d4e587b8551f3bb1e0 (diff) |
Merge pull request #3719 from Karlson2k/carchive_cleanup_01
CArchive cleanup and fix
-rw-r--r-- | xbmc/Temperature.cpp | 2 | ||||
-rw-r--r-- | xbmc/Temperature.h | 3 | ||||
-rw-r--r-- | xbmc/XBDateTime.h | 1 | ||||
-rw-r--r-- | xbmc/utils/Archive.cpp | 73 | ||||
-rw-r--r-- | xbmc/utils/Archive.h | 9 | ||||
-rw-r--r-- | xbmc/utils/CPUInfo.cpp | 6 | ||||
-rw-r--r-- | xbmc/utils/CPUInfo.h | 14 | ||||
-rw-r--r-- | xbmc/utils/StreamDetails.h | 1 |
8 files changed, 39 insertions, 70 deletions
diff --git a/xbmc/Temperature.cpp b/xbmc/Temperature.cpp index 98b9ebc84c..240af9dd06 100644 --- a/xbmc/Temperature.cpp +++ b/xbmc/Temperature.cpp @@ -483,7 +483,7 @@ double CTemperature::ToLocale() const } // Returns temperature as localized string -CStdString CTemperature::ToString() const +std::string CTemperature::ToString() const { if (!IsValid()) return g_localizeStrings.Get(13205); // "Unknown" diff --git a/xbmc/Temperature.h b/xbmc/Temperature.h index 6c3fe72684..88ae4da92b 100644 --- a/xbmc/Temperature.h +++ b/xbmc/Temperature.h @@ -19,6 +19,7 @@ * */ +#include <string> #include "utils/Archive.h" class CTemperature : public IArchivable @@ -95,7 +96,7 @@ public: double ToNewton() const; double ToLocale() const; - CStdString ToString() const; + std::string ToString() const; protected: CTemperature(double value); diff --git a/xbmc/XBDateTime.h b/xbmc/XBDateTime.h index 063d2e43d9..969531c1f6 100644 --- a/xbmc/XBDateTime.h +++ b/xbmc/XBDateTime.h @@ -20,6 +20,7 @@ * */ +#include "utils/StdString.h" #include "utils/Archive.h" /*! \brief TIME_FORMAT enum/bitmask used for formatting time strings diff --git a/xbmc/utils/Archive.cpp b/xbmc/utils/Archive.cpp index 122c41b0c2..ffd7ed25f6 100644 --- a/xbmc/utils/Archive.cpp +++ b/xbmc/utils/Archive.cpp @@ -179,50 +179,28 @@ CArchive& CArchive::operator<<(const std::string& str) return *this; } -CArchive& CArchive::operator<<(const CStdString& str) +CArchive& CArchive::operator<<(const std::wstring& wstr) { - *this << (unsigned int)str.size(); + *this << (unsigned int)wstr.size(); - int size = str.size(); - if (m_BufferPos + size >= BUFFER_MAX) - FlushBuffer(); - - int iBufferMaxParts=size/BUFFER_MAX; - for (int i=0; i<iBufferMaxParts; i++) - { - memcpy(&m_pBuffer[m_BufferPos], str.c_str()+(i*BUFFER_MAX), BUFFER_MAX); - m_BufferPos+=BUFFER_MAX; - FlushBuffer(); - } - - int iPos=iBufferMaxParts*BUFFER_MAX; - int iSizeLeft=size-iPos; - memcpy(&m_pBuffer[m_BufferPos], str.c_str()+iPos, iSizeLeft); - m_BufferPos+=iSizeLeft; - - return *this; -} - -CArchive& CArchive::operator<<(const CStdStringW& str) -{ - *this << (unsigned int)str.size(); - - int size = str.size() * sizeof(wchar_t); - if (m_BufferPos + size >= BUFFER_MAX) - FlushBuffer(); + unsigned int size = wstr.size() * sizeof(wchar_t); + const uint8_t* ptr = (const uint8_t*)wstr.data(); - int iBufferMaxParts=size/BUFFER_MAX; - for (int i=0; i<iBufferMaxParts; ++i) + if (size + m_BufferPos >= BUFFER_MAX) { - memcpy(&m_pBuffer[m_BufferPos], str.c_str()+(i*BUFFER_MAX), BUFFER_MAX); - m_BufferPos+=BUFFER_MAX; FlushBuffer(); + while (size >= BUFFER_MAX) + { + memcpy(m_pBuffer, ptr, BUFFER_MAX); + m_BufferPos = BUFFER_MAX; + ptr += BUFFER_MAX; + size -= BUFFER_MAX; + FlushBuffer(); + } } - int iPos=iBufferMaxParts*BUFFER_MAX; - int iSizeLeft=size-iPos; - memcpy(&m_pBuffer[m_BufferPos], str.c_str()+iPos, iSizeLeft); - m_BufferPos+=iSizeLeft; + memcpy(m_pBuffer + m_BufferPos, ptr, size); + m_BufferPos += size; return *this; } @@ -375,26 +353,15 @@ CArchive& CArchive::operator>>(std::string& str) return *this; } -CArchive& CArchive::operator>>(CStdString& str) +CArchive& CArchive::operator>>(std::wstring& wstr) { unsigned int iLength = 0; *this >> iLength; - m_pFile->Read((void*)str.GetBufferSetLength(iLength), iLength); - str.ReleaseBuffer(); - - - return *this; -} - -CArchive& CArchive::operator>>(CStdStringW& str) -{ - unsigned int iLength = 0; - *this >> iLength; - - m_pFile->Read((void*)str.GetBufferSetLength(iLength), iLength * sizeof(wchar_t)); - str.ReleaseBuffer(); - + wchar_t * const p = new wchar_t[iLength]; + m_pFile->Read(p, iLength); + wstr.assign(p, iLength); + delete[] p; return *this; } diff --git a/xbmc/utils/Archive.h b/xbmc/utils/Archive.h index 97937c0a25..4174268e03 100644 --- a/xbmc/utils/Archive.h +++ b/xbmc/utils/Archive.h @@ -20,7 +20,8 @@ * */ -#include "StdString.h" +#include <string> +#include <vector> #include "system.h" // for SYSTEMTIME namespace XFILE @@ -53,8 +54,7 @@ public: CArchive& operator<<(bool b); CArchive& operator<<(char c); CArchive& operator<<(const std::string &str); - CArchive& operator<<(const CStdString& str); - CArchive& operator<<(const CStdStringW& str); + CArchive& operator<<(const std::wstring& wstr); CArchive& operator<<(const SYSTEMTIME& time); CArchive& operator<<(IArchivable& obj); CArchive& operator<<(const CVariant& variant); @@ -71,8 +71,7 @@ public: CArchive& operator>>(bool& b); CArchive& operator>>(char& c); CArchive& operator>>(std::string &str); - CArchive& operator>>(CStdString& str); - CArchive& operator>>(CStdStringW& str); + CArchive& operator>>(std::wstring& wstr); CArchive& operator>>(SYSTEMTIME& time); CArchive& operator>>(IArchivable& obj); CArchive& operator>>(CVariant& variant); diff --git a/xbmc/utils/CPUInfo.cpp b/xbmc/utils/CPUInfo.cpp index e10e7597ba..f47ab62aac 100644 --- a/xbmc/utils/CPUInfo.cpp +++ b/xbmc/utils/CPUInfo.cpp @@ -731,13 +731,13 @@ bool CCPUInfo::readProcStat(unsigned long long& user, unsigned long long& nice, return true; } -CStdString CCPUInfo::GetCoresUsageString() const +std::string CCPUInfo::GetCoresUsageString() const { - CStdString strCores; + std::string strCores; map<int, CoreInfo>::const_iterator iter = m_cores.begin(); while (iter != m_cores.end()) { - CStdString strCore; + std::string strCore; #ifdef TARGET_WINDOWS // atm we get only the average over all cores strCore = StringUtils::Format("CPU %d core(s) average: %3.1f%% ", m_cpuCount, iter->second.m_fPct); diff --git a/xbmc/utils/CPUInfo.h b/xbmc/utils/CPUInfo.h index 49264a9e91..093884b12e 100644 --- a/xbmc/utils/CPUInfo.h +++ b/xbmc/utils/CPUInfo.h @@ -53,12 +53,12 @@ struct CoreInfo unsigned long long m_system; unsigned long long m_idle; unsigned long long m_io; - CStdString m_strVendor; - CStdString m_strModel; - CStdString m_strBogoMips; - CStdString m_strHardware; - CStdString m_strRevision; - CStdString m_strSerial; + std::string m_strVendor; + std::string m_strModel; + std::string m_strBogoMips; + std::string m_strHardware; + std::string m_strRevision; + std::string m_strSerial; CoreInfo() : m_id(0), m_fSpeed(.0), m_fPct(.0), m_user(0LL), m_nice(0LL), m_system(0LL), m_idle(0LL), m_io(0LL) {} }; @@ -81,7 +81,7 @@ public: const CoreInfo &GetCoreInfo(int nCoreId); bool HasCoreId(int nCoreId) const; - CStdString GetCoresUsageString() const; + std::string GetCoresUsageString() const; unsigned int GetCPUFeatures() { return m_cpuFeatures; } diff --git a/xbmc/utils/StreamDetails.h b/xbmc/utils/StreamDetails.h index 4f62ae780f..67aff50eba 100644 --- a/xbmc/utils/StreamDetails.h +++ b/xbmc/utils/StreamDetails.h @@ -19,6 +19,7 @@ * */ +#include "utils/StdString.h" #include "Archive.h" #include "ISerializable.h" #include <vector> |