{
// lets manage tracks titles without quotes
CStdString titleNoQuote = strLine.Mid(5);
- titleNoQuote.TrimLeft();
+ StringUtils::TrimLeft(titleNoQuote);
if (!titleNoQuote.empty())
{
g_charsetConverter.unknownToUTF8(titleNoQuote);
if (!ExtractQuoteInfo(strLine, m_strGenre))
{
CStdString genreNoQuote = strLine.Mid(9);
- genreNoQuote.TrimLeft();
+ StringUtils::TrimLeft(genreNoQuote);
if (!genreNoQuote.empty())
{
g_charsetConverter.unknownToUTF8(genreNoQuote);
{
// Remove the white space at the beginning and end of the line.
szLine = m_szBuffer;
- szLine.Trim();
+ StringUtils::Trim(szLine);
if (!szLine.empty())
return true;
// If we are here, we have an empty line so try the next line
{
// Get rid of the index number and any whitespace
CStdString numberTime = index.Mid(5);
- numberTime.TrimLeft();
+ StringUtils::TrimLeft(numberTime);
while (!numberTime.empty())
{
if (!isdigit(numberTime[0]))
break;
numberTime.erase(0, 1);
}
- numberTime.TrimLeft();
+ StringUtils::TrimLeft(numberTime);
// split the resulting string
CStdStringArray time;
StringUtils::SplitString(numberTime, ":", time);
int CCueDocument::ExtractNumericInfo(const CStdString &info)
{
CStdString number(info);
- number.TrimLeft();
+ StringUtils::TrimLeft(number);
if (number.empty() || !isdigit(number[0]))
return -1;
return atoi(number.c_str());
int i = m_mimetype.Find(';');
if(i>=0)
m_mimetype.Delete(i, m_mimetype.length() - i);
- m_mimetype.Trim();
+ StringUtils::Trim(m_mimetype);
}
else
m_mimetype = CMime::GetMimeType(*this);
{
// trim whitespaces
CStdString strTest = strCondition;
- strTest.TrimLeft(" \t\r\n");
- strTest.TrimRight(" \t\r\n");
+ StringUtils::Trim(strTest);
vector< Property> info;
SplitInfoString(strTest, info);
break;
case WEATHER_CONDITIONS:
strLabel = g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_COND);
- strLabel = strLabel.Trim();
+ StringUtils::Trim(strLabel);
break;
case WEATHER_TEMPERATURE:
strLabel = StringUtils::Format("%s%s",
unsigned int CGUIInfoManager::Register(const CStdString &expression, int context)
{
CStdString condition(CGUIInfoLabel::ReplaceLocalize(expression));
- condition.TrimLeft(" \t\r\n");
- condition.TrimRight(" \t\r\n");
+ StringUtils::Trim(condition);
if (condition.empty())
return 0;
if (info==LISTITEM_FILE_EXTENSION)
{
CStdString strExtension = URIUtils::GetExtension(strFile);
- return strExtension.TrimLeft(".");
+ return StringUtils::TrimLeft(strExtension, ".");
}
return strFile;
}
image = thumbURL.GetHostName();
CStdString optionString = thumbURL.GetOptions().Mid(1);
- optionString.TrimRight('/'); // in case XBMC adds a slash
+ StringUtils::TrimRight(optionString, "/"); // In case XBMC adds a slash.
std::vector<CStdString> options;
StringUtils::SplitString(optionString, "&", options);
else
m_strFileType = "";
- m_strFileType.Normalize();
+ StringUtils::Trim(m_strFileType);
+ StringUtils::ToLower(m_strFileType);
}
void CURL::SetHostName(const CStdString& strHostName)
}
}
- strTitle = strTitleAndYear.Trim();
+ StringUtils::Trim(strTitleAndYear);
+ strTitle = strTitleAndYear;
// append year
if (!strYear.empty())
result.Replace('<', '_');
result.Replace('>', '_');
result.Replace('|', '_');
- result.TrimRight(".");
- result.TrimRight(" ");
+ StringUtils::TrimRight(result, ". ");
}
return result;
}
function = execString;
// remove any whitespace, and the standard prefix (if it exists)
- function.Trim();
+ StringUtils::Trim(function);
if( StringUtils::StartsWithNoCase(function, "xbmc.") )
function.Delete(0, 5);
void CDateTime::SetFromRFC1123DateTime(const CStdString &dateTime)
{
CStdString date = dateTime;
- date.Trim();
+ StringUtils::Trim(date);
if (date.size() != 29)
return;
vector<ADDON::TYPE> types;
for (unsigned int i = 0 ; i < addonTypes.size() ; i++)
{
- ADDON::TYPE type = TranslateType(addonTypes[i].Trim());
+ StringUtils::Trim(addonTypes[i]);
+ ADDON::TYPE type = TranslateType(addonTypes[i]);
if (type != ADDON_UNKNOWN)
types.push_back(type);
}
bool CGUIDialogAddonSettings::TranslateSingleString(const CStdString &strCondition, vector<CStdString> &condVec)
{
CStdString strTest = strCondition;
- strTest.ToLower();
- strTest.TrimLeft(" ");
- strTest.TrimRight(" ");
+ StringUtils::ToLower(strTest);
+ StringUtils::Trim(strTest);
int pos1 = strTest.Find("(");
int pos2 = strTest.Find(",");
for(size_t i=0; i<lines.size(); i++)
{
line = lines[i];
- line.Trim();
+ StringUtils::Trim(line);
auto_aptr<char> layer(new char[line.length()+1]);
if(sscanf(line.c_str(), "%*[^:]:%[^,],%d:%d:%d%*c%d,%d:%d:%d%*c%d"
#include "DVDCodecs/DVDFactoryCodec.h"
#include "DVDDemuxers/DVDDemuxUtils.h"
#include "utils/log.h"
+#include "utils/StringUtils.h"
#include "threads/SingleLock.h"
#ifdef TARGET_POSIX
#include "config.h"
#include "DVDCodecs/Overlay/DVDOverlayText.h"
#include "DVDClock.h"
#include "utils/StdString.h"
+#include "utils/StringUtils.h"
#include "DVDSubtitleTagSami.h"
using namespace std;
while (m_pStream->ReadLine(line, sizeof(line)))
{
strLine = line;
- strLine.Trim();
+ StringUtils::Trim(strLine);
if (strLine.length() > 0)
{
while (m_pStream->ReadLine(line, sizeof(line)))
{
strLine = line;
- strLine.Trim();
+ StringUtils::Trim(strLine);
// empty line, next subtitle is about to start
if (strLine.length() <= 0) break;
#include "DVDSubtitleStream.h"
#include "DVDCodecs/Overlay/DVDOverlayText.h"
#include "utils/RegExp.h"
+#include "utils/StringUtils.h"
CDVDSubtitleTagSami::~CDVDSubtitleTagSami()
{
{
CStdStringA strUTF8;
strUTF8.assign(line, len);
- strUTF8.Trim();
+ StringUtils::Trim(strUTF8);
int pos = 0;
int del_start = 0;
lc.Name = reg.GetMatch(2);
lc.Lang = reg.GetMatch(3);
lc.SAMIType = reg.GetMatch(4);
- lc.Name.Trim();
- lc.Lang.Trim();
- lc.SAMIType.Trim();
+ StringUtils::Trim(lc.Name);
+ StringUtils::Trim(lc.Lang);
+ StringUtils::Trim(lc.SAMIType);
m_Langclass.push_back(lc);
}
}
#include "DVDClock.h"
#include "DVDCodecs/DVDCodecUtils.h"
#include "utils/log.h"
-
+#include "utils/StringUtils.h"
#include <cmath>
#define MAXERR DVD_MSEC_TO_TIME(2.5)
for (unsigned int i = 0; i < m_pattern.size(); i++)
patternstr.AppendFormat("%.2f ", m_pattern[i]);
- patternstr.Trim();
+ StringUtils::Trim(patternstr);
return patternstr;
}
{
if (thisParam[0] == "rate")
{
- m_SampleRate = atoi(thisParam[1].Trim());
+ StringUtils::Trim(thisParam[1]);
+ m_SampleRate = atoi(thisParam[1]);
}
else if (thisParam[0] == "channels")
{
- m_Channels = atoi(thisParam[1].Trim());
+ StringUtils::Trim(thisParam[1]);
+ m_Channels = atoi(thisParam[1]);
}
}
}
{
if (!parameter.empty())
parameter += ",";
- parameter += db.PrepareSQL("'%s'", (*itIn).Trim().c_str());
+ parameter += db.PrepareSQL("'%s'", StringUtils::Trim(*itIn).c_str());
}
parameter = " IN (" + parameter + ")";
}
if(strLink[0] == '/')
strLink = strLink.Mid(1);
- CStdString strNameTemp = strName.Trim();
+ CStdString strNameTemp = StringUtils::Trim(strName);
CStdStringW wName, wLink, wConverted;
if (fileCharset.empty())
{
result = str;
m_dll->ref_release(str);
- result.Trim();
+ StringUtils::Trim(result);
}
return result;
}
#include "utils/URIUtils.h"
#include "URL.h"
#include "utils/XBMCTinyXML.h"
+#include "utils/StringUtils.h"
#include "FileItem.h"
using namespace XFILE;
// Isolate the IP from the URL and replace the "*" with the real IP
// of the ReplayTV. E.g., rtv://*/Video/192.168.1.100/ becomes
// rtv://192.168.1.100/Video/ . This trickery makes things work.
- strURL = strRoot.TrimRight('/');
+ strURL = StringUtils::TrimRight(strRoot, "/");
pos = strURL.ReverseFind('/');
strRTV = strURL.Left(pos + 1);
strRTV.Replace("*", strURL.Mid(pos + 1));
}
CStdString newPath = smbPath;
- newPath.TrimLeft("/");
+ StringUtils::TrimLeft(newPath, "/");
smbFullPath += newPath;
// Make the mount command.
#include "FileItem.h"
#include "utils/log.h"
#include "utils/URIUtils.h"
+#include "utils/StringUtils.h"
using namespace MUSIC_INFO;
using namespace XFILE;
CStdString uuid = path.GetHostName();
CStdString object = path.GetFileName();
- object.TrimRight("/");
+ StringUtils::TrimRight(object, "/");
CURL::Decode(object);
PLT_DeviceDataReference device;
bool video = true;
bool audio = true;
bool image = true;
- m_strFileMask.TrimLeft("/");
+ StringUtils::TrimLeft(m_strFileMask, "/");
if (!m_strFileMask.empty()) {
video = m_strFileMask.Find(".wmv") >= 0;
audio = m_strFileMask.Find(".wma") >= 0;
#include "DirectoryFactory.h"
#include "Util.h"
#include "utils/URIUtils.h"
+#include "utils/StringUtils.h"
#include "Directory.h"
#include "DirectoryCache.h"
#include "SourcesDirectory.h"
bool CVirtualDirectory::IsSource(const CStdString& strPath, VECSOURCES *sources, CStdString *name) const
{
CStdString strPathCpy = strPath;
- strPathCpy.TrimRight("/");
- strPathCpy.TrimRight("\\");
+ StringUtils::TrimRight(strPathCpy, "/\\");
// just to make sure there's no mixed slashing in share/default defines
// ie. f:/video and f:\video was not be recognised as the same directory,
{
const CMediaSource& share = shares.at(i);
CStdString strShare = share.strPath;
- strShare.TrimRight("/");
- strShare.TrimRight("\\");
+ StringUtils::TrimRight(strShare, "/\\");
if(URIUtils::IsDOSPath(strShare))
strShare.Replace("/", "\\");
if (strShare == strPathCpy)
#include "utils/log.h"
#include "utils/URIUtils.h"
#include "utils/XBMCTinyXML.h"
+#include "utils/StringUtils.h"
CGUIColorManager g_colorManager;
{
// look in our color map
CStdString trimmed(color);
- trimmed.TrimLeft("= ");
+ StringUtils::TrimLeft(trimmed, "= ");
icColor it = m_colors.find(trimmed);
if (it != m_colors.end())
return (*it).second;
#include "GUIWindowManager.h"
#include "Key.h"
#include "utils/log.h"
+#include "utils/StringUtils.h"
using namespace std;
{
m_selectable = selectable;
m_clickAction = clickAction;
- m_clickAction.TrimLeft(" =");
- m_clickAction.TrimRight(" ");
+ StringUtils::TrimLeft(m_clickAction, " =");
+ StringUtils::TrimRight(m_clickAction);
m_text.Update(text);
float height;
m_text.GetTextExtent(m_length, height);
#include "filesystem/SpecialProtocol.h"
#include "utils/EndianSwap.h"
#include "utils/URIUtils.h"
+#include "utils/StringUtils.h"
#include "XBTF.h"
#include <lzo/lzo1x.h>
#include "utils/StringUtils.h"
CStdString CTextureBundleXBT::Normalize(const CStdString &name)
{
CStdString newName(name);
- newName.Normalize();
+
+ StringUtils::Trim(newName);
+ StringUtils::ToLower(newName);
newName.Replace('\\','/');
return newName;
CStdString CTextureBundleXPR::Normalize(const CStdString &name)
{
CStdString newName(name);
- newName.Normalize();
+ StringUtils::Trim(newName);
+ StringUtils::ToLower(newName);
newName.Replace('/','\\');
return newName;
}
for (unsigned int i = 0; i < modArray.size(); i++)
{
CStdString& substr = modArray[i];
- substr.Trim();
+ StringUtils::Trim(substr);
if (substr == "ctrl" || substr == "control")
button_id |= CKey::MODIFIER_CTRL;
else
{
// Don't bother checking the argument: an invalid arg will do seek(0)
- offset = parameter.Mid(15).TrimRight(")");
+ offset = parameter.Mid(15);
+ StringUtils::TrimRight(offset, ")");
float offsetpercent = (float) atof(offset.c_str());
if (offsetpercent < 0 || offsetpercent > 100)
CLog::Log(LOGERROR,"PlayerControl(seekpercentage(n)) argument, %f, must be 0-100", offsetpercent);
context = PARTYMODECONTEXT_VIDEO;
else if (parameter.size() != 16 || !StringUtils::EndsWithNoCase(parameter, "music)"))
{
- strXspPath = parameter.Mid(10).TrimRight(")");
+ strXspPath = parameter.Mid(10);
+ StringUtils::TrimRight(strXspPath, ")");
context = PARTYMODECONTEXT_UNKNOWN;
}
}
{
tokens.clear();
s = line;
- s.TrimLeft(" \t").TrimRight(" \n");
+ StringUtils::Trim(s);
if (s.length() == 0)
continue;
while (getdelim(&line, &linelen, '\n', fp) > 0)
{
s = line;
- s.TrimLeft(" \t").TrimRight(" \n");
+ StringUtils::Trim(s);
if (s.length() == 0)
continue;
try
{
CStdString strGenre = strGenre1;
- strGenre.Trim();
+ StringUtils::Trim(strGenre);
if (strGenre.empty())
strGenre=g_localizeStrings.Get(13205); // Unknown
CStdString CMusicInfoTag::Trim(const CStdString &value) const
{
CStdString trimmedValue(value);
- trimmedValue.TrimLeft(' ');
- trimmedValue.TrimRight(" \n\r");
+ StringUtils::TrimLeft(trimmedValue, " ");
+ StringUtils::TrimRight(trimmedValue, " \n\r");
return trimmedValue;
}
#include "MusicInfoTagLoaderDatabase.h"
#include "MusicInfoTagLoaderASAP.h"
#include "MusicInfoTagLoaderMidi.h"
-
+#include "utils/StringUtils.h"
#include "utils/URIUtils.h"
#include "FileItem.h"
return new CMusicInfoTagLoaderDatabase();
CStdString strExtension = URIUtils::GetExtension(strFileName);
- strExtension.ToLower();
- strExtension.TrimLeft('.');
+ StringUtils::ToLower(strExtension);
+ StringUtils::TrimLeft(strExtension, ".");
if (strExtension.empty())
return NULL;
bool CTagLoaderTagLib::Load(const CStdString& strFileName, CMusicInfoTag& tag, const CStdString& fallbackFileExtension, MUSIC_INFO::EmbeddedArt *art /* = NULL */)
{
CStdString strExtension = URIUtils::GetExtension(strFileName);
- strExtension.ToLower();
- strExtension.TrimLeft('.');
+ StringUtils::ToLower(strExtension);
+ StringUtils::TrimLeft(strExtension, ".");
if (strExtension.empty())
{
if (s != NULL)
{
CStdString strKeyword(line, s - line);
- strKeyword.TrimRight(" ");
+ StringUtils::TrimRight(strKeyword);
CStdString strValue(s+1);
strValue.Replace("\\n", "\n");
if (iPos > -1)
{
CStdString strGenre = strExtd.Mid(iPos + 5, 4);
- strGenre.TrimLeft(' ');
+ StringUtils::TrimLeft(strGenre);
if (StringUtils::IsNaturalNumber(strGenre))
{
int iGenre = strtol(strGenre, NULL, 10);
CStdString Xcddb::TrimToUTF8(const CStdString &untrimmedText)
{
CStdString text(untrimmedText);
- text.Trim();
+ StringUtils::Trim(text);
// You never know if you really get UTF-8 strings from cddb
g_charsetConverter.unknownToUTF8(text);
return text;
std::vector<std::string> tokens;
s = line;
- s.TrimLeft(" \t").TrimRight(" \n");
+ StringUtils::TrimLeft(s, " \t");
+ StringUtils::TrimRight(s," \n");
// skip comments
if (s.length() == 0 || s.GetAt(0) == '#')
std::vector<std::string> tokens;
s = line;
- s.TrimLeft(" \t").TrimRight(" \n");
+ StringUtils::TrimLeft(s, " \t");
+ StringUtils::TrimRight(s," \n");
// skip comments
if (!foundInterface && (s.length() == 0 || s.GetAt(0) == '#'))
{
CStdStringArray protocols;
StringUtils::SplitString(value, ",", protocols);
- for (unsigned int index = 0; index < protocols.size(); index++)
+ for (CStdStringArray::iterator protocol = protocols.begin(); protocol != protocols.end(); ++protocol)
{
- if (protocols.at(index).Trim().Equals(WS_PROTOCOL_JSONRPC))
+ StringUtils::Trim(*protocol);
+ if (*protocol == WS_PROTOCOL_JSONRPC)
{
websocketProtocol = WS_PROTOCOL_JSONRPC;
break;
{
CStdStringArray protocols;
StringUtils::SplitString(value, ",", protocols);
- for (unsigned int index = 0; index < protocols.size(); index++)
+ for (CStdStringArray::iterator protocol = protocols.begin(); protocol != protocols.end(); ++protocol)
{
- if (protocols.at(index).Trim().Equals(WS_PROTOCOL_JSONRPC))
+ StringUtils::Trim(*protocol);
+ if (*protocol == WS_PROTOCOL_JSONRPC)
{
websocketProtocol = WS_PROTOCOL_JSONRPC;
break;
m_configuration.tvVendor = iVendor;
// read the devices to wake when starting
- CStdString strWakeDevices = CStdString(GetSettingString("wake_devices_advanced")).Trim();
+ CStdString strWakeDevices = GetSettingString("wake_devices_advanced");
+ StringUtils::Trim(strWakeDevices);
m_configuration.wakeDevices.Clear();
if (!strWakeDevices.empty())
ReadLogicalAddresses(strWakeDevices, m_configuration.wakeDevices);
ReadLogicalAddresses(GetSettingInt("wake_devices"), m_configuration.wakeDevices);
// read the devices to power off when stopping
- CStdString strStandbyDevices = CStdString(GetSettingString("standby_devices_advanced")).Trim();
+ CStdString strStandbyDevices = GetSettingString("standby_devices_advanced");
+ StringUtils::Trim(strStandbyDevices);
m_configuration.powerOffDevices.Clear();
if (!strStandbyDevices.empty())
ReadLogicalAddresses(strStandbyDevices, m_configuration.powerOffDevices);
{
for (size_t iPtr = 0; iPtr < strString.size(); iPtr++)
{
- CStdString strDevice = CStdString(strString.substr(iPtr, 1)).Trim();
+ CStdString strDevice = strString.substr(iPtr, 1);
+ StringUtils::Trim(strDevice);
if (!strDevice.empty())
{
int iDevice(0);
for (unsigned int iPtr = CECDEVICE_TV; iPtr <= CECDEVICE_BROADCAST; iPtr++)
if (addresses[iPtr])
strPowerOffDevices.AppendFormat(" %X", iPtr);
- bChanged = SetSetting(strAdvancedSettingName, strPowerOffDevices.Trim());
+ StringUtils::Trim(strPowerOffDevices);
+ bChanged = SetSetting(strAdvancedSettingName, strPowerOffDevices);
}
int iSettingPowerOffDevices = LOCALISED_ID_NONE;
while (file.ReadString(szLine, 1024))
{
strLine = szLine;
- strLine.TrimRight(" \t\r\n");
- strLine.TrimLeft(" \t");
+ StringUtils::Trim(strLine);
if (strLine.Left( (int)strlen(M3U_INFO_MARKER) ) == M3U_INFO_MARKER)
{
{
// read and trim a line
strLine = szLine;
- strLine.TrimRight(" \t\r\n");
- strLine.TrimLeft(" \t");
+ StringUtils::Trim(strLine);
// skip the first line
if (strLine == M3U_START_MARKER)
continue;
strLine = szLine;
- strLine.TrimRight(" \t\r\n");
- strLine.TrimLeft(" \t");
+ StringUtils::Trim(strLine);
// this line was empty
if (strLine.empty())
for (size_t i = 0; i < vecParams.size(); i++)
{
// split the param, ensure there was an =
- CStdStringArray vecTuple = StringUtils::SplitString(vecParams[i].Trim(), "=");
+ StringUtils::Trim(vecParams[i]);
+ CStdStringArray vecTuple = StringUtils::SplitString(vecParams[i], "=");
if (vecTuple.size() < 2)
continue;
// remove white space from name and value and store it in the dictionary
- params[vecTuple[0].Trim()] = vecTuple[1].Trim();
+ StringUtils::Trim(vecTuple[0]);
+ StringUtils::Trim(vecTuple[1]);
+ params[vecTuple[0]] = vecTuple[1];
}
return params;
return size() > 0;
}
strLine = szLine;
- strLine.TrimLeft(" \t");
- strLine.TrimRight(" \n\r");
+ StringUtils::Trim(strLine);
if(strLine.Equals(START_PLAYLIST_MARKER))
break;
else
{
strLabel = m_pCdInfo->GetDiscLabel();
- strLabel.TrimRight(" ");
+ StringUtils::TrimRight(strLabel);
}
SetNewDVDShareUrl( strNewUrl , bCDDA, strLabel);
if(GetVolumeInformationW(CStdStringW(strDevice).c_str(), cVolumenName, 127, NULL, NULL, NULL, cFSName, 127)==0)
return "";
g_charsetConverter.wToUTF8(cVolumenName, strDevice);
- return strDevice.TrimRight(" ");
+ return StringUtils::TrimRight(strDevice, " ");
#else
return MEDIA_DETECT::CDetectDVDMedia::GetDVDLabel();
#endif
{
needle+=2;
m_cores[nCurrId].m_strVendor = needle;
- m_cores[nCurrId].m_strVendor.Trim();
+ StringUtils::Trim(m_cores[nCurrId].m_strVendor);
}
}
else if (strncmp(buffer, "Processor", strlen("Processor"))==0)
needle+=2;
m_cpuModel = needle;
m_cores[nCurrId].m_strModel = m_cpuModel;
- m_cores[nCurrId].m_strModel.Trim();
+ StringUtils::Trim(m_cores[nCurrId].m_strModel);
}
}
else if (strncmp(buffer, "BogoMIPS", strlen("BogoMIPS"))==0)
needle+=2;
m_cpuBogoMips = needle;
m_cores[nCurrId].m_strBogoMips = m_cpuBogoMips;
- m_cores[nCurrId].m_strBogoMips.Trim();
+ StringUtils::Trim(m_cores[nCurrId].m_strBogoMips);
}
}
else if (strncmp(buffer, "Hardware", strlen("Hardware"))==0)
needle+=2;
m_cpuHardware = needle;
m_cores[nCurrId].m_strHardware = m_cpuHardware;
- m_cores[nCurrId].m_strHardware.Trim();
+ StringUtils::Trim(m_cores[nCurrId].m_strHardware);
}
}
else if (strncmp(buffer, "Revision", strlen("Revision"))==0)
needle+=2;
m_cpuRevision = needle;
m_cores[nCurrId].m_strRevision = m_cpuRevision;
- m_cores[nCurrId].m_strRevision.Trim();
+ StringUtils::Trim(m_cores[nCurrId].m_strRevision);
}
}
else if (strncmp(buffer, "Serial", strlen("Serial"))==0)
needle+=2;
m_cpuSerial = needle;
m_cores[nCurrId].m_strSerial = m_cpuSerial;
- m_cores[nCurrId].m_strSerial.Trim();
+ StringUtils::Trim(m_cores[nCurrId].m_strSerial);
}
}
else if (strncmp(buffer, "model name", strlen("model name"))==0)
needle+=2;
m_cpuModel = needle;
m_cores[nCurrId].m_strModel = m_cpuModel;
- m_cores[nCurrId].m_strModel.Trim();
+ StringUtils::Trim(m_cores[nCurrId].m_strModel);
}
}
else if (strncmp(buffer, "flags", 5) == 0)
if ( strTwoCharCode.length() == 2 )
{
CStdString strTwoCharCodeLower( strTwoCharCode );
- strTwoCharCodeLower.MakeLower();
- strTwoCharCodeLower.TrimLeft();
- strTwoCharCodeLower.TrimRight();
+ StringUtils::ToLower(strTwoCharCodeLower);
+ StringUtils::Trim(strTwoCharCodeLower);
for (unsigned int index = 0; index < sizeof(CharCode2To3) / sizeof(CharCode2To3[0]); ++index)
{
return false;
CStdString strLower( strTwoCharCode );
- strLower.MakeLower();
- strLower.TrimLeft();
- strLower.TrimRight();
+ StringUtils::ToLower(strLower);
+ StringUtils::Trim(strLower);
for (unsigned int index = 0; index < sizeof(RegionCode2To3) / sizeof(RegionCode2To3[0]); ++index)
{
if (strLower.Equals(RegionCode2To3[index].old))
return false;
CStdString descTmp(desc);
- descTmp.Trim();
+ StringUtils::Trim(descTmp);
STRINGLOOKUPTABLE::iterator it;
for (it = m_mapUser.begin(); it != m_mapUser.end() ; it++)
{
STRINGLOOKUPTABLE::iterator it;
//Make sure we convert to lowercase before trying to find it
CStdString sCode(code);
- sCode.MakeLower();
- sCode.TrimLeft();
- sCode.TrimRight();
+ StringUtils::ToLower(sCode);
+ StringUtils::Trim(sCode);
+
it = m_mapUser.find(sCode);
if (it != m_mapUser.end())
{
long longcode;
CStdString sCode(code);
- sCode.MakeLower();
- sCode.TrimLeft();
- sCode.TrimRight();
+ StringUtils::ToLower(sCode);
+ StringUtils::Trim(sCode);
+
if(sCode.length() == 2)
{
longcode = MAKECODE('\0', '\0', sCode[0], sCode[1]);
strBuffer = strDirty.substr(i+11,i2-i-11);
CStdString strConverted(strBuffer);
HTML::CHTMLUtil::RemoveTags(strConverted);
- RemoveWhiteSpace(strConverted);
+ StringUtils::Trim(strConverted);
strDirty.erase(i,i2-i+11);
strDirty.Insert(i,strConverted);
i += strConverted.size();
if ((i2=strDirty.Find("!!!TRIM!!!",i+10)) != -1)
{
strBuffer = strDirty.substr(i+10,i2-i-10);
- RemoveWhiteSpace(strBuffer);
+ StringUtils::Trim(strBuffer);
strDirty.erase(i,i2-i+10);
strDirty.Insert(i,strBuffer);
i += strBuffer.size();
CStdStringW wConverted;
HTML::CHTMLUtil::ConvertHTMLToW(wbuffer,wConverted);
g_charsetConverter.fromW(wConverted,strBuffer,GetSearchStringEncoding());
- RemoveWhiteSpace(strBuffer);
+ StringUtils::Trim(strBuffer);
ConvertJSON(strBuffer);
strDirty.erase(i,i2-i+14);
strDirty.Insert(i,strBuffer);
}
}
-void CScraperParser::RemoveWhiteSpace(CStdString &string)
-{
- string.TrimLeft(" \t\r\n");
- string.TrimRight(" \t\r\n");
-}
-
void CScraperParser::ConvertJSON(CStdString &string)
{
CRegExp reg;
void ParseExpression(const CStdString& input, CStdString& dest, TiXmlElement* element, bool bAppend);
void ParseNext(TiXmlElement* element);
void Clean(CStdString& strDirty);
- /*! \brief Remove spaces, tabs, and newlines from a string
- \param string the string in question, which will be modified.
- */
- void RemoveWhiteSpace(CStdString &string);
void ConvertJSON(CStdString &string);
void ClearBuffers();
void GetBufferParams(bool* result, const char* attribute, bool defvalue);
return *this;
}
-
- MYTYPE& Normalize()
- {
- return Trim().ToLower();
- }
-
-
// -------------------------------------------------------------------------
// CStdStr -- Direct access to character buffer. In the MS' implementation,
// the at() function that we use here also calls _Freeze() providing us some
#endif
-
- // -------------------------------------------------------------------------
- // Trim and its variants
- // -------------------------------------------------------------------------
- MYTYPE& Trim()
- {
- return TrimLeft().TrimRight();
- }
-
- MYTYPE& TrimLeft()
- {
- this->erase(this->begin(),
- std::find_if(this->begin(), this->end(), NotSpace<CT>()));
-
- return *this;
- }
-
- MYTYPE& TrimLeft(CT tTrim)
- {
- this->erase(0, this->find_first_not_of(tTrim));
- return *this;
- }
-
- MYTYPE& TrimLeft(PCMYSTR szTrimChars)
- {
- this->erase(0, this->find_first_not_of(szTrimChars));
- return *this;
- }
-
- MYTYPE& TrimRight()
- {
- // NOTE: When comparing reverse_iterators here (MYRITER), I avoid using
- // operator!=. This is because namespace rel_ops also has a template
- // operator!= which conflicts with the global operator!= already defined
- // for reverse_iterator in the header <utility>.
- // Thanks to John James for alerting me to this.
-
- MYRITER it = std::find_if(this->rbegin(), this->rend(), NotSpace<CT>());
- if ( !(this->rend() == it) )
- this->erase(this->rend() - it);
-
- this->erase(!(it == this->rend()) ? this->find_last_of(*it) + 1 : 0);
- return *this;
- }
-
- MYTYPE& TrimRight(CT tTrim)
- {
- MYSIZE nIdx = this->find_last_not_of(tTrim);
- this->erase(MYBASE::npos == nIdx ? 0 : ++nIdx);
- return *this;
- }
-
- MYTYPE& TrimRight(PCMYSTR szTrimChars)
- {
- MYSIZE nIdx = this->find_last_not_of(szTrimChars);
- this->erase(MYBASE::npos == nIdx ? 0 : ++nIdx);
- return *this;
- }
-
void FreeExtra()
{
MYTYPE mt;
return str;
}
+std::string& StringUtils::TrimLeft(std::string &str, const std::string& chars)
+{
+ size_t nidx = str.find_first_not_of(chars);
+ str.substr(nidx == str.npos ? 0 : nidx).swap(str);
+ return str;
+}
+
std::string& StringUtils::TrimRight(std::string &str)
{
str.erase(::find_if(str.rbegin(), str.rend(), ::not1(::ptr_fun(isspace_c))).base(), str.end());
return str;
}
+std::string& StringUtils::TrimRight(std::string &str, const std::string& chars)
+{
+ size_t nidx = str.find_last_not_of(chars);
+ str.erase(str.npos == nidx ? 0 : ++nidx);
+ return str;
+}
+
std::string& StringUtils::RemoveDuplicatedSpacesAndTabs(std::string& str)
{
std::string::iterator it = str.begin();
long StringUtils::TimeStringToSeconds(const CStdString &timeString)
{
CStdString strCopy(timeString);
- strCopy.TrimLeft(" \n\r\t");
- strCopy.TrimRight(" \n\r\t");
+ StringUtils::Trim(strCopy);
if(StringUtils::EndsWithNoCase(strCopy, " min"))
{
// this is imdb format of "XXX min"
static std::string Right(const std::string &str, size_t count);
static std::string& Trim(std::string &str);
static std::string& TrimLeft(std::string &str);
+ static std::string& TrimLeft(std::string &str, const std::string &chars);
static std::string& TrimRight(std::string &str);
+ static std::string& TrimRight(std::string &str, const std::string &chars);
static std::string& RemoveDuplicatedSpacesAndTabs(std::string& str);
static int Replace(std::string &str, char oldChar, char newChar);
static int Replace(std::string &str, const std::string &oldStr, const std::string &newStr);
result = buffer;
pclose(pipe);
if (!result.empty())
- return result.Trim();
+ return StringUtils::Trim(result);
}
FILE* file = NULL;
{
result = buffer;
if (!result.empty())
- return result.Trim();
+ return StringUtils::Trim(result);
}
fclose(file);
}
{
result = buffer;
#if defined(TARGET_DARWIN)
- result.Trim();
+ StringUtils::Trim(result);
result += ", ";
result += GetDarwinVersionString();
#endif
}
#endif//else !TARGET_ANDROID
- return result.Trim();
+ return StringUtils::Trim(result);
}
#endif
void CTextSearch::ExtractSearchTerms(const CStdString &strSearchTerm, TextSearchDefault defaultSearchMode)
{
CStdString strParsedSearchTerm(strSearchTerm);
- strParsedSearchTerm = strParsedSearchTerm.Trim();
+ StringUtils::Trim(strParsedSearchTerm);
if (!m_bCaseSensitive)
strParsedSearchTerm = strParsedSearchTerm.ToLower();
while (strParsedSearchTerm.length() > 0)
{
- strParsedSearchTerm = strParsedSearchTerm.TrimLeft();
+ StringUtils::TrimLeft(strParsedSearchTerm);
if (StringUtils::StartsWith(strParsedSearchTerm, "!") || StringUtils::StartsWithNoCase(strParsedSearchTerm, "not"))
{
bNextNOT = (defaultSearchMode == SEARCH_DEFAULT_NOT);
}
- strParsedSearchTerm = strParsedSearchTerm.TrimLeft();
+ StringUtils::TrimLeft(strParsedSearchTerm);
}
}
strUrlPath += strBuffer;
strBuffer = strFilePathInArchive;
- strBuffer.Replace('\\', '/');
- strBuffer.TrimLeft('/');
+ StringUtils::Replace(strBuffer, '\\', '/');
+ StringUtils::TrimLeft(strBuffer, "/");
strUrlPath += "/";
strUrlPath += strBuffer;
LocalizeOverviewToken(words[i]);
str += words[i] + " ";
}
- str.TrimRight(" ");
+ StringUtils::TrimRight(str);
}
// input param must be kmh
m_repeatLine = strData;
m_repeatLogLevel = loglevel;
- unsigned int length = 0;
- while ( length != strData.length() )
- {
- length = strData.length();
- strData.TrimRight(" ");
- strData.TrimRight('\n');
- strData.TrimRight("\r");
- }
-
- if (!length)
+ StringUtils::TrimRight(strData);
+ if (strData.empty())
return;
OutputDebugString(strData);
*/
#include "utils/XBMCTinyXML.h"
+#include "utils/StringUtils.h"
#include "test/TestUtils.h"
#include "gtest/gtest.h"
if (url && url->FirstChild())
{
CStdString str = url->FirstChild()->ValueStr();
- retval = (str.Trim() == "http://api.themoviedb.org/3/movie/12244?api_key=57983e31fb435df4df77afb854740ea9&language=en???");
+ retval = (StringUtils::Trim(str) == "http://api.themoviedb.org/3/movie/12244?api_key=57983e31fb435df4df77afb854740ea9&language=en???");
}
}
EXPECT_TRUE(retval);
for (unsigned int i = 0; i < details.m_artist.size(); i++)
{
CStdString artist = details.m_artist[i];
- artist.Trim();
+ StringUtils::Trim(artist);
int idArtist = AddActor(artist,"");
AddArtistToMusicVideo(idMVideo, idArtist);
}
if ( ! filesToDelete.empty() )
{
- filesToDelete.TrimRight(",");
+ StringUtils::TrimRight(filesToDelete, ",");
// now grab them movies
sql = PrepareSQL("select idMovie from movie where idFile in (%s)",filesToDelete.c_str());
m_pDS->query(sql.c_str());
if ( ! moviesToDelete.empty() )
{
- moviesToDelete = "(" + moviesToDelete.TrimRight(",") + ")";
+ moviesToDelete = "(" + StringUtils::TrimRight(moviesToDelete, ",") + ")";
CLog::Log(LOGDEBUG, "%s: Cleaning movie table", __FUNCTION__);
sql = "delete from movie where idMovie in " + moviesToDelete;
if ( ! episodesToDelete.empty() )
{
- episodesToDelete = "(" + episodesToDelete.TrimRight(",") + ")";
+ episodesToDelete = "(" + StringUtils::TrimRight(episodesToDelete, ",") + ")";
CLog::Log(LOGDEBUG, "%s: Cleaning episode table", __FUNCTION__);
sql = "delete from episode where idEpisode in " + episodesToDelete;
m_pDS->close();
if (!strIds.empty())
{
- strIds.TrimRight(",");
+ StringUtils::TrimRight(strIds, ",");
sql = PrepareSQL("delete from path where idPath in (%s)",strIds.c_str());
m_pDS->exec(sql.c_str());
sql = PrepareSQL("delete from tvshowlinkpath where idPath in (%s)",strIds.c_str());
m_pDS->close();
if (!showsToDelete.empty())
{
- sql = "delete from tvshow where idShow in (" + showsToDelete.TrimRight(",") + ")";
+ sql = "delete from tvshow where idShow in (" + StringUtils::TrimRight(showsToDelete, ",") + ")";
m_pDS->exec(sql.c_str());
}
if ( ! musicVideosToDelete.empty() )
{
- musicVideosToDelete = "(" + musicVideosToDelete.TrimRight(",") + ")";
+ musicVideosToDelete = "(" + StringUtils::TrimRight(musicVideosToDelete, ",") + ")";
CLog::Log(LOGDEBUG, "%s: Cleaning musicvideo table", __FUNCTION__);
sql = "delete from musicvideo where idMVideo in " + musicVideosToDelete;
character = StringUtils::Format("%s %s %s\n", it->strName.c_str(), g_localizeStrings.Get(20347).c_str(), it->strRole.c_str());
strLabel += character;
}
- return strLabel.TrimRight("\n");
+ return StringUtils::TrimRight(strLabel, "\n");
}
void CVideoInfoTag::ParseNative(const TiXmlElement* movie, bool prioritise)
if (m_movieItem->GetVideoInfoTag()->m_playCount == 0 && !CSettings::Get().GetBool("videolibrary.showunwatchedplots"))
strTmp = g_localizeStrings.Get(20370);
- strTmp.Trim();
+ StringUtils::Trim(strTmp);
SetLabel(CONTROL_TEXTAREA, strTmp);
CGUIMessage msg(GUI_MSG_LABEL_BIND, GetID(), CONTROL_LIST, 0, 0, m_castList);
CStdString strParams;
CStdString strWorkingDir;
- strCommand.Trim();
+ StringUtils::Trim(strCommand);
if (strCommand.empty())
{
return false;
URIUtils::AddSlashAtEnd(strDrive);
if(GetVolumeInformation(strDrive.c_str(), cVolumenName, 127, NULL, NULL, NULL, cFSName, 127)==0)
return "";
- return CStdString(cVolumenName).TrimRight(" ");
+ CStdString volume = cVolumenName;
+ return StringUtils::TrimRight(volume, " ");
}
extern "C"
#include "system.h"
#include "PlatformInclude.h"
#include "utils/XBMCTinyXML.h"
+#include "utils/StringUtils.h"
#include "../xbmc/utils/log.h"
#if defined(TARGET_FREEBSD)
{
XOutput xoutput;
xoutput.name = output->Attribute("name");
- xoutput.name.TrimLeft(" \n\r\t");
- xoutput.name.TrimRight(" \n\r\t");
+ StringUtils::Trim(xoutput.name);
xoutput.isConnected = (strcasecmp(output->Attribute("connected"), "true") == 0);
xoutput.w = (output->Attribute("w") != NULL ? atoi(output->Attribute("w")) : 0);
xoutput.h = (output->Attribute("h") != NULL ? atoi(output->Attribute("h")) : 0);
for (TiXmlElement* modeline = pRootElement->FirstChildElement("modeline"); modeline; modeline = modeline->NextSiblingElement("modeline"))
{
name = modeline->Attribute("label");
- name.TrimLeft(" \n\t\r");
- name.TrimRight(" \n\t\r");
+ StringUtils::Trim(name);
strModeLine = modeline->FirstChild()->Value();
- strModeLine.TrimLeft(" \n\t\r");
- strModeLine.TrimRight(" \n\t\r");
+ StringUtils::Trim(strModeLine);
if (getenv("XBMC_BIN_HOME"))
{
snprintf(cmd, sizeof(cmd), "%s/xbmc-xrandr --newmode \"%s\" %s > /dev/null 2>&1", getenv("XBMC_BIN_HOME"),
aml_get_sysfs_str(modalias.c_str(), name, 255);
CStdString strName = name;
- strName.Trim();
+ StringUtils::Trim(strName);
if (strName == "platform:mesonfb")
return true;
return false;
return false;
CStdString fromMode = mode;
- fromMode.Trim();
+ StringUtils::Trim(fromMode);
// strips, for example, 720p* to 720p
// the * indicate the 'native' mode of the display
if (fromMode.Right(1) == "*")
result = GetAdvanceFilteredItems(items);
CStdString trimmedFilter(filter);
- trimmedFilter.TrimLeft().ToLower();
+ StringUtils::TrimLeft(trimmedFilter);
+ StringUtils::ToLower(trimmedFilter);
if (trimmedFilter.empty())
return result;