本文整理汇总了C++中MeiElement::setValue方法的典型用法代码示例。如果您正苦于以下问题:C++ MeiElement::setValue方法的具体用法?C++ MeiElement::setValue怎么用?C++ MeiElement::setValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeiElement
的用法示例。
在下文中一共展示了MeiElement::setValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MeiElement
TEST(TestMeiElement, TestGetSet) {
MeiElement *p = new MeiElement("p");
p->setValue("this is a sentence");
ASSERT_EQ("this is a sentence", p->getValue());
p->setTail("atail");
// We know an id is 'm-<uuid>', so we can check the length
ASSERT_EQ(38, p->getId().length());
ASSERT_EQ("atail", p->getTail());
}
示例2: xmlNodeToMeiElement
MeiElement* XmlImportImpl::xmlNodeToMeiElement(xmlNode *el) {
string id = "";
vector<MeiAttribute*> attributes;
// XML attributes and children. Text nodes will never have these.
if (el->properties) {
xmlAttr *curattr = NULL;
for (curattr = el->properties; curattr; curattr = curattr->next) {
if (curattr->atype == XML_ATTRIBUTE_ID) {
/* we store the ID on the element, not as an attribute. This will be serialized out
* on export
*/
id = (const char*)curattr->children->content;
} else {
string attrname = (const char*)curattr->name;
// values are rendered as children of the attribute *facepalm*
string attrvalue = (const char*)curattr->children->content;
MeiNamespace* meins = NULL;
if (curattr->ns) {
if (!this->meiDocument->hasNamespace(string((const char*)curattr->ns->href))) {
string prefix = (const char*)curattr->ns->prefix;
string href = (const char*)curattr->ns->href;
meins = new MeiNamespace(prefix, href);
} else {
meins = this->meiDocument->getNamespace(string((const char*)curattr->ns->href));
}
}
MeiAttribute *a = new MeiAttribute(meins, attrname, attrvalue);
attributes.push_back(a);
}
}
}
MeiElement *obj = MeiFactory::createInstance((const char*)el->name, id);
obj->setAttributes(attributes);
MeiElement *lastElement = NULL;
xmlNodePtr child = el->children;
while (child != NULL) {
if (child->type == XML_ELEMENT_NODE) {
MeiElement* ch = xmlNodeToMeiElement(child);
obj->addChild(ch);
lastElement = ch;
} else if (child->type == XML_TEXT_NODE) {
if (lastElement) {
const char *content = (const char*)child->content;
if (content) {
lastElement->setTail(content);
}
} else {
const char *content = (const char*)child->content;
if (content) {
obj->setValue(content);
}
}
} else if (child->type == XML_COMMENT_NODE) {
MeiElement *comment = new MeiCommentNode();
comment->setValue(string((const char*)child->content));
obj->addChild(comment);
}
child = child->next;
}
return obj;
}