Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #3890 from ace20022/cleanup_utils

[Utils] Clean up/Fix things found by Cppcheck
  • Loading branch information...
commit a44a60fded27684c25d4b6bb6db0be24b877cc5a 2 parents c638f05 + e92e64c
@ace20022 ace20022 authored
Showing with 194 additions and 191 deletions.
  1. +6 −0 xbmc/pictures/Picture.cpp
  2. +1 −0  xbmc/pictures/Picture.h
  3. +0 −1  xbmc/utils/AMLUtils.cpp
  4. +3 −3 xbmc/utils/Archive.cpp
  5. +2 −2 xbmc/utils/Archive.h
  6. +4 −4 xbmc/utils/BitstreamConverter.cpp
  7. +12 −12 xbmc/utils/BitstreamConverter.h
  8. +0 −2  xbmc/utils/CPUInfo.cpp
  9. +4 −4 xbmc/utils/CPUInfo.h
  10. +4 −0 xbmc/utils/CryptThreading.h
  11. +3 −3 xbmc/utils/DatabaseUtils.cpp
  12. +1 −1  xbmc/utils/Fanart.cpp
  13. +2 −2 xbmc/utils/Fanart.h
  14. +3 −0  xbmc/utils/FileOperationJob.cpp
  15. +4 −4 xbmc/utils/FileOperationJob.h
  16. +2 −2 xbmc/utils/GroupUtils.cpp
  17. +2 −2 xbmc/utils/HTMLUtil.cpp
  18. +4 −4 xbmc/utils/HTMLUtil.h
  19. +7 −7 xbmc/utils/HttpParser.cpp
  20. +6 −6 xbmc/utils/HttpParser.h
  21. +2 −2 xbmc/utils/JSONVariantWriter.cpp
  22. +3 −3 xbmc/utils/JobManager.cpp
  23. +1 −1  xbmc/utils/JobManager.h
  24. +11 −11 xbmc/utils/LabelFormatter.h
  25. +2 −2 xbmc/utils/LangCodeExpander.cpp
  26. +7 −7 xbmc/utils/LangCodeExpander.h
  27. +1 −1  xbmc/utils/POUtils.cpp
  28. +1 −2  xbmc/utils/PerformanceSample.cpp
  29. +2 −2 xbmc/utils/PerformanceStats.cpp
  30. +3 −3 xbmc/utils/RecentlyAddedJob.h
  31. +1 −1  xbmc/utils/RegExp.cpp
  32. +2 −2 xbmc/utils/RegExp.h
  33. +1 −1  xbmc/utils/RingBuffer.cpp
  34. +1 −1  xbmc/utils/RingBuffer.h
  35. +2 −2 xbmc/utils/RssManager.h
  36. +2 −2 xbmc/utils/RssReader.cpp
  37. +2 −2 xbmc/utils/ScraperParser.h
  38. +7 −0 xbmc/utils/Screenshot.cpp
  39. +1 −0  xbmc/utils/Screenshot.h
  40. +4 −4 xbmc/utils/SortUtils.cpp
  41. +1 −2  xbmc/utils/Splash.cpp
  42. +8 −18 xbmc/utils/StdString.h
  43. +4 −9 xbmc/utils/Stopwatch.cpp
  44. +7 −7 xbmc/utils/StreamDetails.cpp
  45. +4 −4 xbmc/utils/StringUtils.cpp
  46. +4 −1 xbmc/utils/SystemInfo.cpp
  47. +7 −7 xbmc/utils/SystemInfo.h
  48. +1 −1  xbmc/utils/TextSearch.h
  49. +5 −5 xbmc/utils/TimeSmoother.h
  50. +2 −3 xbmc/utils/TuxBoxUtil.cpp
  51. +10 −10 xbmc/utils/TuxBoxUtil.h
  52. +3 −3 xbmc/utils/URIUtils.cpp
  53. +2 −2 xbmc/utils/UrlOptions.cpp
  54. +2 −3 xbmc/utils/Variant.cpp
  55. +1 −1  xbmc/utils/Weather.cpp
  56. +2 −2 xbmc/utils/Weather.h
  57. +2 −2 xbmc/utils/WindowsShortcut.cpp
  58. +1 −1  xbmc/utils/WindowsShortcut.h
  59. +1 −1  xbmc/utils/log.h
  60. +1 −1  xbmc/utils/test/TestCharsetConverter.cpp
