[cstdstring] drops Mid(), replacing with substr()
authornight199uk <night199uk@xbmc.org>
Tue, 17 Sep 2013 16:57:43 +0000 (00:57 +0800)
committerJonathan Marshall <jmarshall@xbmc.org>
Wed, 13 Nov 2013 21:52:53 +0000 (10:52 +1300)
70 files changed:
xbmc/CueDocument.cpp
xbmc/FileItem.cpp
xbmc/TextureCacheJob.cpp
xbmc/URL.cpp
xbmc/Util.cpp
xbmc/XBDateTime.cpp
xbmc/addons/AddonVersion.cpp
xbmc/addons/GUIDialogAddonSettings.cpp
xbmc/addons/Scraper.cpp
xbmc/addons/Skin.cpp
xbmc/cores/ExternalPlayer/ExternalPlayer.cpp
xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecSSA.cpp
xbmc/cores/dvdplayer/Edl.cpp
xbmc/dialogs/GUIDialogKeyboardGeneric.cpp
xbmc/dialogs/GUIDialogSmartPlaylistEditor.cpp
xbmc/filesystem/CurlFile.cpp
xbmc/filesystem/FavouritesDirectory.cpp
xbmc/filesystem/FileReaderFile.cpp
xbmc/filesystem/HTSPDirectory.cpp
xbmc/filesystem/HTTPDirectory.cpp
xbmc/filesystem/MultiPathDirectory.cpp
xbmc/filesystem/MythDirectory.cpp
xbmc/filesystem/MythFile.cpp
xbmc/filesystem/MythSession.cpp
xbmc/filesystem/RSSDirectory.cpp
xbmc/filesystem/RTVDirectory.cpp
xbmc/filesystem/RarFile.cpp
xbmc/filesystem/SFTPFile.cpp
xbmc/filesystem/SpecialProtocol.cpp
xbmc/filesystem/SpecialProtocolDirectory.cpp
xbmc/filesystem/StackDirectory.cpp
xbmc/filesystem/VTPFile.cpp
xbmc/guilib/GUIBaseContainer.cpp
xbmc/guilib/GUIInfoTypes.cpp
xbmc/guilib/GUIMultiSelectText.cpp
xbmc/guilib/GUITextLayout.cpp
xbmc/input/ButtonTranslator.cpp
xbmc/interfaces/Builtins.cpp
xbmc/interfaces/legacy/Dialog.cpp
xbmc/interfaces/legacy/ListItem.cpp
xbmc/linux/LinuxTimezone.cpp
xbmc/music/dialogs/GUIDialogMusicInfo.cpp
xbmc/music/karaoke/karaokelyricstext.cpp
xbmc/music/karaoke/karaokelyricstextustar.cpp
xbmc/music/windows/GUIWindowMusicPlaylistEditor.cpp
xbmc/network/AirPlayServer.cpp
xbmc/network/cddb.cpp
xbmc/network/linux/NetworkLinux.cpp
xbmc/network/upnp/UPnPServer.cpp
xbmc/pictures/PictureInfoTag.cpp
xbmc/playlists/PlayListM3U.cpp
xbmc/playlists/PlayListURL.cpp
xbmc/settings/dialogs/GUIDialogContentSettings.cpp
xbmc/utils/Fanart.cpp
xbmc/utils/HTMLTable.cpp
xbmc/utils/HTMLUtil.cpp
xbmc/utils/LabelFormatter.cpp
xbmc/utils/LangCodeExpander.cpp
xbmc/utils/RssReader.cpp
xbmc/utils/ScraperParser.cpp
xbmc/utils/StdString.h
xbmc/utils/StringUtils.cpp
xbmc/utils/URIUtils.cpp
xbmc/video/VideoDatabase.cpp
xbmc/video/VideoInfoScanner.cpp
xbmc/video/dialogs/GUIDialogAudioSubtitleSettings.cpp
xbmc/video/dialogs/GUIDialogVideoInfo.cpp
xbmc/video/windows/GUIWindowVideoBase.cpp
xbmc/video/windows/GUIWindowVideoNav.cpp
xbmc/windows/GUIMediaWindow.cpp

