本文整理汇总了C++中CStdString::Find方法的典型用法代码示例。如果您正苦于以下问题:C++ CStdString::Find方法的具体用法?C++ CStdString::Find怎么用?C++ CStdString::Find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStdString
的用法示例。
在下文中一共展示了CStdString::Find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadFromFileInMem
bool CBaseTexture::LoadFromFileInMem(unsigned char* buffer, size_t size, const std::string& mimeType, unsigned int maxWidth, unsigned int maxHeight)
{
if (!buffer || !size)
return false;
//ImageLib is sooo sloow for jpegs. Try our own decoder first. If it fails, fall back to ImageLib.
if (mimeType == "image/jpeg")
{
CJpegIO jpegfile;
if (jpegfile.Read(buffer, size, maxWidth, maxHeight))
{
if (jpegfile.Width() > 0 && jpegfile.Height() > 0)
{
Allocate(jpegfile.Width(), jpegfile.Height(), XB_FMT_A8R8G8B8);
if (jpegfile.Decode(m_pixels, GetPitch(), XB_FMT_A8R8G8B8))
{
m_hasAlpha=false;
ClampToEdge();
return true;
}
}
}
}
DllImageLib dll;
if (!dll.Load())
return false;
ImageInfo image;
memset(&image, 0, sizeof(image));
unsigned int width = maxWidth ? std::min(maxWidth, g_Windowing.GetMaxTextureSize()) : g_Windowing.GetMaxTextureSize();
unsigned int height = maxHeight ? std::min(maxHeight, g_Windowing.GetMaxTextureSize()) : g_Windowing.GetMaxTextureSize();
CStdString ext = mimeType;
int nPos = ext.Find('/');
if (nPos > -1)
ext.Delete(0, nPos + 1);
if(!dll.LoadImageFromMemory(buffer, size, ext.c_str(), width, height, &image))
{
CLog::Log(LOGERROR, "Texture manager unable to load image from memory");
return false;
}
LoadFromImage(image);
dll.ReleaseImage(&image);
return true;
}
示例2: getAttributeOfTag
void CHTMLUtil::getAttributeOfTag(const CStdString& strTagAndValue, const CStdString& strTag, CStdString& strValue)
{
// strTagAndValue contains:
// like <a href=""value".....
strValue = strTagAndValue;
int iStart = strTagAndValue.Find(strTag);
if (iStart < 0) return ;
iStart += (int)strTag.size();
while (strTagAndValue[iStart + 1] == 0x20 || strTagAndValue[iStart + 1] == 0x27 || strTagAndValue[iStart + 1] == 34) iStart++;
int iEnd = iStart + 1;
while (strTagAndValue[iEnd] != 0x27 && strTagAndValue[iEnd] != 0x20 && strTagAndValue[iEnd] != 34 && strTagAndValue[iEnd] != '>') iEnd++;
if (iStart >= 0 && iEnd >= 0)
{
strValue = strTagAndValue.Mid(iStart, iEnd - iStart);
}
}
示例3: splitUrlIntoExportAndPath
bool CNfsConnection::splitUrlIntoExportAndPath(const CURL& url, CStdString &exportPath, CStdString &relativePath)
{
bool ret = false;
//refresh exportlist if empty or hostname change
if(m_exportList.empty() || !url.GetHostName().Equals(m_hostName,false))
{
m_exportList = GetExportList(url);
}
if(!m_exportList.empty())
{
relativePath = "";
exportPath = "";
CStdString path = url.GetFileName();
//GetFileName returns path without leading "/"
//but we need it because the export paths start with "/"
//and path.Find(*it) wouldn't work else
if(!path.empty() && path[0] != '/')
{
path = "/" + path;
}
std::list<CStdString>::iterator it;
for(it=m_exportList.begin();it!=m_exportList.end();it++)
{
//if path starts with the current export path
if( path.Find(*it) == 0 )
{
exportPath = *it;
//handle special case where root is exported
//in that case we don't want to stripp off to
//much from the path
if( exportPath == "/" )
relativePath = "//" + path.Right((path.length()) - exportPath.length());
else
relativePath = "//" + path.Right((path.length()-1) - exportPath.length());
ret = true;
break;
}
}
}
return ret;
}
示例4: CreateFileTypesSafeArray
long CSaveAsObject::CreateFileTypesSafeArray(const CStdString& sFormatString, CSDSafeArray& safeArray, const long& lFormatIndex)
{
// These MUST be a complete list of possible file formats, otherwise the format index will be off :(
std::vector<CStdString> vValidFileFormats;
vValidFileFormats.push_back(_T("Workshare DeltaFile"));
vValidFileFormats.push_back(_T("Word 97-2003 Document"));
vValidFileFormats.push_back(_T("Word Document"));
vValidFileFormats.push_back(_T("Text Only"));
vValidFileFormats.push_back(_T("Rich Text Format"));
vValidFileFormats.push_back(_T("HTML Document"));
vValidFileFormats.push_back(_T("Works 6.0 & 7.0"));
vValidFileFormats.push_back(_T("Word 97-2003 & 6.0/95 - RTF"));
vValidFileFormats.push_back(_T("Adobe Acrobat File"));
vValidFileFormats.push_back(_T("Adobe Acrobat PDF/A File"));
/*DE9488: For the moment we don't want the Excel and Powerpoint to show in the menu, but at a later
*date we will add this to save menus*/
//vValidFileFormats.push_back(_T("Excel Document"));
//vValidFileFormats.push_back(_T("Excel 2007 Document"));
//vValidFileFormats.push_back(_T("PowerPoint Document"));
//vValidFileFormats.push_back(_T("PowerPoint 2007 Document"));
std::vector<CStdString> vRequiredFileFormats;
std::vector<CStdString>::iterator iter;
for(iter = vValidFileFormats.begin(); iter != vValidFileFormats.end(); ++iter )
{
if(sFormatString.Find(*iter) != -1)
{
vRequiredFileFormats.push_back(*iter);
}
}
long lVectorIndex = GetVectorIndexFormatPosition(sFormatString, lFormatIndex, vRequiredFileFormats);
int index = 0;
if(safeArray.Create(VT_BSTR, (x64_int_cast)vRequiredFileFormats.size()))
{
for(iter = vRequiredFileFormats.begin(); iter != vRequiredFileFormats.end(); ++iter )
{
safeArray.PutElement(index, bstr_t(iter->c_str()).copy());
++index;
}
}
return lVectorIndex;
}
示例5: GetFirstStackedFile
CStdString CStackDirectory::GetFirstStackedFile(const CStdString &strPath)
{
// the stacked files are always in volume order, so just get up to the first filename
// occurence of " , "
CStdString file, folder;
int pos = strPath.Find(" , ");
if (pos > 0)
URIUtils::Split(strPath.Left(pos), folder, file);
else
URIUtils::Split(strPath, folder, file); // single filed stacks - should really not happen
// remove "stack://" from the folder
folder = folder.Mid(8);
file.Replace(",,", ",");
return URIUtils::AddFileToFolder(folder, file);
}
示例6: Parameter
void CLastFmManager::Parameter(const CStdString& key, const CStdString& data, CStdString& value)
{
value = "";
vector<CStdString> params;
StringUtils::SplitString(data, "\n", params);
for (int i = 0; i < (int)params.size(); i++)
{
CStdString tmp = params[i];
if (int pos = tmp.Find(key) >= 0)
{
tmp.Delete(pos - 1, key.GetLength() + 1);
value = tmp;
break;
}
}
CLog::Log(LOGDEBUG, "Parameter %s -> %s", key.c_str(), value.c_str());
}
示例7: Compute
void IpRanges::Compute()
{
m_ipRangePrefixes.clear();
m_ipRangeBitWidths.clear();
std::list<CStdString>::iterator it;
for(it = m_asciiIpRanges.begin(); it != m_asciiIpRanges.end(); it++)
{
CStdString cidrPrefixLengthString;
unsigned int cidrPrefixLength = 32; // by default, x.x.x.x/32
CStdString cidrIpAddressString;
struct in_addr cidrIpAddress;
CStdString entry = *it;
int slashPosition = entry.Find('/');
if(slashPosition > 0)
{
cidrIpAddressString = entry.Left(slashPosition);
cidrPrefixLengthString = entry.Mid(slashPosition+1);
bool notAnInt = false;
try
{
cidrPrefixLength = StringToInt(cidrPrefixLengthString);
}
catch (...) {notAnInt = true;}
if(cidrPrefixLength < 1 || cidrPrefixLength > 32 || notAnInt)
{
throw (CStdString("IpRanges: invalid CIDR prefix length" + entry));
}
}
else
{
cidrIpAddressString = entry;
}
if(ACE_OS::inet_aton((PCSTR)cidrIpAddressString, &cidrIpAddress))
{
unsigned int rangeBitWidth = 32-cidrPrefixLength;
unsigned int prefix = ntohl((unsigned int)cidrIpAddress.s_addr) >> (rangeBitWidth);
m_ipRangePrefixes.push_back(prefix);
m_ipRangeBitWidths.push_back(rangeBitWidth);
}
else
{
throw (CStdString("invalid IP range:" + entry));
示例8: lock
CPeripheral *CPeripherals::GetByPath(const CStdString &strPath) const
{
if (!strPath.Left(14).Equals("peripherals://"))
return NULL;
CStdString strPathCut = strPath.Right(strPath.length() - 14);
CStdString strBus = strPathCut.Left(strPathCut.Find('/'));
CSingleLock lock(m_critSection);
for (unsigned int iBusPtr = 0; iBusPtr < m_busses.size(); iBusPtr++)
{
if (strBus.Equals(PeripheralTypeTranslator::BusTypeToString(m_busses.at(iBusPtr)->Type())))
return m_busses.at(iBusPtr)->GetByPath(strPath);
}
return NULL;
}
示例9: checkForFunctionTypeParas
bool CHttpApi::checkForFunctionTypeParas(CStdString &cmd, CStdString ¶s)
{
int open, close;
open = cmd.Find("(");
if (open>0)
{
close=cmd.length();
while (close>open && cmd.Mid(close,1)!=")")
close--;
if (close>open)
{
paras = cmd.Mid(open + 1, close - open - 1);
cmd = cmd.Left(open);
return (close-open)>1;
}
}
return false;
}
示例10: GetTypeAndSource
bool CVirtualPathDirectory::GetTypeAndSource(const CStdString& strPath, CStdString& strType, CStdString& strSource)
{
// format: virtualpath://type/sourcename
CStdString strTemp = strPath;
CUtil::RemoveSlashAtEnd(strTemp);
CStdString strTest = "virtualpath://";
if (strTemp.Left(strTest.length()).Equals(strTest))
{
strTemp = strTemp.Mid(strTest.length());
int iPos = strTemp.Find('/');
if (iPos < 1)
return false;
strType = strTemp.Mid(0, iPos);
strSource = strTemp.Mid(iPos + 1);
//CLog::Log(LOGDEBUG,"CVirtualPathDirectory::GetTypeAndSource(%s) = [%s],[%s]", strPath.c_str(), strType.c_str(), strSource.c_str());
return true;
}
return false;
}
示例11: GetOneTrack
bool Addon_music_spotify::GetOneTrack(CFileItemList& items, CStdString& path) {
Logger::printOut("get one track");
CURL url(path);
CStdString uri = url.GetFileNameWithoutPath();
if (uri.Left(13).Equals("spotify:track")) {
if (isReady()) {
sp_link *spLink = sp_link_create_from_string(uri.Left(uri.Find('.')));
if (!spLink) return false;
sp_track *spTrack = sp_link_as_track(spLink);
if (spTrack) {
SxTrack* track = TrackStore::getInstance()->getTrack(spTrack);
items.Add(Utils::SxTrackToItem(track));
sp_track_release(spTrack);
}
sp_link_release(spLink);
}
}
return true;
}
示例12: UpdateEjectButtonState
void CGUIWindowBoxeeBrowseLocal::UpdateEjectButtonState()
{
#ifndef HAS_EMBEDDED
SET_CONTROL_HIDDEN(BUTTON_EJECT);
SET_CONTROL_HIDDEN(BUTTON_EJECT_USER);
#else
CStdString strPath = ((CLocalBrowseWindowState*)m_windowState)->GetCurrentPath();
if (CUtil::HasSlashAtEnd(strPath))
{
// remove slash at the end
strPath.Delete(strPath.size() - 1);
}
if(!strPath.Equals("afp://") && !strPath.Equals("afp://all") && strPath.Find("afp://") != -1)
{
SET_CONTROL_VISIBLE(BUTTON_EJECT_USER);
SET_CONTROL_HIDDEN(BUTTON_EJECT);
return;
}
if (strPath != "network://protocols" && strPath != "")
{
SET_CONTROL_HIDDEN(BUTTON_EJECT);
SET_CONTROL_HIDDEN(BUTTON_EJECT_USER);
return;
}
VECSOURCES removableDrives;
g_mediaManager.GetRemovableDrives(removableDrives);
if (removableDrives.size() == 0)
{
SET_CONTROL_HIDDEN(BUTTON_EJECT);
SET_CONTROL_HIDDEN(BUTTON_EJECT_USER);
return;
}
SET_CONTROL_HIDDEN(BUTTON_EJECT_USER);
SET_CONTROL_VISIBLE(BUTTON_EJECT);
#endif
}
示例13: GetCustomExtensions
void CAdvancedSettings::GetCustomExtensions(TiXmlElement *pRootElement, CStdString& extensions)
{
CStdString extraExtensions;
CSettings::GetString(pRootElement,"add",extraExtensions,"");
if (extraExtensions != "")
extensions += "|" + extraExtensions;
CSettings::GetString(pRootElement,"remove",extraExtensions,"");
if (extraExtensions != "")
{
CStdStringArray exts;
StringUtils::SplitString(extraExtensions,"|",exts);
for (unsigned int i=0;i<exts.size();++i)
{
int iPos = extensions.Find(exts[i]);
if (iPos == -1)
continue;
extensions.erase(iPos,exts[i].size()+1);
}
}
}
示例14: Has
bool CAppRegistry::Has(const CStdString& key)
{
CSingleLock lock(m_lock);
CStdString tempKey = key;
size_t i = 0;
// If we are asked for a variable with {}, take it from the vector, otherwise return the first
int pos1 = key.Find("{");
int pos2 = key.Find("}");
if (pos1 >= 0 && pos2 > 0)
{
i = atoi(key.Mid(pos1+1, pos2 - pos1-1).c_str());
tempKey = key.Mid(0, pos1);
}
if (m_data.find(tempKey) == m_data.end())
return false;
return true;
}
示例15: GetAndCutNextTerm
void CTextSearch::GetAndCutNextTerm(CStdString &strSearchTerm, CStdString &strNextTerm)
{
CStdString strFindNext(" ");
if (StringUtils::EndsWith(strSearchTerm, "\""))
{
strSearchTerm.erase(0, 1);
strFindNext = "\"";
}
int iNextPos = strSearchTerm.Find(strFindNext);
if (iNextPos != -1)
{
strNextTerm = strSearchTerm.Left(iNextPos);
strSearchTerm.erase(0, iNextPos + 1);
}
else
{
strNextTerm = strSearchTerm;
strSearchTerm.clear();
}
}