本文整理汇总了C++中TokenPtr::get方法的典型用法代码示例。如果您正苦于以下问题:C++ TokenPtr::get方法的具体用法?C++ TokenPtr::get怎么用?C++ TokenPtr::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TokenPtr
的用法示例。
在下文中一共展示了TokenPtr::get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _processBlocksItems
void Document::_processBlocksItems(TokenPtr inTokenContainer) {
if (!inTokenContainer->isContainer()) return;
token::Container *tokens=dynamic_cast<token::Container*>(inTokenContainer.get());
assert(tokens!=0);
TokenGroup processed;
for (TokenGroup::const_iterator ii=tokens->subTokens().begin(),
iie=tokens->subTokens().end(); ii!=iie; ++ii)
{
if ((*ii)->text()) {
optional<TokenPtr> subitem;
if (!subitem) subitem=parseHeader(ii, iie);
if (!subitem) subitem=parseHorizontalRule(ii, iie);
if (!subitem) subitem=parseListBlock(ii, iie);
if (!subitem) subitem=parseBlockQuote(ii, iie);
if (!subitem) subitem=parseCodeBlock(ii, iie);
if (subitem) {
_processBlocksItems(*subitem);
processed.push_back(*subitem);
if (ii==iie) break;
continue;
} else processed.push_back(*ii);
} else if ((*ii)->isContainer()) {
_processBlocksItems(*ii);
processed.push_back(*ii);
}
}
tokens->swapSubtokens(processed);
}
示例2: yield_if
void PageTemplate::yield_if(const ArgumentList& arguments, const ArrayArgument::Item* arrayItem, const TokenPtr& token, std::string& result) const
{
const IfToken* iftoken = static_cast<const IfToken*>(token.get());
const std::string& value = get_variable(arguments, arrayItem, iftoken->data);
if (value.empty())
yield_tokens(arguments, arrayItem, iftoken->if_false, result);
else
yield_tokens(arguments, arrayItem, iftoken->if_true, result);
}
示例3: yield_foreach
void PageTemplate::yield_foreach(const ArgumentList& arguments, const TokenPtr& token, std::string& result) const
{
const ForeachToken* ftoken = static_cast<const ForeachToken*>(token.get());
ArgumentList::const_iterator i = arguments.find(ftoken->data);
if (i == arguments.end() || !i->second->is_array())
return;
const ArrayArgument* array = static_cast<const ArrayArgument*>(i->second.get());
for (std::size_t i = 0, n = array->size(); i < n; i++)
{
if (i > 0)
yield_tokens(arguments, 0, ftoken->sep, result);
yield_tokens(arguments, &array->get(i), ftoken->body, result);
}
}
示例4: _processParagraphLines
void Document::_processParagraphLines(TokenPtr inTokenContainer) {
token::Container *tokens=dynamic_cast<token::Container*>(inTokenContainer.get());
assert(tokens!=0);
bool noPara=tokens->inhibitParagraphs();
for (TokenGroup::const_iterator ii=tokens->subTokens().begin(),
iie=tokens->subTokens().end(); ii!=iie; ++ii)
if ((*ii)->isContainer()) _processParagraphLines(*ii);
TokenGroup processed;
std::string paragraphText;
TokenGroup paragraphTokens;
for (TokenGroup::const_iterator ii=tokens->subTokens().begin(),
iie=tokens->subTokens().end(); ii!=iie; ++ii)
{
if ((*ii)->text() && (*ii)->canContainMarkup() && !(*ii)->inhibitParagraphs()) {
static const boost::regex cExpression("^(.*) $");
if (!paragraphText.empty()) paragraphText+=" ";
boost::smatch m;
if (boost::regex_match(*(*ii)->text(), m, cExpression)) {
paragraphText += m[1];
flushParagraph(paragraphText, paragraphTokens, processed, noPara);
processed.push_back(TokenPtr(new markdown::token::HtmlTag("br/")));
} else paragraphText += *(*ii)->text();
} else {
flushParagraph(paragraphText, paragraphTokens, processed, noPara);
processed.push_back(*ii);
}
}
// Make sure the last paragraph is properly flushed too.
flushParagraph(paragraphText, paragraphTokens, processed, noPara);
tokens->swapSubtokens(processed);
}