index 1137970..7265916 100644 (file)
@@ -131,7 +131,7 @@ bool CCueDocument::Parse(const CStdString &strFile)
       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())
         {
@@ -149,7 +149,7 @@ bool CCueDocument::Parse(const CStdString &strFile)
     }
     else if (StringUtils::StartsWithNoCase(strLine,"TRACK"))
     {
-      int iTrackNumber = ExtractNumericInfo(strLine.Mid(5));
+      int iTrackNumber = ExtractNumericInfo(strLine.substr(5));
 
       m_iTotalTracks++;
 
@@ -166,7 +166,7 @@ bool CCueDocument::Parse(const CStdString &strFile)
     }
     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;
     }
@@ -184,7 +184,7 @@ bool CCueDocument::Parse(const CStdString &strFile)
     }
     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;
     }
@@ -192,7 +192,7 @@ bool CCueDocument::Parse(const CStdString &strFile)
     {
       if (!ExtractQuoteInfo(strLine, m_strGenre))
       {
-        CStdString genreNoQuote = strLine.Mid(9);
+        CStdString genreNoQuote = strLine.substr(9);
         StringUtils::TrimLeft(genreNoQuote);
         if (!genreNoQuote.empty())
         {
@@ -202,13 +202,13 @@ bool CCueDocument::Parse(const CStdString &strFile)
       }
     }
     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
@@ -309,7 +309,7 @@ bool CCueDocument::ExtractQuoteInfo(const CStdString &line, CStdString &quote)
   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;
 }
@@ -324,7 +324,7 @@ bool CCueDocument::ExtractQuoteInfo(const CStdString &line, CStdString &quote)
 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())
   {
index 1805d1b..1f33fa0 100644 (file)
@@ -802,7 +802,7 @@ bool CFileItem::IsVideo() const
   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") )
@@ -860,7 +860,7 @@ bool CFileItem::IsAudio() const
 
   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") )
index 0922382..3e04964 100644 (file)
@@ -145,7 +145,7 @@ CStdString CTextureCacheJob::DecodeImageURL(const CStdString &url, unsigned int
 
     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;
@@ -157,7 +157,7 @@ CStdString CTextureCacheJob::DecodeImageURL(const CStdString &url, unsigned int
       if (pos != -1)
       {
         option = i->Left(pos);
-        value  = i->Mid(pos + 1);
+        value  = i->substr(pos + 1);
       }
       else
       {
index 6e1e878..0bc7a3d 100644 (file)
@@ -163,7 +163,7 @@ void CURL::Parse(const CStdString& strURL1)
     m_strProtocol.Equals("special")
     )
   {
-    SetFileName(strURL.Mid(iPos));
+    SetFileName(strURL.substr(iPos));
     return;
   }
 
@@ -227,7 +227,7 @@ void CURL::Parse(const CStdString& strURL1)
     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"))
@@ -266,7 +266,7 @@ void CURL::Parse(const CStdString& strURL1)
   // 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)
     {
@@ -283,7 +283,7 @@ void CURL::Parse(const CStdString& strURL1)
   }
   else
   {
-    CStdString strHostNameAndPort = strURL.Mid(iPos, iSlash - iPos);
+    CStdString strHostNameAndPort = strURL.substr(iPos, iSlash - iPos);
     int iColon = strHostNameAndPort.Find(":");
     if (iColon >= 0)
     {
@@ -299,7 +299,7 @@ void CURL::Parse(const CStdString& strURL1)
     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)
@@ -408,7 +408,7 @@ void CURL::SetProtocolOptions(const CStdString& strOptions)
   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);
index f283377..bcd45c6 100644 (file)
@@ -270,7 +270,7 @@ void CUtil::CleanString(const CStdString& strFileName, CStdString& strTitle, CSt
     }
     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:
@@ -337,14 +337,14 @@ void CUtil::GetQualifiedFilename(const CStdString &strBasePath, CStdString &strF
   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);
   }
@@ -552,7 +552,7 @@ int CUtil::GetDVDIfoTitle(const CStdString& strFile)
   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)
@@ -1038,7 +1038,7 @@ void CUtil::SplitExecFunction(const CStdString &execString, CStdString &function
   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
@@ -1092,7 +1092,7 @@ void CUtil::SplitParams(const CStdString &paramString, std::vector<CStdString> &
           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.
@@ -1132,7 +1132,7 @@ void CUtil::SplitParams(const CStdString &paramString, std::vector<CStdString> &
     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.
@@ -1191,7 +1191,7 @@ int CUtil::GetMatchingSource(const CStdString& strPath1, VECSOURCES& VECSOURCES,
       // "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))
     {
@@ -1291,28 +1291,28 @@ CStdString CUtil::TranslateSpecialSource(const CStdString &strSpecial)
   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;
 }
@@ -1544,7 +1544,7 @@ void CUtil::GetSkinThemes(vector<CStdString>& vecTheme)
           (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));
       }
     }
   }
@@ -2131,7 +2131,7 @@ void CUtil::GetExternalStreamDetailsFromFilename(const CStdString& strVideo, con
 
   // 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);
@@ -2208,7 +2208,7 @@ bool CUtil::FindVobSubPair( const std::vector<CStdString>& vecSubtitles, const C
         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;
@@ -2236,7 +2236,7 @@ bool CUtil::IsVobSub( const std::vector<CStdString>& vecSubtitles, const CStdStr
       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;
     }
   }
index 0fdf9d1..c5860b1 100644 (file)
@@ -175,8 +175,8 @@ void CDateTimeSpan::SetDateTimeSpan(int day, int hour, int minute, int second)
 
 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);
 }
 
