本文整理汇总了C++中rfind函数的典型用法代码示例。如果您正苦于以下问题:C++ rfind函数的具体用法?C++ rfind怎么用?C++ rfind使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rfind函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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];
}
}
示例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);
}
示例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;
}
示例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);
}
示例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();
}
示例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" )
);
}
示例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;
}
示例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);
}
}
}
}
示例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);
}
示例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);
}
示例12: rfind
String String::lastToken(char delimiter) {
int pos = rfind(delimiter);
if (pos >= 0) {
return substr(pos + 1);
}
return *this;
}
示例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();
}
}
}
示例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;
}
示例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;
}