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