@@ -224,10 +224,10 @@ void CDateTimeSpan::SetFromPeriod(const CStdString &period)
 {
   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)
@@ -698,7 +698,7 @@ void CDateTime::SetFromDateString(const CStdString &date)
   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);
@@ -706,8 +706,8 @@ void CDateTime::SetFromDateString(const CStdString &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])
@@ -920,11 +920,11 @@ void CDateTime::SetFromW3CDate(const CStdString &dateTime)
     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
@@ -933,22 +933,22 @@ void CDateTime::SetFromW3CDate(const CStdString &dateTime)
   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);
 }
@@ -958,12 +958,12 @@ void CDateTime::SetFromDBDateTime(const CStdString &dateTime)
   // 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);
   }
 }
@@ -975,15 +975,15 @@ void CDateTime::SetFromDBDate(const CStdString &date)
   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);
 }
@@ -994,9 +994,9 @@ void CDateTime::SetFromDBTime(const CStdString &time)
   // 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);
 }
@@ -1009,9 +1009,9 @@ void CDateTime::SetFromRFC1123DateTime(const CStdString &dateTime)
   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++)
   {
@@ -1025,10 +1025,10 @@ void CDateTime::SetFromRFC1123DateTime(const CStdString &dateTime)
   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);
 }
@@ -1059,12 +1059,12 @@ CStdString CDateTime::GetAsLocalizedTime(const CStdString &format, bool withSeco
       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;
       }
 
@@ -1218,13 +1218,13 @@ CStdString CDateTime::GetAsLocalizedDate(const CStdString &strFormat, bool withS
       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;
index f3b20a2..d8c5ad4 100644 (file)
@@ -135,9 +135,9 @@ namespace ADDON
     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;
   }
