necessary! This applies to certain DLLs or use from Python DLLs/scripts
that incorrectly generate double (back) slashes.
*/
- if (bFixDoubleSlashes)
+ if (bFixDoubleSlashes && !result.empty())
{
// Fixup for double back slashes (but ignore the \\ of unc-paths)
- for (int x = 1; x < result.GetLength() - 1; x++)
+ for (size_t x = 1; x < result.size() - 1; x++)
{
if (result[x] == '\\' && result[x+1] == '\\')
result.erase(x);
necessary! This applies to certain DLLs or use from Python DLLs/scripts
that incorrectly generate double (back) slashes.
*/
- if (bFixDoubleSlashes)
+ if (bFixDoubleSlashes && !result.empty())
{
// Fixup for double forward slashes(/) but don't touch the :// of URLs
- for (int x = 2; x < result.GetLength() - 1; x++)
+ for (size_t x = 2; x < result.size() - 1; x++)
{
if ( result[x] == '/' && result[x + 1] == '/' && !(result[x - 1] == ':' || (result[x - 1] == '/' && result[x - 2] == ':')) )
result.erase(x);
if (whiteSpacePos)
parameter.erase(whiteSpacePos);
// trim off start and end quotes
- if (parameter.GetLength() > 1 && parameter[0] == '"' && parameter[parameter.GetLength() - 1] == '"')
- parameter = parameter.substr(1,parameter.GetLength() - 2);
- else if (parameter.GetLength() > 3 && parameter[parameter.GetLength() - 1] == '"')
+ if (parameter.size() > 1 && parameter[0] == '"' && parameter[parameter.size() - 1] == '"')
+ parameter = parameter.substr(1,parameter.size() - 2);
+ else if (parameter.size() > 3 && parameter[parameter.size() - 1] == '"')
{
// check name="value" style param.
size_t quotaPos = parameter.find('"');
CStdString xbmcPath = CSpecialProtocol::TranslatePath("special://xbmc");
CStdString homePath = CSpecialProtocol::TranslatePath("special://home");
CStdString tempPath = CSpecialProtocol::TranslatePath("special://temp");
- return ((strncmp(xbmcPath.c_str(), dllPath.c_str(), xbmcPath.GetLength()) == 0) ||
- (strncmp(homePath.c_str(), dllPath.c_str(), homePath.GetLength()) == 0) ||
- (strncmp(tempPath.c_str(), dllPath.c_str(), tempPath.GetLength()) == 0));
+ return ((strncmp(xbmcPath.c_str(), dllPath.c_str(), xbmcPath.size()) == 0) ||
+ (strncmp(homePath.c_str(), dllPath.c_str(), homePath.size()) == 0) ||
+ (strncmp(tempPath.c_str(), dllPath.c_str(), tempPath.size()) == 0));
}
void Win32DllLoader::RestoreImports()
}
else if (b == XBMCVK_END)
{
- SetCursorPos(m_strEdit.GetLength());
+ SetCursorPos(m_strEdit.size());
}
else if (b == XBMCVK_LEFT)
{
}
else if (b == XBMCVK_DELETE)
{
- if (GetCursorPos() < m_strEdit.GetLength())
+ if (GetCursorPos() < (int)m_strEdit.size())
{
MoveCursor(1);
Backspace();
Close();
break;
case 0x7F: // Delete
- if (GetCursorPos() < m_strEdit.GetLength())
+ if (GetCursorPos() < (int)m_strEdit.size())
{
MoveCursor(1);
Backspace();
#include "threads/SingleLock.h"
#include "utils/log.h"
#include "utils/URIUtils.h"
+#include "utils/StringUtils.h"
#include "climits"
using namespace std;
iCache i = m_cache.begin();
while (i != m_cache.end())
{
- CStdString path = i->first;
- if (strncmp(path.c_str(), storedPath.c_str(), storedPath.GetLength()) == 0)
+ if (StringUtils::StartsWith(i->first, storedPath))
Delete(i++);
else
i++;
{
// Prepare variables
CStdString strDigits = StringUtils::Format("%u", uiChannel);
- unsigned int uiNumberOfDigits = strDigits.GetLength();
+ size_t uiNumberOfDigits = strDigits.size();
// Change the channel using IR commands
- for (unsigned int i = 0; i < uiNumberOfDigits; i++)
+ for (size_t i = 0; i < uiNumberOfDigits; i++)
{
if (m_pSlingbox->SendIRCommand(m_sSlingboxSettings.uiCodeNumber[strDigits[i] - '0']))
{
#include "SpecialProtocolDirectory.h"
#include "SpecialProtocol.h"
#include "Directory.h"
+#include "utils/StringUtils.h"
#include "utils/URIUtils.h"
#include "FileItem.h"
for (int i = 0; i < items.Size(); i++)
{
CFileItemPtr item = items[i];
- if (strnicmp(item->GetPath().c_str(), translatedPath.c_str(), translatedPath.GetLength()) == 0)
- item->SetPath(URIUtils::AddFileToFolder(untranslatedPath, item->GetPath().substr(translatedPath.GetLength())));
+ if (StringUtils::StartsWith(item->GetPath(), translatedPath))
+ item->SetPath(URIUtils::AddFileToFolder(untranslatedPath, item->GetPath().substr(translatedPath.size())));
}
return true;
}
void CTextureBundleXBT::GetTexturesFromPath(const CStdString &path, std::vector<CStdString> &textures)
{
- if (path.GetLength() > 1 && path[1] == ':')
+ if (path.size() > 1 && path[1] == ':')
return;
if (!m_XBTFReader.IsOpen() && !OpenBundle())
void CTextureBundleXPR::GetTexturesFromPath(const CStdString &path, std::vector<CStdString> &textures)
{
- if (path.GetLength() > 1 && path[1] == ':')
+ if (path.size() > 1 && path[1] == ':')
return;
if (m_hFile == NULL && !OpenBundle())
int iImages = AnimatedGifSet.LoadGIF(strPath.c_str());
if (iImages == 0)
{
- CStdString rootPath = strPath.substr(0, g_SkinInfo->Path().GetLength());
+ CStdString rootPath = strPath.substr(0, g_SkinInfo->Path().size());
if (0 == rootPath.CompareNoCase(g_SkinInfo->Path()))
CLog::Log(LOGERROR, "Texture manager unable to load file: %s", strPath.c_str());
return emptyTexture;
CStdString strVariousArtists = g_localizeStrings.Get(340).c_str();
CStdString strSQL;
- if (search.GetLength() >= MIN_FULL_SEARCH_LENGTH)
+ if (search.size() >= MIN_FULL_SEARCH_LENGTH)
strSQL=PrepareSQL("select * from artist "
"where (strArtist like '%s%%' or strArtist like '%% %s%%') and strArtist <> '%s' "
, search.c_str(), search.c_str(), strVariousArtists.c_str() );
return false;
CStdString strSQL;
- if (search.GetLength() >= MIN_FULL_SEARCH_LENGTH)
+ if (search.size() >= MIN_FULL_SEARCH_LENGTH)
strSQL=PrepareSQL("select * from songview where strTitle like '%s%%' or strTitle like '%% %s%%' limit 1000", search.c_str(), search.c_str());
else
strSQL=PrepareSQL("select * from songview where strTitle like '%s%%' limit 1000", search.c_str());
if (NULL == m_pDS.get()) return false;
CStdString strSQL;
- if (search.GetLength() >= MIN_FULL_SEARCH_LENGTH)
+ if (search.size() >= MIN_FULL_SEARCH_LENGTH)
strSQL=PrepareSQL("select * from albumview where strAlbum like '%s%%' or strAlbum like '%% %s%%'", search.c_str(), search.c_str());
else
strSQL=PrepareSQL("select * from albumview where strAlbum like '%s%%'", search.c_str());
do
{
- ret = sendto(client_socket, command.message, command.message.GetLength(), 0, (struct sockaddr *) & command.address, sizeof(command.address));
+ ret = sendto(client_socket, command.message, command.message.size(), 0, (struct sockaddr *) & command.address, sizeof(command.address));
}
while (ret == -1 && !m_bStop);
}
// DTITLE may contain artist and disc title, separated with " / ",
// for example: DTITLE=Modern Talking / Album: Victory (The 11th Album)
bool found = false;
- for (int i = 0; i < strValue.GetLength() - 2; i++)
+ for (int i = 0; i < (int)strValue.size() - 2; i++)
{
if (strValue[i] == ' ' && strValue[i + 1] == '/' && strValue[i + 2] == ' ')
{
{
CStdString temp;
ar >> temp;
- length = min((size_t)temp.GetLength(), length - 1);
+ length = min((size_t)temp.size(), length - 1);
if (!temp.empty())
memcpy(string, temp.c_str(), length);
string[length] = 0;
if (!strUseBase.empty())
{
/* adding "/" to make sure that base matches the complete folder name and not only parts of it */
- if (strUsePath.GetLength() <= strUseBase.GetLength() || !StringUtils::StartsWith(strUsePath, strUseBase + "/"))
+ if (strUsePath.size() <= strUseBase.size() || !StringUtils::StartsWith(strUsePath, strUseBase + "/"))
return strReturn;
- strUsePath.erase(0, strUseBase.GetLength());
+ strUsePath.erase(0, strUseBase.size());
}
/* check for more occurences */
CStdString strUseDir = TrimSlashes(strDirectory);
CStdString strAllRecordingsPathExtension(PVR_ALL_RECORDINGS_PATH_EXTENSION);
- if (strUseDir.GetLength() < strAllRecordingsPathExtension.GetLength())
+ if (strUseDir.size() < strAllRecordingsPathExtension.size())
return false;
- if (strUseDir.GetLength() == strAllRecordingsPathExtension.GetLength())
+ if (strUseDir.size() == strAllRecordingsPathExtension.size())
return strUseDir.Equals(strAllRecordingsPathExtension);
return StringUtils::EndsWith(strUseDir, "/" + strAllRecordingsPathExtension);
if (!HasAllRecordingsPathExtension(strDirectory))
return strDirectory;
- return strDirectory.substr(0, strDirectory.GetLength() - strlen(PVR_ALL_RECORDINGS_PATH_EXTENSION) - 1);
+ return strDirectory.substr(0, strDirectory.size() - strlen(PVR_ALL_RECORDINGS_PATH_EXTENSION) - 1);
}
int CPVRRecordings::Load(void)
CArchive& CArchive::operator<<(const CStdString& str)
{
- *this << str.GetLength();
+ *this << (unsigned int)str.size();
- int size = str.GetLength();
+ int size = str.size();
if (m_BufferPos + size >= BUFFER_MAX)
FlushBuffer();
CArchive& CArchive::operator<<(const CStdStringW& str)
{
- *this << str.GetLength();
+ *this << (unsigned int)str.size();
- int size = str.GetLength() * sizeof(wchar_t);
+ int size = str.size() * sizeof(wchar_t);
if (m_BufferPos + size >= BUFFER_MAX)
FlushBuffer();
CArchive& CArchive::operator>>(CStdString& str)
{
- int iLength = 0;
+ unsigned int iLength = 0;
*this >> iLength;
m_pFile->Read((void*)str.GetBufferSetLength(iLength), iLength);
CArchive& CArchive::operator>>(CStdStringW& str)
{
- int iLength = 0;
+ unsigned int iLength = 0;
*this >> iLength;
m_pFile->Read((void*)str.GetBufferSetLength(iLength), iLength * sizeof(wchar_t));
else
m_strFeed[iFeed] += aString;
- int nStringLength = aString.GetLength();
+ size_t nStringLength = aString.size();
- for (int i = 0;i < nStringLength;i++)
+ for (size_t i = 0;i < nStringLength;i++)
aString[i] = (CHAR) (48 + aColour);
if (m_rtlText)
CStdString temp = StringUtils::Format("$$%i",i+1);
while ((iIndex = strDest.find(temp,iIndex)) != CStdString::npos) // COPIED FROM CStdString WITH THE ADDITION OF $ ESCAPING
{
- strDest.replace(strDest.begin()+iIndex,strDest.begin()+iIndex+temp.GetLength(),m_param[i]);
+ strDest.replace(strDest.begin()+iIndex,strDest.begin()+iIndex+temp.size(),m_param[i]);
iIndex += m_param[i].length();
}
}
return BufferSet(nLen);
}
- // GetLength() -- MFC docs say this is the # of BYTES but
- // in truth it is the number of CHARACTERs (chars or wchar_ts)
- int GetLength() const
- {
- return static_cast<int>(this->length());
- }
-
#ifndef SS_ANSI
bool LoadString(UINT nId)
{
{
CStdString uriPath = CSpecialProtocol::TranslatePath(uri);
CStdString basePath = CSpecialProtocol::TranslatePath(baseURI);
- return (strncmp(uriPath.c_str(), basePath.c_str(), basePath.GetLength()) == 0);
+ return StringUtils::StartsWith(uriPath, basePath);
}
/* returns filename extension including period of filename */
strIn += PrepareSQL("%i,", m_pDS->fv(0).get_asInt());
m_pDS->next();
}
- strIn[strIn.GetLength() - 1] = ')'; // replace last , with )
+ strIn[strIn.size() - 1] = ')'; // replace last , with )
}
m_pDS->close();
return true;