当前位置: 首页>>代码示例>>C++>>正文


C++ ends_with函数代码示例

本文整理汇总了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;
};
开发者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


注:本文中的ends_with函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。