index 06a0292..6c48974 100644 (file)
@@ -1088,9 +1088,9 @@ bool CGUIDialogAddonSettings::TranslateSingleString(const CStdString &strConditi
   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;
index 9a79cea..1d4568d 100644 (file)
@@ -897,7 +897,7 @@ EPISODELIST CScraper::GetEpisodeList(XFILE::CCurlFile &fcurl, const CScraperUrl
         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);
index d689e60..770fc21 100644 (file)
@@ -305,7 +305,7 @@ void CSkinInfo::SettingOptionsSkinColorsFiller(const CSetting *setting, std::vec
     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());
index 2808a58..132d97e 100644 (file)
@@ -212,7 +212,7 @@ void CExternalPlayer::Process()
         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;
         }
index 7ac67fe..4fe030f 100644 (file)
@@ -103,7 +103,7 @@ int CDVDOverlayCodecSSA::Decode(DemuxPacket *pPacket)
       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);
 
index 9881ac3..f2d82a8 100644 (file)
@@ -262,9 +262,9 @@ bool CEdl::ReadEdl(const CStdString& strMovie, const float fFramesPerSecond)
           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
       {
index 42b360a..2209ae0 100644 (file)
@@ -664,13 +664,13 @@ void CGUIDialogKeyboardGeneric::OnIPAddress()
   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));
index 5080d1a..3a7d3cd 100644 (file)
@@ -160,6 +160,7 @@ void CGUIDialogSmartPlaylistEditor::OnRuleList(int item)
 
 void CGUIDialogSmartPlaylistEditor::OnOK()
 {
+  std::string systemPlaylistsPath = CSettings::Get().GetString("system.playlistspath");
   // save our playlist
   if (m_path.empty())
   {
@@ -167,7 +168,7 @@ void CGUIDialogSmartPlaylistEditor::OnOK()
     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
@@ -182,14 +183,14 @@ void CGUIDialogSmartPlaylistEditor::OnOK()
   {
     // 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);
       }
     }
index 05aaa5d..15b688e 100644 (file)
@@ -663,7 +663,7 @@ void CCurlFile::ParseAndCorrectUrl(CURL &url2)
     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("");
     }
index bf80cf4..5339fb8 100644 (file)
@@ -193,9 +193,9 @@ CStdString CFavouritesDirectory::GetExecutePath(const CFileItem &item, const std
       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())
index edf524f..2b27aea 100644 (file)
@@ -44,18 +44,18 @@ CFileReaderFile::~CFileReaderFile()
 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);
 }
 
 
index 252f5b5..2406477 100644 (file)
@@ -406,7 +406,7 @@ bool CHTSPDirectory::GetTag(const CURL &base, CFileItemList &items)
 {
   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())
