本文整理汇总了C++中unc_text::startswith方法的典型用法代码示例。如果您正苦于以下问题:C++ unc_text::startswith方法的具体用法?C++ unc_text::startswith怎么用?C++ unc_text::startswith使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unc_text
的用法示例。
在下文中一共展示了unc_text::startswith方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: next_up
static int next_up(const unc_text& text, int idx, unc_text& tag)
{
int offs = 0;
while ((idx < text.size()) && unc_isspace(text[idx]))
{
idx++;
offs++;
}
if (text.startswith(tag, idx))
{
return(offs);
}
return(-1);
}
示例2: add_comment_kw
/**
* text starts with '$('. see if this matches a keyword and add text based
* on that keyword.
* @return the number of characters eaten from the text
*/
static int add_comment_kw(const unc_text& text, int idx, cmt_reflow& cmt)
{
if (text.startswith("$(filename)", idx))
{
add_text(path_basename(cpd.filename));
return(11);
}
if (text.startswith("$(class)", idx))
{
chunk_t *tmp = get_next_class(cmt.pc);
if (tmp != NULL)
{
add_text(tmp->str);
return(8);
}
}
/* If we can't find the function, we are done */
chunk_t *fcn = get_next_function(cmt.pc);
if (fcn == NULL)
{
return(0);
}
if (text.startswith("$(message)", idx))
{
add_text(fcn->str);
chunk_t *tmp = chunk_get_next_ncnl(fcn);
chunk_t *word = NULL;
while (tmp)
{
if ((tmp->type == CT_BRACE_OPEN) || (tmp->type == CT_SEMICOLON))
{
break;
}
if (tmp->type == CT_OC_COLON)
{
if (word != NULL)
{
add_text(word->str);
word = NULL;
}
add_text(":");
}
if (tmp->type == CT_WORD)
{
word = tmp;
}
tmp = chunk_get_next_ncnl(tmp);
}
return(10);
}
if (text.startswith("$(function)", idx))
{
if (fcn->parent_type == CT_OPERATOR)
{
add_text("operator ");
}
add_text(fcn->str);
return(11);
}
if (text.startswith("$(javaparam)", idx))
{
add_comment_javaparam(fcn, cmt);
return(12);
}
if (text.startswith("$(fclass)", idx))
{
chunk_t *tmp = chunk_get_prev_ncnl(fcn);
if ((tmp != NULL) && (tmp->type == CT_OPERATOR))
{
tmp = chunk_get_prev_ncnl(tmp);
}
if ((tmp != NULL) && ((tmp->type == CT_DC_MEMBER) ||
(tmp->type == CT_MEMBER)))
{
tmp = chunk_get_prev_ncnl(tmp);
add_text(tmp->str);
return(9);
}
}
return(0);
}