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


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

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


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

示例1: escapeString

docstring sgml::escapeString(docstring const & raw)
{
	docstring bin;
	bin.reserve(raw.size() * 2); // crude approximation is sufficient
	for (size_t i = 0; i != raw.size(); ++i)
		bin += sgml::escapeChar(raw[i]);

	return bin;
}
开发者ID:315234,项目名称:lyx-retina,代码行数:9,代码来源:sgml.cpp

示例2: plaintext

int InsetRef::plaintext(odocstringstream & os,
        OutputParams const &, size_t) const
{
	docstring const str = getParam("reference");
	os << '[' << str << ']';
	return 2 + str.size();
}
开发者ID:hashinisenaratne,项目名称:HSTML,代码行数:7,代码来源:InsetRef.cpp

示例3: plaintext

int InsetCommand::plaintext(odocstream & os, OutputParams const &) const
{
	docstring const str = "[" + buffer().B_("LaTeX Command: ")
		+ from_utf8(getCmdName()) + "]";
	os << str;
	return str.size();
}
开发者ID:rpavlik,项目名称:lyx-lucid-backport,代码行数:7,代码来源:InsetCommand.cpp

示例4: 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

示例5: convertDelimToLatexName

static docstring convertDelimToLatexName(docstring const & name)
{
	if (name.size() == 1) {
		char_type const c = name[0];
		if (c == '<' || c == '(' || c == '[' || c == '.'
		    || c == '>' || c == ')' || c == ']' || c == '/' || c == '|')
			return name;
	}
	return '\\' + name + ' ';
}
开发者ID:315234,项目名称:lyx-retina,代码行数:10,代码来源:InsetMathDelim.cpp

示例6: plaintext

int InsetFormulaMacro::plaintext(odocstream & os, OutputParams const & runparams) const
{
	odocstringstream oss;
	WriteStream wi(oss, false, true, WriteStream::wsDefault, runparams.encoding);
	tmpl()->write(wi);

	docstring const str = oss.str();
	os << str;
	return str.size();
}
开发者ID:djmitche,项目名称:lyx,代码行数:10,代码来源:InsetFormulaMacro.cpp

示例7: plaintext

int InsetCitation::plaintext(odocstringstream & os,
       OutputParams const &, size_t) const
{
	string const & cmd = getCmdName();
	if (cmd == "nocite")
		return 0;

	docstring const label = generateLabel(false);
	os << label;
	return label.size();
}
开发者ID:315234,项目名称:lyx-retina,代码行数:11,代码来源:InsetCitation.cpp

示例8: plaintext

int InsetHyperlink::plaintext(odocstream & os, OutputParams const &) const
{
	odocstringstream oss;

	oss << '[' << getParam("target");
	if (getParam("name").empty())
		oss << ']';
	else
		oss << "||" << getParam("name") << ']';

	docstring const str = oss.str();
	os << str;
	return str.size();
}
开发者ID:JoaquimBellmunt,项目名称:lyx,代码行数:14,代码来源:InsetHyperlink.cpp

示例9: getFormattedCmd

// the ref argument is the label name we are referencing.
// we expect ref to be in the form: pfx:suffix.
//
// if it isn't, then we can't produce a formatted reference, 
// so we return "\ref" and put ref into label.
//
// for refstyle, we return "\pfxcmd", and put suffix into 
// label and pfx into prefix. this is because refstyle expects
// the command: \pfxcmd{suffix}.
// 
// for prettyref, we return "\prettyref" and put ref into label
// and pfx into prefix. this is because prettyref uses the whole
// label, thus: \prettyref{pfx:suffix}.
//
docstring InsetRef::getFormattedCmd(docstring const & ref, 
	docstring & label, docstring & prefix) const
{
	static docstring const defcmd = from_ascii("\\ref");
	static docstring const prtcmd = from_ascii("\\prettyref");
	
	label = split(ref, prefix, ':');

	// we have to have xxx:xxxxx...
	if (label.empty()) {
		LYXERR0("Label `" << ref << "' contains no prefix.");
		label = ref;
		prefix = from_ascii("");
		return defcmd;
	}

	if (prefix.empty()) {
		// we have ":xxxx"
		label = ref;
		return defcmd;
	}
	
	if (!buffer().params().use_refstyle) {
		// \prettyref uses the whole label
		label = ref;
		return prtcmd;
	}

	// make sure the prefix is legal for a latex command
	int const len = prefix.size();
	for (int i = 0; i < len; i++) {
		char_type const c = prefix[i];
		if (!isAlphaASCII(c)) {
			LYXERR0("Prefix `" << prefix << "' is invalid for LaTeX.");
			// restore the label
			label = ref;
			return defcmd;
		}
	}
	return from_ascii("\\") + prefix + from_ascii("ref");
}
开发者ID:hashinisenaratne,项目名称:HSTML,代码行数:55,代码来源:InsetRef.cpp