index bbb75e8..cfab872 100644 (file)
@@ -89,7 +89,7 @@ bool CHTTPDirectory::GetDirectory(const CStdString& strPath, CFileItemList &item
       strName = reItem.GetMatch(2);
 
       if(strLink[0] == '/')
-        strLink = strLink.Mid(1);
+        strLink = strLink.substr(1);
 
       CStdString strNameTemp = StringUtils::Trim(strName);
 
@@ -107,7 +107,7 @@ bool CHTTPDirectory::GetDirectory(const CStdString& strPath, CFileItemList &item
       // 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;
index 13c5155..041ab08 100644 (file)
@@ -151,7 +151,7 @@ CStdString CMultiPathDirectory::GetFirstPath(const CStdString &strPath)
   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;
   }
@@ -164,7 +164,7 @@ bool CMultiPathDirectory::GetPaths(const CStdString& strPath, vector<CStdString>
   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 "/"
@@ -186,7 +186,7 @@ bool CMultiPathDirectory::GetPaths(const CStdString& strPath, vector<CStdString>
 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 "/"
index 15c4164..befb0a0 100644 (file)
@@ -532,7 +532,7 @@ bool CMythDirectory::GetDirectory(const CStdString& strPath, CFileItemList &item
   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")
@@ -540,7 +540,7 @@ bool CMythDirectory::GetDirectory(const CStdString& strPath, CFileItemList &item
   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;
 }
 
index ca3902d..7da296a 100644 (file)
@@ -30,6 +30,7 @@
 #include "utils/log.h"
 #include "utils/StringUtils.h"
 #include "utils/TimeUtils.h"
+#include "utils/StringUtils.h"
 
 extern "C" {
 #include "cmyth/include/cmyth/cmyth.h"
@@ -271,13 +272,13 @@ bool CMythFile::SetupLiveTV(const CURL& url)
 
 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)
index aed3ebb..fc7b404 100644 (file)
@@ -288,10 +288,10 @@ void CMythSession::SetSeasonAndEpisode(const cmyth_proginfo_t &program, int *sea
   &&  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
@@ -330,7 +330,7 @@ void CMythSession::SetSeasonAndEpisode(const cmyth_proginfo_t &program, int *sea
       *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));
index 3e66177..765d316 100644 (file)
@@ -522,7 +522,7 @@ static void ParseItem(CFileItem* item, TiXmlElement* root, const CStdString& pat
 
     /* 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;
index 3d0bc7d..59c8474 100644 (file)
@@ -103,7 +103,7 @@ bool CRTVDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items
       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
@@ -192,17 +192,17 @@ bool CRTVDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items
           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;
index 15c45fc..d558553 100644 (file)
@@ -547,7 +547,7 @@ void CRarFile::InitFromUrl(const CURL& url)
   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;
 
index 7759875..6d8a9d5 100644 (file)
@@ -50,8 +50,8 @@ using namespace std;
 
 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;
 }
index 6067a9c..7b45c33 100644 (file)
@@ -118,13 +118,13 @@ CStdString CSpecialProtocol::TranslatePath(const CURL &url)
   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;
index 0c44efb..cb5378f 100644 (file)
@@ -45,7 +45,7 @@ bool CSpecialProtocolDirectory::GetDirectory(const CStdString& strPath, CFileIte
     {
       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;
   }
index 7fa3384..c9a49fc 100644 (file)
@@ -166,7 +166,7 @@ namespace XFILE
       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);
@@ -179,7 +179,7 @@ namespace XFILE
     // 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);
index 9b18bc8..4be41b6 100644 (file)
@@ -68,7 +68,7 @@ bool CVTPFile::Open(const CURL& url2)
   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());
index d62d331..29a7a5b 100644 (file)
@@ -574,15 +574,15 @@ void CGUIBaseContainer::OnJumpSMS(int letter)
 
   // 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;
index 918c822..dab9e18 100644 (file)
@@ -107,7 +107,7 @@ void CGUIInfoColor::Parse(const CStdString &label, int context)
 
   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));
@@ -115,7 +115,7 @@ void CGUIInfoColor::Parse(const CStdString &label, int 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)
@@ -204,17 +204,17 @@ CStdString CGUIInfoLabel::ReplaceLocalize(const CStdString &label)
 {
   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
@@ -232,17 +232,17 @@ CStdString CGUIInfoLabel::ReplaceAddonStrings(const CStdString &label)
   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;
     }
@@ -280,13 +280,13 @@ void CGUIInfoLabel::Parse(const CStdString &label, int context)
   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);
@@ -303,7 +303,7 @@ void CGUIInfoLabel::Parse(const CStdString &label, int context)
       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;
@@ -324,7 +324,7 @@ void CGUIInfoLabel::Parse(const CStdString &label, int context)
           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
       {
index 6e93348..0cf39d8 100644 (file)
@@ -302,17 +302,17 @@ void CGUIMultiSelectTextControl::UpdateText(const CStdString &text)
 
   // 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
@@ -320,12 +320,12 @@ void CGUIMultiSelectTextControl::UpdateText(const CStdString &text)
       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;
index 47dde56..21d09a5 100644 (file)
@@ -351,8 +351,8 @@ void CGUITextLayout::ParseText(const CStdStringW &text, uint32_t defaultStyle, c
   // 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;
@@ -360,52 +360,52 @@ void CGUITextLayout::ParseText(const CStdStringW &text, uint32_t defaultStyle, c
     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
@@ -435,7 +435,7 @@ void CGUITextLayout::ParseText(const CStdStringW &text, uint32_t defaultStyle, c
 
     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)
@@ -455,7 +455,7 @@ void CGUITextLayout::ParseText(const CStdStringW &text, uint32_t defaultStyle, c
     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)
index f1612ab..f5a2593 100644 (file)
@@ -1194,14 +1194,14 @@ int CButtonTranslator::TranslateWindow(const CStdString &window)
     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
index e990a64..9440b34 100644 (file)
@@ -660,7 +660,7 @@ int CBuiltins::Execute(const CStdString& execString)
         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);
       }
     }
@@ -760,7 +760,7 @@ int CBuiltins::Execute(const CStdString& execString)
         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);
       }
     }
 
@@ -866,11 +866,11 @@ int CBuiltins::Execute(const CStdString& execString)
       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)
@@ -900,7 +900,7 @@ int CBuiltins::Execute(const CStdString& execString)
           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;
         }
index 492f981..a684a27 100644 (file)
@@ -216,9 +216,9 @@ namespace XBMCAddon
           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);
@@ -303,9 +303,9 @@ namespace XBMCAddon
             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);
index 592502d..2222921 100644 (file)
@@ -370,7 +370,12 @@ namespace XBMCAddon
           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());
           }
@@ -431,7 +436,11 @@ namespace XBMCAddon
           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());
@@ -460,13 +469,18 @@ namespace XBMCAddon
           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);
           }
         }
index 515c2bc..29844f9 100644 (file)
@@ -136,8 +136,8 @@ CLinuxTimezone::CLinuxTimezone() : m_IsDST(0)
             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;
index fe3d889..8b65c04 100644 (file)
@@ -409,7 +409,7 @@ void CGUIDialogMusicInfo::OnGetThumb()
   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")
@@ -507,9 +507,9 @@ void CGUIDialogMusicInfo::OnGetFanart()
   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();
   }
index c787e36..4516dca 100644 (file)
@@ -658,7 +658,7 @@ void CKaraokeLyricsText::rescanLyrics()
         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 == " " )
       {
index dfd4e13..3b6dfb8 100644 (file)
@@ -140,16 +140,15 @@ bool CKaraokeLyricsTextUStar::Load()
   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;
index 04ceecb..57c3018 100644 (file)
@@ -391,8 +391,8 @@ void CGUIWindowMusicPlaylistEditor::OnSavePlaylist()
 {
   // 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;
index 778c44f..cc92d0d 100644 (file)
@@ -841,19 +841,21 @@ int CAirPlayServer::CTCPClient::ProcessRequest( CStdString& responseHeader,
     {
       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());
       }
     }
index 34bae4a..877180b 100644 (file)
@@ -532,8 +532,8 @@ void Xcddb::parseData(const char *buffer)
       {
         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;
         }
@@ -558,7 +558,7 @@ void Xcddb::parseData(const char *buffer)
         // 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())
@@ -568,7 +568,7 @@ void Xcddb::parseData(const char *buffer)
         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))
           {
index c58c9e5..9e54915 100644 (file)
@@ -209,7 +209,7 @@ CStdString CNetworkInterfaceLinux::GetCurrentDefaultGateway(void)
     if (fread(buffer, sizeof(char), sizeof(buffer), pipe) > 0 && !ferror(pipe))
     {
       tmpStr = buffer;
-      result = tmpStr.Mid(11);
+      result = tmpStr.substr(11);
     }
     else
     {
@@ -482,7 +482,7 @@ std::vector<CStdString> CNetworkLinux::GetNameServers(void)
     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
     {
index 0f81865..4f7378f 100644 (file)
@@ -1199,7 +1199,7 @@ CUPnPServer::SortItems(CFileItemList& items, const char* sort_criteria)
   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 + */
index 89ff42b..ef2dc25 100644 (file)
@@ -643,12 +643,12 @@ void CPictureInfoTag::ConvertDateTime()
   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);
   }
 }
index 043c439..f182781 100644 (file)
@@ -94,16 +94,18 @@ bool CPlayListM3U::Load(const CStdString& strFileName)
     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);
       }
     }
