本文整理汇总了C++中TreeNode::Attrib方法的典型用法代码示例。如果您正苦于以下问题:C++ TreeNode::Attrib方法的具体用法?C++ TreeNode::Attrib怎么用?C++ TreeNode::Attrib使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TreeNode
的用法示例。
在下文中一共展示了TreeNode::Attrib方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: output_toc_node
void output_toc_node(FILE *f, const TreeNode& node) {
if (node.mName != "tocnode")
error("Invalid node <%s> found during HTML help TOC generation", node.mName.c_str());
const TreeAttribute *attrib = node.Attrib("name");
if (!attrib || attrib->mbNoValue)
error("<tocnode> must have NAME attribute");
const TreeAttribute *target = node.Attrib("target");
fputs("<LI><OBJECT type=\"text/sitemap\">\n", f);
fprintf(f, "<param name=\"Name\" value=\"%s\">\n", HTMLize(attrib->mValue).c_str());
if (target && !target->mbNoValue)
fprintf(f, "<param name=\"Local\" value=\"%s\">\n", HTMLize(target->mValue).c_str());
fputs("</OBJECT>\n", f);
output_toc_children(f, node);
}
示例2: output_special_tag
void output_special_tag(Context& ctx, std::string *out, const TreeNode& tag) {
if (tag.mName == "lina:fireball") {
const TreeAttribute *a1 = tag.Attrib("src");
const TreeAttribute *a2 = tag.Attrib("dst");
if (!a1 || !a2)
error(ctx, "<lina:fireball> requires SRC and DST attributes");
g_fileCopies[a2->mValue] = a1->mValue;
} else if (tag.mName == "lina:write") {
const TreeAttribute *a = tag.Attrib("file");
if (!a)
error(ctx, "<lina:write> must specify FILE");
std::string s;
std::list<TreeNode *> tempStack;
ctx.construction_stack.swap(tempStack);
int cdataCount = ctx.cdata_count;
int preCount = ctx.pre_count;
ctx.cdata_count = 0;
ctx.pre_count = 0;
bool bHoldingSpace = ctx.holding_space;
bool bEatNextSpace = ctx.eat_next_space;
ctx.holding_space = false;
ctx.eat_next_space = true;
output_tag_contents(ctx, &s, tag);
ctx.holding_space = bHoldingSpace;
ctx.eat_next_space = bEatNextSpace;
ctx.pre_count = cdataCount;
ctx.cdata_count = preCount;
ctx.construction_stack.swap(tempStack);
std::string filename(create_output_filename(a->mValue));
FILE *f = fopen(filename.c_str(), "wb");
if (!f)
error(ctx, "couldn't create \"%s\"", a->mValue.c_str());
fwrite(s.data(), s.length(), 1, f);
fclose(f);
printf("created file: %s\n", a->mValue.c_str());
} else if (tag.mName == "lina:body") {
// printf("outputting:\n");
// dump_parse_tree(*ctx.invocation_stack.back(), 4);
output_tag_contents(ctx, out, *ctx.invocation_stack.back());
} else if (tag.mName == "lina:tag") {
const TreeAttribute *a = tag.Attrib("name");
if (!a)
error(ctx, "<lina:tag> must have NAME attribute");
ctx.construction_stack.push_back(ctx.mpDocument->AllocNode());
TreeNode *new_tag = ctx.construction_stack.back();
new_tag->mpLocation = tag.mpLocation;
new_tag->mLineno = tag.mLineno;
new_tag->mName = a->mValue;
new_tag->mbIsText = false;
new_tag->mbIsControl = false;
// compatibility
if (!new_tag->mName.compare(0, 2, "w:"))
new_tag->mName.replace(0, 2, "lina:");
output_tag_contents(ctx, NULL, tag);
ctx.construction_stack.pop_back();
output_tag(ctx, out, *new_tag);
} else if (tag.mName == "lina:arg") {
if (!out && ctx.construction_stack.empty())
error(ctx, "<lina:arg> can only be used in an output context");
const TreeAttribute *a = tag.Attrib("name");
if (!a)
error(ctx, "<lina:arg> must have NAME attribute");
if (ctx.invocation_stack.empty())
error(ctx, "<lina:arg> can only be used during macro expansion");
std::list<const TreeNode *>::const_iterator it(ctx.invocation_stack.end());
--it;
int levels = 1;
const char *name = a->mValue.c_str();
while(*name == '^') {
++levels;
++name;
if (it == ctx.invocation_stack.begin())
error(ctx, "Number of up-scope markers in name exceeds macro nesting level");
--it;
}
const TreeNode& macrotag = **it;
const TreeAttribute *a2 = macrotag.Attrib(name);
if (!a2)
error(ctx, "macro invocation <%s> does not have an attribute \"%s\"", macrotag.mName.c_str(), name);
//.........这里部分代码省略.........