本文整理汇总了C++中rfind函数的典型用法代码示例。如果您正苦于以下问题:C++ rfind函数的具体用法?C++ rfind怎么用?C++ rfind使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rfind函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: FN
//---------------------------------------------------------------------------
Ztring& FileName::Name_Set(const Ztring &Name)
{
#ifdef ZENLIB_USEWX
wxFileName FN(c_str());
if (FN==FN.GetName()) //Bug of WxWidgets? if C:\\dir\\(no name), name is C:\\dir\\(no name)
FN.SetPath(c_str());
FN.SetName(Name.c_str());
assign ((FN.GetFullPath()+FN.GetPathSeparator()/*FileName_PathSeparator*/+FN.GetFullName()).c_str());
#else //ZENLIB_USEWX
#ifdef WINDOWS
//Path limit
size_t Pos_Path=rfind(_T('\\'));
if (Pos_Path==Ztring::npos)
Pos_Path=0; //Not found
//Extension limit
size_t Pos_Ext=rfind(_T('.'));
if (Pos_Ext==Ztring::npos || Pos_Ext<Pos_Path)
Pos_Ext=size(); //Not found
replace(Pos_Path+1, Pos_Ext-Pos_Path-1, Name, 0, Ztring::npos);
#else
//Not supported
#endif
#endif //ZENLIB_USEWX
return *this;
}
开发者ID:Kyouju,项目名称:mpc-hc,代码行数:26,代码来源:FileName.cpp
示例2: updateConfigParser
void RuntimeEngine::setupRuntime()
{
//
// 1. get project type fron config.json
// 2. init Lua / Js runtime
//
updateConfigParser();
auto entryFile = ConfigParser::getInstance()->getEntryFile();
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32) && (CC_TARGET_PLATFORM != CC_PLATFORM_MAC)
ConfigParser::getInstance()->readConfig();
entryFile = ConfigParser::getInstance()->getEntryFile();
#endif
// Lua
if ((entryFile.rfind(".lua") != std::string::npos) ||
(entryFile.rfind(".luac") != std::string::npos))
{
_launchEvent = "lua";
_runtime = _runtimes[kRuntimeEngineLua];
}
// Js
else if ((entryFile.rfind(".js") != std::string::npos) ||
(entryFile.rfind(".jsc") != std::string::npos))
{
_launchEvent = "js";
_runtime = _runtimes[kRuntimeEngineJs];
}
}
开发者ID:253056965,项目名称:cocos2d-x-lite,代码行数:29,代码来源:Runtime.cpp
示例3: get_domain
static void get_domain(const struct phishcheck* pchk,struct string* dest,struct string* host)
{
char* domain;
char* tld = strrchr(host->data,'.');
if(!tld) {
cli_dbgmsg("Phishcheck: Encountered a host without a tld? (%s)\n",host->data);
string_assign(dest,host);
return;
}
if(isCountryCode(pchk,tld+1)) {
const char* countrycode = tld+1;
tld = rfind(host->data,'.',tld-host->data-1);
if(!tld) {
cli_dbgmsg("Phishcheck: Weird, a name with only 2 levels (%s)\n",
host->data);
string_assign(dest,host);
return;
}
if(!isTLD(pchk,tld+1,countrycode-tld-1)) {
string_assign_ref(dest,host,tld+1);
return;/*it was a name like: subdomain.domain.uk, return domain.uk*/
}
}
/*we need to strip one more level, this is the actual domain*/
domain = rfind(host->data,'.',tld-host->data-1);
if(!domain) {
string_assign(dest,host);
return;/* it was like sourceforge.net?*/
}
string_assign_ref(dest,host,domain+1);
}
开发者ID:5432935,项目名称:crossbridge,代码行数:31,代码来源:libclamav_phishcheck.c
示例4: rfind
FileName FileName::removeFileFormat() const
{
size_t found = rfind(NUM);
if (found != String::npos)
return substr(0, found);
found = rfind(COLON);
if (found != String::npos)
return substr(0, found);
return *this;
}
开发者ID:I2PC,项目名称:scipion,代码行数:10,代码来源:xmipp_filename.cpp
示例5: getChunksOfLocalizedDescriptions
static vector< vector< string > > getChunksOfLocalizedDescriptions(
const Config& config, const IndexEntry& entry)
{
vector< vector< string > > result;
if (entry.category != IndexEntry::Binary)
{
return result;
}
vector< string > chunksBase;
if (!entry.component.empty())
{
chunksBase.push_back(entry.component);
}
chunksBase.push_back("i18n");
set< string > alreadyAddedTranslations;
auto addTranslation = [&chunksBase, &alreadyAddedTranslations, &result](const string& locale)
{
if (alreadyAddedTranslations.insert(locale).second)
{
auto chunks = chunksBase;
chunks.push_back(string("Translation-") + locale);
result.push_back(chunks);
}
};
auto translationVariable = config.getString("cupt::languages::indexes");
auto translations = split(',', translationVariable);
FORIT(translationIt, translations)
{
auto locale = (*translationIt == "environment") ?
setlocale(LC_MESSAGES, NULL) : *translationIt;
if (locale == "none")
{
continue;
}
// cutting out an encoding
auto dotPosition = locale.rfind('.');
if (dotPosition != string::npos)
{
locale.erase(dotPosition);
}
addTranslation(locale);
// cutting out an country specificator
auto underlinePosition = locale.rfind('_');
if (underlinePosition != string::npos)
{
locale.erase(underlinePosition);
}
addTranslation(locale);
}
开发者ID:jamessan,项目名称:cupt,代码行数:55,代码来源:cachefiles.cpp
示例6: if
String FileName::getFileFormat() const
{
size_t first;
FileName result;
if (find(NUM) != npos)
return "raw";
else if ((first = rfind(COLON)) != npos)
result = substr(first + 1);
else if ((first = rfind(".")) != npos)
result = substr(first + 1);
return result.toLowercase();
}
开发者ID:I2PC,项目名称:scipion,代码行数:12,代码来源:xmipp_filename.cpp
示例7: take_over
void take_over()
{
auto old_path = winapi::get_module_path();
if( !winapi::path_file_exists( old_path ) ) {
old_path = winapi::get_module_path().substr( 0, old_path.rfind( "\\" ) );
}
mmaccel::mmaccel_txt_to_key_map_txt(
old_path.substr( 0, old_path.rfind( u8"\\" ) ) + u8"\\mmaccel.txt",
winapi::get_module_path() + u8"\\key_map.txt",
mmaccel::mmd_map::load( winapi::get_module_path() + u8"\\mmd_map.json" )
);
}
开发者ID:LNSEAB,项目名称:mmaccel,代码行数:13,代码来源:main.cpp
示例8: defined
AString cFile::ChangeFileExt(const AString & a_FileName, const AString & a_NewExt)
{
auto res = a_FileName;
// If the path separator is the last character of the string, return the string unmodified (refers to a folder):
#if defined(_MSC_VER)
// Find either path separator - MSVC CRT accepts slashes as separators, too
auto LastPathSep = res.find_last_of("/\\");
#elif defined(_WIN32)
// Windows with different CRTs support only the backslash separator
auto LastPathSep = res.rfind('\\');
#else
// Linux supports only the slash separator
auto LastPathSep = res.rfind('/');
#endif
if ((LastPathSep != AString::npos) && (LastPathSep + 1 == res.size()))
{
return res;
}
// Append or replace the extension:
auto DotPos = res.rfind('.');
if (
(DotPos == AString::npos) || // No dot found
((LastPathSep != AString::npos) && (LastPathSep > DotPos)) // Last dot is before the last path separator (-> in folder name)
)
{
// No extension, just append the new one:
if (!a_NewExt.empty() && (a_NewExt[0] != '.'))
{
// a_NewExt doesn't start with a dot, insert one:
res.push_back('.');
}
res.append(a_NewExt);
}
else
{
// Replace existing extension:
if (!a_NewExt.empty() && (a_NewExt[0] != '.'))
{
// a_NewExt doesn't start with a dot, keep the current one:
res.erase(DotPos + 1, AString::npos);
}
else
{
res.erase(DotPos, AString::npos);
}
res.append(a_NewExt);
}
return res;
}
开发者ID:1285done,项目名称:cuberite,代码行数:51,代码来源:File.cpp
示例9: run
void FixKernelParameterCallback::run(
const ast_matchers::MatchFinder::MatchResult& result)
{
auto funcDecl = result.Nodes.getDeclAs<FunctionDecl>("decl");
if (funcDecl) {
// Check if function is an OpenCL kernel
if (!funcDecl->hasAttr<OpenCLKernelAttr>()) { return; }
// search all parameters ...
for ( auto param = funcDecl->param_begin(),
last = funcDecl->param_end();
param != last;
++param ) {
// ... and look for a type ending in _matrix_t
auto fullType = (*param)->getOriginalType().getAsString();
auto pos = fullType.rfind("_matrix_t");
if ( pos != std::string::npos) {
// if found transform this parameter into two and adopt the body
// accordingly
auto dataType = fullType.substr(0, pos);
auto paramName = (*param)->getName().str();
rewriteParameter(*param, dataType, paramName, *result.SourceManager);
adoptBody(funcDecl, fullType, paramName, *result.SourceManager);
}
}
}
}
开发者ID:skelcl,项目名称:skelcl,代码行数:26,代码来源:FixKernelParameterCallback.cpp
示例10: while
String String::strip(Strings tokens) const
{
if(tokens.empty())
tokens.push_back(L" ");
IndexVar left = 0, right = mContent.size();
while(left<mContent.size())
{
bool flag = false;
for(Strings::iterator ptr = tokens.begin(); ptr != tokens.end(); ptr++)
if(find(*ptr,left)==left)
{
flag = true;
break;
}
if(!flag)
break;
left++;
}
while(right>=0)
{
bool flag = false;
for(Strings::iterator ptr = tokens.begin(); ptr != tokens.end(); ptr++)
if(rfind(*ptr,right-1)==right-1)
{
flag = true;
break;
}
if(!flag)
break;
right--;
}
return substr(left,right-left);
}
开发者ID:EtcDot,项目名称:PomeloCpp,代码行数:34,代码来源:String.cpp
示例11: while
CL_StringData8::size_type CL_StringData8::rfind(const char *s, size_type pos) const
{
size_type len = 0;
while (s[len] != 0)
len++;
return rfind(s, pos, len);
}
开发者ID:Boerlam001,项目名称:proton_sdk_source,代码行数:7,代码来源:string_data8.cpp
示例12: rfind
String String::lastToken(char delimiter) {
int pos = rfind(delimiter);
if (pos >= 0) {
return substr(pos + 1);
}
return *this;
}
开发者ID:silvajohnny,项目名称:hiphop-php,代码行数:7,代码来源:type_string.cpp
示例13: py_bind_tensor_types
static void py_bind_tensor_types(const std::vector<PyTensorType>& tensor_types) {
auto torch_module = THPObjectPtr(PyImport_ImportModule("torch"));
if (!torch_module) throw python_error();
auto tensor_classes = THPObjectPtr(PyObject_GetAttrString(torch_module.get(), "_tensor_classes"));
if (!tensor_classes) throw python_error();
for (auto& tensor_type : tensor_types) {
auto name = std::string(tensor_type.name);
auto idx = name.rfind(".");
auto type_name = name.substr(idx + 1);
auto module_name = name.substr(0, idx);
auto module_obj = THPObjectPtr(PyImport_ImportModule(module_name.c_str()));
if (!module_obj) throw python_error();
PyObject* type_obj = (PyObject*)&tensor_type;
Py_INCREF(type_obj);
if (PyModule_AddObject(module_obj.get(), type_name.c_str(), type_obj) < 0) {
throw python_error();
}
if (PySet_Add(tensor_classes.get(), type_obj) < 0) {
throw python_error();
}
}
}
开发者ID:inkawhich,项目名称:pytorch,代码行数:26,代码来源:python_tensor.cpp
示例14: CCASSERT
ParticleSystem* ParticleManager::getEmitter(const std::string& filename) {
auto filepath = FileUtils::getInstance()->fullPathForFilename(filename);
ValueMap dict;
ParticleSystem* emitter;
auto iter = _emitters.find(filepath);
if (iter != _emitters.end()) {
dict = iter->second;
}
else {
dict = FileUtils::getInstance()->getValueMapFromFile(filepath);
_emitters[filepath] = dict;
}
CCASSERT(!dict.empty(), "Particles: file not found");
if (filepath.find('/') != std::string::npos) {
filepath = filepath.substr(0, filepath.rfind('/') + 1);
emitter = ParticleSystemCustom::createWithDictionary(dict, filepath);
}
else {
emitter = ParticleSystemCustom::createWithDictionary(dict, "");
}
return emitter;
}
开发者ID:changbiao,项目名称:cocos2d-x-pong-cpp,代码行数:26,代码来源:ParticleManager.cpp
示例15: rfind
inline bool Eliza::bot_repeat() const {
int pos = rfind(vResponseLog, m_sResponse);
if(pos != -1) {
return (pos + 1 < response_list.size());
}
return 0;
}
开发者ID:ASAP-Project,项目名称:ASAP,代码行数:7,代码来源:Eliza_1.cpp
示例16: rfind
// Retrieve the substring preceding the last occurrence of Str
// (or the whole string if it doesn't contain Str)
CStr CStr::BeforeLast(const CStr& Str, size_t startPos) const
{
size_t pos = rfind(Str, startPos);
if (pos == npos)
return *this;
else
return substr(0, pos);
}
开发者ID:Gallaecio,项目名称:0ad,代码行数:10,代码来源:CStr.cpp
示例17: extension
path path::extension() const
{
auto const filename = this->filename().string();
if ( filename.empty() ) return path{};
auto pos = filename.rfind( "." );
if ( filename.size() == 1 || filename.size() == 2 || pos == std::string::npos ) return path{};
return path{ filename.substr( pos ) };
}
开发者ID:iamOgunyinka,项目名称:tinydircpp,代码行数:8,代码来源:utilities.cpp
示例18: TestShipperEmail
static bool TestShipperEmail(ref<CWarehouseReceipt> const& whr)
{
auto email = whr->GetShipperEmail();
const std::string domain = "@magaya.com";
// return std::equal(rbegin(email), rbegin(email) + domain.size(), rbegin(domain));
return email.rfind(domain) != std::string::npos;
}
开发者ID:knizhnik,项目名称:goods-samples,代码行数:8,代码来源:FillDatabase.cpp
示例19: rfind
//++
// Details: Remove '\n' from the end of string if found. It does not alter
// *this string.
// Type: Method.
// Args: None.
// Return: CMIUtilString - New version of the string.
// Throws: None.
//--
CMIUtilString CMIUtilString::StripCREndOfLine() const {
const size_t nPos = rfind('\n');
if (nPos == std::string::npos)
return *this;
const CMIUtilString strNew(substr(0, nPos));
return strNew;
}
开发者ID:llvm-project,项目名称:lldb,代码行数:17,代码来源:MIUtilString.cpp
示例20: FN
//---------------------------------------------------------------------------
Ztring FileName::Name_Get() const
{
#ifdef ZENLIB_USEWX
wxFileName FN(c_str());
if (FN==FN.GetName()) //Bug of WxWidgets? if C:\\dir\\(no name), name is C:\\dir\\(no name)
return Ztring();
return FN.GetName().c_str();
#else //ZENLIB_USEWX
size_t Pos_Path=rfind(FileName_PathSeparator); //Path limit
if (Pos_Path==Ztring::npos)
Pos_Path=(size_type)-1; //Not found
//Extension limit
size_t Pos_Ext=rfind(_T('.'));
if (Pos_Ext==Ztring::npos || Pos_Ext<Pos_Path)
Pos_Ext=size(); //Not found
return Ztring(*this, Pos_Path+1, Pos_Ext-Pos_Path-1);
#endif //ZENLIB_USEWX
}
开发者ID:asfdfdfd,项目名称:MediaInfoLib-Avdump2-Mac,代码行数:19,代码来源:FileName.cpp
注:本文中的rfind函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论