index 1d22b3f..ade2ed2 100644 (file)
@@ -60,15 +60,15 @@ bool CPlayListURL::Load(const CStdString& strFileName)
     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);
         }
       }
index 25cc503..1404373 100644 (file)
@@ -96,7 +96,7 @@ bool CGUIDialogContentSettings::OnMessage(CGUIMessage &message)
         // 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)");
index 190835f..6026d10 100644 (file)
@@ -111,7 +111,7 @@ const CStdString CFanart::GetColor(unsigned int index) const
     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)
index fe92835..8421380 100644 (file)
@@ -55,7 +55,7 @@ void CHTMLRow::Parse(const CStdString& strTable)
       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;
@@ -96,7 +96,7 @@ void CHTMLTable::Parse(const CStdString& strHTML)
       iPosEnd = (int)strHTML.size();
     }
 
-    CStdString strTable = strHTML.Mid(iPosStart, 1 + iPosEnd - iPosStart);
+    CStdString strTable = strHTML.substr(iPosStart, 1 + iPosEnd - iPosStart);
     int iTableRowStart = 0;
     do
     {
@@ -108,7 +108,7 @@ void CHTMLTable::Parse(const CStdString& strHTML)
         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);
index 72f8af1..f23d9e7 100644 (file)
@@ -42,7 +42,7 @@ int CHTMLUtil::FindTag(const CStdString& strHTML, const CStdString& strTag, CStd
   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;
 }
 
