本文整理汇总了C++中CStdString::find_first_of方法的典型用法代码示例。如果您正苦于以下问题:C++ CStdString::find_first_of方法的具体用法?C++ CStdString::find_first_of怎么用?C++ CStdString::find_first_of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStdString
的用法示例。
在下文中一共展示了CStdString::find_first_of方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetExtension
/* returns filename extension including period of filename */
const CStdString URIUtils::GetExtension(const CStdString& strFileName)
{
if(IsURL(strFileName))
{
CURL url(strFileName);
return GetExtension(url.GetFileName());
}
int period = strFileName.find_last_of('.');
if(period >= 0)
{
if( strFileName.find_first_of('/', period+1) != string::npos ) return "";
if( strFileName.find_first_of('\\', period+1) != string::npos ) return "";
return strFileName.substr(period);
}
else
return "";
}
示例2: GetObjectAddress
BYTE CMapFile::GetObjectAddress( const char * cObjName, DWORD * addr ){
CStdString sAux;
CStdString sFindObj;
int i;
char cBuffer[512];
int j;
DWORD dwRet;
if ( fIn.bad() == true ){
return FALSE;
}
sFindObj.Format( " %s ", cObjName );
while( fIn.eof() == false ){
fIn.getline( cBuffer, sizeof( cBuffer ) );
sAux = cBuffer;
if ( sAux.find( sFindObj.c_str() ) != std::string::npos ){
break;
}
}
if ( fIn.eof() ){
return FALSE;
}
i = sAux.find_first_of( "0x" );
if ( i == std::string::npos ){
return -1;
}
i+= 2;
j = sAux.find_first_of( " ", i );
sFindObj = sAux.substr( i, j-i );
dwRet = atohex( sFindObj.c_str() );
*addr = dwRet;
return TRUE;
}
示例3: getArtworkPath
/*
* Function takes the title of a show, and a folder to search in
* returns a path to the artwork in the form of 'special://home/cache/folder/image.jpg'
*/
CStdString fileOps::getArtworkPath ( CStdString title, FILE_OPTIONS Get_What )
{
CStdString retPath;
if (title.IsEmpty())
return retPath;
CStdString awGroup;
if (Get_What == FILE_OPS_GET_CHAN_ICONS)
awGroup = "channels";
else if (Get_What == FILE_OPS_GET_COVERART)
awGroup = "coverart";
else if (Get_What == FILE_OPS_GET_FANART)
awGroup = "fanart";
else
return retPath;
if (Get_What == FILE_OPS_GET_CHAN_ICONS)
{
CURL someUrl(title);
title = someUrl.GetFileNameWithoutPath();
}
else {
int mrkrPos = title.find_first_of("::");
if (mrkrPos<=0)
mrkrPos=title.length();
title = title.Left(mrkrPos);
}
XBMC->Log(LOG_DEBUG,"%s - ## - Checking for Artwork File - %s - in - %s - ##",
__FUNCTION__, title.c_str(), awGroup.c_str());
retPath = checkFolderForTitle(title,awGroup);
if (retPath.IsEmpty() && isMyth)
{
// If still no result check if we can sync with mythbackends storage group and try again
if (!mythConP.IsConnected())
{
XBMC->Log(LOG_DEBUG,"%s - ###########Not connected to mythbackend#######", __FUNCTION__);
return retPath;
}
if (Get_What == FILE_OPS_GET_CHAN_ICONS)
{
GetFileFromBackend(title,"channels");
}
else
{
syncSGCache(awGroup); //Thread this function, so xbmc doesnt hang when getting recordings.
}
retPath = checkFolderForTitle(title,awGroup);
}
return retPath;
}
示例4: ff_avutil_log
void ff_avutil_log(void* ptr, int level, const char* format, va_list va)
{
static CStdString buffer;
AVClass* avc= ptr ? *(AVClass**)ptr : NULL;
if(level >= AV_LOG_DEBUG && g_advancedSettings.m_logLevel <= LOG_LEVEL_DEBUG_SAMBA)
return;
else if(g_advancedSettings.m_logLevel <= LOG_LEVEL_NORMAL)
return;
int type;
switch(level)
{
case AV_LOG_INFO : type = LOGINFO; break;
case AV_LOG_ERROR : type = LOGERROR; break;
case AV_LOG_DEBUG :
default : type = LOGDEBUG; break;
}
CStdString message, prefix;
message.FormatV(format, va);
prefix = "ffmpeg: ";
if(avc)
{
if(avc->item_name)
prefix += CStdString("[") + avc->item_name(ptr) + "] ";
else if(avc->class_name)
prefix += CStdString("[") + avc->class_name + "] ";
}
buffer += message;
int pos, start = 0;
while( (pos = buffer.find_first_of('\n', start)) >= 0 )
{
if(pos>start)
CLog::Log(type, "%s%s", prefix.c_str(), buffer.substr(start, pos-start).c_str());
start = pos+1;
}
buffer.erase(0, start);
}
示例5: if
std::vector<CStdString> PdfListLevel::Tokenize(const CStdString &sText, const CStdString &breakChars)
{
int iPos = -1;
std::vector<CStdString> results;
do
{
int iNextPos = (x64_int_cast)sText.find_first_of(breakChars, iPos+1);
if (iNextPos == 0)
{
// first char is a breakChar
results.push_back(sText.substr(0,1));
}
else if (iNextPos == -1)
{
// end of string
results.push_back(sText.substr(iPos+1));
}
else if (iNextPos == iPos+1)
{
// another break char hmmm
results.back()+=sText.substr(iNextPos,1);
}
else
{
results.push_back(sText.substr(iPos+1, iNextPos-iPos -1));
results.push_back(sText.substr(iNextPos, 1));
}
iPos = iNextPos;
if (iPos == (int)(x64_int_cast)sText.size()-1)
break;
} while (iPos != -1);
return results;
}
示例6: checkDirectory
bool fileOps::checkDirectory ( CStdString dirPath, bool hasFilename/* = false */)
{
int pos = 0;
int offset = 0;
CStdString srchString = dirPath;
while (pos >= 0) {
pos = srchString.find_first_of("/",pos+1);
if (pos < 0) {
break;
}
if (pos <= baseLocalCachepath.length()) {
continue;
}
CUtil::CreateDirectoryEx(srchString.Left(pos));
if (offset > 20) {
break;
}
offset++;
}
if (!hasFilename) {
CUtil::CreateDirectoryEx(dirPath);
}
return true;
}
示例7: ReadFile
bool CIniFile::ReadFile()
{
// Normally you would use ifstream, but the SGI CC compiler has
// a few bugs with ifstream. So ... fstream used.
fstream f;
CStdString line;
CStdString keyname, valuename, value;
CStdString::size_type pLeft, pRight;
f.open( (LPCSTR)path, fstream::in );
if ( f.fail()){
f.open( (LPCSTR)path, fstream::out );
if ( f.fail() )
return false;
f.close();
f.open( (LPCSTR)path, fstream::in );
}
while( getline( f, line)) {
if ( !line.length() ){
continue;
}
// To be compatible with Win32, check for existence of '\r'.
// Win32 files have the '\r' and Unix files don't at the end of a line.
// Note that the '\r' will be written to INI files from
// Unix so that the created INI file can be read under Win32
// without change.
if ( line[line.length() - 1] == '\r')
line = line.substr( 0, line.length() - 1);
if ( line.length()) {
// Check that the user hasn't openned a binary file by checking the first
// character of each line!
if ( !isprint( line[0])) {
printf( "Failing on char %d\n", line[0]);
f.close();
return false;
}
if (( pLeft = line.find_first_of(";#[=")) != CStdString::npos) {
switch ( line[pLeft]) {
case '[':
if ((pRight = line.find_last_of("]")) != CStdString::npos && pRight > pLeft) {
keyname = line.substr( pLeft + 1, pRight - pLeft - 1);
AddKeyName( keyname);
}
break;
case '=':
valuename = line.substr( 0, pLeft);
value = line.substr( pLeft + 1);
SetValue( keyname, valuename, value);
break;
case ';':
case '#':
if ( !names.size())
HeaderComment( line.substr( pLeft + 1));
else
KeyComment( keyname, line.substr( pLeft + 1));
break;
}
}
}
}
f.close();
if ( names.size())
return true;
return false;
}
示例8: Parse
//.........这里部分代码省略.........
if (iPos == -1) iPos = 0;
// for protocols supporting options, chop that part off here
// maybe we should invert this list instead?
int iEnd = strURL.length();
const char* sep = NULL;
//TODO fix all Addon paths
CStdString strProtocol2 = GetTranslatedProtocol();
if(m_strProtocol.Equals("rss") ||
m_strProtocol.Equals("rar") ||
m_strProtocol.Equals("addons") ||
m_strProtocol.Equals("image") ||
m_strProtocol.Equals("videodb") ||
m_strProtocol.Equals("musicdb") ||
m_strProtocol.Equals("androidapp"))
sep = "?";
else
if(strProtocol2.Equals("http")
|| strProtocol2.Equals("https")
|| strProtocol2.Equals("plugin")
|| strProtocol2.Equals("addons")
|| strProtocol2.Equals("hdhomerun")
|| strProtocol2.Equals("rtsp")
|| strProtocol2.Equals("apk")
|| strProtocol2.Equals("zip"))
sep = "?;#|";
else if(strProtocol2.Equals("ftp")
|| strProtocol2.Equals("ftps"))
sep = "?;";
if(sep)
{
int iOptions = strURL.find_first_of(sep, iPos);
if (iOptions >= 0 )
{
// we keep the initial char as it can be any of the above
int iProto = strURL.find_first_of("|",iOptions);
if (iProto >= 0)
{
m_strProtocolOptions = strURL.substr(iProto+1);
m_strOptions = strURL.substr(iOptions,iProto-iOptions);
}
else
m_strOptions = strURL.substr(iOptions);
iEnd = iOptions;
m_options.AddOptions(m_strOptions);
}
}
int iSlash = strURL.Find("/", iPos);
if(iSlash >= iEnd)
iSlash = -1; // was an invalid slash as it was contained in options
if( !m_strProtocol.Equals("iso9660") )
{
int iAlphaSign = strURL.Find("@", iPos);
if (iAlphaSign >= 0 && iAlphaSign < iEnd && (iAlphaSign < iSlash || iSlash < 0))
{
// username/password found
CStdString strUserNamePassword = strURL.Mid(iPos, iAlphaSign - iPos);
// first extract domain, if protocol is smb
if (m_strProtocol.Equals("smb"))
{
int iSemiColon = strUserNamePassword.Find(";");
示例9: IsFileOnly
bool CURL::IsFileOnly(const CStdString &url)
{
return url.find_first_of("/\\") == CStdString::npos;
}
示例10: if
CStdString CID3Tag::ParseMP3Genre(const CStdString& str) const
{
m_dll.Load();
CStdString strTemp = str;
set<CStdString> setGenres;
while (!strTemp.IsEmpty())
{
// remove any leading spaces
strTemp.TrimLeft();
if (strTemp.IsEmpty())
break;
// start off looking for (something)
if (strTemp[0] == '(')
{
strTemp.erase(0, 1);
if (strTemp.empty())
break;
// now look for ((something))
if (strTemp[0] == '(')
{
// remove ((something))
int i = strTemp.find_first_of(')');
strTemp.erase(0, i + 2);
}
}
// no parens, so we have a start of a string
// push chars into temp string until valid terminator found
// valid terminators are ) or , or ;
else
{
CStdString t;
size_t i = strTemp.find_first_of("),;");
if (i != std::string::npos)
{
t = strTemp.Left(i);
strTemp.erase(0, i + 1);
} else {
t = strTemp;
strTemp.clear();
}
// remove any leading or trailing white space
// from temp string
t.Trim();
if (!t.length()) continue;
// if the temp string is natural number try to convert it to a genre string
if (StringUtils::IsNaturalNumber(t))
{
id3_ucs4_t* ucs4=m_dll.id3_latin1_ucs4duplicate((id3_latin1_t*)t.c_str());
const id3_ucs4_t* genre=m_dll.id3_genre_name(ucs4);
m_dll.id3_ucs4_free(ucs4);
t=ToStringCharset(genre, ID3_FIELD_TEXTENCODING_ISO_8859_1);
}
// convert RX to Remix as per ID3 V2.3 spec
else if ((t == "RX") || (t == "Rx") || (t == "rX") || (t == "rx"))
{
t = "Remix";
}
// convert CR to Cover as per ID3 V2.3 spec
else if ((t == "CR") || (t == "Cr") || (t == "cR") || (t == "cr"))
{
t = "Cover";
}
// insert genre name in set
setGenres.insert(t);
}
}
// return a " / " seperated string
CStdString strGenre;
set<CStdString>::iterator it;
for (it = setGenres.begin(); it != setGenres.end(); it++)
{
CStdString strTemp = *it;
if (!strGenre.IsEmpty())
strGenre += g_advancedSettings.m_musicItemSeparator;
strGenre += strTemp;
}
return strGenre;
}
示例11: if
CStdString CID3Tag::ParseMP3Genre(const CStdString& str) const
{
if (!m_dll.IsLoaded())
m_dll.Load();
CStdString strTemp = str;
set<CStdString> setGenres;
while (!strTemp.IsEmpty())
{
// remove any leading spaces
int i = strTemp.find_first_not_of(" ");
if (i > 0) strTemp.erase(0, i);
// pull off the first character
char p = strTemp[0];
// start off looking for (something)
if (p == '(')
{
strTemp.erase(0, 1);
// now look for ((something))
p = strTemp[0];
if (p == '(')
{
// remove ((something))
i = strTemp.find_first_of("))");
strTemp.erase(0, i + 2);
}
}
// no parens, so we have a start of a string
// push chars into temp string until valid terminator found
// valid terminators are ) or , or ;
else
{
CStdString t;
while ((!strTemp.IsEmpty()) && (p != ')') && (p != ',') && (p != ';'))
{
strTemp.erase(0, 1);
t.push_back(p);
p = strTemp[0];
}
// loop exits when terminator is found
// be sure to remove the terminator
strTemp.erase(0, 1);
// remove any leading or trailing white space
// from temp string
t.Trim();
if (!t.size()) continue;
// if the temp string is natural number try to convert it to a genre string
if (StringUtils::IsNaturalNumber(t))
{
id3_ucs4_t* ucs4=m_dll.id3_latin1_ucs4duplicate((id3_latin1_t*)t.c_str());
const id3_ucs4_t* genre=m_dll.id3_genre_name(ucs4);
m_dll.id3_ucs4_free(ucs4);
t=ToStringCharset(genre, ID3_FIELD_TEXTENCODING_ISO_8859_1);
}
// convert RX to Remix as per ID3 V2.3 spec
else if ((t == "RX") || (t == "Rx") || (t == "rX") || (t == "rx"))
{
t = "Remix";
}
// convert CR to Cover as per ID3 V2.3 spec
else if ((t == "CR") || (t == "Cr") || (t == "cR") || (t == "cr"))
{
t = "Cover";
}
// insert genre name in set
setGenres.insert(t);
}
}
// return a " / " seperated string
CStdString strGenre;
set<CStdString>::iterator it;
for (it = setGenres.begin(); it != setGenres.end(); it++)
{
CStdString strTemp = *it;
if (!strGenre.IsEmpty())
strGenre += g_advancedSettings.m_musicItemSeparator;
strGenre += strTemp;
}
return strGenre;
}