本文整理汇总了C++中ends_with函数的典型用法代码示例。如果您正苦于以下问题:C++ ends_with函数的具体用法?C++ ends_with怎么用?C++ ends_with使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ends_with函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: all_c_code
static int all_c_code(const char * f){
if(is_dir(f) && !starts_with(f,".")){ return 1; }
if(starts_with(f, "_")){ return 0; } //TODO fixme
if(ends_with(f, ".h") || ends_with(f, ".c")){
return 1;
}
return 0;
};
开发者ID:bjarneh,项目名称:organice,代码行数:12,代码来源:dag.c
示例2: if
TokenMap* TokenMap::from_partitioner(StringRef partitioner) {
if (ends_with(partitioner, Murmur3Partitioner::name())) {
return new TokenMapImpl<Murmur3Partitioner>();
} else if (ends_with(partitioner, RandomPartitioner::name())) {
return new TokenMapImpl<RandomPartitioner>();
} else if (ends_with(partitioner, ByteOrderedPartitioner::name())) {
return new TokenMapImpl<ByteOrderedPartitioner>();
} else {
LOG_WARN("Unsupported partitioner class '%s'", partitioner.to_string().c_str());
return NULL;
}
}
开发者ID:PlexChat,项目名称:cpp-driver,代码行数:12,代码来源:token_map.cpp
示例3: fqd_http_mime_type
static const char *
fqd_http_mime_type(const char *url) {
if(ends_with(url, ".js")) return "text/javascript";
if(ends_with(url, ".json")) return "application/json";
if(ends_with(url, ".css")) return "text/css";
if(ends_with(url, ".jpg") || ends_with(url, ".jpeg")) return "image/jpeg";
if(ends_with(url, ".gif")) return "image/gif";
if(ends_with(url, ".png")) return "image/png";
if(ends_with(url, "/") || ends_with(url, ".html") || ends_with(url, ".htm"))
return "text/html";
return "application/octet-stream";
}
开发者ID:HeinrichHartmann,项目名称:fq,代码行数:12,代码来源:fqd_http.c
示例4: outfile
bool MeshModel::saveToFile(const std::string filename) const
{
std::ofstream outfile(filename);
if (outfile.bad())
return false;
if (ends_with(filename, "off") || ends_with(filename, "OFF"))
return saveOFF(outfile);
else if (ends_with(filename, "obj") || ends_with(filename, "OBJ"))
return saveOBJ(outfile);
return false;
}
开发者ID:maximlevitsky,项目名称:animations-editor-bdmorph,代码行数:14,代码来源:MeshModel.cpp
示例5: step1a
static void
step1a(wchar_t *word) {
int len;
len = wcslen(word);
if(ends_with(word, L"SSES")) {
word[len-2] = '\0';
} else if(ends_with(word, L"IES")) {
word[len-2] = '\0';
} else if(!ends_with(word, L"SS") && ends_with(word, L"S")) {
word[len-1] = '\0';
}
}
开发者ID:munnellg,项目名称:ir_system,代码行数:14,代码来源:stem.c
示例6: NetworkTopologyStrategy
SharedRefPtr<ReplicationStrategy> ReplicationStrategy::from_keyspace_meta(const KeyspaceMetadata& ks_meta) {
std::string strategy_class = ks_meta.strategy_class();
SharedRefPtr<ReplicationStrategy> strategy;
if (ends_with(strategy_class, NetworkTopologyStrategy::STRATEGY_CLASS)) {
return SharedRefPtr<ReplicationStrategy>(
new NetworkTopologyStrategy(strategy_class, ks_meta.strategy_options()));
} else if (ends_with(strategy_class, SimpleStrategy::STRATEGY_CLASS)) {
return SharedRefPtr<ReplicationStrategy>(
new SimpleStrategy(strategy_class, ks_meta.strategy_options()));
} else {
return SharedRefPtr<ReplicationStrategy>(new NonReplicatedStrategy(strategy_class));
}
}
开发者ID:Ilceren,项目名称:cpp-driver,代码行数:14,代码来源:replication_strategy.cpp
示例7: GetImageMetadata
int64_t
GetImageMetadata(const char *path, char *name)
{
if (ends_with (path, ".jpg") || ends_with (path, ".jpeg"))
{
return _get_jpeg_metadata (path, name);
}
else if (ends_with (path, ".png"))
{
return _get_png_metadata (path, name);
}
else
return 0;
}
开发者ID:MelissaJS,项目名称:minidlna,代码行数:14,代码来源:metadata.c
示例8:
size_t Environment<T>::print(std::string prefix)
{
size_t indent = 0;
if (parent_) indent = parent_->print(prefix) + 1;
std::cerr << prefix << std::string(indent, ' ') << "== " << this << std::endl;
for (typename std::map<std::string, T>::iterator i = local_frame_.begin(); i != local_frame_.end(); ++i) {
if (!ends_with(i->first, "[f]") && !ends_with(i->first, "[f]4") && !ends_with(i->first, "[f]2")) {
std::cerr << prefix << std::string(indent, ' ') << i->first << " " << i->second;
if (Value* val = dynamic_cast<Value*>(i->second))
{ std::cerr << " : " << val->to_string(); }
std::cerr << std::endl;
}
}
return indent ;
}
开发者ID:0065paula,项目名称:green-seeds,代码行数:15,代码来源:environment.cpp
示例9: get_j4a_loader_file
inline std::string get_j4a_loader_file(const std::string& value)
{
if (ends_with(value, ".c")) {
std::string result(value, 0, value.length() - 2);
return result + ".loader.j4a";
} else if (ends_with(value, ".cpp")) {
std::string result(value, 0, value.length() - 4);
return result + ".loader.j4a";
} else if (ends_with(value, ".java")) {
std::string result(value, 0, value.length() - 5);
return result + ".loader.j4a";
}
return value + ".loader.j4a";
}
开发者ID:Jabervan,项目名称:jni4android,代码行数:15,代码来源:main.cpp
示例10: step5
static void
step5(wchar_t *word) {
int len;
len = wcslen(word);
if(ends_with(word, L"E") && compute_measure(word, len-1) > 1) {
word[len-1] = '\0';
} else if(ends_with(word, L"E") && compute_measure(word, len-1) == 1 && !ends_consonant_vowel_consonant(word, len-1)) {
word[len-1] = '\0';
}
if(ends_with(word, L"L") && compute_measure(word, len) > 1 && ends_double_consonant(word, len)) {
word[len-1] = '\0';
}
}
开发者ID:munnellg,项目名称:ir_system,代码行数:15,代码来源:stem.c
示例11: selectionModel
void DirectoryTree::import_from_files()
{
QModelIndexList ids = selectionModel()->selectedIndexes();
if (ids.size() == 0)
return;
QModelIndex index = ids.at(0);
if (!index.isValid())
return;
// 弹出对话框
QStringList files = QFileDialog::getOpenFileNames(this,
tr("打开文件"),
QString::fromLocal8Bit(_last_visited_dir.data(), _last_visited_dir.length()),
"Text file (*.txt)");
const size_t size = files.size();
if (size == 0)
return;
DirectoryTreeModel *m = dynamic_cast<DirectoryTreeModel*>(model());
assert(NULL != m);
for (size_t i = 0; i < size; ++i)
{
const QString& file = files.at(i);
// get title
string dir, name;
Path::split(file.toLocal8Bit(), &dir, &name);
if (!ends_with(name.c_str(), ".txt") && !ends_with(name.c_str(), ".TXT"))
continue;
string title;
Path::split_ext(name.c_str(), &title, NULL);
_last_visited_dir = dir;
// get content
QString all = read_text_file(file);
all = convert_txt_to_html(all);
// insert to db
m->insert_article(index, QString::fromLocal8Bit(title.data(), title.length()),
MIME_PKM_RICHTEXT, all);
}
// 发送通知
DirectoryItem *p = static_cast<DirectoryItem*>(index.internalPointer());
assert(NULL != p);
PkmPlugin *plugin = dynamic_cast<PkmPlugin*>(get_plugin().pointer());
plugin->directory_activated(p->get_id(), p->get_name());
}
开发者ID:jingqi,项目名称:organic,代码行数:48,代码来源:directory_tree.cpp
示例12: while
vector<string> *Sound::get_wav_filenames()
{
vector<string> *wav_filenames = new vector<string>;
struct dirent *dirent;
DIR *dir;
if (base_sound_directory.empty())
{
error->log(SOUND, IMPORTANT, "No sound directory specified\n");
return NULL;
}
if ((dir = opendir(base_sound_directory.c_str())) == NULL)
{
error->log(SOUND, CRITICAL, "Can't open " + base_sound_directory + "\n");
return NULL;
}
while ((dirent = readdir(dir)))
{
if (ends_with(dirent->d_name, ".wav"))
{
wav_filenames->push_back(dirent->d_name);
}
}
if (closedir(dir) != 0)
{
error->log(SOUND, CRITICAL, "Trouble closing " + base_sound_directory + "\n");
return NULL;
}
return wav_filenames;
}
开发者ID:amitahire,项目名称:z-fight-club,代码行数:30,代码来源:sound.cpp
示例13: is_source_file
bool is_source_file(const std::string& filename, std::string &fixed_file_name)
{
StringVec_t extensions;
extensions.push_back(".cpp");
extensions.push_back(".cxx");
extensions.push_back(".cc");
extensions.push_back(".c");
for(size_t n=0; n<extensions.size(); ++n) {
if ( ends_with(filename, extensions.at(n)) ) {
fixed_file_name = filename;
#ifdef _WIN32
std::replace(fixed_file_name.begin(), fixed_file_name.end(), '/', '\\');
#endif
char* ret = normalize_path(fixed_file_name.c_str(), fixed_file_name.length());
fixed_file_name = ret;
free(ret);
// rtrim
fixed_file_name.erase(0, fixed_file_name.find_first_not_of("\t\r\v\n\" "));
// ltrim
fixed_file_name.erase(fixed_file_name.find_last_not_of("\t\r\v\n\" ")+1);
return true;
}
}
fixed_file_name.clear();
return false;
}
开发者ID:eranif,项目名称:codelite,代码行数:30,代码来源:main.cpp
示例14: validate_tags
/* Validates list of tags. Returns zero if tags are well-formed and non-zero
* otherwise. */
static int
validate_tags(const char tags[])
{
return tags[0] == '\0'
|| starts_with_lit(tags, ",") || strstr(tags, ",,") != NULL
|| ends_with(tags, ",");
}
开发者ID:acklinr,项目名称:vifm,代码行数:9,代码来源:bmarks.c
示例15: is_executable
static int is_executable(const char *name)
{
struct stat st;
if (stat(name, &st) || /* stat, not lstat */
!S_ISREG(st.st_mode))
return 0;
#if defined(GIT_WINDOWS_NATIVE)
/* On Windows we cannot use the executable bit. The executable
* state is determined by extension only. We do this first
* because with virus scanners opening an executeable for
* reading is potentially expensive.
*/
if (ends_with(name, ".exe"))
return S_IXUSR;
{ /* now that we know it does not have an executable extension,
peek into the file instead */
char buf[3] = { 0 };
int n;
int fd = open(name, O_RDONLY);
st.st_mode &= ~S_IXUSR;
if (fd >= 0) {
n = read(fd, buf, 2);
if (n == 2)
/* look for a she-bang */
if (!strcmp(buf, "#!"))
st.st_mode |= S_IXUSR;
close(fd);
}
}
#endif
return st.st_mode & S_IXUSR;
}
开发者ID:CSRedRat,项目名称:git,代码行数:35,代码来源:help.c
示例16: extract_outfile_gen
static FILE *
extract_outfile_gen(char **outname_ptr, int w, int h, int bc, int i)
{
char *inname = *outname_ptr;
if (output == NULL || is_directory(output)) {
StrBuf *outname;
char *inbase;
outname = strbuf_new();
if (output != NULL) {
strbuf_append(outname, output);
if (!ends_with(output, "/"))
strbuf_append(outname, "/");
}
inbase = strrchr(inname, '/');
inbase = (inbase == NULL ? inname : inbase+1);
if (ends_with_nocase(inbase, ".ico") || ends_with_nocase(inbase, ".cur")) {
strbuf_append_substring(outname, inbase, 0, strlen(inbase)-4);
} else {
strbuf_append(outname, inbase);
}
strbuf_appendf(outname, "_%d_%dx%dx%d.png", i, w, h, bc);
*outname_ptr = strbuf_free_to_string(outname);
return fopen(*outname_ptr, "wb");
}
else if (strcmp(output, "-") == 0) {
*outname_ptr = xstrdup(_("(standard out)"));
return stdout;
}
*outname_ptr = xstrdup(output);
return fopen(output, "wb");
}
开发者ID:Lampus,项目名称:icoutils,代码行数:34,代码来源:main.c
示例17: get_deps_from_app_binary
/**
* Given path to app binary, say app.dll or app.exe, retrieve the app.deps.json.
*/
pal::string_t get_deps_from_app_binary(const pal::string_t& app)
{
assert(app.find(DIR_SEPARATOR) != pal::string_t::npos);
assert(ends_with(app, _X(".dll"), false) || ends_with(app, _X(".exe"), false));
// First append directory.
pal::string_t deps_file;
deps_file.assign(get_directory(app));
deps_file.push_back(DIR_SEPARATOR);
// Then the app name and the file extension
pal::string_t app_name = get_filename(app);
deps_file.append(app_name, 0, app_name.find_last_of(_X(".")));
deps_file.append(_X(".deps.json"));
return deps_file;
}
开发者ID:brthor,项目名称:core-setup,代码行数:19,代码来源:fx_muxer.cpp
示例18: iends_with
inline bool iends_with(
const Range1T& Input,
const Range2T& Test,
const std::locale& Loc=std::locale())
{
return ends_with(Input, Test, is_iequal(Loc));
}
开发者ID:GDXN,项目名称:fitsliberator,代码行数:7,代码来源:predicate.hpp
示例19: get_midi_files
/**
* Get the list of midi files directly in the given directory
* return a vector of file names
* note: we don't check if they are valid MIDI files, only if the
* MIDI extension is here
*/
static std::vector<std::string> get_midi_files(const std::string& path) {
const std::string MIDI_EXTENSION(".mid");
std::vector<std::string> midiFileNames;
tinydir_dir midiDir;
tinydir_open_sorted(&midiDir, path.c_str());
for (unsigned i = 0; i < midiDir.n_files; i++) {
tinydir_file file;
tinydir_readfile_n(&midiDir, &file, i);
if (file.is_dir) {
continue;
}
std::string tmpFileName(file.name);
std::cout << tmpFileName << std::endl;
if (!ends_with(tmpFileName, MIDI_EXTENSION)) {
continue ;
}
std::cout << tmpFileName << std::endl;
midiFileNames.push_back(tmpFileName);
}
tinydir_close(&midiDir);
return midiFileNames;
}
开发者ID:EQ4,项目名称:linthesia,代码行数:34,代码来源:file_select_screen.cpp
示例20: cat_files
/**
* Concatenate two file names into a new string.
* If file is "." return a duplicate of file2.
*/
char *
cat_files(const char *file, const char *file2)
{
if (strcmp(file, ".") == 0)
return xstrdup(file2);
return xasprintf("%s%s%s", file, (ends_with(file, "/") ? "" : "/"), file2);
}
开发者ID:GregBowyer,项目名称:regex-markup,代码行数:11,代码来源:string-utils.c
注:本文中的ends_with函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论