@@ -64,7 +64,7 @@ int CHTMLUtil::FindClosingTag(const CStdString& strHTML, const CStdString& strTa
 
   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;
 }
 
@@ -78,7 +78,7 @@ void CHTMLUtil::getValueOfTag(const CStdString& strTagAndValue, CStdString& strV
   if (iStart >= 0 && iEnd >= 0)
   {
     iStart++;
-    strValue = strTagAndValue.Mid(iStart, iEnd - iStart);
+    strValue = strTagAndValue.substr(iStart, iEnd - iStart);
   }
 }
 
@@ -95,7 +95,7 @@ void CHTMLUtil::getAttributeOfTag(const CStdString& strTagAndValue, const CStdSt
   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);
   }
 }
 
@@ -295,7 +295,7 @@ void CHTMLUtil::ConvertHTMLToW(const CStdStringW& strHTML, CStdStringW& strStrip
            (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());
index 9b52e78..aa92b84 100644 (file)
@@ -341,7 +341,7 @@ void CLabelFormatter::SplitMask(unsigned int label, const CStdString &mask)
     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);
 }
@@ -367,7 +367,7 @@ void CLabelFormatter::AssembleMask(unsigned int label, const CStdString& mask)
             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);
@@ -385,7 +385,7 @@ bool CLabelFormatter::FillMusicTag(const CStdString &fileName, CMusicInfoTag *ta
     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;
index 15a23b4..07c07a7 100644 (file)
@@ -96,15 +96,15 @@ bool CLangCodeExpander::Lookup(CStdString& desc, const CStdString& code)
   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)
       {
@@ -114,7 +114,7 @@ bool CLangCodeExpander::Lookup(CStdString& desc, const CStdString& code)
       else
       {
         desc += " - ";
-        desc += code.Mid(iSplit + 1);
+        desc += code.substr(iSplit + 1);
       }
       return true;
     }
index 97ff833..b11c8b5 100644 (file)
@@ -361,7 +361,7 @@ bool CRssReader::Parse(int iFeed)
   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)
     {
index 411a03b..3aae3a1 100644 (file)
@@ -151,12 +151,12 @@ bool CScraperParser::LoadFromXML()
 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();
@@ -164,10 +164,10 @@ void CScraperParser::ReplaceBuffers(CStdString& strDest)
   }
   // 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);
