本文整理汇总了C++中CStdString::GetLength方法的典型用法代码示例。如果您正苦于以下问题:C++ CStdString::GetLength方法的具体用法?C++ CStdString::GetLength怎么用?C++ CStdString::GetLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStdString
的用法示例。
在下文中一共展示了CStdString::GetLength方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetModuleHandleW
bool Win32DllLoader::NeedsHooking(const char *dllName)
{
LibraryLoader *loader = DllLoaderContainer::GetModule(dllName);
if (loader)
{
// may have hooked this already (we can have repeats in the import table)
for (unsigned int i = 0; i < m_referencedDlls.size(); i++)
{
if (loader->GetHModule() == m_referencedDlls[i])
return false;
}
}
CStdStringW strdllNameW;
g_charsetConverter.utf8ToW(_P(dllName), strdllNameW, false);
HMODULE hModule = GetModuleHandleW(strdllNameW.c_str());
wchar_t filepathW[MAX_PATH];
GetModuleFileNameW(hModule, filepathW, MAX_PATH);
CStdString dllPath;
g_charsetConverter.wToUTF8(filepathW, dllPath);
// compare this filepath with some special directories
CStdString xbmcPath = _P("special://xbmc");
CStdString homePath = _P("special://home");
CStdString tempPath = _P("special://temp");
return ((strncmp(xbmcPath.c_str(), dllPath.c_str(), xbmcPath.GetLength()) == 0) ||
(strncmp(homePath.c_str(), dllPath.c_str(), homePath.GetLength()) == 0) ||
(strncmp(tempPath.c_str(), dllPath.c_str(), tempPath.GetLength()) == 0));
}
示例2: ClearSubPaths
void CDirectoryCache::ClearSubPaths(const CStdString& strPath)
{
CSingleLock lock (m_cs);
CStdString storedPath = _P(strPath);
CUtil::RemoveSlashAtEnd(storedPath);
ivecCache i = m_vecCache.begin();
for (bool found=false; i != m_vecCache.end(); )
{
CDir* dir = *i;
printf("Comparing %s to %s (%d characters)\n",
dir->m_strPath.c_str(),
storedPath.c_str(), storedPath.GetLength());
if (found)
{
delete dir;
i = m_vecCache.erase(i);
}
else if (strncmp(dir->m_strPath.c_str(), storedPath.c_str(), storedPath.GetLength()) == 0 &&
dir->m_strPath.size() > storedPath.size())
{
delete dir;
i = m_vecCache.erase(i);
}
else
{
i++;
}
if (storedPath == dir->m_strPath)
found = true;
}
}
示例3: RemoveTrailingSlash
CStdString DotNetRegistrar::RemoveTrailingSlash(CStdString sText)
{
if (sText.GetLength() == 0)
return _T("");
if (sText[sText.GetLength()-1] == '\\')
sText = sText.Left(sText.GetLength()-1);
return sText;
}
示例4: SplitString
// Splits the string input into pieces delimited by delimiter.
// if 2 delimiters are in a row, it will include the empty string between them.
int StringUtils::SplitString(const CStdString& input, const CStdString& delimiter, CStdStringArray &results)
{
int iPos = -1;
int newPos = -1;
int sizeS2 = delimiter.GetLength();
int isize = input.GetLength();
results.clear();
//CArray positions;
vector<unsigned int> positions;
newPos = input.Find (delimiter, 0);
if ( newPos < 0 )
{
results.push_back(input);
return 1;
}
int numFound = 1;
while ( newPos > iPos )
{
numFound++;
positions.push_back(newPos);
iPos = newPos;
newPos = input.Find (delimiter, iPos + sizeS2);
}
for ( unsigned int i = 0; i <= positions.size(); i++ )
{
CStdString s;
if ( i == 0 )
{
if (i == positions.size())
s = input;
else
s = input.Mid( i, positions[i] );
}
else
{
int offset = positions[i - 1] + sizeS2;
if ( offset < isize )
{
if ( i == positions.size() )
s = input.Mid(offset);
else if ( i > 0 )
s = input.Mid( positions[i - 1] + sizeS2,
positions[i] - positions[i - 1] - sizeS2 );
}
}
results.push_back(s);
}
return numFound;
}
示例5: Init
bool Codec::Init(const CStdString & strFile, unsigned int filecache) {
m_bufferSize = 2048 * sizeof(int16_t) * 50;
m_buffer = new char[m_bufferSize];
CStdString uri = URIUtils::GetFileName(strFile);
CStdString extension = uri.Right(uri.GetLength() - uri.Find('.') - 1);
if (extension.Left(12) == "spotifyradio") {
//if its a radiotrack the radionumber and tracknumber is secretly encoded at the end of the extension
CStdString trackStr = extension.Right(
extension.GetLength() - extension.ReverseFind('#') - 1);
Logger::printOut(extension);
CStdString radioNumber = extension.Left(uri.Find('#'));
Logger::printOut(radioNumber);
radioNumber = radioNumber.Right(
radioNumber.GetLength() - radioNumber.Find('#') - 1);
Logger::printOut("loading codec radio");
RadioHandler::getInstance()->pushToTrack(atoi(radioNumber),
atoi(trackStr));
}
//we have a non legit extension so remove it manually
uri = uri.Left(uri.Find('.'));
Logger::printOut("trying to load track:");
Logger::printOut(uri);
sp_link *spLink = sp_link_create_from_string(uri);
m_currentTrack = sp_link_as_track(spLink);
sp_track_add_ref(m_currentTrack);
sp_link_release(spLink);
m_endOfTrack = false;
m_bufferPos = 0;
m_startStream = false;
m_isPlayerLoaded = false;
m_TotalTime = sp_track_duration(m_currentTrack);
//prefetch the next track!
CPlayList& playlist = g_playlistPlayer.GetPlaylist(PLAYLIST_MUSIC);
int nextSong = g_playlistPlayer.GetNextSong();
if (nextSong >= 0 && nextSong < playlist.size()){
CFileItemPtr song = playlist[nextSong];
if (song != NULL){
CStdString uri = song->GetPath();
if (uri.Left(7).Equals("spotify")){
uri = uri.Left(uri.Find('.'));
Logger::printOut("prefetching track:");
Logger::printOut(uri);
sp_link *spLink = sp_link_create_from_string(uri);
sp_track* track = sp_link_as_track(spLink);
sp_session_player_prefetch(getSession(), track);
sp_link_release(spLink);
}
}
}
return true;
}
示例6: setSource
void XBPyThread::setSource(const CStdString &src)
{
#ifdef TARGET_WINDOWS
CStdString strsrc = src;
g_charsetConverter.utf8ToSystem(strsrc);
m_source = new char[strsrc.GetLength()+1];
strcpy(m_source, strsrc);
#else
m_source = new char[src.GetLength()+1];
strcpy(m_source, src);
#endif
}
示例7: HasAllRecordingsPathExtension
bool CPVRRecordings::HasAllRecordingsPathExtension(const CStdString &strDirectory)
{
CStdString strUseDir = TrimSlashes(strDirectory);
CStdString strAllRecordingsPathExtension(PVR_ALL_RECORDINGS_PATH_EXTENSION);
if (strUseDir.GetLength() < strAllRecordingsPathExtension.GetLength())
return false;
if (strUseDir.GetLength() == strAllRecordingsPathExtension.GetLength())
return strUseDir.Equals(strAllRecordingsPathExtension);
return strUseDir.Right(strAllRecordingsPathExtension.GetLength() + 1).Equals("/" + strAllRecordingsPathExtension);
}
示例8: x_SetData
bool CMarkupSTL::x_SetData( int iPos, const char * szData, int nCDATA )
{
// Set data at specified position
// if nCDATA==1, set content of element to a CDATA Section
CStdString csInsert;
// Set data in iPos element
if ( ! iPos || m_aPos[iPos].iElemChild )
return false;
// Build csInsert from szData based on nCDATA
// If CDATA section not valid, use parsed text (PCDATA) instead
if ( nCDATA != 0 )
if ( ! x_CreateNode(csInsert, MNT_CDATA_SECTION, szData) )
nCDATA = 0;
if ( nCDATA == 0 )
csInsert = x_TextToDoc( szData );
// Decide where to insert
int nInsertAt, nReplace;
if ( m_aPos[iPos].IsEmptyElement() )
{
nInsertAt = m_aPos[iPos].nEndL;
nReplace = 1;
// Pre-adjust since <NAME/> becomes <NAME>data</NAME>
CStdString csTagName = x_GetTagName( iPos );
m_aPos[iPos].nStartR -= 1;
m_aPos[iPos].nEndL -= (1 + csTagName.GetLength());
CStdString csFormat;
csFormat = _T(">");
csFormat += csInsert;
csFormat += _T("</");
csFormat += csTagName;
csInsert = csFormat;
}
else
{
nInsertAt = m_aPos[iPos].nStartR+1;
nReplace = m_aPos[iPos].nEndL - m_aPos[iPos].nStartR - 1;
}
x_DocChange( nInsertAt, nReplace, csInsert );
int nAdjust = csInsert.GetLength() - nReplace;
x_Adjust( iPos, nAdjust );
m_aPos[iPos].AdjustEnd( nAdjust );
MARKUP_SETDEBUGSTATE;
return true;
}
示例9: SetValueStringFormat
BOOL CObjectEntry::SetValueStringFormat(CStdString strFormattedValue)
{
CMmcDataConversion conversion;
unsigned __int64 uInt64Value(0);
CStdString strValue = _T("");
int iIndex;
BOOL oResult(TRUE);
//Remove leading text
iIndex = strFormattedValue.FindOneOf("0123456789");
if(iIndex != -1) strValue = strFormattedValue.Right(strFormattedValue.GetLength()-iIndex); else strValue = strFormattedValue;
//Check Types
if(conversion.DecUInt64Str2UInt64(strValue, &uInt64Value, FALSE))
{
m_ValueStringFormat = OVF_DEC;
oResult = TRUE;
}
else if(conversion.HexUInt64Str2UInt64(strValue, &uInt64Value, FALSE))
{
m_ValueStringFormat = OVF_HEX;
oResult = TRUE;
}
else
{
m_ValueStringFormat = OVF_DEC;
oResult = FALSE;
}
return oResult;
}
示例10: RemoveAllRecordingsPathExtension
CStdString CPVRRecordings::RemoveAllRecordingsPathExtension(const CStdString &strDirectory)
{
if (!HasAllRecordingsPathExtension(strDirectory))
return strDirectory;
return strDirectory.Left(strDirectory.GetLength() - strlen(PVR_ALL_RECORDINGS_PATH_EXTENSION) - 1);
}
示例11: x_DocChange
void CMarkupSTL::x_DocChange( int nLeft, int nReplace, const CStdString& csInsert )
{
// Insert csInsert int m_csDoc at nLeft replacing nReplace chars
// Do this with only one buffer reallocation if it grows
//
int nDocLength = m_csDoc.GetLength();
int nInsLength = csInsert.GetLength();
// Make sure nLeft and nReplace are within bounds
nLeft = max( 0, min( nLeft, nDocLength ) );
nReplace = max( 0, min( nReplace, nDocLength-nLeft ) );
// Get pointer to buffer with enough room
int nNewLength = nInsLength + nDocLength - nReplace;
int nBufferLen = nNewLength;
_TCHAR* pDoc = m_csDoc.GetBuffer( nBufferLen );
// Move part of old doc that goes after insert
if ( nLeft+nReplace < nDocLength )
memmove( &pDoc[nLeft+nInsLength], &pDoc[nLeft+nReplace], (nDocLength-nLeft-nReplace)*sizeof(_TCHAR) );
// Copy insert
memcpy( &pDoc[nLeft], csInsert, nInsLength*sizeof(_TCHAR) );
// Release
m_csDoc.ReleaseBuffer( nNewLength );
}
示例12: ReplaceBuffers
void CScraperParser::ReplaceBuffers(CStdString& strDest)
{
// insert buffers
int iIndex;
for (int i=MAX_SCRAPER_BUFFERS-1; i>=0; i--)
{
CStdString temp;
iIndex = 0;
temp.Format("$$%i",i+1);
while ((size_t)(iIndex = strDest.find(temp,iIndex)) != CStdString::npos) // COPIED FROM CStdString WITH THE ADDITION OF $ ESCAPING
{
strDest.replace(strDest.begin()+iIndex,strDest.begin()+iIndex+temp.GetLength(),m_param[i]);
iIndex += m_param[i].length();
}
}
// insert settings
iIndex = 0;
while ((size_t)(iIndex = strDest.find("$INFO[",iIndex)) != CStdString::npos)
{
int iEnd = strDest.Find("]",iIndex);
CStdString strInfo = strDest.Mid(iIndex+6,iEnd-iIndex-6);
CStdString strReplace;
if (m_scraper)
strReplace = m_scraper->GetSetting(strInfo);
strDest.replace(strDest.begin()+iIndex,strDest.begin()+iEnd+1,strReplace);
iIndex += strReplace.length();
}
iIndex = 0;
while ((size_t)(iIndex = strDest.find("\\n",iIndex)) != CStdString::npos)
strDest.replace(strDest.begin()+iIndex,strDest.begin()+iIndex+2,"\n");
}
示例13: GetTracks
bool Addon_music_spotify::GetTracks(CFileItemList& items, CStdString& path,
CStdString artistName, int albumId) {
Logger::printOut("get tracks");
CURL url(path);
CStdString uri = url.GetFileNameWithoutPath();
//the path will look something like this "musicdb://2/spotify:artist:0LcJLqbBmaGUft1e9Mm8HV/-1/"
//if we are trying to show all tracks for a spotify artist, we cant use the params becouse they are only integers.
CURL url2(path.Left(path.GetLength() - 3));
CStdString artist = url2.GetFileNameWithoutPath();
if (uri.Left(13).Equals("spotify:album")) {
return getAlbumTracks(items, uri);
} else if (artist.Left(14).Equals("spotify:artist")) {
return getArtistTracks(items, artist);
} else if (uri.Left(16).Equals("spotify:playlist")) {
uri.Delete(0, 17);
return getPlaylistTracks(items, atoi(uri));
} else if (artist.Left(15).Equals("spotify:toplist")) {
return g_spotify->getTopListTracks(items);
} else if (uri.Left(13).Equals("spotify:radio")) {
return getRadioTracks(items, atoi(uri.Right(1)));
} else if (uri.Left(13).Equals("spotify:track")) {
return getAlbumTracksFromTrack(items, uri);
} else if (albumId == -1) {
return getAllTracks(items, artistName);
}
return true;
}
示例14: GetTrackName
CStdString CCDDARipper::GetTrackName(CFileItem *item)
{
// get track number from "cdda://local/01.cdda"
int trackNumber = atoi(item->GetPath().substr(13, item->GetPath().size() - 13 - 5).c_str());
// Format up our ripped file label
CFileItem destItem(*item);
destItem.SetLabel("");
// get track file name format from audiocds.trackpathformat setting,
// use only format part starting from the last '/'
CStdString strFormat = CSettings::Get().GetString("audiocds.trackpathformat");
int pos = max(strFormat.ReverseFind('/'), strFormat.ReverseFind('\\'));
if (pos != -1)
{
strFormat = strFormat.Right(strFormat.GetLength() - pos - 1);
}
CLabelFormatter formatter(strFormat, "");
formatter.FormatLabel(&destItem);
// grab the label to use it as our ripped filename
CStdString track = destItem.GetLabel();
if (track.IsEmpty())
track.Format("%s%02i", "Track-", trackNumber);
track += GetExtension(CSettings::Get().GetInt("audiocds.encoder"));
return track;
}
示例15: IsIpAddress
bool IsIpAddress(const CStdString& address, bool allowNull)
{
if (GetIPV6LongForm(address) != _T(""))
return true;
int segment = 0;
int dotcount = 0;
for (int i = 0; i < address.GetLength(); ++i) {
const TCHAR& c = address[i];
if (c == '.') {
if (address[i + 1] == '.')
// Disallow multiple dots in a row
return false;
if (segment > 255)
return false;
if (!dotcount && !segment && !allowNull)
return false;
dotcount++;
segment = 0;
}
else if (c < '0' || c > '9')
return false;
segment = segment * 10 + c - '0';
}
if (dotcount != 3)
return false;
if (segment > 255)
return false;
return true;
}