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


C++ docstring::substr方法代码示例

本文整理汇总了C++中docstring::substr方法的典型用法代码示例。如果您正苦于以下问题:C++ docstring::substr方法的具体用法?C++ docstring::substr怎么用?C++ docstring::substr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在docstring的用法示例。


在下文中一共展示了docstring::substr方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: path_prefix_is

bool path_prefix_is(string & path, string const & pre, path_case how)
{
#ifdef __APPLE__
	docstring const p1 = from_utf8(path);
	docstring const p2 = from_utf8(pre);
	docstring::size_type const p1_len = p1.length();
	docstring::size_type const p2_len = p2.length();
	docstring::size_type common_len = common_path(p1, p2);

	if (p2[p2_len - 1] == '/' && p1_len != p2_len)
		++common_len;

	if (common_len != p2_len)
		return false;

	if (how == CASE_ADJUSTED && !prefixIs(path, pre)) {
		if (p1_len < common_len)
			path = to_utf8(p2.substr(0, p1_len));
		else
			path = to_utf8(p2 + p1.substr(common_len,
							p1_len - common_len));
	}

	return true;
#else
	// silence compiler warnings
	(void)how;

	return prefixIs(path, pre);
#endif
}
开发者ID:bsjung,项目名称:Lyx,代码行数:31,代码来源:os_unix.cpp

示例2: add

bool BranchList::add(docstring const & s)
{
	bool added = false;
	size_t i = 0;
	while (true) {
		size_t const j = s.find_first_of(separator_, i);
		docstring name;
		if (j == docstring::npos)
			name = s.substr(i);
		else
			name = s.substr(i, j - i);
		// Is this name already in the list?
		bool const already =
			find_if(list.begin(), list.end(),
				     BranchNamesEqual(name)) != list.end();
		if (!already) {
			added = true;
			Branch br;
			br.setBranch(name);
			br.setSelected(false);
			br.setFileNameSuffix(false);
			list.push_back(br);
		}
		if (j == docstring::npos)
			break;
		i = j + 1;
	}
	return added;
}
开发者ID:cburschka,项目名称:lyx,代码行数:29,代码来源:BranchList.cpp

示例3: signedWidth

int GuiFontMetrics::signedWidth(docstring const & s) const
{
	if (s.empty())
		return 0;

	if (s[0] == '-')
		return -width(s.substr(1, s.size() - 1));
	else
		return width(s);
}
开发者ID:bsjung,项目名称:Lyx,代码行数:10,代码来源:GuiFontMetrics.cpp

示例4: add

bool IndicesList::add(docstring const & n, docstring const & s)
{
	bool added = false;
	size_t i = 0;
	while (true) {
		size_t const j = n.find_first_of(separator_, i);
		docstring name;
		if (j == docstring::npos)
			name = n.substr(i);
		else
			name = n.substr(i, j - i);
		// Is this name already in the list?
		bool const already =
			find_if(list.begin(), list.end(),
				     IndexNamesEqual(name)) != list.end();
		if (!already) {
			added = true;
			Index in;
			in.setIndex(name);
			docstring sc = s.empty() ?
				trim(lowercase(name.substr(0, 3))) : s;
			if (findShortcut(sc) != 0) {
				int i = 1;
				docstring scn = sc + convert<docstring>(i);
				while (findShortcut(scn) != 0) {
					++i;
					scn = sc + convert<docstring>(i);
				}
				in.setShortcut(scn);
			} else
				in.setShortcut(sc);
			list.push_back(in);
		}
		if (j == docstring::npos)
			break;
		i = j + 1;
	}
	return added;
}
开发者ID:rpavlik,项目名称:lyx-lucid-backport,代码行数:39,代码来源:IndicesList.cpp


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