@@ -176,10 +176,10 @@ void CScraperParser::ReplaceBuffers(CStdString& strDest)
   }
   // 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));
@@ -187,7 +187,7 @@ void CScraperParser::ReplaceBuffers(CStdString& strDest)
     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");
 }
 
index 19f0af8..ff0ad19 100644 (file)
@@ -2715,36 +2715,6 @@ public:
     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);
index f944327..c295608 100644 (file)
@@ -483,7 +483,7 @@ int StringUtils::SplitString(const CStdString& input, const CStdString& delimite
       if ( i == numFound )
         s = input;
       else
-        s = input.Mid( i, positions[i] );
+        s = input.substr(i, positions[i]);
     }
     else
     {
@@ -491,9 +491,9 @@ int StringUtils::SplitString(const CStdString& input, const CStdString& delimite
       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 );
       }
     }
index ce16b18..5a917ec 100644 (file)
@@ -415,7 +415,7 @@ CStdString URIUtils::SubstitutePath(const CStdString& strPath, bool reverse /* =
       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;
       }
@@ -425,7 +425,7 @@ CStdString URIUtils::SubstitutePath(const CStdString& strPath, bool reverse /* =
       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;
       }
@@ -469,7 +469,7 @@ bool URIUtils::IsRemote(const CStdString& strFile)
 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
 
@@ -602,8 +602,8 @@ bool URIUtils::IsDVD(const CStdString& strFile)
   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)
@@ -625,7 +625,7 @@ bool URIUtils::IsRAR(const CStdString& strFile)
 {
   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)
@@ -1038,7 +1038,7 @@ CStdString URIUtils::AddFileToFolder(const CStdString& strFolder,
 
   // 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;
 
@@ -1064,7 +1064,7 @@ CStdString URIUtils::GetDirectory(const CStdString &strFilePath)
   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,
index 3a93557..b714227 100644 (file)
@@ -1651,11 +1651,13 @@ void CVideoDatabase::DeleteDetailsForTvShow(const CStdString& strPath, int idTvS
     // 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 (...)
@@ -7330,7 +7332,7 @@ void CVideoDatabase::GetMusicVideoAlbumsByName(const CStdString& strSearch, CFil
     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() );
@@ -8007,7 +8009,7 @@ void CVideoDatabase::CleanDatabase(CGUIDialogProgressBarHandle* handle, const se
       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";
@@ -8499,8 +8501,8 @@ void CVideoDatabase::ExportToXML(const CStdString &path, bool singleFiles /* = f
     {
       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)
       {
index 188971b..40f228a 100644 (file)
@@ -1562,9 +1562,9 @@ namespace VIDEO
       {
         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);
         }
index 21e2464..584df71 100644 (file)
@@ -138,8 +138,8 @@ void CGUIDialogAudioSubtitleSettings::AddAudioStreams(unsigned int id)
   {
     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))
index 6559bf0..12a8aea 100644 (file)
@@ -734,9 +734,9 @@ void CGUIDialogVideoInfo::OnGetArt()
         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")
@@ -837,7 +837,7 @@ void CGUIDialogVideoInfo::OnGetFanart()
 
   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;
index 06305d8..150a909 100644 (file)
@@ -777,12 +777,9 @@ void CGUIWindowVideoBase::AddItemToPlayList(const CFileItemPtr &pItem, CFileItem
       {
         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() &&
index 5ef887c..f17562a 100644 (file)
@@ -1194,7 +1194,7 @@ bool CGUIWindowVideoNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button)
       // 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")
@@ -1448,8 +1448,8 @@ bool CGUIWindowVideoNav::OnClick(int iItem)
       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;
index 255f52f..a9e1674 100644 (file)
@@ -1032,13 +1032,13 @@ bool CGUIMediaWindow::OnClick(int iItem)
     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;
     }