else if (!ExtractQuoteInfo(strLine, m_Track[m_iTotalTracks].strTitle))
{
// lets manage tracks titles without quotes
- CStdString titleNoQuote = strLine.Mid(5);
+ CStdString titleNoQuote = strLine.substr(5);
StringUtils::TrimLeft(titleNoQuote);
if (!titleNoQuote.empty())
{
}
else if (StringUtils::StartsWithNoCase(strLine,"TRACK"))
{
- int iTrackNumber = ExtractNumericInfo(strLine.Mid(5));
+ int iTrackNumber = ExtractNumericInfo(strLine.substr(5));
m_iTotalTracks++;
}
else if (StringUtils::StartsWithNoCase(strLine,"REM DISCNUMBER"))
{
- int iDiscNumber = ExtractNumericInfo(strLine.Mid(14));
+ int iDiscNumber = ExtractNumericInfo(strLine.substr(14));
if (iDiscNumber > 0)
m_iDiscNumber = iDiscNumber;
}
}
else if (StringUtils::StartsWithNoCase(strLine,"REM DATE"))
{
- int iYear = ExtractNumericInfo(strLine.Mid(8));
+ int iYear = ExtractNumericInfo(strLine.substr(8));
if (iYear > 0)
m_iYear = iYear;
}
{
if (!ExtractQuoteInfo(strLine, m_strGenre))
{
- CStdString genreNoQuote = strLine.Mid(9);
+ CStdString genreNoQuote = strLine.substr(9);
StringUtils::TrimLeft(genreNoQuote);
if (!genreNoQuote.empty())
{
}
}
else if (StringUtils::StartsWithNoCase(strLine,"REM REPLAYGAIN_ALBUM_GAIN"))
- m_replayGainAlbumGain = (float)atof(strLine.Mid(26));
+ m_replayGainAlbumGain = (float)atof(strLine.substr(26).c_str());
else if (StringUtils::StartsWithNoCase(strLine,"REM REPLAYGAIN_ALBUM_PEAK"))
- m_replayGainAlbumPeak = (float)atof(strLine.Mid(26));
+ m_replayGainAlbumPeak = (float)atof(strLine.substr(26).c_str());
else if (StringUtils::StartsWithNoCase(strLine,"REM REPLAYGAIN_TRACK_GAIN") && m_iTotalTracks >= 0)
- m_Track[m_iTotalTracks].replayGainTrackGain = (float)atof(strLine.Mid(26));
+ m_Track[m_iTotalTracks].replayGainTrackGain = (float)atof(strLine.substr(26).c_str());
else if (StringUtils::StartsWithNoCase(strLine,"REM REPLAYGAIN_TRACK_PEAK") && m_iTotalTracks >= 0)
- m_Track[m_iTotalTracks].replayGainTrackPeak = (float)atof(strLine.Mid(26));
+ m_Track[m_iTotalTracks].replayGainTrackPeak = (float)atof(strLine.substr(26).c_str());
}
// reset track counter to 0, and fill in the last tracks end time
if (left < 0) return false;
int right = line.Find('\"', left + 1);
if (right < 0) return false;
- quote = line.Mid(left + 1, right - left - 1);
+ quote = line.substr(left + 1, right - left - 1);
g_charsetConverter.unknownToUTF8(quote);
return true;
}
int CCueDocument::ExtractTimeFromIndex(const CStdString &index)
{
// Get rid of the index number and any whitespace
- CStdString numberTime = index.Mid(5);
+ CStdString numberTime = index.substr(5);
StringUtils::TrimLeft(numberTime);
while (!numberTime.empty())
{
CStdString extension;
if( StringUtils::StartsWithNoCase(m_mimetype, "application/") )
{ /* check for some standard types */
- extension = m_mimetype.Mid(12);
+ extension = m_mimetype.substr(12);
if( extension.Equals("ogg")
|| extension.Equals("mp4")
|| extension.Equals("mxf") )
if( StringUtils::StartsWithNoCase(m_mimetype, "application/") )
{ /* check for some standard types */
- CStdString extension = m_mimetype.Mid(12);
+ CStdString extension = m_mimetype.substr(12);
if( extension.Equals("ogg")
|| extension.Equals("mp4")
|| extension.Equals("mxf") )
image = thumbURL.GetHostName();
- CStdString optionString = thumbURL.GetOptions().Mid(1);
+ CStdString optionString = thumbURL.GetOptions().substr(1);
StringUtils::TrimRight(optionString, "/"); // In case XBMC adds a slash.
std::vector<CStdString> options;
if (pos != -1)
{
option = i->Left(pos);
- value = i->Mid(pos + 1);
+ value = i->substr(pos + 1);
}
else
{
m_strProtocol.Equals("special")
)
{
- SetFileName(strURL.Mid(iPos));
+ SetFileName(strURL.substr(iPos));
return;
}
if (iAlphaSign >= 0 && iAlphaSign < iEnd && (iAlphaSign < iSlash || iSlash < 0))
{
// username/password found
- CStdString strUserNamePassword = strURL.Mid(iPos, iAlphaSign - iPos);
+ CStdString strUserNamePassword = strURL.substr(iPos, iAlphaSign - iPos);
// first extract domain, if protocol is smb
if (m_strProtocol.Equals("smb"))
// detect hostname:port/
if (iSlash < 0)
{
- CStdString strHostNameAndPort = strURL.Mid(iPos, iEnd - iPos);
+ CStdString strHostNameAndPort = strURL.substr(iPos, iEnd - iPos);
int iColon = strHostNameAndPort.Find(":");
if (iColon >= 0)
{
}
else
{
- CStdString strHostNameAndPort = strURL.Mid(iPos, iSlash - iPos);
+ CStdString strHostNameAndPort = strURL.substr(iPos, iSlash - iPos);
int iColon = strHostNameAndPort.Find(":");
if (iColon >= 0)
{
iPos = iSlash + 1;
if (iEnd > iPos)
{
- m_strFileName = strURL.Mid(iPos, iEnd - iPos);
+ m_strFileName = strURL.substr(iPos, iEnd - iPos);
iSlash = m_strFileName.Find("/");
if(iSlash < 0)
if (strOptions.length() > 0)
{
if (strOptions[0] == '|')
- m_strProtocolOptions = strOptions.Mid(1);
+ m_strProtocolOptions = strOptions.substr(1);
else
m_strProtocolOptions = strOptions;
m_protocolOptions.AddOptions(m_strProtocolOptions);
}
int j=0;
if ((j=reTags.RegFind(strTitleAndYear.c_str())) > 0)
- strTitleAndYear = strTitleAndYear.Mid(0, j);
+ strTitleAndYear = strTitleAndYear.substr(0, j);
}
// final cleanup - special characters used instead of spaces:
while ((pos = strFilename.Find("/../")) > 0)
{
CStdString basePath = strFilename.Left(pos+1);
- strFilename = strFilename.Mid(pos+4);
+ strFilename.erase(0, pos + 4);
basePath = URIUtils::GetParentPath(basePath);
strFilename = URIUtils::AddFileToFolder(basePath, strFilename);
}
while ((pos = strFilename.Find("\\..\\")) > 0)
{
CStdString basePath = strFilename.Left(pos+1);
- strFilename = strFilename.Mid(pos+4);
+ strFilename.erase(0, pos + 4);
basePath = URIUtils::GetParentPath(basePath);
strFilename = URIUtils::AddFileToFolder(basePath, strFilename);
}
CStdString strFilename = URIUtils::GetFileName(strFile);
if (strFilename.Equals("video_ts.ifo")) return 0;
//VTS_[TITLE]_0.IFO
- return atoi(strFilename.Mid(4, 2).c_str());
+ return atoi(strFilename.substr(4, 2).c_str());
}
CStdString CUtil::GetFileMD5(const CStdString& strPath)
int iPos2 = execString.ReverseFind(")");
if (iPos > 0 && iPos2 > 0)
{
- paramString = execString.Mid(iPos + 1, iPos2 - iPos - 1);
+ paramString = execString.substr(iPos + 1, iPos2 - iPos - 1);
function = execString.Left(iPos);
}
else
parameter = parameter.Left(whiteSpacePos);
// trim off start and end quotes
if (parameter.GetLength() > 1 && parameter[0] == '"' && parameter[parameter.GetLength() - 1] == '"')
- parameter = parameter.Mid(1,parameter.GetLength() - 2);
+ parameter = parameter.substr(1,parameter.GetLength() - 2);
else if (parameter.GetLength() > 3 && parameter[parameter.GetLength() - 1] == '"')
{
// check name="value" style param.
parameter = parameter.Left(whiteSpacePos);
// trim off start and end quotes
if (parameter.GetLength() > 1 && parameter[0] == '"' && parameter[parameter.GetLength() - 1] == '"')
- parameter = parameter.Mid(1,parameter.GetLength() - 2);
+ parameter = parameter.substr(1,parameter.GetLength() - 2);
else if (parameter.GetLength() > 3 && parameter[parameter.GetLength() - 1] == '"')
{
// check name="value" style param.
// "Name (Drive Status/Disc Name)"
int iPos = strName.ReverseFind('(');
if (iPos > 1)
- strName = strName.Mid(0, iPos - 1);
+ strName = strName.substr(0, iPos - 1);
}
if (strPath.Equals(strName))
{
if (!strSpecial.empty() && strSpecial[0] == '$')
{
if (StringUtils::StartsWithNoCase(strSpecial, "$home"))
- return URIUtils::AddFileToFolder("special://home/", strSpecial.Mid(5));
+ return URIUtils::AddFileToFolder("special://home/", strSpecial.substr(5));
else if (StringUtils::StartsWithNoCase(strSpecial, "$subtitles"))
- return URIUtils::AddFileToFolder("special://subtitles/", strSpecial.Mid(10));
+ return URIUtils::AddFileToFolder("special://subtitles/", strSpecial.substr(10));
else if (StringUtils::StartsWithNoCase(strSpecial, "$userdata"))
- return URIUtils::AddFileToFolder("special://userdata/", strSpecial.Mid(9));
+ return URIUtils::AddFileToFolder("special://userdata/", strSpecial.substr(9));
else if (StringUtils::StartsWithNoCase(strSpecial, "$database"))
- return URIUtils::AddFileToFolder("special://database/", strSpecial.Mid(9));
+ return URIUtils::AddFileToFolder("special://database/", strSpecial.substr(9));
else if (StringUtils::StartsWithNoCase(strSpecial, "$thumbnails"))
- return URIUtils::AddFileToFolder("special://thumbnails/", strSpecial.Mid(11));
+ return URIUtils::AddFileToFolder("special://thumbnails/", strSpecial.substr(11));
else if (StringUtils::StartsWithNoCase(strSpecial, "$recordings"))
- return URIUtils::AddFileToFolder("special://recordings/", strSpecial.Mid(11));
+ return URIUtils::AddFileToFolder("special://recordings/", strSpecial.substr(11));
else if (StringUtils::StartsWithNoCase(strSpecial, "$screenshots"))
- return URIUtils::AddFileToFolder("special://screenshots/", strSpecial.Mid(12));
+ return URIUtils::AddFileToFolder("special://screenshots/", strSpecial.substr(12));
else if (StringUtils::StartsWithNoCase(strSpecial, "$musicplaylists"))
- return URIUtils::AddFileToFolder("special://musicplaylists/", strSpecial.Mid(15));
+ return URIUtils::AddFileToFolder("special://musicplaylists/", strSpecial.substr(15));
else if (StringUtils::StartsWithNoCase(strSpecial, "$videoplaylists"))
- return URIUtils::AddFileToFolder("special://videoplaylists/", strSpecial.Mid(15));
+ return URIUtils::AddFileToFolder("special://videoplaylists/", strSpecial.substr(15));
else if (StringUtils::StartsWithNoCase(strSpecial, "$cdrips"))
- return URIUtils::AddFileToFolder("special://cdrips/", strSpecial.Mid(7));
+ return URIUtils::AddFileToFolder("special://cdrips/", strSpecial.substr(7));
// this one will be removed post 2.0
else if (StringUtils::StartsWithNoCase(strSpecial, "$playlists"))
- return URIUtils::AddFileToFolder(CSettings::Get().GetString("system.playlistspath"), strSpecial.Mid(10));
+ return URIUtils::AddFileToFolder(CSettings::Get().GetString("system.playlistspath"), strSpecial.substr(10));
}
return strSpecial;
}
(strExtension == ".xbt" && pItem->GetLabel().CompareNoCase("Textures.xbt")))
{
CStdString strLabel = pItem->GetLabel();
- vecTheme.push_back(strLabel.Mid(0, strLabel.size() - 4));
+ vecTheme.push_back(strLabel.substr(0, strLabel.size() - 4));
}
}
}
// we check left part - if it's same as video base name - strip it
if (toParse.Left(videoBaseName.length()).Equals(videoBaseName))
- toParse = toParse.Mid(videoBaseName.length());
+ toParse = toParse.substr(videoBaseName.length());
// trim any non-alphanumeric char in the begining
std::string::iterator result = std::find_if(toParse.begin(), toParse.end(), ::isalnum);
CURL::Decode(strSubDirectory);
if (URIUtils::HasExtension(strSubFile, ".sub") &&
(URIUtils::ReplaceExtension(strIdxFile,"").Equals(URIUtils::ReplaceExtension(strSubFile,"")) ||
- strSubDirectory.Mid(6, strSubDirectory.length()-11).Equals(URIUtils::ReplaceExtension(strIdxPath,""))))
+ StringUtils::EqualsNoCase(strSubDirectory.substr(6, strSubDirectory.length()-11), URIUtils::ReplaceExtension(strIdxPath,""))))
{
strSubPath = vecSubtitles[j];
return true;
URIUtils::Split(vecSubtitles[j], strIdxDirectory, strIdxFile);
if (URIUtils::HasExtension(strIdxFile, ".idx") &&
(URIUtils::ReplaceExtension(strIdxFile,"").Equals(URIUtils::ReplaceExtension(strSubFile,"")) ||
- strSubDirectory.Mid(6, strSubDirectory.length()-11).Equals(URIUtils::ReplaceExtension(vecSubtitles[j],""))))
+ StringUtils::EqualsNoCase(strSubDirectory.substr(6, strSubDirectory.length()-11), URIUtils::ReplaceExtension(vecSubtitles[j],""))))
return true;
}
}
void CDateTimeSpan::SetFromTimeString(const CStdString& time) // hh:mm
{
- int hour = atoi(time.Mid(0,2).c_str());
- int minutes = atoi(time.Mid(3,2).c_str());
+ int hour = atoi(time.substr(0, 2).c_str());
+ int minutes = atoi(time.substr(3, 2).c_str());
SetDateTimeSpan(0,hour,minutes,0);
}
{
long days = atoi(period.c_str());
// find the first non-space and non-number
- int pos = period.find_first_not_of("0123456789 ", 0);
- if (pos >= 0)
+ size_t pos = period.find_first_not_of("0123456789 ", 0);
+ if (pos != std::string::npos)
{
- CStdString units = period.Mid(pos, 3);
+ CStdString units = period.substr(pos, 3);
if (units.CompareNoCase("wee") == 0)
days *= 7;
else if (units.CompareNoCase("mon") == 0)
else
iDayPos = 0;
- CStdString strMonth = date.Mid(iDayPos,iPos-iDayPos);
+ CStdString strMonth = date.substr(iDayPos, iPos - iDayPos);
if (strMonth.empty()) // assume dbdate format
{
SetFromDBDate(date);
}
int iPos2 = date.Find(",");
- CStdString strDay = date.Mid(iPos,iPos2-iPos);
- CStdString strYear = date.Mid(date.Find(" ",iPos2)+1);
+ CStdString strDay = date.substr(iPos, iPos2-iPos);
+ CStdString strYear = date.substr(date.find(" ", iPos2) + 1);
while (months[j] && stricmp(strMonth.c_str(),months[j]) != 0)
j++;
if (!months[j])
date = dateTime.Left(posT);
CStdString::size_type posZ = dateTime.find_first_of("+-Z", posT);
if(posZ == CStdString::npos)
- time = dateTime.Mid(posT+1);
+ time = dateTime.substr(posT + 1);
else
{
- time = dateTime.Mid(posT+1, posZ-posT-1);
- zone = dateTime.Mid(posZ);
+ time = dateTime.substr(posT + 1, posZ - posT - 1);
+ zone = dateTime.substr(posZ);
}
}
else
int year = 0, month = 1, day = 1, hour = 0, min = 0, sec = 0;
if (date.size() >= 4)
- year = atoi(date.Mid(0,4).c_str());
+ year = atoi(date.substr(0, 4).c_str());
if (date.size() >= 10)
{
- month = atoi(date.Mid(5,2).c_str());
- day = atoi(date.Mid(8,2).c_str());
+ month = atoi(date.substr(5, 2).c_str());
+ day = atoi(date.substr(8, 2).c_str());
}
if (time.length() >= 5)
{
- hour = atoi(time.Mid(0,2).c_str());
- min = atoi(time.Mid(3,2).c_str());
+ hour = atoi(time.substr(0, 2).c_str());
+ min = atoi(time.substr(3, 2).c_str());
}
if (time.length() >= 8)
- sec = atoi(time.Mid(6,2).c_str());
+ sec = atoi(time.substr(6, 2).c_str());
SetDateTime(year, month, day, hour, min, sec);
}
// assumes format YYYY-MM-DD HH:MM:SS
if (dateTime.size() == 19)
{
- int year = atoi(dateTime.Mid(0,4).c_str());
- int month = atoi(dateTime.Mid(5,2).c_str());
- int day = atoi(dateTime.Mid(8,2).c_str());
- int hour = atoi(dateTime.Mid(11,2).c_str());
- int min = atoi(dateTime.Mid(14,2).c_str());
- int sec = atoi(dateTime.Mid(17,2).c_str());
+ int year = atoi(dateTime.substr(0, 4).c_str());
+ int month = atoi(dateTime.substr(5, 2).c_str());
+ int day = atoi(dateTime.substr(8, 2).c_str());
+ int hour = atoi(dateTime.substr(11, 2).c_str());
+ int min = atoi(dateTime.substr(14, 2).c_str());
+ int sec = atoi(dateTime.substr(17, 2).c_str());
SetDateTime(year, month, day, hour, min, sec);
}
}
int year = 0, month = 0, day = 0;
if (date.size() > 2 && (date[2] == '-' || date[2] == '.'))
{
- day = atoi(date.Mid(0,2).c_str());
- month = atoi(date.Mid(3,2).c_str());
- year = atoi(date.Mid(6,4).c_str());
+ day = atoi(date.substr(0, 2).c_str());
+ month = atoi(date.substr(3, 2).c_str());
+ year = atoi(date.substr(6, 4).c_str());
}
else
{
- year = atoi(date.Mid(0,4).c_str());
- month = atoi(date.Mid(5,2).c_str());
- day = atoi(date.Mid(8,2).c_str());
+ year = atoi(date.substr(0, 4).c_str());
+ month = atoi(date.substr(5, 2).c_str());
+ day = atoi(date.substr(8, 2).c_str());
}
SetDate(year, month, day);
}
// HH:MM:SS
int hour, minute, second;
- hour = atoi(time.Mid(0,2).c_str());
- minute = atoi(time.Mid(3,2).c_str());
- second = atoi(time.Mid(6,2).c_str());
+ hour = atoi(time.substr(0, 2).c_str());
+ minute = atoi(time.substr(3, 2).c_str());
+ second = atoi(time.substr(6, 2).c_str());
SetTime(hour, minute, second);
}
if (date.size() != 29)
return;
- int day = strtol(date.Mid(5, 2).c_str(), NULL, 10);
+ int day = strtol(date.substr(5, 2).c_str(), NULL, 10);
- CStdString strMonth = date.Mid(8, 3);
+ CStdString strMonth = date.substr(8, 3);
int month = 0;
for (unsigned int index = 0; index < 12; index++)
{
if (month < 1)
return;
- int year = strtol(date.Mid(12, 4).c_str(), NULL, 10);
- int hour = strtol(date.Mid(17, 2).c_str(), NULL, 10);
- int min = strtol(date.Mid(20, 2).c_str(), NULL, 10);
- int sec = strtol(date.Mid(23, 2).c_str(), NULL, 10);
+ int year = strtol(date.substr(12, 4).c_str(), NULL, 10);
+ int hour = strtol(date.substr(17, 2).c_str(), NULL, 10);
+ int min = strtol(date.substr(20, 2).c_str(), NULL, 10);
+ int sec = strtol(date.substr(23, 2).c_str(), NULL, 10);
SetDateTime(year, month, day, hour, min, sec);
}
if (pos>-1)
{
// Extract string between ' '
- strPart=strFormat.Mid(i+1, pos-i-1);
+ strPart=strFormat.substr(i + 1, pos - i - 1);
i=pos;
}
else
{
- strPart=strFormat.Mid(i+1, length-i-1);
+ strPart=strFormat.substr(i + 1, length - i - 1);
i=length;
}
if (pos>-1)
{
// Extract string between ' '
- strPart=strFormat.Mid(i+1, pos-i-1);
- i=pos;
+ strPart = strFormat.substr(i + 1, pos - i - 1);
+ i = pos;
}
else
{
- strPart=strFormat.Mid(i+1, length-i-1);
- i=length;
+ strPart = strFormat.substr(i + 1, length - i - 1);
+ i = length;
}
strPart.Replace("''", "'");
strOut+=strPart;
int dpos = filename.rfind("-");
if (dpos < 0)
return false;
- ID = filename.Mid(0,dpos);
- version = filename.Mid(dpos+1);
- version = version.Mid(0,version.size()-4);
+ ID = filename.substr(0, dpos);
+ version = filename.substr(dpos + 1);
+ version = version.substr(0, version.size() - 4);
return true;
}
int pos3 = strTest.Find(")");
if (pos1 >= 0 && pos2 > pos1 && pos3 > pos2)
{
- condVec.push_back(strTest.Left(pos1));
- condVec.push_back(strTest.Mid(pos1 + 1, pos2 - pos1 - 1));
- condVec.push_back(strTest.Mid(pos2 + 1, pos3 - pos2 - 1));
+ condVec.push_back(strTest.substr(0, pos1));
+ condVec.push_back(strTest.substr(pos1 + 1, pos2 - pos1 - 1));
+ condVec.push_back(strTest.substr(pos2 + 1, pos3 - pos2 - 1));
return true;
}
return false;
CScraperUrl &scurlEp(ep.cScraperUrl);
int dot = strEpNum.Find(".");
ep.iEpisode = atoi(strEpNum.c_str());
- ep.iSubepisode = (dot > -1) ? atoi(strEpNum.Mid(dot + 1).c_str()) : 0;
+ ep.iSubepisode = (dot > -1) ? atoi(strEpNum.substr(dot + 1).c_str()) : 0;
if (!XMLUtils::GetString(pxeMovie, "title", scurlEp.strTitle) || scurlEp.strTitle.empty() )
scurlEp.strTitle = g_localizeStrings.Get(416);
XMLUtils::GetString(pxeMovie, "id", scurlEp.strId);
CFileItemPtr pItem = items[i];
if (!pItem->m_bIsFolder && !StringUtils::EqualsNoCase(pItem->GetLabel(), "defaults.xml"))
{ // not the default one
- vecColors.push_back(pItem->GetLabel().Mid(0, pItem->GetLabel().size() - 4));
+ vecColors.push_back(pItem->GetLabel().substr(0, pItem->GetLabel().size() - 4));
}
}
sort(vecColors.begin(), vecColors.end(), sortstringbyname());
while ((iStart = regExp.RegFind(mainFile, iStart)) > -1)
{
int iLength = regExp.GetFindLen();
- mainFile = mainFile.Left(iStart) + regExp.GetReplaceString(strRep).c_str() + mainFile.Mid(iStart + iLength);
+ mainFile = mainFile.substr(0, iStart) + regExp.GetReplaceString(strRep) + mainFile.substr(iStart + iLength);
if (!bGlobal)
break;
}
if(pos == CStdString::npos)
continue;
- line2 = StringUtils::Format("%d,%s,%s", m_order++, layer.get(), line.Mid(pos+1).c_str());
+ line2 = StringUtils::Format("%d,%s,%s", m_order++, layer.get(), line.substr(pos+1).c_str());
m_libass->DecodeDemuxPkt((char*)line2.c_str(), line2.length(), beg, end - beg);
continue;
}
}
- else if (strFields[i].Left(1) == "#") // #12345 format for frame number
+ else if (strFields[i][0] == '#') // #12345 format for frame number
{
- iCutStartEnd[i] = (int64_t)(atol(strFields[i].Mid(1)) / fFramesPerSecond * 1000); // frame number to ms
+ iCutStartEnd[i] = (int64_t)(atol(strFields[i].substr(1).c_str()) / fFramesPerSecond * 1000); // frame number to ms
}
else // Plain old seconds in float format, e.g. 123.45
{
if (start > -1)
{
length = reg.GetSubLength(0);
- ip = utf8String.Mid(start, length);
+ ip = utf8String.substr(start, length);
}
else
start = utf8String.size();
if (CGUIDialogNumeric::ShowAndGetIPAddress(ip, g_localizeStrings.Get(14068)))
{
- utf8String = utf8String.Left(start) + ip + utf8String.Mid(start + length);
+ utf8String = utf8String.substr(0, start) + ip.c_str() + utf8String.substr(start + length);
g_charsetConverter.utf8ToW(utf8String, m_strEdit);
UpdateLabel();
CGUILabelControl* pEdit = ((CGUILabelControl*)GetControl(CTL_LABEL_EDIT));
void CGUIDialogSmartPlaylistEditor::OnOK()
{
+ std::string systemPlaylistsPath = CSettings::Get().GetString("system.playlistspath");
// save our playlist
if (m_path.empty())
{
CStdString path;
if (CGUIKeyboardFactory::ShowAndGetInput(filename, g_localizeStrings.Get(16013), false))
{
- path = URIUtils::AddFileToFolder(CSettings::Get().GetString("system.playlistspath"),m_playlist.GetSaveLocation());
+ path = URIUtils::AddFileToFolder(systemPlaylistsPath, m_playlist.GetSaveLocation());
path = URIUtils::AddFileToFolder(path, CUtil::MakeLegalFileName(filename));
}
else
{
// check if we need to actually change the save location for this playlist
// this occurs if the user switches from music video <> songs <> mixed
- if (StringUtils::EqualsNoCase(m_path.Left(CSettings::Get().GetString("system.playlistspath").size()), CSettings::Get().GetString("system.playlistspath"))) // fugly, well aware
+ if (StringUtils::StartsWith(m_path, systemPlaylistsPath))
{
CStdString filename = URIUtils::GetFileName(m_path);
- CStdString strFolder = m_path.Mid(CSettings::Get().GetString("system.playlistspath").size(),m_path.size()-filename.size()-CSettings::Get().GetString("system.playlistspath").size()-1);
+ CStdString strFolder = m_path.substr(systemPlaylistsPath.size(), m_path.size() - filename.size() - systemPlaylistsPath.size() - 1);
if (strFolder != m_playlist.GetSaveLocation())
{ // move to the correct folder
XFILE::CFile::Delete(m_path);
- m_path = URIUtils::AddFileToFolder(CSettings::Get().GetString("system.playlistspath"),m_playlist.GetSaveLocation());
+ m_path = URIUtils::AddFileToFolder(systemPlaylistsPath, m_playlist.GetSaveLocation());
m_path = URIUtils::AddFileToFolder(m_path, filename);
}
}
if (!url2.GetOptions().empty())
{
CLog::Log(LOGWARNING, "%s: ftp url option is deprecated, please switch to use protocol option (change '?' to '|'), url: [%s]", __FUNCTION__, url2.GetRedacted().c_str());
- url2.SetProtocolOptions(url2.GetOptions().Mid(1));
+ url2.SetProtocolOptions(url2.GetOptions().substr(1));
/* ftp has no options */
url2.SetOptions("");
}
execute = StringUtils::Format("ActivateWindow(%s,%s,return)", contextWindow.c_str(), StringUtils::Paramify(item.GetPath()).c_str());
}
else if (item.IsScript())
- execute = StringUtils::Format("RunScript(%s)", StringUtils::Paramify(item.GetPath().Mid(9)).c_str());
+ execute = StringUtils::Format("RunScript(%s)", StringUtils::Paramify(item.GetPath().substr(9)).c_str());
else if (item.IsAndroidApp())
- execute = StringUtils::Format("StartAndroidActivity(%s)", StringUtils::Paramify(item.GetPath().Mid(26)).c_str());
+ execute = StringUtils::Format("StartAndroidActivity(%s)", StringUtils::Paramify(item.GetPath().substr(26)).c_str());
else // assume a media file
{
if (item.IsVideoDb() && item.HasVideoInfoTag())
bool CFileReaderFile::Open(const CURL& url)
{
CStdString strURL = url.Get();
- strURL = strURL.Mid(13);
+ strURL = strURL.substr(13);
return m_reader.Open(strURL,READ_CACHED);
}
bool CFileReaderFile::Exists(const CURL& url)
{
- return CFile::Exists(url.Get().Mid(13));
+ return CFile::Exists(url.Get().substr(13));
}
int CFileReaderFile::Stat(const CURL& url, struct __stat64* buffer)
{
- return CFile::Stat(url.Get().Mid(13),buffer);
+ return CFile::Stat(url.Get().substr(13), buffer);
}
{
CURL url(base);
- int id = atoi(url.GetFileName().Mid(5));
+ int id = atoi(url.GetFileName().substr(5).c_str());
SChannels channels = m_session->GetChannels(id);
if(channels.empty())
strName = reItem.GetMatch(2);
if(strLink[0] == '/')
- strLink = strLink.Mid(1);
+ strLink = strLink.substr(1);
CStdString strNameTemp = StringUtils::Trim(strName);
// split link with url options
int pos = strLinkBase.Find('?');
if (pos != -1) {
- strLinkOptions = strLinkBase.Mid(pos);
+ strLinkOptions = strLinkBase.substr(pos);
strLinkBase.erase(pos);
}
CStdString strLinkTemp = strLinkBase;
int pos = strPath.Find("/", 12);
if (pos >= 0)
{
- CStdString firstPath = strPath.Mid(12, pos - 12);
+ CStdString firstPath = strPath.substr(12, pos - 12);
CURL::Decode(firstPath);
return firstPath;
}
CStdString strPath1 = strPath;
// remove multipath:// from path and any trailing / (so that the last path doesn't get any more than it originally had)
- strPath1 = strPath1.Mid(12);
+ strPath1 = strPath1.substr(12);
URIUtils::RemoveSlashAtEnd(strPath1);
// split on "/"
bool CMultiPathDirectory::HasPath(const CStdString& strPath, const CStdString& strPathToFind)
{
// remove multipath:// from path and any trailing / (so that the last path doesn't get any more than it originally had)
- CStdString strPath1 = strPath.Mid(12);
+ CStdString strPath1 = strPath.substr(12);
URIUtils::RemoveSlashAtEnd(strPath1);
// split on "/"
else if (fileName == "guide")
return GetGuide(base, items);
else if (fileName.Left(6) == "guide/")
- return GetGuideForChannel(base, items, atoi(fileName.Mid(6)));
+ return GetGuideForChannel(base, items, atoi(fileName.substr(6).c_str()));
else if (fileName == "movies")
return GetRecordings(base, items, MOVIES);
else if (fileName == "recordings")
else if (fileName == "tvshows")
return GetTvShowFolders(base, items);
else if (fileName.Left(8) == "tvshows/")
- return GetRecordings(base, items, TV_SHOWS, fileName.Mid(8));
+ return GetRecordings(base, items, TV_SHOWS, fileName.substr(8).c_str());
return false;
}
#include "utils/log.h"
#include "utils/StringUtils.h"
#include "utils/TimeUtils.h"
+#include "utils/StringUtils.h"
extern "C" {
#include "cmyth/include/cmyth/cmyth.h"
bool CMythFile::SetupFile(const CURL& url)
{
- if (url.GetFileName().Left(6) != "files/")
+ if (!StringUtils::StartsWith(url.GetFileName(), "files/"))
return false;
if(!SetupConnection(url, true, false, false))
return false;
- m_filename = url.GetFileName().Mid(6);
+ m_filename = url.GetFileName().substr(6);
m_file = m_dll->conn_connect_path((char*)m_filename.c_str(), m_control, 16*1024, 4096);
if(!m_file)
&& category != "SP") // Sports
return;
- if (programid.Mid(category.length(), seriesid.length()) != seriesid) // Series ID does not follow the category
+ if (programid.substr(category.length(), seriesid.length()) != seriesid) // Series ID does not follow the category
return;
- CStdString remainder = programid.Mid(category.length() + seriesid.length()); // Whatever is after series ID
+ CStdString remainder = programid.substr(category.length() + seriesid.length()); // Whatever is after series ID
/*
* All SchedulesDirect remainders appear to be 4 characters and start with a 0. If the assumption
*season = atoi(remainder.Right(2));
*episode = atoi(remainder.Left(1));
}
- else if (remainder.Mid(2, 1) == "0") // e.g. 203. Can't have a season start with 0. Must be end of episode.
+ else if (remainder.substr(2, 1) == "0") // e.g. 203. Can't have a season start with 0. Must be end of episode.
{
*season = atoi(remainder.Right(1)); // TODO: Fix for base 36 in Myth 0.24. Assume season < 10
*episode = atoi(remainder.Left(2));
/* handling of mimetypes fo directories are sub optimal at best */
if(best->mime == "application/rss+xml" && StringUtils::StartsWithNoCase(item->GetPath(), "http://"))
- item->SetPath("rss://" + item->GetPath().Mid(7));
+ item->SetPath("rss://" + item->GetPath().substr(7));
if(StringUtils::StartsWithNoCase(item->GetPath(), "rss://"))
item->m_bIsFolder = true;
strURL = StringUtils::TrimRight(strRoot, "/");
pos = strURL.ReverseFind('/');
strRTV = strURL.Left(pos + 1);
- strRTV.Replace("*", strURL.Mid(pos + 1));
+ strRTV.Replace("*", strURL.substr(pos + 1).c_str());
CURL tmpURL(strRTV);
// Force the newly constructed share into the right variables to
CStdString strRecorded = recordedNode->FirstChild()->Value();
int iYear, iMonth, iDay;
- iYear = atoi(strRecorded.Left(4).c_str());
- iMonth = atoi(strRecorded.Mid(5, 2).c_str());
- iDay = atoi(strRecorded.Mid(8, 2).c_str());
+ iYear = atoi(strRecorded.substr(0, 4).c_str());
+ iMonth = atoi(strRecorded.substr(5, 2).c_str());
+ iDay = atoi(strRecorded.substr(8, 2).c_str());
dtDateTime.wYear = iYear;
dtDateTime.wMonth = iMonth;
dtDateTime.wDay = iDay;
int iHour, iMin, iSec;
- iHour = atoi(strRecorded.Mid(11, 2).c_str());
- iMin = atoi(strRecorded.Mid(14, 2).c_str());
- iSec = atoi(strRecorded.Mid(17, 2).c_str());
+ iHour = atoi(strRecorded.substr(11, 2).c_str());
+ iMin = atoi(strRecorded.substr(14, 2).c_str());
+ iSec = atoi(strRecorded.substr(17, 2).c_str());
dtDateTime.wHour = iHour;
dtDateTime.wMinute = iMin;
dtDateTime.wSecond = iSec;
m_strPathInRar = url.GetFileName();
vector<std::string> options;
- StringUtils::Tokenize(url.GetOptions().Mid(1), options, "&");
+ StringUtils::Tokenize(url.GetOptions().substr(1), options, "&");
m_bFileOptions = 0;
static CStdString CorrectPath(const CStdString path)
{
- if(path == "~" || path.Left(2) == "~/")
- return "./" + path.Mid(2);
+ if(path == "~" || path.substr(0, 2) == "~/")
+ return "./" + path.substr(2);
else
return "/" + path;
}
CStdString RootDir;
// Split up into the special://root and the rest of the filename
- int pos = FullFileName.Find('/');
- if (pos != -1 && pos > 1)
+ size_t pos = FullFileName.find('/');
+ if (pos != std::string::npos && pos > 1)
{
- RootDir = FullFileName.Left(pos);
+ RootDir = FullFileName.substr(0, pos);
- if (pos < FullFileName.GetLength())
- FileName = FullFileName.Mid(pos + 1);
+ if (pos < FullFileName.size())
+ FileName = FullFileName.substr(pos + 1);
}
else
RootDir = FullFileName;
{
CFileItemPtr item = items[i];
if (strnicmp(item->GetPath().c_str(), translatedPath.c_str(), translatedPath.GetLength()) == 0)
- item->SetPath(URIUtils::AddFileToFolder(untranslatedPath, item->GetPath().Mid(translatedPath.GetLength())));
+ item->SetPath(URIUtils::AddFileToFolder(untranslatedPath, item->GetPath().substr(translatedPath.GetLength())));
}
return true;
}
URIUtils::Split(strPath, folder, file); // single filed stacks - should really not happen
// remove "stack://" from the folder
- folder = folder.Mid(8);
+ folder = folder.substr(8);
file.Replace(",,", ",");
return URIUtils::AddFileToFolder(folder, file);
// filenames with commas are double escaped (ie replaced with ,,), thus the " , " separator used.
CStdString path = strPath;
// remove stack:// from the beginning
- path = path.Mid(8);
+ path = path.substr(8);
vecPaths.clear();
StringUtils::SplitString(path, " , ", vecPaths);
if (path.Left(9) == "channels/")
{
- CStdString channel = path.Mid(9);
+ CStdString channel = path.substr(9);
if(!URIUtils::HasExtension(channel, ".ts"))
{
CLog::Log(LOGERROR, "%s - invalid channel url %s", __FUNCTION__, channel.c_str());
// now switch to the next letter
CStdString current = m_letterOffsets[currentLetter].second;
- int startPos = (letters.Find(current) + 1) % letters.size();
+ size_t startPos = (letters.find(current) + 1) % letters.size();
// now jump to letters[startPos], or another one in the same range if possible
- int pos = startPos;
+ size_t pos = startPos;
while (true)
{
// check if we can jump to this letter
- for (unsigned int i = 0; i < m_letterOffsets.size(); i++)
+ for (size_t i = 0; i < m_letterOffsets.size(); i++)
{
- if (m_letterOffsets[i].second == letters.Mid(pos, 1))
+ if (m_letterOffsets[i].second == letters.substr(pos, 1))
{
SelectItem(m_letterOffsets[i].first);
return;
if (StringUtils::StartsWithNoCase(label, "$var"))
{
- label2 = label.Mid(5, label.length() - 6);
+ label2 = label.substr(5, label.length() - 6);
m_info = g_infoManager.TranslateSkinVariableString(label2, context);
if (!m_info)
m_info = g_infoManager.RegisterSkinVariableString(g_SkinInfo->CreateSkinVariable(label2, context));
}
if (StringUtils::StartsWithNoCase(label, "$info"))
- label2 = label.Mid(6, label.length()-7);
+ label2 = label.substr(6, label.length()-7);
m_info = g_infoManager.TranslateString(label2);
if (!m_info)
{
CStdString work(label);
// Replace all $LOCALIZE[number] with the real string
- int pos1 = work.Find("$LOCALIZE[");
- while (pos1 >= 0)
+ size_t pos1 = work.find("$LOCALIZE[");
+ while (pos1 != std::string::npos)
{
- int pos2 = StringUtils::FindEndBracket(work, '[', ']', pos1 + 10);
+ size_t pos2 = StringUtils::FindEndBracket(work, '[', ']', pos1 + 10);
if (pos2 > pos1)
{
- CStdString left = work.Left(pos1);
- CStdString right = work.Mid(pos2 + 1);
- CStdString replace = g_localizeStringsTemp.Get(atoi(work.Mid(pos1 + 10).c_str()));
+ CStdString left = work.substr(0, pos1);
+ CStdString right = work.substr(pos2 + 1);
+ CStdString replace = g_localizeStringsTemp.Get(atoi(work.substr(pos1 + 10).c_str()));
if (replace == "")
- replace = g_localizeStrings.Get(atoi(work.Mid(pos1 + 10).c_str()));
+ replace = g_localizeStrings.Get(atoi(work.substr(pos1 + 10).c_str()));
work = left + replace + right;
}
else
CStdString work(label);
//FIXME why not use RE here?
// Replace all $ADDON[id number] with the real string
- int pos1 = work.Find("$ADDON[");
- while (pos1 >= 0)
+ size_t pos1 = work.find("$ADDON[");
+ while (pos1 != std::string::npos)
{
- int pos2 = StringUtils::FindEndBracket(work, '[', ']', pos1 + 7);
+ size_t pos2 = StringUtils::FindEndBracket(work, '[', ']', pos1 + 7);
if (pos2 > pos1)
{
- CStdString left = work.Left(pos1);
- CStdString right = work.Mid(pos2 + 1);
- int length = work.Find(" ", pos1 + 7) - (pos1 + 7);
- CStdString id = work.substr(pos1+7, length);
- int stringid = atoi(work.substr(pos1+7+id.length()+1, 5).c_str());
+ CStdString left = work.substr(0, pos1);
+ CStdString right = work.substr(pos2 + 1);
+ size_t length = work.find(" ", pos1 + 7) - (pos1 + 7);
+ CStdString id = work.substr(pos1 + 7, length);
+ int stringid = atoi(work.substr(pos1 + 7 + id.length() + 1, 5).c_str());
CStdString replace = CAddonMgr::Get().GetString(id, stringid);
work = left + replace + right;
}
do
{
format = NONE;
- int pos1 = work.size();
- int pos2;
- int len = 0;
+ size_t pos1 = work.size();
+ size_t pos2;
+ size_t len = 0;
for (size_t i = 0; i < sizeof(infoformatmap) / sizeof(infoformat); i++)
{
pos2 = work.Find(infoformatmap[i].str);
- if (pos2 != (int)string::npos && pos2 < pos1)
+ if (pos2 != string::npos && pos2 < pos1)
{
pos1 = pos2;
len = strlen(infoformatmap[i].str);
if (pos2 > pos1)
{
// decipher the block
- CStdString block = work.Mid(pos1 + len, pos2 - pos1 - len);
+ CStdString block = work.substr(pos1 + len, pos2 - pos1 - len);
CStdStringArray params;
StringUtils::SplitString(block, ",", params);
int info;
postfix = params[2];
m_info.push_back(CInfoPortion(info, prefix, postfix, format == FORMATESCINFO));
// and delete it from our work string
- work = work.Mid(pos2 + 1);
+ work = work.substr(pos2 + 1);
}
else
{
// add the first unclickable block
if (startClickable != CStdString::npos)
- AddString(text.Mid(startUnclickable, startClickable - startUnclickable), false);
+ AddString(text.substr(startUnclickable, startClickable - startUnclickable), false);
else
- AddString(text.Mid(startUnclickable), false);
+ AddString(text.substr(startUnclickable), false);
while (startClickable != CStdString::npos)
{
// grep out the action and the end of the string
- size_t endAction = text.Find(']', startClickable + 8);
- size_t endClickable = text.Find("[/ONCLICK]", startClickable + 8);
- if (endAction != CStdString::npos && endClickable != CStdString::npos)
+ size_t endAction = text.find(']', startClickable + 8);
+ size_t endClickable = text.find("[/ONCLICK]", startClickable + 8);
+ if (endAction != std::string::npos && endClickable != std::string::npos)
{ // success - add the string, and move the start of our next unclickable portion along
- AddString(text.Mid(endAction + 1, endClickable - endAction - 1), true, text.Mid(startClickable + 8, endAction - startClickable - 8));
+ AddString(text.substr(endAction + 1, endClickable - endAction - 1), true, text.substr(startClickable + 8, endAction - startClickable - 8));
startUnclickable = endClickable + 10;
}
else
CLog::Log(LOGERROR, "Invalid multiselect string %s", text.c_str());
break;
}
- startClickable = text.Find("[ONCLICK", startUnclickable);
+ startClickable = text.find("[ONCLICK", startUnclickable);
// add the unclickable portion
if (startClickable != CStdString::npos)
- AddString(text.Mid(startUnclickable, startClickable - startUnclickable), false);
+ AddString(text.substr(startUnclickable, startClickable - startUnclickable), false);
else
- AddString(text.Mid(startUnclickable), false);
+ AddString(text.substr(startUnclickable), false);
}
m_oldText = text;
// but [LOWERCASE]Glah[UPPERCASE]FReD[/UPPERCASE]Georeg[/LOWERCASE] won't
int startPos = 0;
- size_t pos = text.Find(L'[');
- while (pos != CStdString::npos && pos + 1 < text.size())
+ size_t pos = text.find(L'[');
+ while (pos != std::string::npos && pos + 1 < text.size())
{
uint32_t newStyle = 0;
color_t newColor = currentColor;
bool newLine = false;
// have a [ - check if it's an ON or OFF switch
bool on(true);
- int endPos = pos++; // finish of string
+ size_t endPos = pos++; // finish of string
if (text[pos] == L'/')
{
on = false;
pos++;
}
// check for each type
- if (text.Mid(pos,2) == L"B]")
+ if (text.compare(pos, 2, L"B]") == 0)
{ // bold - finish the current text block and assign the bold state
pos += 2;
- if ((on && text.Find(L"[/B]",pos) >= 0) || // check for a matching end point
+ if ((on && text.find(L"[/B]",pos) != std::string::npos) || // check for a matching end point
(!on && (currentStyle & FONT_STYLE_BOLD))) // or matching start point
newStyle = FONT_STYLE_BOLD;
}
- else if (text.Mid(pos,2) == L"I]")
+ else if (text.compare(pos, 2, L"I]") == 0)
{ // italics
pos += 2;
- if ((on && text.Find(L"[/I]",pos) >= 0) || // check for a matching end point
+ if ((on && text.find(L"[/I]", pos) != std::string::npos) || // check for a matching end point
(!on && (currentStyle & FONT_STYLE_ITALICS))) // or matching start point
newStyle = FONT_STYLE_ITALICS;
}
- else if (text.Mid(pos,10) == L"UPPERCASE]")
+ else if (text.compare(pos, 10, L"UPPERCASE]") == 0)
{
pos += 10;
- if ((on && text.Find(L"[/UPPERCASE]",pos) >= 0) || // check for a matching end point
+ if ((on && text.find(L"[/UPPERCASE]", pos) != std::string::npos) || // check for a matching end point
(!on && (currentStyle & FONT_STYLE_UPPERCASE))) // or matching start point
newStyle = FONT_STYLE_UPPERCASE;
}
- else if (text.Mid(pos,10) == L"LOWERCASE]")
+ else if (text.compare(pos, 10, L"LOWERCASE]") == 0)
{
pos += 10;
- if ((on && text.Find(L"[/LOWERCASE]",pos) >= 0) || // check for a matching end point
+ if ((on && text.find(L"[/LOWERCASE]", pos) != std::string::npos) || // check for a matching end point
(!on && (currentStyle & FONT_STYLE_LOWERCASE))) // or matching start point
newStyle = FONT_STYLE_LOWERCASE;
}
- else if (text.Mid(pos,3) == L"CR]" && on)
+ else if (text.compare(pos, 3, L"CR]") == 0 && on)
{
newLine = true;
pos += 3;
}
- else if (text.Mid(pos,5) == L"COLOR")
+ else if (text.compare(pos,5, L"COLOR") == 0)
{ // color
- size_t finish = text.Find(L']', pos + 5);
- if (on && finish != CStdString::npos && (size_t)text.Find(L"[/COLOR]",finish) != CStdString::npos)
+ size_t finish = text.find(L']', pos + 5);
+ if (on && finish != std::string::npos && text.find(L"[/COLOR]",finish) != std::string::npos)
{
- color_t color = g_colorManager.GetColor(text.Mid(pos + 5, finish - pos - 5));
+ color_t color = g_colorManager.GetColor(text.substr(pos + 5, finish - pos - 5));
vecColors::const_iterator it = std::find(colors.begin(), colors.end(), color);
if (it == colors.end())
{ // create new color
if (newStyle || colorTagChange || newLine)
{ // we have a new style or a new color, so format up the previous segment
- CStdStringW subText = text.Mid(startPos, endPos - startPos);
+ CStdStringW subText = text.substr(startPos, endPos - startPos);
if (currentStyle & FONT_STYLE_UPPERCASE)
StringUtils::ToUpper(subText);
if (currentStyle & FONT_STYLE_LOWERCASE)
pos = text.Find(L'[',pos);
}
// now grab the remainder of the string
- CStdStringW subText = text.Mid(startPos, text.GetLength() - startPos);
+ CStdStringW subText = text.substr(startPos);
if (currentStyle & FONT_STYLE_UPPERCASE)
StringUtils::ToUpper(subText);
if (currentStyle & FONT_STYLE_LOWERCASE)
return WINDOW_INVALID;
StringUtils::ToLower(strWindow);
// eliminate .xml
- if (strWindow.Mid(strWindow.GetLength() - 4) == ".xml" )
- strWindow = strWindow.Mid(0, strWindow.GetLength() - 4);
+ if (StringUtils::EndsWith(strWindow, ".xml"))
+ strWindow = strWindow.substr(0, strWindow.size() - 4);
// window12345, for custom window to be keymapped
if (strWindow.length() > 6 && StringUtils::StartsWithNoCase(strWindow, "window"))
- strWindow = strWindow.Mid(6);
+ strWindow = strWindow.substr(6);
if (strWindow.Left(2) == "my") // drop "my" prefix
- strWindow = strWindow.Mid(2);
+ strWindow = strWindow.substr(2);
if (StringUtils::IsNaturalNumber(strWindow))
{
// allow a full window id or a delta id
askToResume = false;
}
else if (StringUtils::StartsWithNoCase(params[i], "playoffset=")) {
- playOffset = atoi(params[i].Mid(11)) - 1;
+ playOffset = atoi(params[i].substr(11).c_str()) - 1;
item.SetProperty("playlist_starting_track", playOffset);
}
}
else if (params[i].Equals("pause"))
flags |= 8;
else if (StringUtils::StartsWithNoCase(params[i], "beginslide="))
- beginSlidePath = params[i].Mid(11);
+ beginSlidePath = params[i].substr(11);
}
}
if (parameter.size() == 14)
CLog::Log(LOGERROR,"PlayerControl(seekpercentage(n)) called with no argument");
else if (parameter.size() < 17) // arg must be at least "(N)"
- CLog::Log(LOGERROR,"PlayerControl(seekpercentage(n)) called with invalid argument: \"%s\"", parameter.Mid(14).c_str());
+ CLog::Log(LOGERROR,"PlayerControl(seekpercentage(n)) called with invalid argument: \"%s\"", parameter.substr(14).c_str());
else
{
// Don't bother checking the argument: an invalid arg will do seek(0)
- offset = parameter.Mid(15);
+ offset = parameter.substr(15);
StringUtils::TrimRight(offset, ")");
float offsetpercent = (float) atof(offset.c_str());
if (offsetpercent < 0 || offsetpercent > 100)
context = PARTYMODECONTEXT_VIDEO;
else if (parameter.size() != 16 || !StringUtils::EndsWithNoCase(parameter, "music)"))
{
- strXspPath = parameter.Mid(10);
+ strXspPath = parameter.substr(10);
StringUtils::TrimRight(strXspPath, ")");
context = PARTYMODECONTEXT_UNKNOWN;
}
if (!defaultt.empty() && defaultt.size() == 10)
{
CStdString sDefault = defaultt;
- timedate.wDay = atoi(sDefault.Left(2));
- timedate.wMonth = atoi(sDefault.Mid(3,4));
- timedate.wYear = atoi(sDefault.Right(4));
+ timedate.wDay = atoi(sDefault.substr(0, 2).c_str());
+ timedate.wMonth = atoi(sDefault.substr(3, 4).c_str());
+ timedate.wYear = atoi(sDefault.substr(sDefault.size() - 4).c_str());
}
if (CGUIDialogNumeric::ShowAndGetDate(timedate, heading))
value = StringUtils::Format("%2d/%2d/%4d", timedate.wDay, timedate.wMonth, timedate.wYear);
if (!defaultt.empty() && defaultt.size() == 10)
{
CStdString sDefault = defaultt;
- timedate.wDay = atoi(sDefault.Left(2));
- timedate.wMonth = atoi(sDefault.Mid(3,4));
- timedate.wYear = atoi(sDefault.Right(4));
+ timedate.wDay = atoi(sDefault.substr(0, 2).c_str());
+ timedate.wMonth = atoi(sDefault.substr(3, 4).c_str());
+ timedate.wYear = atoi(sDefault.substr(sDefault.size() - 4).c_str());
}
if (CGUIDialogNumeric::ShowAndGetDate(timedate, heading))
value = StringUtils::Format("%2d/%2d/%4d", timedate.wDay, timedate.wMonth, timedate.wYear);
else if (key == "date")
{
if (value.length() == 10)
- item->m_dateTime.SetDate(atoi(value.Right(4).c_str()), atoi(value.Mid(3,4).c_str()), atoi(value.Left(2).c_str()));
+ {
+ int year = atoi(value.substr(value.size() - 4).c_str());
+ int month = atoi(value.substr(3, 4).c_str());
+ int day = atoi(value.substr(0, 2).c_str());
+ item->m_dateTime.SetDate(year, month, day);
+ }
else
CLog::Log(LOGERROR,"NEWADDON Invalid Date Format \"%s\"",value.c_str());
}
else if (key == "date")
{
if (strlen(value) == 10)
- item->m_dateTime.SetDate(atoi(value.Right(4)), atoi(value.Mid(3,4)), atoi(value.Left(2)));
+ {
+ int year = atoi(value.substr(value.size() - 4).c_str());
+ int month = atoi(value.substr(3, 4).c_str());
+ int day = atoi(value.substr(0, 2).c_str());
+ item->m_dateTime.SetDate(year, month, day); }
}
else
CLog::Log(LOGERROR,"NEWADDON Unknown Music Info Key \"%s\"", key.c_str());
else if (key == "date")
{
if (strlen(value) == 10)
- item->m_dateTime.SetDate(atoi(value.Right(4)), atoi(value.Mid(3,4)), atoi(value.Left(2)));
+ {
+ int year = atoi(value.substr(value.size() - 4).c_str());
+ int month = atoi(value.substr(3, 4).c_str());
+ int day = atoi(value.substr(0, 2).c_str());
+ item->m_dateTime.SetDate(year, month, day);
+ }
}
else
{
const CStdString& exifkey = key;
if (!StringUtils::StartsWithNoCase(exifkey, "exif:") || exifkey.length() < 6) continue;
- int info = CPictureInfoTag::TranslateString(exifkey.Mid(5));
+ int info = CPictureInfoTag::TranslateString(exifkey.substr(5));
item->GetPictureInfoTag()->SetInfo(info, value);
}
}
while (s[i] == ' ' || s[i] == '\t') i++;
}
- countryCode = s.Left(2);
- countryName = s.Mid(i);
+ countryCode = s.substr(0, 2);
+ countryName = s.substr(i);
m_counties.push_back(countryName);
m_countryByCode[countryCode] = countryName;
CStdString newThumb;
if (result.Left(14) == "thumb://Remote")
{
- int number = atoi(result.Mid(14));
+ int number = atoi(result.substr(14).c_str());
newThumb = thumbs[number];
}
else if (result == "thumb://Local")
if (result.Equals("fanart://Local"))
result = strLocal;
- if (result.Left(15) == "fanart://Remote")
+ if (StringUtils::StartsWith(result, "fanart://Remote"))
{
- int iFanart = atoi(result.Mid(15).c_str());
+ int iFanart = atoi(result.substr(15).c_str());
m_artist.fanart.SetPrimaryFanart(iFanart);
result = m_artist.fanart.GetImageURL();
}
l.flags = 0;
l.timing = (unsigned int) MathUtils::round_int( m_lyrics[ i ].timing + j * time_per_char );
- g_charsetConverter.wToUTF8( utf16.Mid( j, 1 ), l.text );
+ g_charsetConverter.wToUTF8( utf16.substr(j, 1), l.text);
if ( l.text == " " )
{
for ( ; idx < lines.size() && lines[idx][0] == '#'; idx++ )
{
// Parse into key:value
- int offset = lines[idx].Find( ':' );
-
- if ( offset == -1 )
+ size_t offset = lines[idx].find(':');
+ if (offset == std::string::npos)
{
CLog::Log( LOGERROR, "UStar lyric loader: invalid line '%s', no semicolon", lines[idx].c_str() );
return false;
}
- CStdString key = lines[idx].Mid( 1, offset - 1 );
- CStdString value = lines[idx].Mid( offset + 1 );
+ CStdString key = lines[idx].substr(1, offset - 1);
+ CStdString value = lines[idx].substr(offset + 1);
if ( key == "TITLE" )
m_songName = value;
{
// saves playlist to the playlist folder
CStdString name = URIUtils::GetFileName(m_strLoadedPlaylist);
- CStdString strExt = URIUtils::GetExtension(name);
- name = name.Mid(0,name.size()-strExt.size());
+ URIUtils::RemoveExtension(name);
+
if (CGUIKeyboardFactory::ShowAndGetInput(name, g_localizeStrings.Get(16012), false))
{ // save playlist as an .m3u
PLAYLIST::CPlayListM3U playlist;
{
CAirPlayServer::m_isPlaying++;
// Get URL to play
- int start = body.Find("Content-Location: ");
- if (start == -1)
+ std::string contentLocation = "Content-Location: ";
+ size_t start = body.find(contentLocation);
+ if (start == std::string::npos)
return AIRPLAY_STATUS_NOT_IMPLEMENTED;
- start += strlen("Content-Location: ");
- int end = body.Find('\n', start);
- location = body.Mid(start, end - start);
+ start += contentLocation.size();
+ int end = body.find('\n', start);
+ location = body.substr(start, end - start);
- start = body.Find("Start-Position");
- if (start != -1)
+ std::string startPosition = "Start-Position: ";
+ start = body.find(startPosition);
+ if (start != std::string::npos)
{
- start += strlen("Start-Position: ");
- int end = body.Find('\n', start);
- CStdString positionStr = body.Mid(start, end - start);
+ start += startPosition.size();
+ int end = body.find('\n', start);
+ std::string positionStr = body.substr(start, end - start);
position = (float)atof(positionStr.c_str());
}
}
{
if (strValue[i] == ' ' && strValue[i + 1] == '/' && strValue[i + 2] == ' ')
{
- m_strDisk_artist = TrimToUTF8(strValue.Left(i));
- m_strDisk_title = TrimToUTF8(strValue.Mid(i+3));
+ m_strDisk_artist = TrimToUTF8(strValue.substr(0, i));
+ m_strDisk_title = TrimToUTF8(strValue.substr(i+3));
found = true;
break;
}
// as a fallback
int iPos = strExtd.Find("YEAR:");
if (iPos > -1) // You never know if you really get UTF-8 strings from cddb
- g_charsetConverter.unknownToUTF8(strExtd.Mid(iPos + 6, 4), m_strYear);
+ g_charsetConverter.unknownToUTF8(strExtd.substr(iPos + 6, 4), m_strYear);
}
if (m_strGenre.empty())
int iPos = strExtd.Find("ID3G:");
if (iPos > -1)
{
- CStdString strGenre = strExtd.Mid(iPos + 5, 4);
+ CStdString strGenre = strExtd.substr(iPos + 5, 4);
StringUtils::TrimLeft(strGenre);
if (StringUtils::IsNaturalNumber(strGenre))
{
if (fread(buffer, sizeof(char), sizeof(buffer), pipe) > 0 && !ferror(pipe))
{
tmpStr = buffer;
- result = tmpStr.Mid(11);
+ result = tmpStr.substr(11);
}
else
{
if (fread(buffer, sizeof(char), sizeof(buffer), pipe) > 0 && !ferror(pipe))
{
tmpStr = buffer;
- result.push_back(tmpStr.Mid(17));
+ result.push_back(tmpStr.substr(17));
}
else
{
bool sorted = false;
CStdStringArray tokens = StringUtils::SplitString(criteria, ",");
for (vector<CStdString>::reverse_iterator itr = tokens.rbegin(); itr != tokens.rend(); itr++) {
- CStdString method = itr->Mid(1);
+ CStdString method = itr->substr(1);
SortDescription sorting;
/* Platinum guarantees 1st char is - or + */
if (strlen(m_exifInfo.DateTime) >= 19 && m_exifInfo.DateTime[0] != ' ')
{
CStdString dateTime = m_exifInfo.DateTime;
- int year = atoi(dateTime.Mid(0, 4).c_str());
- int month = atoi(dateTime.Mid(5, 2).c_str());
- int day = atoi(dateTime.Mid(8, 2).c_str());
- int hour = atoi(dateTime.Mid(11,2).c_str());
- int min = atoi(dateTime.Mid(14,2).c_str());
- int sec = atoi(dateTime.Mid(17,2).c_str());
+ int year = atoi(dateTime.substr(0, 4).c_str());
+ int month = atoi(dateTime.substr(5, 2).c_str());
+ int day = atoi(dateTime.substr(8, 2).c_str());
+ int hour = atoi(dateTime.substr(11,2).c_str());
+ int min = atoi(dateTime.substr(14,2).c_str());
+ int sec = atoi(dateTime.substr(17,2).c_str());
m_dateTimeTaken.SetDateTime(year, month, day, hour, min, sec);
}
}
if (strLine.Left( (int)strlen(M3U_INFO_MARKER) ) == M3U_INFO_MARKER)
{
// start of info
- int iColon = (int)strLine.find(":");
- int iComma = (int)strLine.find(",");
- if (iColon >= 0 && iComma >= 0 && iComma > iColon)
+ size_t iColon = strLine.find(":");
+ size_t iComma = strLine.find(",");
+ if (iColon != std::string::npos &&
+ iComma != std::string::npos &&
+ iComma > iColon)
{
// Read the info and duration
iColon++;
- CStdString strLength = strLine.Mid(iColon, iComma - iColon);
+ CStdString strLength = strLine.substr(iColon, iComma - iColon);
lDuration = atoi(strLength.c_str());
iComma++;
- strInfo = strLine.Right((int)strLine.size() - iComma);
+ strInfo = strLine.substr(iComma);
g_charsetConverter.unknownToUTF8(strInfo);
}
}
strLine = szLine;
StringUtils::RemoveCRLF(strLine);
- if (strLine.Left(18) == "[InternetShortcut]")
+ if (StringUtils::StartsWith(strLine, "[InternetShortcut]"))
{
if (file.ReadString(szLine,1024))
{
strLine = szLine;
StringUtils::RemoveCRLF(strLine);
- if (strLine.Left(4) == "URL=")
+ if (StringUtils::StartsWith(strLine, "URL="))
{
- CFileItemPtr newItem(new CFileItem(strLine.Mid(4),false));
+ CFileItemPtr newItem(new CFileItem(strLine.substr(4), false));
Add(newItem);
}
}
// This is tricky - ideally we want to completely save the state of this dialog,
// close it while linking to the addon manager, then reopen it on return.
// For now, we just close the dialog + send the GetPath() to open the addons window
- CStdString content = m_vecItems->Get(iSelected)->GetPath().Mid(14);
+ CStdString content = m_vecItems->Get(iSelected)->GetPath().substr(14);
OnCancel();
Close();
CBuiltins::Execute("ActivateWindow(AddonBrowser,addons://all/xbmc.metadata.scraper." + content + ",return)");
return "FFFFFFFF";
// format is AARRGGBB,AARRGGBB etc.
- return m_fanart[0].strColors.Mid(index*9, 8);
+ return m_fanart[0].strColors.substr(index*9, 8);
}
bool CFanart::SetPrimaryFanart(unsigned int index)
if (iTableRowEnd < -1)
break;
- CStdString strRow = strTable.Mid(iTableRowStart, 1 + iTableRowEnd - iTableRowStart);
+ CStdString strRow = strTable.substr(iTableRowStart, 1 + iTableRowEnd - iTableRowStart);
m_vecColums.push_back(strRow);
iTableRowStart = iTableRowEnd + 1;
iPosEnd = (int)strHTML.size();
}
- CStdString strTable = strHTML.Mid(iPosStart, 1 + iPosEnd - iPosStart);
+ CStdString strTable = strHTML.substr(iPosStart, 1 + iPosEnd - iPosStart);
int iTableRowStart = 0;
do
{
if (iTableRowEnd < 0)
break;
- CStdString strRow = strTable.Mid(iTableRowStart, 1 + iTableRowEnd - iTableRowStart);
+ CStdString strRow = strTable.substr(iTableRowStart, 1 + iTableRowEnd - iTableRowStart);
CHTMLRow row;
row.Parse(strRow);
m_vecRows.push_back(row);
if (iStart < 0) return -1;
int iEnd = strHTMLLow.Find(">", iStart);
if (iEnd < 0) iEnd = (int)strHTMLLow.size();
- strtagFound = strHTMLLow.Mid(iStart, (iEnd + 1) - iStart);
+ strtagFound = strHTMLLow.substr(iStart, (iEnd + 1) - iStart);
return iStart;
}
int iEnd = strHTMLLow.Find(">", iStart);
if (iEnd < 0) iEnd = (int)strHTMLLow.size();
- strtagFound = strHTMLLow.Mid(iStart, (iEnd + 1) - iStart);
+ strtagFound = strHTMLLow.substr(iStart, (iEnd + 1) - iStart);
return iStart;
}
if (iStart >= 0 && iEnd >= 0)
{
iStart++;
- strValue = strTagAndValue.Mid(iStart, iEnd - iStart);
+ strValue = strTagAndValue.substr(iStart, iEnd - iStart);
}
}
while (strTagAndValue[iEnd] != 0x27 && strTagAndValue[iEnd] != 0x20 && strTagAndValue[iEnd] != 34 && strTagAndValue[iEnd] != '>') iEnd++;
if (iStart >= 0 && iEnd >= 0)
{
- strValue = strTagAndValue.Mid(iStart, iEnd - iStart);
+ strValue = strTagAndValue.substr(iStart, iEnd - iStart);
}
}
(base==16?iswxdigit(strStripped[iPos]):iswdigit(strStripped[iPos])))
iPos++;
- num = strStripped.Mid(i,iPos-i);
+ num = strStripped.substr(i, iPos-i);
wchar_t val = (wchar_t)wcstol(num.c_str(),NULL,base);
if (base == 10)
num = StringUtils::Format(L"&#%ls;", num.c_str());
m_staticContent[label].push_back(work.Left(findStart));
m_dynamicContent[label].push_back(CMaskString("",
reg.GetMatch(1)[0], ""));
- work = work.Mid(findStart + reg.GetFindLen());
+ work = work.substr(findStart + reg.GetFindLen());
}
m_staticContent[label].push_back(work);
}
reg.GetMatch(2),
reg.GetMatch(4)[0],
reg.GetMatch(5)));
- work = work.Mid(findStart + reg.GetFindLen());
+ work = work.substr(findStart + reg.GetFindLen());
}
SplitMask(label, work);
assert(m_staticContent[label].size() == m_dynamicContent[label].size() + 1);
if (pos2 == (int)CStdString::npos)
return false;
// found static content - thus we have the dynamic content surrounded
- FillMusicMaskContent(m_dynamicContent[0][i - 1].m_content, fileName.Mid(pos1, pos2 - pos1), tag);
+ FillMusicMaskContent(m_dynamicContent[0][i - 1].m_content, fileName.substr(pos1, pos2 - pos1), tag);
pos1 = pos2 + m_staticContent[0][i].size();
}
return true;
if (iSplit > 0)
{
CStdString strLeft, strRight;
- const bool bLeft = Lookup(strLeft, code.Left(iSplit));
- const bool bRight = Lookup(strRight, code.Mid(iSplit + 1));
+ const bool bLeft = Lookup(strLeft, code.substr(0, iSplit));
+ const bool bRight = Lookup(strRight, code.substr(iSplit + 1));
if (bLeft || bRight)
{
desc = "";
if (strLeft.length() > 0)
desc = strLeft;
else
- desc = code.Left(iSplit);
+ desc = code.substr(0, iSplit);
if (strRight.length() > 0)
{
else
{
desc += " - ";
- desc += code.Mid(iSplit + 1);
+ desc += code.substr(iSplit + 1);
}
return true;
}
GetNewsItems(rssXmlNode,iFeed);
// avoid trailing ' - '
- if (m_strFeed[iFeed].size() > 3 && m_strFeed[iFeed].Mid(m_strFeed[iFeed].size() - 3) == L" - ")
+ if (m_strFeed[iFeed].size() > 3 && m_strFeed[iFeed].substr(m_strFeed[iFeed].size() - 3) == L" - ")
{
if (m_rtlText)
{
void CScraperParser::ReplaceBuffers(CStdString& strDest)
{
// insert buffers
- int iIndex;
+ size_t iIndex;
for (int i=MAX_SCRAPER_BUFFERS-1; i>=0; i--)
{
iIndex = 0;
CStdString temp = StringUtils::Format("$$%i",i+1);
- while ((size_t)(iIndex = strDest.find(temp,iIndex)) != CStdString::npos) // COPIED FROM CStdString WITH THE ADDITION OF $ ESCAPING
+ 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]);
iIndex += m_param[i].length();
}
// insert settings
iIndex = 0;
- while ((size_t)(iIndex = strDest.find("$INFO[",iIndex)) != CStdString::npos)
+ while ((iIndex = strDest.find("$INFO[", iIndex)) != CStdString::npos)
{
- int iEnd = strDest.Find("]",iIndex);
- CStdString strInfo = strDest.Mid(iIndex+6,iEnd-iIndex-6);
+ size_t iEnd = strDest.find("]", iIndex);
+ CStdString strInfo = strDest.substr(iIndex+6, iEnd - iIndex - 6);
CStdString strReplace;
if (m_scraper)
strReplace = m_scraper->GetSetting(strInfo);
}
// insert localize strings
iIndex = 0;
- while ((size_t)(iIndex = strDest.find("$LOCALIZE[",iIndex)) != CStdString::npos)
+ while ((iIndex = strDest.find("$LOCALIZE[", iIndex)) != CStdString::npos)
{
- int iEnd = strDest.Find("]",iIndex);
- CStdString strInfo = strDest.Mid(iIndex+10,iEnd-iIndex-10);
+ size_t iEnd = strDest.find("]", iIndex);
+ CStdString strInfo = strDest.substr(iIndex+10, iEnd - iIndex - 10);
CStdString strReplace;
if (m_scraper)
strReplace = m_scraper->GetString(strtol(strInfo.c_str(),NULL,10));
iIndex += strReplace.length();
}
iIndex = 0;
- while ((size_t)(iIndex = strDest.find("\\n",iIndex)) != CStdString::npos)
+ while ((iIndex = strDest.find("\\n",iIndex)) != CStdString::npos)
strDest.replace(strDest.begin()+iIndex,strDest.begin()+iIndex+2,"\n");
}
std::reverse(this->begin(), this->end());
}
- MYTYPE Mid(int nFirst) const
- {
- return Mid(nFirst, this->GetLength()-nFirst);
- }
-
- MYTYPE Mid(int nFirst, int nCount) const
- {
- // CString does range checking here. Since we're trying to emulate it,
- // we must check too.
-
- if ( nFirst < 0 )
- nFirst = 0;
- if ( nCount < 0 )
- nCount = 0;
-
- int nSize = static_cast<int>(this->size());
-
- if ( nFirst + nCount > nSize )
- nCount = nSize - nFirst;
-
- if ( nFirst > nSize )
- return MYTYPE();
-
- ASSERT(nFirst >= 0);
- ASSERT(nFirst + nCount <= nSize);
-
- return this->substr(static_cast<MYSIZE>(nFirst),
- static_cast<MYSIZE>(nCount));
- }
-
void ReleaseBuffer(int nNewLen=-1)
{
RelBuf(nNewLen);
if ( i == numFound )
s = input;
else
- s = input.Mid( i, positions[i] );
+ s = input.substr(i, positions[i]);
}
else
{
if ( offset < isize )
{
if ( i == numFound )
- s = input.Mid(offset);
+ s = input.substr(offset);
else if ( i > 0 )
- s = input.Mid( positions[i - 1] + sizeS2,
+ s = input.substr( positions[i - 1] + sizeS2,
positions[i] - positions[i - 1] - sizeS2 );
}
}
if (strncmp(strPath.c_str(), i->first.c_str(), HasSlashAtEnd(i->first.c_str()) ? i->first.size()-1 : i->first.size()) == 0)
{
if (strPath.size() > i->first.size())
- return URIUtils::AddFileToFolder(i->second, strPath.Mid(i->first.size()));
+ return URIUtils::AddFileToFolder(i->second, strPath.substr(i->first.size()));
else
return i->second;
}
if (strncmp(strPath.c_str(), i->second.c_str(), HasSlashAtEnd(i->second.c_str()) ? i->second.size()-1 : i->second.size()) == 0)
{
if (strPath.size() > i->second.size())
- return URIUtils::AddFileToFolder(i->first, strPath.Mid(i->second.size()));
+ return URIUtils::AddFileToFolder(i->first, strPath.substr(i->second.size()));
else
return i->first;
}
bool URIUtils::IsOnDVD(const CStdString& strFile)
{
#ifdef TARGET_WINDOWS
- if (strFile.Mid(1,1) == ":")
+ if (strFile.substr(1,1) == ":")
return (GetDriveType(strFile.Left(3)) == DRIVE_CDROM);
#endif
if (StringUtils::StartsWithNoCase(strFile, "dvd://"))
return true;
- if(strFile.Mid(1) != ":\\"
- && strFile.Mid(1) != ":")
+ if(strFile.substr(1) != ":\\"
+ && strFile.substr(1) != ":")
return false;
if(GetDriveType(strFile.c_str()) == DRIVE_CDROM)
{
CStdString strExtension = GetExtension(strFile);
- if (strExtension.Equals(".001") && strFile.Mid(strFile.length()-7,7).CompareNoCase(".ts.001"))
+ if (strExtension.Equals(".001") && !StringUtils::EndsWithNoCase(strFile, ".ts.001"))
return true;
if (strExtension.CompareNoCase(".cbr") == 0)
// Remove any slash at the start of the file
if (strFile.size() && (strFile[0] == '/' || strFile[0] == '\\'))
- strResult += strFile.Mid(1);
+ strResult += strFile.substr(1);
else
strResult += strFile;
if (iPosBar == string::npos)
return strFilePath.Left(iPosSlash + 1); // Only path
- return strFilePath.Left(iPosSlash + 1) + strFilePath.Mid(iPosBar); // Path + options
+ return strFilePath.substr(0, iPosSlash + 1) + strFilePath.substr(iPosBar); // Path + options
}
void URIUtils::CreateArchivePath(CStdString& strUrlPath,
// remove all info other than the id
// we do this due to the way we have the link between the file + movie tables.
- strSQL = "update tvshow set ";
+ std::vector<string> ids;
for (int iType = VIDEODB_ID_TV_MIN + 1; iType < VIDEODB_ID_TV_MAX; iType++)
- strSQL += StringUtils::Format("c%02d=NULL,", iType);
+ ids.push_back(StringUtils::Format("c%02d=NULL", iType));
- strSQL = strSQL.Mid(0, strSQL.size() - 1) + PrepareSQL(" where idShow=%i", idTvShow);
+ strSQL = "update tvshow set ";
+ strSQL += StringUtils::Join(ids, ", ");
+ strSQL += PrepareSQL(" where idShow=%i", idTvShow);
m_pDS->exec(strSQL.c_str());
}
catch (...)
else
{
if (!strLike.empty())
- strLike = "where "+strLike.Mid(4);
+ strLike = "where " + strLike.substr(4);
strSQL=PrepareSQL("select distinct musicvideo.c%02d,musicvideo.idMVideo from musicvideo"+strLike,VIDEODB_ID_MUSICVIDEO_ALBUM,strSearch.c_str());
}
m_pDS->query( strSQL.c_str() );
CStdString strPaths;
for (std::set<int>::const_iterator i = paths->begin(); i != paths->end(); ++i)
strPaths += StringUtils::Format(",%i",*i);
- sql = PrepareSQL("select * from files,path where files.idPath=path.idPath and path.idPath in (%s)",strPaths.Mid(1).c_str());
+ sql = PrepareSQL("select * from files, path where files.idPath=path.idPath and path.idPath in (%s)", strPaths.substr(1).c_str());
}
else
sql = "select * from files, path where files.idPath = path.idPath";
{
CVideoInfoTag movie = GetDetailsForMovie(m_pDS, true);
// strip paths to make them relative
- if (movie.m_strTrailer.Mid(0,movie.m_strPath.size()).Equals(movie.m_strPath))
- movie.m_strTrailer = movie.m_strTrailer.Mid(movie.m_strPath.size());
+ if (StringUtils::StartsWith(movie.m_strTrailer, movie.m_strPath))
+ movie.m_strTrailer = movie.m_strTrailer.substr(movie.m_strPath.size());
map<string, string> artwork;
if (GetArtForItem(movie.m_iDbId, movie.m_type, artwork) && !singleFiles)
{
{
URIUtils::RemoveSlashAtEnd(strPath); // need no slash for the check that follows
CFileItem item2;
- if (strPath.Mid(strPath.size()-3).Equals("cd1"))
+ if (StringUtils::EndsWithNoCase(strPath, "cd1"))
{
- strPath = strPath.Mid(0,strPath.size()-3);
+ strPath.erase(strPath.size() - 3);
item2.SetPath(URIUtils::AddFileToFolder(strPath, URIUtils::GetFileName(item->GetPath())));
return GetnfoFile(&item2, bGrabAny);
}
{
CStdString strAudioInfo;
g_application.m_pPlayer->GetAudioInfo(strAudioInfo);
- int iNumChannels = atoi(strAudioInfo.Right(strAudioInfo.size() - strAudioInfo.Find("chns:") - 5).c_str());
- CStdString strAudioCodec = strAudioInfo.Mid(7, strAudioInfo.Find(") VBR") - 5);
+ int iNumChannels = atoi(strAudioInfo.substr(strAudioInfo.find("chns:") + 5).c_str());
+ CStdString strAudioCodec = strAudioInfo.substr(7, strAudioInfo.find(") VBR") - 5);
bool bDTS = strstr(strAudioCodec.c_str(), "DTS") != 0;
bool bAC3 = strstr(strAudioCodec.c_str(), "AC3") != 0;
if (iNumChannels == 2 && !(bDTS || bAC3))
result != "thumb://Current") // user didn't choose the one they have
{
CStdString newThumb;
- if (result.Left(14) == "thumb://Remote")
+ if (StringUtils::StartsWith(result, "thumb://Remote"))
{
- int number = atoi(result.Mid(14));
+ int number = atoi(result.substr(14).c_str());
newThumb = thumbs[number];
}
else if (result == "thumb://Thumb")
if (result.Left(15) == "fanart://Remote")
{
- int iFanart = atoi(result.Mid(15).c_str());
+ int iFanart = atoi(result.substr(15).c_str());
// set new primary fanart, and update our database accordingly
m_movieItem->GetVideoInfoTag()->m_fanart.SetPrimaryFanart(iFanart);
CVideoDatabase db;
{
CStdString strPath = items[i]->GetPath();
URIUtils::RemoveSlashAtEnd(strPath);
- StringUtils::ToLower(strPath);
- if (strPath.size() > 6)
+ if (StringUtils::EndsWithNoCase(strPath, "sample")) // skip sample folders
{
- CStdString strSub = strPath.substr(strPath.size()-6);
- if (strPath.Mid(strPath.size()-6).Equals("sample")) // skip sample folders
- continue;
+ continue;
}
}
else if (items[i]->HasVideoInfoTag() &&
// new thumbnail
if (result.Left(14) == "thumb://Remote")
{
- int number = atoi(result.Mid(14));
+ int number = atoi(result.substr(14).c_str());
result = thumbs[number];
}
else if (result == "thumb://None")
return true;
// get the media type and convert from plural to singular (by removing the trailing "s")
- CStdString mediaType = item->GetPath().Mid(9);
- mediaType = mediaType.Left(mediaType.size() - 1);
+ CStdString mediaType = item->GetPath().substr(9);
+ mediaType = mediaType.substr(0, mediaType.size() - 1);
CStdString localizedType = GetLocalizedType(mediaType);
if (localizedType.empty())
return true;
else if (StringUtils::StartsWithNoCase(pItem->GetPath(), "newsmartplaylist://"))
{
m_vecItems->RemoveDiscCache(GetID());
- if (CGUIDialogSmartPlaylistEditor::NewPlaylist(pItem->GetPath().Mid(19)))
+ if (CGUIDialogSmartPlaylistEditor::NewPlaylist(pItem->GetPath().substr(19)))
Refresh();
return true;
}
else if (StringUtils::StartsWithNoCase(pItem->GetPath(), "addons://more/"))
{
- CBuiltins::Execute("ActivateWindow(AddonBrowser,addons://all/xbmc.addon." + pItem->GetPath().Mid(14) + ",return)");
+ CBuiltins::Execute("ActivateWindow(AddonBrowser,addons://all/xbmc.addon." + pItem->GetPath().substr(14) + ",return)");
return true;
}