示例10: width

int GuiFontMetrics::width(docstring const & s) const
{
	size_t ls = s.size();
	int w = 0;
	for (unsigned int i = 0; i < ls; ++i) {
		//FIXME: we need to detect surrogate pairs and act accordingly
		/**
		if isSurrogateBase(s[i]) {
			docstring c = s[i];
			if (smallcaps_shape_)
				w += metrics_.width(toqstr(c + s[i + 1]));
			else
				w += smallcaps_metrics_.width(toqstr(c + s[i + 1]));
			++i;
		}
		else
		*/
		w += width(s[i]);
	}

	return w;
}
开发者ID:bsjung,项目名称:Lyx,代码行数:22,代码来源:GuiFontMetrics.cpp

示例11: writeLaTeX

void PDFOptions::writeLaTeX(OutputParams & runparams, otexstream & os,
			    bool hyperref_already_provided) const
{
	// FIXME Unicode
	string opt;
	string hyperset;
	
	// since LyX uses unicode, also set the PDF strings to unicode strings with the
	// hyperref option "unicode"
	opt += "unicode=true,";

	// only use the hyperref settings if hyperref is enabled by the user
	// see bug #7052
	if (use_hyperref) {
		// try to extract author and title from document when none is
		// explicitly given
		if (pdfusetitle && title.empty() && author.empty())
			opt += "pdfusetitle,";
		opt += "\n ";
		opt += "bookmarks=" + convert<string>(bookmarks) + ',';
		if (bookmarks) {
			opt += "bookmarksnumbered=" + convert<string>(bookmarksnumbered) + ',';
			opt += "bookmarksopen=" + convert<string>(bookmarksopen) + ',';
			if (bookmarksopen)
				opt += "bookmarksopenlevel="
				+ convert<string>(bookmarksopenlevel) + ',';
		}
		opt += "\n ";
		opt += "breaklinks=" + convert<string>(breaklinks) + ',';
		opt += "pdfborder={0 0 ";
		opt += (pdfborder ? '0' : '1');
		opt += "},";
		opt += "backref=" + backref + ',';
		opt += "colorlinks=" + convert<string>(colorlinks) + ',';
		if (!pagemode.empty())
			opt += "pdfpagemode=" + pagemode + ',';

		// load the pdftitle etc. as hypersetup, otherwise you'll get
		// LaTeX-errors when using non-latin characters
		if (!title.empty())
			hyperset += "pdftitle={" + title + "},";
		if (!author.empty())			
			hyperset += "\n pdfauthor={" + author + "},";
		if (!subject.empty())
			hyperset += "\n pdfsubject={" + subject + "},";
		if (!keywords.empty())
			hyperset += "\n pdfkeywords={" + keywords + "},";
		if (!quoted_options.empty()){
			hyperset += "\n ";
			hyperset += quoted_options;
		}
		hyperset = rtrim(hyperset,",");
	}

	// check if the hyperref settings use an encoding that exceeds
	// ours. If so, we have to switch to utf8.
	Encoding const * const enc = runparams.encoding;
	docstring const hs = from_utf8(hyperset);
	bool need_unicode = false;
	if (enc) {
		for (size_t n = 0; n < hs.size(); ++n) {
			if (!enc->encodable(hs[n]))
				need_unicode = true;
		}
	}

	// use in \\usepackage parameter as not all options can be handled inside \\hypersetup
	if (!hyperref_already_provided) {
		opt = rtrim(opt, ",");
		opt = "\\usepackage[" + opt + "]\n {hyperref}\n";

		if (!hyperset.empty())
			opt += "\\hypersetup{" + hyperset + "}\n";
	} else {
		// only in case hyperref is already loaded by the current text class
		// try to put it into hyperset
		//
		// FIXME: rename in this case the PDF settings dialog checkbox
		//  label from "Use Hyperref" to "Customize Hyperref Settings"
		//  as discussd in bug #6293
		opt = "\\hypersetup{" + rtrim(opt + hyperset, ",") + "}\n";
	}

	// hyperref expects utf8!
	if (need_unicode && enc && enc->iconvName() != "UTF-8"
	    &&!runparams.isFullUnicode()) {
		os << "\\inputencoding{utf8}\n"
		   << setEncoding("UTF-8");
	}
	// If hyperref is loaded by the document class, we output
	// \hypersetup \AtBeginDocument if hypersetup is not (yet)
	// defined. In this case, the class loads hyperref late
	// (see bug #7048).
	if (hyperref_already_provided && !opt.empty()) {
		os << "\\ifx\\hypersetup\\undefined\n"
		   << "  \\AtBeginDocument{%\n    "
		   << from_utf8(opt)
		   << "  }\n"
		   << "\\else\n  "
		   << from_utf8(opt)
//.........这里部分代码省略.........
开发者ID:JoaquimBellmunt,项目名称:lyx,代码行数:101,代码来源:PDFOptions.cpp

示例12: writeLaTeX

int PDFOptions::writeLaTeX(OutputParams & runparams, odocstream & os,
			    bool hyperref_already_provided) const
{
	int lines = 0;
	// FIXME Unicode
	string opt;
	
	// since LyX uses unicode, also set the PDF strings to unicode strings with the
	// hyperref option "unicode"
	opt += "unicode=true, ";
	
	// try to extract author and title from document when none is
	// explicitly given
	if (pdfusetitle && title.empty() && author.empty())
		opt += "pdfusetitle,";
	opt += "\n ";

	opt += "bookmarks=" + convert<string>(bookmarks) + ',';
	if (bookmarks) {
		opt += "bookmarksnumbered=" + convert<string>(bookmarksnumbered) + ',';
		opt += "bookmarksopen=" + convert<string>(bookmarksopen) + ',';
		if (bookmarksopen)
			opt += "bookmarksopenlevel="
			    + convert<string>(bookmarksopenlevel) + ',';
	}
	opt += "\n ";
	opt += "breaklinks=" + convert<string>(breaklinks) + ',';

	opt += "pdfborder={0 0 ";
	opt += (pdfborder ? '0' : '1');
	opt += "},";

	opt += "backref=" + backref + ',';
	opt += "colorlinks=" + convert<string>(colorlinks) + ',';
	if (!pagemode.empty())
		opt += "pdfpagemode=" + pagemode + ',';
	


	// load the pdftitle etc. as hypersetup, otherwise you'll get
	// LaTeX-errors when using non-latin characters
	string hyperset;
	if (!title.empty())
		hyperset += "pdftitle={" + title + "},";
	if (!author.empty())
		hyperset += "\n pdfauthor={" + author + "},";
	if (!subject.empty())
		hyperset += "\n pdfsubject={" + subject + "},";
	if (!keywords.empty())
		hyperset += "\n pdfkeywords={" + keywords + "},";
	if (!quoted_options.empty()){
		hyperset += "\n ";
		hyperset += quoted_options;
	}
	hyperset = rtrim(hyperset,",");

	// check if the hyperref settings use an encoding that exceeds
	// ours. If so, we have to switch to utf8.
	Encoding const * const enc = runparams.encoding;
	docstring const hs = from_utf8(hyperset);
	bool need_unicode = false;
	if (enc) {
		for (size_t n = 0; n < hs.size(); ++n) {
			if (enc->latexChar(hs[n], true) != docstring(1, hs[n]))
				need_unicode = true;
		}
	}

	// use in \\usepackage parameter as not all options can be handled inside \\hypersetup
	if (!hyperref_already_provided) {
		opt = rtrim(opt, ",");
		opt = "\\usepackage[" + opt + "]\n {hyperref}\n";

		if (!hyperset.empty())
			opt += "\\hypersetup{" + hyperset + "}\n";
	} else
		// only in case hyperref is already loaded by the current text class
		// try to put it into hyperset
		//
		// FIXME: this still does not fix the cases where hyperref is loaded
		//        and the option is active only when part of usepackage parameter
		//        (e.g. pdfusetitle).
		{
			opt = "\\hypersetup{" + opt + hyperset + "}\n";
		}

	lines = int(count(opt.begin(), opt.end(), '\n'));

	// hyperref expects utf8!
	if (need_unicode && enc && enc->iconvName() != "UTF-8") {
		os << "\\inputencoding{utf8}\n"
		   << setEncoding("UTF-8");
		++lines;
	}
	os << from_utf8(opt);
	if (need_unicode && enc && enc->iconvName() != "UTF-8") {
		os << setEncoding(enc->iconvName())
		   << "\\inputencoding{" << from_ascii(enc->latexName()) << "}\n";
		++lines;
	}
//.........这里部分代码省略.........
开发者ID:bsjung,项目名称:Lyx,代码行数:101,代码来源:PDFOptions.cpp

示例13: cleanID

docstring sgml::cleanID(Buffer const & buf, OutputParams const & runparams,
	docstring const & orig)
{
	// The standard DocBook SGML declaration only allows letters,
	// digits, '-' and '.' in a name.
	// Since users might change that declaration one has to cater
	// for additional allowed characters.
	// This routine replaces illegal characters by '-' or '.'
	// and adds a number for uniqueness.
	// If you know what you are doing, you can set allowed==""
	// to disable this mangling.
	DocumentClass const & tclass = buf.params().documentClass();
	docstring const allowed = from_ascii(
		runparams.flavor == OutputParams::XML ? ".-_:" : tclass.options());

	if (allowed.empty())
		return orig;

	docstring::const_iterator it  = orig.begin();
	docstring::const_iterator end = orig.end();

	docstring content;

	// FIXME THREAD
	typedef map<docstring, docstring> MangledMap;
	static MangledMap mangledNames;
	static int mangleID = 1;

	MangledMap::const_iterator const known = mangledNames.find(orig);
	if (known != mangledNames.end())
		return known->second;

	// make sure it starts with a letter
	if (!isAlphaASCII(*it) && allowed.find(*it) >= allowed.size())
		content += "x";

	bool mangle = false;
	for (; it != end; ++it) {
		char_type c = *it;
		if (isAlphaASCII(c) || isDigitASCII(c) || c == '-' || c == '.'
		      || allowed.find(c) < allowed.size())
			content += c;
		else if (c == '_' || c == ' ') {
			mangle = true;
			content += "-";
		}
		else if (c == ':' || c == ',' || c == ';' || c == '!') {
			mangle = true;
			content += ".";
		}
		else {
			mangle = true;
		}
	}

	if (mangle)
		content += "-" + convert<docstring>(mangleID++);
	else if (isDigitASCII(content[content.size() - 1]))
		content += ".";

	mangledNames[orig] = content;

	return content;
}
开发者ID:315234,项目名称:lyx-retina,代码行数:64,代码来源:sgml.cpp

示例14: string

string const to_utf8(docstring const & ucs4)
{
	vector<char> const utf8 = ucs4_to_utf8(ucs4.data(), ucs4.size());
	return string(utf8.begin(), utf8.end());
}
开发者ID:djmitche,项目名称:lyx,代码行数:5,代码来源:docstring.cpp


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