View
6 xbmc/pictures/Picture.cpp
@@ -87,6 +87,11 @@ CThumbnailWriter::CThumbnailWriter(unsigned char* buffer, int width, int height,
m_thumbFile = thumbFile;
}
+CThumbnailWriter::~CThumbnailWriter()
+{
+ delete m_buffer;
+}
+
bool CThumbnailWriter::DoWork()
{
bool success = true;
@@ -98,6 +103,7 @@ bool CThumbnailWriter::DoWork()
}
delete [] m_buffer;
+ m_buffer = NULL;
return success;
}
View
1  xbmc/pictures/Picture.h
@@ -65,6 +65,7 @@ class CThumbnailWriter : public CJob
public:
//WARNING: buffer is deleted from DoWork()
CThumbnailWriter(unsigned char* buffer, int width, int height, int stride, const CStdString& thumbFile);
+ ~CThumbnailWriter();
bool DoWork();
private:
View
1  xbmc/utils/AMLUtils.cpp
@@ -219,7 +219,6 @@ void aml_set_audio_passthrough(bool passthrough)
void aml_probe_hdmi_audio()
{
- std::vector<CStdString> audio_formats;
// Audio {format, channel, freq, cce}
// {1, 7, 7f, 7}
// {7, 5, 1e, 0}
View
6 xbmc/utils/Archive.cpp
@@ -61,12 +61,12 @@ void CArchive::Close()
FlushBuffer();
}
-bool CArchive::IsLoading()
+bool CArchive::IsLoading() const
{
return (m_iMode == load);
}
-bool CArchive::IsStoring()
+bool CArchive::IsStoring() const
{
return (m_iMode == store);
}
@@ -187,7 +187,7 @@ CArchive& CArchive::operator<<(const CVariant& variant)
break;
case CVariant::VariantTypeObject:
*this << variant.size();
- for (CVariant::const_iterator_map itr = variant.begin_map(); itr != variant.end_map(); itr++)
+ for (CVariant::const_iterator_map itr = variant.begin_map(); itr != variant.end_map(); ++itr)
{
*this << itr->first;
*this << itr->second;
View
4 xbmc/utils/Archive.h
@@ -139,8 +139,8 @@ class CArchive
CArchive& operator>>(std::vector<std::string>& strArray);
CArchive& operator>>(std::vector<int>& iArray);
- bool IsLoading();
- bool IsStoring();
+ bool IsLoading() const;
+ bool IsStoring() const;
void Close();
View
8 xbmc/utils/BitstreamConverter.cpp
@@ -519,7 +519,7 @@ bool CBitstreamConverter::Convert(uint8_t *pData, int iSize)
}
-uint8_t *CBitstreamConverter::GetConvertBuffer()
+uint8_t *CBitstreamConverter::GetConvertBuffer() const
{
if((m_convert_bitstream || m_convert_bytestream || m_convert_3byteTo4byteNALSize) && m_convertBuffer != NULL)
return m_convertBuffer;
@@ -527,7 +527,7 @@ uint8_t *CBitstreamConverter::GetConvertBuffer()
return m_inputBuffer;
}
-int CBitstreamConverter::GetConvertSize()
+int CBitstreamConverter::GetConvertSize() const
{
if((m_convert_bitstream || m_convert_bytestream || m_convert_3byteTo4byteNALSize) && m_convertBuffer != NULL)
return m_convertSize;
@@ -535,14 +535,14 @@ int CBitstreamConverter::GetConvertSize()
return m_inputSize;
}
-uint8_t *CBitstreamConverter::GetExtraData()
+uint8_t *CBitstreamConverter::GetExtraData() const
{
if(m_convert_bitstream)
return m_sps_pps_context.sps_pps_data;
else
return m_extradata;
}
-int CBitstreamConverter::GetExtraSize()
+int CBitstreamConverter::GetExtraSize() const
{
if(m_convert_bitstream)
return m_sps_pps_context.size;
View
24 xbmc/utils/BitstreamConverter.h
@@ -136,12 +136,12 @@ class CBitstreamParser
CBitstreamParser();
~CBitstreamParser();
- bool Open();
- void Close();
- bool FindIdrSlice(const uint8_t *buf, int buf_size);
+ static bool Open();
+ static void Close();
+ static bool FindIdrSlice(const uint8_t *buf, int buf_size);
protected:
- const uint8_t* find_start_code(const uint8_t *p, const uint8_t *end, uint32_t *state);
+ static const uint8_t* find_start_code(const uint8_t *p, const uint8_t *end, uint32_t *state);
};
class CBitstreamConverter
@@ -152,12 +152,12 @@ class CBitstreamConverter
bool Open(enum AVCodecID codec, uint8_t *in_extradata, int in_extrasize, bool to_annexb);
void Close(void);
- bool NeedConvert(void) { return m_convert_bitstream; };
+ bool NeedConvert(void) const { return m_convert_bitstream; };
bool Convert(uint8_t *pData, int iSize);
- uint8_t* GetConvertBuffer(void);
- int GetConvertSize();
- uint8_t* GetExtraData(void);
- int GetExtraSize();
+ uint8_t* GetConvertBuffer(void) const;
+ int GetConvertSize() const;
+ uint8_t* GetExtraData(void) const;
+ int GetExtraSize() const;
static void bits_reader_set( bits_reader_t *br, uint8_t *buf, int len );
static uint32_t read_bits( bits_reader_t *br, int nbits );
@@ -173,13 +173,13 @@ class CBitstreamConverter
static bool mpeg2_sequence_header(const uint8_t *data, const uint32_t size, mpeg2_sequence *sequence);
protected:
- const int avc_parse_nal_units(AVIOContext *pb, const uint8_t *buf_in, int size);
- const int avc_parse_nal_units_buf(const uint8_t *buf_in, uint8_t **buf, int *size);
+ static const int avc_parse_nal_units(AVIOContext *pb, const uint8_t *buf_in, int size);
+ static const int avc_parse_nal_units_buf(const uint8_t *buf_in, uint8_t **buf, int *size);
const int isom_write_avcc(AVIOContext *pb, const uint8_t *data, int len);
// bitstream to bytestream (Annex B) conversion support.
bool BitstreamConvertInit(void *in_extradata, int in_extrasize);
bool BitstreamConvert(uint8_t* pData, int iSize, uint8_t **poutbuf, int *poutbuf_size);
- void BitstreamAllocAndCopy(uint8_t **poutbuf, int *poutbuf_size,
+ static void BitstreamAllocAndCopy(uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *sps_pps, uint32_t sps_pps_size, const uint8_t *in, uint32_t in_size);
typedef struct omx_bitstream_ctx {
View
2  xbmc/utils/CPUInfo.cpp
@@ -196,7 +196,6 @@ CCPUInfo::CCPUInfo(void)
}
subKeyNameLen = sizeof(subKeyName) / sizeof(wchar_t); // restore length value
}
- DWORD err = GetLastError();
RegCloseKey(hKeyCpuRoot);
std::sort(cpuCores.begin(), cpuCores.end()); // sort cores by id
for (size_t i = 0; i < cpuCores.size(); i++)
@@ -512,7 +511,6 @@ float CCPUInfo::getCPUFrequency()
return 0.f;
return hz / 1000000.0;
#elif defined TARGET_WINDOWS
- float retVal = 0;
if (m_cpuFreqCounter && PdhCollectQueryData(m_cpuQueryFreq) == ERROR_SUCCESS)
{
PDH_RAW_COUNTER cnt;
View
8 xbmc/utils/CPUInfo.h
@@ -74,7 +74,7 @@ struct CoreInfo
#elif defined(TARGET_WINDOWS)
CoreInfo() : m_id(0), m_fSpeed(.0), m_fPct(.0), m_coreCounter(NULL), m_total(0LL), m_idle(0LL) {}
#endif
- bool operator<(const CoreInfo& other) { return m_id < other.m_id; }
+ bool operator<(const CoreInfo& other) const { return m_id < other.m_id; }
};
class CCPUInfo
@@ -84,7 +84,7 @@ class CCPUInfo
~CCPUInfo();
int getUsedPercentage();
- int getCPUCount() { return m_cpuCount; }
+ int getCPUCount() const { return m_cpuCount; }
float getCPUFrequency();
bool getTemperature(CTemperature& temperature);
std::string& getCPUModel() { return m_cpuModel; }
@@ -98,13 +98,13 @@ class CCPUInfo
std::string GetCoresUsageString() const;
- unsigned int GetCPUFeatures() { return m_cpuFeatures; }
+ unsigned int GetCPUFeatures() const { return m_cpuFeatures; }
private:
bool readProcStat(unsigned long long& user, unsigned long long& nice, unsigned long long& system,
unsigned long long& idle, unsigned long long& io);
void ReadCPUFeatures();
- bool HasNeon();
+ static bool HasNeon();
#ifdef TARGET_POSIX
FILE* m_fProcStat;
View
4 xbmc/utils/CryptThreading.h
@@ -34,6 +34,10 @@ class CryptThreadingInitializer
~CryptThreadingInitializer();
CCriticalSection* get_lock(int index);
+
+private:
+ CryptThreadingInitializer(const CryptThreadingInitializer &rhs);
+ CryptThreadingInitializer& operator=(const CryptThreadingInitializer&);
};
XBMC_GLOBAL_REF(CryptThreadingInitializer,g_cryptThreadingInitializer);
View
6 xbmc/utils/DatabaseUtils.cpp
@@ -286,7 +286,7 @@ bool DatabaseUtils::GetSelectFields(const Fields &fields, const MediaType &media
sortFields.insert(FieldArtist);
selectFields.clear();
- for (Fields::const_iterator it = sortFields.begin(); it != sortFields.end(); it++)
+ for (Fields::const_iterator it = sortFields.begin(); it != sortFields.end(); ++it)
{
// ignore FieldLabel because it needs special handling (see further up)
if (*it == FieldLabel)
@@ -377,7 +377,7 @@ bool DatabaseUtils::GetDatabaseResults(const MediaType &mediaType, const FieldLi
std::vector<int> fieldIndexLookup;
fieldIndexLookup.reserve(fields.size());
- for (FieldList::const_iterator it = fields.begin(); it != fields.end(); it++)
+ for (FieldList::const_iterator it = fields.begin(); it != fields.end(); ++it)
fieldIndexLookup.push_back(GetFieldIndex(*it, mediaType));
results.reserve(resultSet.records.size() + offset);
@@ -387,7 +387,7 @@ bool DatabaseUtils::GetDatabaseResults(const MediaType &mediaType, const FieldLi
result[FieldRow] = index + offset;
unsigned int lookupIndex = 0;
- for (FieldList::const_iterator it = fields.begin(); it != fields.end(); it++)
+ for (FieldList::const_iterator it = fields.begin(); it != fields.end(); ++it)
{
int fieldIndex = fieldIndexLookup[lookupIndex++];
if (fieldIndex < 0)
View
2  xbmc/utils/Fanart.cpp
@@ -128,7 +128,7 @@ bool CFanart::SetPrimaryFanart(unsigned int index)
return true;
}
-unsigned int CFanart::GetNumFanarts()
+unsigned int CFanart::GetNumFanarts() const
{
return m_fanart.size();
}
View
4 xbmc/utils/Fanart.h
@@ -81,7 +81,7 @@ class CFanart
///
/// Returns how many fanarts are stored
/// \return An integer indicating how many fanarts are stored in the class. Fanart indices are 0 to (GetNumFanarts() - 1)
- unsigned int GetNumFanarts();
+ unsigned int GetNumFanarts() const;
///
/// m_xml contains an XML formatted string which is all fanart packed into one string.
///
@@ -102,7 +102,7 @@ class CFanart
/// \param colorsIn: CStdString containing a string of colors in some format to be converted
/// \param colorsOut: XBMC ARGB Hexadecimal string comma seperated "FFFFFFFF,DDDDDDDD,AAAAAAAA"
/// \return boolean indicating success or failure.
- bool ParseColors(const CStdString &colorsIn, CStdString &colorsOut);
+ static bool ParseColors(const CStdString &colorsIn, CStdString &colorsOut);
struct SFanartData
{
View
3  xbmc/utils/FileOperationJob.cpp
@@ -43,6 +43,9 @@ using namespace XFILE;
CFileOperationJob::CFileOperationJob()
{
+ m_action = ActionCopy;
+ m_heading = 0;
+ m_line = 0;
m_handle = NULL;
m_displayProgress = false;
}
View
8 xbmc/utils/FileOperationJob.h
@@ -54,10 +54,10 @@ class CFileOperationJob : public CJob
const char* GetType() const { return m_displayProgress?"filemanager":""; }
virtual bool DoWork();
- const CStdString &GetAverageSpeed() { return m_avgSpeed; }
- const CStdString &GetCurrentOperation() { return m_currentOperation; }
- const CStdString &GetCurrentFile() { return m_currentFile; }
- const CFileItemList &GetItems() { return m_items; }
+ const CStdString &GetAverageSpeed() const { return m_avgSpeed; }
+ const CStdString &GetCurrentOperation() const { return m_currentOperation; }
+ const CStdString &GetCurrentFile() const { return m_currentFile; }
+ const CFileItemList &GetItems() const { return m_items; }
FileAction GetAction() const { return m_action; }
int GetHeading() const { return m_heading; }
int GetLine() const { return m_line; }
View
4 xbmc/utils/GroupUtils.cpp
@@ -67,7 +67,7 @@ bool GroupUtils::Group(GroupBy groupBy, const std::string &baseDir, const CFileI
if (!itemsUrl.FromString(baseDir))
return false;
- for (SetMap::const_iterator set = setMap.begin(); set != setMap.end(); set++)
+ for (SetMap::const_iterator set = setMap.begin(); set != setMap.end(); ++set)
{
// only one item in the set, so just re-add it
if (set->second.size() == 1 && (groupAttributes & GroupAttributeIgnoreSingleItems))
@@ -98,7 +98,7 @@ bool GroupUtils::Group(GroupBy groupBy, const std::string &baseDir, const CFileI
int ratings = 0;
int iWatched = 0; // have all the movies been played at least once?
std::set<CStdString> pathSet;
- for (std::set<CFileItemPtr>::const_iterator movie = set->second.begin(); movie != set->second.end(); movie++)
+ for (std::set<CFileItemPtr>::const_iterator movie = set->second.begin(); movie != set->second.end(); ++movie)
{
CVideoInfoTag* movieInfo = (*movie)->GetVideoInfoTag();
// handle rating
View
4 xbmc/utils/HTMLUtil.cpp
@@ -31,7 +31,7 @@ CHTMLUtil::CHTMLUtil(void)
CHTMLUtil::~CHTMLUtil(void)
{}
-int CHTMLUtil::FindTag(const CStdString& strHTML, const CStdString& strTag, CStdString& strtagFound, int iPos) const
+int CHTMLUtil::FindTag(const CStdString& strHTML, const CStdString& strTag, CStdString& strtagFound, int iPos)
{
CStdString strHTMLLow = strHTML;
CStdString strTagLow = strTag;
@@ -51,7 +51,7 @@ int CHTMLUtil::FindTag(const CStdString& strHTML, const CStdString& strTag, CStd
return iStart;
}
-int CHTMLUtil::FindClosingTag(const CStdString& strHTML, const CStdString& strTag, CStdString& strtagFound, int iPos) const
+int CHTMLUtil::FindClosingTag(const CStdString& strHTML, const CStdString& strTag, CStdString& strtagFound, int iPos)
{
CStdString strHTMLLow = strHTML;
CStdString strTagLow = strTag;
View
8 xbmc/utils/HTMLUtil.h
@@ -29,10 +29,10 @@ class CHTMLUtil
public:
CHTMLUtil(void);
virtual ~CHTMLUtil(void);
- int FindTag(const CStdString& strHTML, const CStdString& strTag, CStdString& strtagFound, int iPos = 0) const;
- int FindClosingTag(const CStdString& strHTML, const CStdString& strTag, CStdString& strtagFound, int iPos) const;
- void getValueOfTag(const CStdString& strTagAndValue, CStdString& strValue);
- void getAttributeOfTag(const CStdString& strTagAndValue, const CStdString& strTag, CStdString& strValue);
+ static int FindTag(const CStdString& strHTML, const CStdString& strTag, CStdString& strtagFound, int iPos = 0);
+ static int FindClosingTag(const CStdString& strHTML, const CStdString& strTag, CStdString& strtagFound, int iPos);
+ static void getValueOfTag(const CStdString& strTagAndValue, CStdString& strValue);
+ static void getAttributeOfTag(const CStdString& strTagAndValue, const CStdString& strTag, CStdString& strValue);
static void RemoveTags(CStdString& strHTML);
static void ConvertHTMLToW(const CStdStringW& strHTML, CStdStringW& strStripped);
};
View
14 xbmc/utils/HttpParser.cpp
@@ -206,19 +206,19 @@ HttpParser::addBytes( const char* bytes, unsigned len )
}
const char*
-HttpParser::getMethod()
+HttpParser::getMethod() const
{
return &_data[0];
}
const char*
-HttpParser::getUri()
+HttpParser::getUri() const
{
return &_data[_uriIndex];
}
const char*
-HttpParser::getQueryString()
+HttpParser::getQueryString() const
{
const char* pos = getUri();
while( *pos ) {
@@ -232,7 +232,7 @@ HttpParser::getQueryString()
}
const char*
-HttpParser::getBody()
+HttpParser::getBody() const
{
if ( _contentLength > 0 ) {
return &_data[_contentStart];
@@ -243,9 +243,9 @@ HttpParser::getBody()
// key should be in lower case.
const char*
-HttpParser::getValue( const char* key )
+HttpParser::getValue( const char* key ) const
{
- for( IntArray::iterator iter = _keys.begin();
+ for( IntArray::const_iterator iter = _keys.begin();
iter != _keys.end(); ++iter )
{
unsigned index = *iter;
@@ -259,7 +259,7 @@ HttpParser::getValue( const char* key )
}
unsigned
-HttpParser::getContentLength()
+HttpParser::getContentLength() const
{
return _contentLength;
}
View
12 xbmc/utils/HttpParser.h
@@ -65,13 +65,13 @@ class HttpParser
status_t addBytes( const char* bytes, unsigned len );
- const char* getMethod();
- const char* getUri();
- const char* getQueryString();
- const char* getBody();
+ const char* getMethod() const;
+ const char* getUri() const;
+ const char* getQueryString() const;
+ const char* getBody() const;
// key should be in lower case when looking up.
- const char* getValue( const char* key );
- unsigned getContentLength();
+ const char* getValue( const char* key ) const;
+ unsigned getContentLength() const;
private:
void parseHeader();
View
4 xbmc/utils/JSONVariantWriter.cpp
@@ -102,7 +102,7 @@ bool CJSONVariantWriter::InternalWrite(yajl_gen g, const CVariant &value)
case CVariant::VariantTypeArray:
success = yajl_gen_status_ok == yajl_gen_array_open(g);
- for (CVariant::const_iterator_array itr = value.begin_array(); itr != value.end_array() && success; itr++)
+ for (CVariant::const_iterator_array itr = value.begin_array(); itr != value.end_array() && success; ++itr)
success &= InternalWrite(g, *itr);
if (success)
@@ -112,7 +112,7 @@ bool CJSONVariantWriter::InternalWrite(yajl_gen g, const CVariant &value)
case CVariant::VariantTypeObject:
success = yajl_gen_status_ok == yajl_gen_map_open(g);
- for (CVariant::const_iterator_map itr = value.begin_map(); itr != value.end_map() && success; itr++)
+ for (CVariant::const_iterator_map itr = value.begin_map(); itr != value.end_map() && success; ++itr)
{
#if YAJL_MAJOR == 2
success &= yajl_gen_status_ok == yajl_gen_string(g, (const unsigned char*)itr->first.c_str(), (size_t)itr->first.length());
View
6 xbmc/utils/JobManager.cpp
@@ -320,7 +320,7 @@ bool CJobManager::IsProcessing(const CJob::PRIORITY &priority) const
if (m_pauseJobs)
return false;
- for(Processing::const_iterator it = m_processing.begin(); it < m_processing.end(); it++)
+ for(Processing::const_iterator it = m_processing.begin(); it < m_processing.end(); ++it)
{
if (priority == it->m_priority)
return true;
@@ -336,7 +336,7 @@ int CJobManager::IsProcessing(const std::string &type) const
if (m_pauseJobs)
return 0;
- for(Processing::const_iterator it = m_processing.begin(); it < m_processing.end(); it++)
+ for(Processing::const_iterator it = m_processing.begin(); it < m_processing.end(); ++it)
{
if (type == std::string(it->m_job->GetType()))
jobsMatched++;
@@ -425,7 +425,7 @@ void CJobManager::RemoveWorker(const CJobWorker *worker)
m_workers.erase(i); // workers auto-delete
}
-unsigned int CJobManager::GetMaxWorkers(CJob::PRIORITY priority) const
+unsigned int CJobManager::GetMaxWorkers(CJob::PRIORITY priority)
{
static const unsigned int max_workers = 5;
return max_workers - (CJob::PRIORITY_HIGH - priority);
View
2  xbmc/utils/JobManager.h
@@ -314,7 +314,7 @@ class CJobManager
void StartWorkers(CJob::PRIORITY priority);
void RemoveWorker(const CJobWorker *worker);
- unsigned int GetMaxWorkers(CJob::PRIORITY priority) const;
+ static unsigned int GetMaxWorkers(CJob::PRIORITY priority);
unsigned int m_jobCounter;
View
22 xbmc/utils/LabelFormatter.h
@@ -32,13 +32,12 @@ class CFileItem; // forward
struct LABEL_MASKS
{
- LABEL_MASKS(const CStdString& strLabelFile="", const CStdString& strLabel2File="", const CStdString& strLabelFolder="", const CStdString& strLabel2Folder="")
- {
- m_strLabelFile=strLabelFile;
- m_strLabel2File=strLabel2File;
- m_strLabelFolder=strLabelFolder;
- m_strLabel2Folder=strLabel2Folder;
- }
+ LABEL_MASKS(const CStdString& strLabelFile="", const CStdString& strLabel2File="", const CStdString& strLabelFolder="", const CStdString& strLabel2Folder="") :
+ m_strLabelFile(strLabelFile),
+ m_strLabel2File(strLabel2File),
+ m_strLabelFolder(strLabelFolder),
+ m_strLabel2Folder(strLabel2Folder)
+ {}
CStdString m_strLabelFile;
CStdString m_strLabel2File;
CStdString m_strLabelFolder;
@@ -64,10 +63,11 @@ class CLabelFormatter
class CMaskString
{
public:
- CMaskString(const CStdString &prefix, char content, const CStdString &postfix)
- {
- m_prefix = prefix; m_content = content; m_postfix = postfix;
- };
+ CMaskString(const CStdString &prefix, char content, const CStdString &postfix) :
+ m_prefix(prefix),
+ m_postfix(postfix),
+ m_content(content)
+ {};
CStdString m_prefix;
CStdString m_postfix;
char m_content;
View
4 xbmc/utils/LangCodeExpander.cpp
@@ -327,7 +327,7 @@ bool CLangCodeExpander::ReverseLookup(const CStdString& desc, CStdString& code)
CStdString descTmp(desc);
StringUtils::Trim(descTmp);
STRINGLOOKUPTABLE::iterator it;
- for (it = m_mapUser.begin(); it != m_mapUser.end() ; it++)
+ for (it = m_mapUser.begin(); it != m_mapUser.end() ; ++it)
{
if (descTmp.Equals(it->second))
{
@@ -446,7 +446,7 @@ bool CLangCodeExpander::CompareFullLangNames(const CStdString& lang1, const CStd
return expandedLang1.Equals(expandedLang2);
}
-std::vector<std::string> CLangCodeExpander::GetLanguageNames(LANGFORMATS format /* = CLangCodeExpander::ISO_639_1 */) const
+std::vector<std::string> CLangCodeExpander::GetLanguageNames(LANGFORMATS format /* = CLangCodeExpander::ISO_639_1 */)
{
std::vector<std::string> languages;
const LCENTRY *lang = g_iso639_1;
View
14 xbmc/utils/LangCodeExpander.h
@@ -74,18 +74,18 @@ class CLangCodeExpander
* \return The 3-Char ISO 639-2/T code of lang if that code exists, lang otherwise.
*/
CStdString ConvertToISO6392T(const CStdString& lang);
- bool ConvertTwoToThreeCharCode(CStdString& strThreeCharCode, const CStdString& strTwoCharCode, bool checkWin32Locales = false);
- bool ConvertToThreeCharCode(CStdString& strThreeCharCode, const CStdString& strCharCode, bool checkXbmcLocales = true, bool checkWin32Locales = false);
+ static bool ConvertTwoToThreeCharCode(CStdString& strThreeCharCode, const CStdString& strTwoCharCode, bool checkWin32Locales = false);
+ static bool ConvertToThreeCharCode(CStdString& strThreeCharCode, const CStdString& strCharCode, bool checkXbmcLocales = true, bool checkWin32Locales = false);
#ifdef TARGET_WINDOWS
- bool ConvertLinuxToWindowsRegionCodes(const CStdString& strTwoCharCode, CStdString& strThreeCharCode);
- bool ConvertWindowsToGeneralCharCode(const CStdString& strWindowsCharCode, CStdString& strThreeCharCode);
+ static bool ConvertLinuxToWindowsRegionCodes(const CStdString& strTwoCharCode, CStdString& strThreeCharCode);
+ static bool ConvertWindowsToGeneralCharCode(const CStdString& strWindowsCharCode, CStdString& strThreeCharCode);
#endif
void LoadUserCodes(const TiXmlElement* pRootElement);
void Clear();
- std::vector<std::string> GetLanguageNames(LANGFORMATS format = ISO_639_1) const;
+ static std::vector<std::string> GetLanguageNames(LANGFORMATS format = ISO_639_1);
protected:
/** \brief Converts a language code given as a long, see #MAKECODE(a, b, c, d)
@@ -93,12 +93,12 @@ class CLangCodeExpander
* \param[in] code The language code given as a long, see #MAKECODE(a, b, c, d).
* \param[out] ret The string representation of the given language code code.
*/
- void CodeToString(long code, CStdString& ret);
+ static void CodeToString(long code, CStdString& ret);
typedef std::map<CStdString, CStdString> STRINGLOOKUPTABLE;
STRINGLOOKUPTABLE m_mapUser;
- bool LookupInDb(CStdString& desc, const CStdString& code);
+ static bool LookupInDb(CStdString& desc, const CStdString& code);
bool LookupInMap(CStdString& desc, const CStdString& code);
/** \brief Looks up the ISO 639-1, ISO 639-2/T, or ISO 639-2/B, whichever it finds first,
View
2  xbmc/utils/POUtils.cpp
@@ -312,7 +312,7 @@ void CPODocument::ConvertLineEnds(const std::string &filename)
std::string strTemp;
strTemp.reserve(m_strBuffer.size());
- for (std::string::const_iterator it = m_strBuffer.begin(); it < m_strBuffer.end(); it++)
+ for (std::string::const_iterator it = m_strBuffer.begin(); it < m_strBuffer.end(); ++it)
{
if (*it == '\r')
{
View
3  xbmc/utils/PerformanceSample.cpp
@@ -33,9 +33,8 @@ using namespace std;
int64_t CPerformanceSample::m_tmFreq;
-CPerformanceSample::CPerformanceSample(const string &statName, bool bCheckWhenDone)
+CPerformanceSample::CPerformanceSample(const string &statName, bool bCheckWhenDone) : m_statName(statName)
{
- m_statName = statName;
m_bCheckWhenDone = bCheckWhenDone;
if (m_tmFreq == 0LL)
m_tmFreq = CurrentHostFrequency();
View
4 xbmc/utils/PerformanceStats.cpp
@@ -35,7 +35,7 @@ CPerformanceStats::~CPerformanceStats()
while (iter != m_mapStats.end())
{
delete iter->second;
- iter++;
+ ++iter;
}
m_mapStats.clear();
}
@@ -71,7 +71,7 @@ void CPerformanceStats::DumpStats()
double dAvgSys = iter->second->m_sys / (double)iter->second->m_samples;
CLog::Log(LOGINFO, "%s - counter <%s>. avg duration: <%f sec>, avg user: <%f>, avg sys: <%f> (%"PRIu64" samples)",
__FUNCTION__, iter->first.c_str(), dAvg, dAvgUser, dAvgSys, iter->second->m_samples);
- iter++;
+ ++iter;
}
}
View
6 xbmc/utils/RecentlyAddedJob.h
@@ -32,9 +32,9 @@ class CRecentlyAddedJob : public CJob
{
public:
CRecentlyAddedJob(int flag);
- bool UpdateVideo();
- bool UpdateMusic();
- bool UpdateTotal();
+ static bool UpdateVideo();
+ static bool UpdateMusic();
+ static bool UpdateTotal();
virtual bool DoWork();
private:
int m_flag;
View
2  xbmc/utils/RegExp.cpp
@@ -243,7 +243,7 @@ CRegExp::CRegExp(const CRegExp& re)
*this = re;
}
-const CRegExp& CRegExp::operator=(const CRegExp& re)
+CRegExp& CRegExp::operator=(const CRegExp& re)
{
size_t size;
Cleanup();
View
4 xbmc/utils/RegExp.h
@@ -140,9 +140,9 @@ class CRegExp
* Check is RegExp object is ready for matching
* @return true if RegExp object is ready for matching, false otherwise
*/
- inline bool IsCompiled(void)
+ inline bool IsCompiled(void) const
{ return !m_pattern.empty(); }
- const CRegExp& operator= (const CRegExp& re);
+ CRegExp& operator= (const CRegExp& re);
static bool IsUtf8Supported(void);
static bool AreUnicodePropertiesSupported(void);
static bool LogCheckUtf8Support(void);
View
2  xbmc/utils/RingBuffer.cpp
@@ -233,7 +233,7 @@ unsigned int CRingBuffer::getSize()
return m_size;
}
-unsigned int CRingBuffer::getReadPtr()
+unsigned int CRingBuffer::getReadPtr() const
{
return m_readPtr;
}
View
2  xbmc/utils/RingBuffer.h
@@ -44,7 +44,7 @@ class CRingBuffer
bool Copy(CRingBuffer &rBuf);
char *getBuffer();
unsigned int getSize();
- unsigned int getReadPtr();
+ unsigned int getReadPtr() const;
unsigned int getWritePtr();
unsigned int getMaxReadSize();
unsigned int getMaxWriteSize();
View
4 xbmc/utils/RssManager.h
@@ -61,11 +61,11 @@ class CRssManager : public ISettingCallback, public ISettingsHandler
protected:
CRssManager();
- CRssManager(const CRssManager&);
- CRssManager const& operator=(CRssManager const&);
~CRssManager();
private:
+ CRssManager(const CRssManager&);
+ CRssManager& operator=(const CRssManager&);
struct READERCONTROL
{
int controlID;
View
4 xbmc/utils/RssReader.cpp
@@ -269,7 +269,7 @@ void CRssReader::GetNewsItems(TiXmlElement* channelXmlNode, int iFeed)
{
CStdString strName = childNode->Value();
- for (i = m_tagSet.begin(); i != m_tagSet.end(); i++)
+ for (i = m_tagSet.begin(); i != m_tagSet.end(); ++i)
{
if (!childNode->NoChildren() && i->Equals(strName))
{
@@ -295,7 +295,7 @@ void CRssReader::GetNewsItems(TiXmlElement* channelXmlNode, int iFeed)
}
int rsscolour = RSS_COLOR_HEADLINE;
- for (i = m_tagSet.begin(); i != m_tagSet.end(); i++)
+ for (i = m_tagSet.begin(); i != m_tagSet.end(); ++i)
{
map <CStdString, CStdStringW>::iterator j = mTagElements.find(*i);
View
4 xbmc/utils/ScraperParser.h
@@ -45,10 +45,10 @@ class CScraperParser
~CScraperParser();
CScraperParser& operator= (const CScraperParser& parser);
bool Load(const CStdString& strXMLFile);
- bool IsNoop() { return m_isNoop; };
+ bool IsNoop() const { return m_isNoop; };
void Clear();
- const CStdString GetFilename() { return m_strFile; }
+ const CStdString& GetFilename() const { return m_strFile; }
CStdString GetSearchStringEncoding() const
{ return m_SearchStringEncoding; }
const CStdString Parse(const CStdString& strTag,
View
7 xbmc/utils/Screenshot.cpp
@@ -58,6 +58,11 @@ CScreenshotSurface::CScreenshotSurface()
m_buffer = NULL;
}
+CScreenshotSurface::~CScreenshotSurface()
+{
+ delete m_buffer;
+}
+
bool CScreenshotSurface::capture()
{
#if defined(TARGET_RASPBERRY_PI)
@@ -193,6 +198,7 @@ void CScreenShot::TakeScreenshot(const CStdString &filename, bool sync)
CLog::Log(LOGERROR, "Unable to write screenshot %s", filename.c_str());
delete [] surface.m_buffer;
+ surface.m_buffer = NULL;
}
else
{
@@ -207,6 +213,7 @@ void CScreenShot::TakeScreenshot(const CStdString &filename, bool sync)
//buffer is deleted from CThumbnailWriter
CThumbnailWriter* thumbnailwriter = new CThumbnailWriter(surface.m_buffer, surface.m_width, surface.m_height, surface.m_stride, filename);
CJobManager::GetInstance().AddJob(thumbnailwriter, NULL);
+ surface.m_buffer = NULL;
}
}
View
1  xbmc/utils/Screenshot.h
@@ -31,6 +31,7 @@ class CScreenshotSurface
unsigned char* m_buffer;
CScreenshotSurface(void);
+ ~CScreenshotSurface();
bool capture( void );
};
View
8 xbmc/utils/SortUtils.cpp
@@ -628,10 +628,10 @@ void SortUtils::Sort(SortBy sortBy, SortOrder sortOrder, SortAttribute attribute
Fields sortingFields = GetFieldsForSorting(sortBy);
// Prepare the string used for sorting and store it under FieldSort
- for (DatabaseResults::iterator item = items.begin(); item != items.end(); item++)
+ for (DatabaseResults::iterator item = items.begin(); item != items.end(); ++item)
{
// add all fields to the item that are required for sorting if they are currently missing
- for (Fields::const_iterator field = sortingFields.begin(); field != sortingFields.end(); field++)
+ for (Fields::const_iterator field = sortingFields.begin(); field != sortingFields.end(); ++field)
{
if (item->find(*field) == item->end())
item->insert(pair<Field, CVariant>(*field, CVariant::ConstNullVariant));
@@ -667,10 +667,10 @@ void SortUtils::Sort(SortBy sortBy, SortOrder sortOrder, SortAttribute attribute
Fields sortingFields = GetFieldsForSorting(sortBy);
// Prepare the string used for sorting and store it under FieldSort
- for (SortItems::iterator item = items.begin(); item != items.end(); item++)
+ for (SortItems::iterator item = items.begin(); item != items.end(); ++item)
{
// add all fields to the item that are required for sorting if they are currently missing
- for (Fields::const_iterator field = sortingFields.begin(); field != sortingFields.end(); field++)
+ for (Fields::const_iterator field = sortingFields.begin(); field != sortingFields.end(); ++field)
{
if ((*item)->find(*field) == (*item)->end())
(*item)->insert(pair<Field, CVariant>(*field, CVariant::ConstNullVariant));
View
3  xbmc/utils/Splash.cpp
@@ -30,9 +30,8 @@
using namespace XFILE;
-CSplash::CSplash(const CStdString& imageName) : CThread("Splash")
+CSplash::CSplash(const CStdString& imageName) : CThread("Splash"), m_ImageName(imageName)
{
- m_ImageName = imageName;
fade = 0.5;
m_messageLayout = NULL;
m_image = NULL;
View
26 xbmc/utils/StdString.h
@@ -862,16 +862,11 @@ inline const Type& SSMAX(const Type& arg1, const Type& arg2)
{
PCSTR pNextSrcA = pSrcA;
PWSTR pNextDstW = pDstW;
- SSCodeCvt::result res = SSCodeCvt::ok;
const SSCodeCvt& conv = SS_USE_FACET(loc, SSCodeCvt);
-#if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD)
- SSCodeCvt::state_type st= { { 0 } };
-#else
- SSCodeCvt::state_type st= { 0 };
-#endif
- res = conv.in(st,
- pSrcA, pSrcA + nSrc, pNextSrcA,
- pDstW, pDstW + nDst, pNextDstW);
+ SSCodeCvt::state_type st= {};
+ SSCodeCvt::result res = conv.in(st,
+ pSrcA, pSrcA + nSrc, pNextSrcA,
+ pDstW, pDstW + nDst, pNextDstW);
#ifdef TARGET_POSIX
#define ASSERT2(a) if (!(a)) {fprintf(stderr, "StdString: Assertion Failed on line %d\n", __LINE__);}
#else
@@ -909,16 +904,11 @@ inline const Type& SSMAX(const Type& arg1, const Type& arg2)
{
PSTR pNextDstA = pDstA;
PCWSTR pNextSrcW = pSrcW;
- SSCodeCvt::result res = SSCodeCvt::ok;
const SSCodeCvt& conv = SS_USE_FACET(loc, SSCodeCvt);
-#if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD)
- SSCodeCvt::state_type st= { { 0 } };
-#else
- SSCodeCvt::state_type st= { 0 };
-#endif
- res = conv.out(st,
- pSrcW, pSrcW + nSrc, pNextSrcW,
- pDstA, pDstA + nDst, pNextDstA);
+ SSCodeCvt::state_type st= {};
+ SSCodeCvt::result res = conv.out(st,
+ pSrcW, pSrcW + nSrc, pNextSrcW,
+ pDstA, pDstA + nDst, pNextDstA);
#ifdef TARGET_POSIX
#define ASSERT2(a) if (!(a)) {fprintf(stderr, "StdString: Assertion Failed on line %d\n", __LINE__);}
#else
View
13 xbmc/utils/Stopwatch.cpp
@@ -32,19 +32,14 @@ CStopWatch::CStopWatch(bool useFrameTime /*=false*/)
m_isRunning = false;
m_useFrameTime = useFrameTime;
+#ifdef TARGET_POSIX
+ m_timerPeriod = 1.0f / 1000.0f; // we want seconds
+#else
if (m_useFrameTime)
- {
m_timerPeriod = 1.0f / 1000.0f; //frametime is in milliseconds
- }
else
- {
- // Get the timer frequency (ticks per second)
-#ifndef TARGET_POSIX
- m_timerPeriod = 1.0f / (float)CurrentHostFrequency();
-#else
- m_timerPeriod = 1.0f / 1000.0f; // we want seconds
+ m_timerPeriod = 1.0f / (float)CurrentHostFrequency();
#endif
- }
}
CStopWatch::~CStopWatch()
View
14 xbmc/utils/StreamDetails.cpp
@@ -180,7 +180,7 @@ CStreamDetails& CStreamDetails::operator=(const CStreamDetails &that)
{
Reset();
std::vector<CStreamDetail *>::const_iterator iter;
- for (iter = that.m_vecItems.begin(); iter != that.m_vecItems.end(); iter++)
+ for (iter = that.m_vecItems.begin(); iter != that.m_vecItems.end(); ++iter)
{
switch ((*iter)->m_eType)
{
@@ -271,7 +271,7 @@ int CStreamDetails::GetStreamCount(CStreamDetail::StreamType type) const
{
int retVal = 0;
std::vector<CStreamDetail *>::const_iterator iter;
- for (iter = m_vecItems.begin(); iter != m_vecItems.end(); iter++)
+ for (iter = m_vecItems.begin(); iter != m_vecItems.end(); ++iter)
if ((*iter)->m_eType == type)
retVal++;
return retVal;
@@ -310,7 +310,7 @@ void CStreamDetails::Reset(void)
m_pBestSubtitle = NULL;
std::vector<CStreamDetail *>::iterator iter;
- for (iter = m_vecItems.begin(); iter != m_vecItems.end(); iter++)
+ for (iter = m_vecItems.begin(); iter != m_vecItems.end(); ++iter)
delete *iter;
m_vecItems.clear();
}
@@ -337,7 +337,7 @@ const CStreamDetail* CStreamDetails::GetNthStream(CStreamDetail::StreamType type
}
std::vector<CStreamDetail *>::const_iterator iter;
- for (iter = m_vecItems.begin(); iter != m_vecItems.end(); iter++)
+ for (iter = m_vecItems.begin(); iter != m_vecItems.end(); ++iter)
if ((*iter)->m_eType == type)
{
idx--;
@@ -452,7 +452,7 @@ void CStreamDetails::Archive(CArchive& ar)
ar << (int)m_vecItems.size();
std::vector<CStreamDetail *>::const_iterator iter;
- for (iter = m_vecItems.begin(); iter != m_vecItems.end(); iter++)
+ for (iter = m_vecItems.begin(); iter != m_vecItems.end(); ++iter)
{
// the type goes before the actual item. When loading we need
// to know the type before we can construct an instance to serialize
@@ -489,7 +489,7 @@ void CStreamDetails::Serialize(CVariant& value) const
std::vector<CStreamDetail *>::const_iterator iter;
CVariant v;
- for (iter = m_vecItems.begin(); iter != m_vecItems.end(); iter++)
+ for (iter = m_vecItems.begin(); iter != m_vecItems.end(); ++iter)
{
v.clear();
(*iter)->Serialize(v);
@@ -515,7 +515,7 @@ void CStreamDetails::DetermineBestStreams(void)
m_pBestSubtitle = NULL;
std::vector<CStreamDetail *>::const_iterator iter;
- for (iter = m_vecItems.begin(); iter != m_vecItems.end(); iter++)
+ for (iter = m_vecItems.begin(); iter != m_vecItems.end(); ++iter)
{
CStreamDetail **champion;
switch ((*iter)->m_eType)
View
8 xbmc/utils/StringUtils.cpp
@@ -317,7 +317,7 @@ std::string& StringUtils::RemoveDuplicatedSpacesAndTabs(std::string& str)
int StringUtils::Replace(string &str, char oldChar, char newChar)
{
int replacedChars = 0;
- for (string::iterator it = str.begin(); it != str.end(); it++)
+ for (string::iterator it = str.begin(); it != str.end(); ++it)
{
if (*it == oldChar)
{
@@ -459,7 +459,7 @@ bool StringUtils::EndsWithNoCase(const std::string &str1, const char *s2)
void StringUtils::JoinString(const CStdStringArray &strings, const CStdString& delimiter, CStdString& result)
{
result = "";
- for(CStdStringArray::const_iterator it = strings.begin(); it != strings.end(); it++ )
+ for(CStdStringArray::const_iterator it = strings.begin(); it != strings.end(); ++it )
result += (*it) + delimiter;
if(result != "")
@@ -961,7 +961,7 @@ int StringUtils::FindBestMatch(const CStdString &str, const CStdStringArray &str
matchscore = 0;
int i = 0;
- for (CStdStringArray::const_iterator it = strings.begin(); it != strings.end(); it++, i++)
+ for (CStdStringArray::const_iterator it = strings.begin(); it != strings.end(); ++it, i++)
{
int maxlength = max(str.length(), it->length());
double score = StringUtils::CompareFuzzy(str, *it) / maxlength;
@@ -976,7 +976,7 @@ int StringUtils::FindBestMatch(const CStdString &str, const CStdStringArray &str
bool StringUtils::ContainsKeyword(const CStdString &str, const CStdStringArray &keywords)
{
- for (CStdStringArray::const_iterator it = keywords.begin(); it != keywords.end(); it++)
+ for (CStdStringArray::const_iterator it = keywords.begin(); it != keywords.end(); ++it)
{
if (str.find(*it) != str.npos)
return true;
View
5 xbmc/utils/SystemInfo.cpp
@@ -109,7 +109,10 @@ static std::string getValueFromOs_release(std::string key)
size_t len = fread(buf, 1, 10 * 1024, os_rel);
fclose(os_rel);
if (len == 0)
+ {
+ delete[] buf;
return "";
+ }
std::string content(buf, len);
delete[] buf;
@@ -300,7 +303,7 @@ double CSysInfoJob::GetCPUFrequency()
bool CSysInfoJob::SystemUpTime(int iInputMinutes, int &iMinutes, int &iHours, int &iDays)
{
- iMinutes=0;iHours=0;iDays=0;
+ iHours = 0; iDays = 0;
iMinutes = iInputMinutes;
if (iMinutes >= 60) // Hour's
{
View
14 xbmc/utils/SystemInfo.h
@@ -66,13 +66,13 @@ class CSysInfoJob : public CJob
static CSysData::INTERNET_STATE GetInternetState();
private:
- bool SystemUpTime(int iInputMinutes, int &iMinutes, int &iHours, int &iDays);
- double GetCPUFrequency();
- CStdString GetSystemUpTime(bool bTotalUptime);
- CStdString GetCPUFreqInfo();
- CStdString GetMACAddress();
- CStdString GetVideoEncoder();
- CStdString GetBatteryLevel();
+ static bool SystemUpTime(int iInputMinutes, int &iMinutes, int &iHours, int &iDays);
+ static double GetCPUFrequency();
+ static CStdString GetSystemUpTime(bool bTotalUptime);
+ static CStdString GetCPUFreqInfo();
+ static CStdString GetMACAddress();
+ static CStdString GetVideoEncoder();
+ static CStdString GetBatteryLevel();
CSysData m_info;
};
View
2  xbmc/utils/TextSearch.h
@@ -39,7 +39,7 @@ class CTextSearch
bool IsValid(void) const;
private:
- void GetAndCutNextTerm(CStdString &strSearchTerm, CStdString &strNextTerm);
+ static void GetAndCutNextTerm(CStdString &strSearchTerm, CStdString &strNextTerm);
void ExtractSearchTerms(const CStdString &strSearchTerm, TextSearchDefault defaultSearchMode);
bool m_bCaseSensitive;
View
10 xbmc/utils/TimeSmoother.h
@@ -123,7 +123,7 @@ class CTimeSmoother
\param threshold the threshold to determine whether a data point is close to a given bin as a proportion of bin mean
\param minbinsize the minimum bin size of each bin
*/
- void BinData(const boost::circular_buffer<double> &data, std::vector<double> &bins, const double threshold, const unsigned int minbinsize);
+ static void BinData(const boost::circular_buffer<double> &data, std::vector<double> &bins, const double threshold, const unsigned int minbinsize);
/*! \brief Given a real value, find a rational convergent
Uses a continued fraction expansion of value to determine the numerator and denominator of a rational convergent
@@ -133,7 +133,7 @@ class CTimeSmoother
\param denom [out] the denominator
\param maxnumden the maximal value of min(num, denom)
*/
- void GetConvergent(double value, unsigned int &num, unsigned int &denom, const unsigned int maxnumden);
+ static void GetConvergent(double value, unsigned int &num, unsigned int &denom, const unsigned int maxnumden);
/*! \brief Given a set of data, find integer multipliers such that data[i] \sim quotient[i] * gcd(data)
Uses rational convergents to data[i]/min(data) to find integer multipliers to the (approximate) greatest common divisor
@@ -143,7 +143,7 @@ class CTimeSmoother
\param maxminmult the maximal value of multiplier[min(data)]
\sa GetConvergent
*/
- void GetGCDMultipliers(const std::vector<double> &data, std::vector<unsigned int> &multipliers, const unsigned int maxminmult);
+ static void GetGCDMultipliers(const std::vector<double> &data, std::vector<unsigned int> &multipliers, const unsigned int maxminmult);
/*! \brief Given a set of bins and integer values associated with each bin, find the integer representation of some data
This allows noisy data to be approximated by a set of clean data, and to compute the integer representation of that data.
@@ -152,7 +152,7 @@ class CTimeSmoother
\param bins the bins to use for approximating the data
\param intBins the integer representation of the bins
*/
- void GetIntRepresentation(const boost::circular_buffer<double> &data, std::vector<unsigned int> &intData, const std::vector<double> &bins, const std::vector<unsigned int> &intBins);
+ static void GetIntRepresentation(const boost::circular_buffer<double> &data, std::vector<unsigned int> &intData, const std::vector<double> &bins, const std::vector<unsigned int> &intBins);
/*! \brief Given a set of data, and an integer representation of that data, estimate the period of the data
Essentially we solve a linear regression d_i = \theta*z_i, where d_i is the original data, and z_i is the integer
@@ -163,7 +163,7 @@ class CTimeSmoother
\param intData an integral representation of the data
\return the period of the data
*/
- double EstimatePeriod(const boost::circular_buffer<double> &data, const std::vector<unsigned int> &intData);
+ static double EstimatePeriod(const boost::circular_buffer<double> &data, const std::vector<unsigned int> &intData);
/*! \brief Compute the next frame time
\param currentTime the current time
View
5 xbmc/utils/TuxBoxUtil.cpp
@@ -57,6 +57,7 @@ CTuxBoxService::~CTuxBoxService()
CTuxBoxUtil::CTuxBoxUtil(void)
{
sCurSrvData.requested_audio_channel = 0;
+ vVideoSubChannel.mode = false;
sZapstream.initialized = false;
sZapstream.available = false;
}
@@ -767,7 +768,6 @@ bool CTuxBoxUtil::GetHttpXML(CURL url,CStdString strRequestType)
if(http.Open(url))
{
int size_read = 0;
- int data_size = 0;
int size_total = (int)http.GetLength();
if(size_total > 0)
@@ -780,7 +780,6 @@ bool CTuxBoxUtil::GetHttpXML(CURL url,CStdString strRequestType)
{
buffer[size_read] = 0;
strTmp += buffer;
- data_size += size_read;
}
// parse returned xml
@@ -1464,7 +1463,7 @@ bool CTuxBoxUtil::GetGUIRequestedAudioChannel(AUDIOCHANNEL& sRequestedAC)
}
return false;
}
-bool CTuxBoxUtil::GetRequestedAudioChannel(AUDIOCHANNEL& sRequestedAC)
+bool CTuxBoxUtil::GetRequestedAudioChannel(AUDIOCHANNEL& sRequestedAC) const
{
sRequestedAC = sCurSrvData.audio_channels[sCurSrvData.requested_audio_channel];
View
20 xbmc/utils/TuxBoxUtil.h
@@ -149,10 +149,10 @@ class CTuxBoxUtil
virtual ~CTuxBoxUtil(void);
bool GetZapUrl(const CStdString& strPath, CFileItem &items);
- bool ParseBouquets(TiXmlElement *root, CFileItemList &items, CURL &url, CStdString strFilter, CStdString strChild);
- bool ParseBouquetsEnigma2(TiXmlElement *root, CFileItemList &items, CURL &url, CStdString& strFilter, CStdString& strChild);
- bool ParseChannels(TiXmlElement *root, CFileItemList &items, CURL &url, CStdString strFilter, CStdString strChild);
- bool ParseChannelsEnigma2(TiXmlElement *root, CFileItemList &items, CURL &url, CStdString& strFilter, CStdString& strChild);
+ static bool ParseBouquets(TiXmlElement *root, CFileItemList &items, CURL &url, CStdString strFilter, CStdString strChild);
+ static bool ParseBouquetsEnigma2(TiXmlElement *root, CFileItemList &items, CURL &url, CStdString& strFilter, CStdString& strChild);
+ static bool ParseChannels(TiXmlElement *root, CFileItemList &items, CURL &url, CStdString strFilter, CStdString strChild);
+ static bool ParseChannelsEnigma2(TiXmlElement *root, CFileItemList &items, CURL &url, CStdString& strFilter, CStdString& strChild);
bool ZapToUrl(CURL url, const CStdString &pathOption);
bool StreamInformations(TiXmlElement *pRootElement);
bool CurrentServiceData(TiXmlElement *pRootElement);
@@ -161,16 +161,16 @@ class CTuxBoxUtil
bool ServiceEPG(TiXmlElement *pRootElement);
bool GetHttpXML(CURL url,CStdString strRequestType);
bool GetGUIRequestedAudioChannel(AUDIOCHANNEL& sRequestedAC);
- bool GetRequestedAudioChannel(AUDIOCHANNEL& sRequestedAC);
+ bool GetRequestedAudioChannel(AUDIOCHANNEL& sRequestedAC) const;
bool GetVideoSubChannels(CStdString& strVideoSubChannelName, CStdString& strVideoSubChannelPid);
bool GetVideoChannels(TiXmlElement *pRootElement);
bool CreateNewItem(const CFileItem& item, CFileItem& item_new);
- bool InitZapstream(const CStdString& strPath);
- bool SetAudioChannel(const CStdString& strPath, const AUDIOCHANNEL& sAC);
+ static bool InitZapstream(const CStdString& strPath);
+ static bool SetAudioChannel(const CStdString& strPath, const AUDIOCHANNEL& sAC);
- CStdString GetPicon(CStdString strServiceName);
- CStdString GetSubMode(int iMode, CStdString& strXMLRootString, CStdString& strXMLChildString);
- CStdString DetectSubMode(CStdString strSubMode, CStdString& strXMLRootString, CStdString& strXMLChildString);
+ static CStdString GetPicon(CStdString strServiceName);
+ static CStdString GetSubMode(int iMode, CStdString& strXMLRootString, CStdString& strXMLChildString);
+ static CStdString DetectSubMode(CStdString strSubMode, CStdString& strXMLRootString, CStdString& strXMLChildString);
};
extern CTuxBoxUtil g_tuxbox;
View
6 xbmc/utils/URIUtils.cpp
@@ -443,7 +443,7 @@ std::string URIUtils::ChangeBasePath(const std::string &fromPath, const std::str
CStdString URIUtils::SubstitutePath(const CStdString& strPath, bool reverse /* = false */)
{
for (CAdvancedSettings::StringMapping::iterator i = g_advancedSettings.m_pathSubstitutions.begin();
- i != g_advancedSettings.m_pathSubstitutions.end(); i++)
+ i != g_advancedSettings.m_pathSubstitutions.end(); ++i)
{
CStdString fromPath;
CStdString toPath;
@@ -1207,7 +1207,7 @@ std::string URIUtils::resolvePath(const std::string &path)
vector<string> parts = StringUtils::Split(path, delim);
vector<string> realParts;
- for (vector<string>::const_iterator part = parts.begin(); part != parts.end(); part++)
+ for (vector<string>::const_iterator part = parts.begin(); part != parts.end(); ++part)
{
if (part->empty() || part->compare(".") == 0)
continue;
@@ -1254,7 +1254,7 @@ bool URIUtils::UpdateUrlEncoding(std::string &strFilename)
if (!CStackDirectory::GetPaths(strFilename, files))
return false;
- for (vector<CStdString>::iterator file = files.begin(); file != files.end(); file++)
+ for (vector<CStdString>::iterator file = files.begin(); file != files.end(); ++file)
{
std::string filePath = *file;
UpdateUrlEncoding(filePath);
View
4 xbmc/utils/UrlOptions.cpp
@@ -43,7 +43,7 @@ CUrlOptions::~CUrlOptions()
std::string CUrlOptions::GetOptionsString(bool withLeadingSeperator /* = false */) const
{
std::string options;
- for (UrlOptions::const_iterator opt = m_options.begin(); opt != m_options.end(); opt++)
+ for (UrlOptions::const_iterator opt = m_options.begin(); opt != m_options.end(); ++opt)
{
if (opt != m_options.begin())
options += "&";
@@ -133,7 +133,7 @@ void CUrlOptions::AddOptions(const std::string &options)
// split the options by & and process them one by one
vector<string> optionList = StringUtils::Split(strOptions, "&");
- for (vector<string>::const_iterator option = optionList.begin(); option != optionList.end(); option++)
+ for (vector<string>::const_iterator option = optionList.begin(); option != optionList.end(); ++option)
{
if (option->empty())
continue;
View
5 xbmc/utils/Variant.cpp
@@ -257,7 +257,7 @@ CVariant::CVariant(const std::map<std::string, std::string> &strMap)
{
m_type = VariantTypeObject;
m_data.map = new VariantMap;
- for (std::map<std::string, std::string>::const_iterator it = strMap.begin(); it != strMap.end(); it++)
+ for (std::map<std::string, std::string>::const_iterator it = strMap.begin(); it != strMap.end(); ++it)
m_data.map->insert(make_pair(it->first, CVariant(it->second)));
}
@@ -500,7 +500,6 @@ std::wstring CVariant::asWideString(const std::wstring &fallback /* = L"" */) co
else
strStream << m_data.dvalue;
return strStream.str();
- break;
}
default:
return fallback;
@@ -550,7 +549,7 @@ const CVariant &CVariant::operator[](unsigned int position) const
CVariant &CVariant::operator=(const CVariant &rhs)
{
- if (m_type == VariantTypeConstNull)
+ if (m_type == VariantTypeConstNull || this == &rhs)
return *this;
cleanup();
View
2  xbmc/utils/Weather.cpp
@@ -321,7 +321,7 @@ static CStdString ConstructPath(std::string in) // copy intended
void CWeatherJob::SetFromProperties()
{
// Load in our tokens if necessary
- if (!m_localizedTokens.size())
+ if (m_localizedTokens.empty())
LoadLocalizedToken();
CGUIWindow* window = g_windowManager.GetWindow(WINDOW_WEATHER);
View
4 xbmc/utils/Weather.h
@@ -103,7 +103,7 @@ class CWeatherJob : public CJob
void LocalizeOverview(CStdString &str);
void LocalizeOverviewToken(CStdString &str);
void LoadLocalizedToken();
- int ConvertSpeed(int speed);
+ static int ConvertSpeed(int speed);
void SetFromProperties();
@@ -111,7 +111,7 @@ class CWeatherJob : public CJob
\param text the string to format
\param temp the temperature (in degrees celcius).
*/
- void FormatTemperature(CStdString &text, int temp);
+ static void FormatTemperature(CStdString &text, int temp);
struct ci_less : std::binary_function<std::string, std::string, bool>
{
View
4 xbmc/utils/WindowsShortcut.cpp
@@ -96,7 +96,7 @@ bool CWindowsShortcut::GetShortcut(const string& strFileName, string& strFileOrD
strFileOrDir = "smb:";
// share name
iPos += dwOffsetNetworkVolumeInfo + 0x14;
- while (byHeader[iPos] != 0 && iPos < iBytesRead)
+ while (iPos < iBytesRead && byHeader[iPos] != 0)
{
if (byHeader[iPos] == '\\') byHeader[iPos] = '/';
strFileOrDir += (char)byHeader[iPos];
@@ -105,7 +105,7 @@ bool CWindowsShortcut::GetShortcut(const string& strFileName, string& strFileOrD
iPos++;
// file/folder name
strFileOrDir += '/';
- while (byHeader[iPos] != 0 && iPos < iBytesRead)
+ while (iPos < iBytesRead && byHeader[iPos] != 0)
{
if (byHeader[iPos] == '\\') byHeader[iPos] = '/';
strFileOrDir += (char)byHeader[iPos];
View
2  xbmc/utils/WindowsShortcut.h
@@ -37,7 +37,7 @@ class CWindowsShortcut
CWindowsShortcut();
virtual ~CWindowsShortcut();
static bool IsShortcut(const string& strFileName);
- bool GetShortcut(const string& strFileName, string& strFileOrDir);
+ static bool GetShortcut(const string& strFileName, string& strFileOrDir);
};
#endif // !defined(AFX_WINDOWSSHORTCUT_H__A905CF83_3C3D_44FF_B3EF_778D70676D2C__INCLUDED_)
View
2  xbmc/utils/log.h
@@ -40,7 +40,7 @@ class CLog
class CLogGlobals
{
public:
- CLogGlobals() : m_file(NULL), m_repeatCount(0), m_repeatLogLevel(-1), m_logLevel(LOG_LEVEL_DEBUG) {}
+ CLogGlobals() : m_file(NULL), m_repeatCount(0), m_repeatLogLevel(-1), m_logLevel(LOG_LEVEL_DEBUG), m_extraLogLevels(0) {}
FILE* m_file;
int m_repeatCount;
int m_repeatLogLevel;
View
2  xbmc/utils/test/TestCharsetConverter.cpp
@@ -337,7 +337,7 @@ TEST_F(TestCharsetConverter, getCharsetLabels)
ASSERT_EQ(reflabels.size(), varlabels.size());
std::vector<std::string>::iterator it;
- for (it = varlabels.begin(); it < varlabels.end(); it++)
+ for (it = varlabels.begin(); it < varlabels.end(); ++it)
{
EXPECT_STREQ((reflabels.at(it - varlabels.begin())).c_str(), (*it).c_str());
}
Please sign in to comment.
Something went wrong with that request. Please try again.