本文整理汇总了C++中Attr类的典型用法代码示例。如果您正苦于以下问题:C++ Attr类的具体用法?C++ Attr怎么用?C++ Attr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Attr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
Node*
Element::_getElementById (const DOMString& id)
{
for (size_t i = 0; i < _children.length(); i++) {
NamedNodeMap attrs = _children.item(i)->attributes();
for (size_t h = 0; h < attrs.length(); h++) {
Attr* attr = (Attr*) attrs.item(h);
if (attr->_isId) {
if (attr->value() == id) {
return _children.item(i);
}
}
}
}
for (size_t i = 0; i < _children.length(); i++) {
Node* element = _children.item(i)->_getElementById(id);
if (element) {
return element;
}
}
return NULL;
}
示例2: runTest
/*
* Runs the test case.
*/
void runTest()
{
Document doc;
NodeList acronymList;
Node testNode;
NamedNodeMap attributes;
Attr titleAttr;
String value;
Node textNode;
Node retval;
Node lastChild;
Document otherDoc;
doc = (Document) baseT::load("hc_staff", true);
otherDoc = (Document) baseT::load("hc_staff", true);
acronymList = doc.getElementsByTagName(SA::construct_from_utf8("acronym"));
testNode = acronymList.item(3);
attributes = testNode.getAttributes();
titleAttr = (Attr) attributes.getNamedItem(SA::construct_from_utf8("title"));
textNode = otherDoc.createTextNode(SA::construct_from_utf8("terday"));
{
boolean success = false;
try {
retval = titleAttr.appendChild(textNode);
} catch (const DOMException& ex) {
success = (ex.code() == DOMException::WRONG_DOCUMENT_ERR);
}
assertTrue(success);
}
}
示例3: while
PRBool
txXPathTreeWalker::moveToNextAttribute()
{
// XXX an assertion should be enough here with the current code
if (INNER->nodeType != Node::ATTRIBUTE_NODE) {
return PR_FALSE;
}
Element* element = static_cast<Element*>(INNER->getXPathParent());
Attr *attribute = element->getFirstAttribute();
while (attribute != INNER) {
attribute = attribute->getNextAttribute();
}
NS_ASSERTION(attribute, "Attr not attribute of it's owner?");
attribute = attribute->getNextAttribute();
while (attribute) {
if (attribute->getNamespaceID() != kNameSpaceID_XMLNS) {
INNER = attribute;
return PR_TRUE;
}
attribute = attribute->getNextAttribute();
}
return PR_FALSE;
}
示例4: push_explicit_style
bool push_explicit_style(Attr const& src, Attr & dst, markers_symbolizer const& sym)
{
boost::optional<stroke> const& strk = sym.get_stroke();
boost::optional<color> const& fill = sym.get_fill();
if (strk || fill)
{
for(unsigned i = 0; i < src.size(); ++i)
{
mapnik::svg::path_attributes attr = src[i];
if (strk)
{
attr.stroke_flag = true;
attr.stroke_width = strk->get_width();
color const& s_color = strk->get_color();
attr.stroke_color = agg::rgba(s_color.red()/255.0,s_color.green()/255.0,
s_color.blue()/255.0,(s_color.alpha()*strk->get_opacity())/255.0);
}
if (fill)
{
attr.fill_flag = true;
color const& f_color = *fill;
attr.fill_color = agg::rgba(f_color.red()/255.0,f_color.green()/255.0,
f_color.blue()/255.0,(f_color.alpha()*sym.get_opacity())/255.0);
}
dst.push_back(attr);
}
return true;
}
return false;
}
示例5: runTest
/*
* Runs the test case.
*/
void runTest()
{
Document doc;
NodeList acronymList;
Node testNode;
NamedNodeMap attributes;
Attr titleAttr;
String value;
Text textNode;
Node retval;
Node lastChild;
doc = (Document) baseT::load("hc_staff", true);
titleAttr = doc.createAttribute(SA::construct_from_utf8("title"));
textNode = doc.createTextNode(SA::construct_from_utf8("Yesterday"));
retval = titleAttr.appendChild(textNode);
value = titleAttr.getValue();
baseT::assertEquals("Yesterday", value, __LINE__, __FILE__);
value = titleAttr.getNodeValue();
baseT::assertEquals("Yesterday", value, __LINE__, __FILE__);
value = retval.getNodeValue();
baseT::assertEquals("Yesterday", value, __LINE__, __FILE__);
lastChild = titleAttr.getLastChild();
value = lastChild.getNodeValue();
baseT::assertEquals("Yesterday", value, __LINE__, __FILE__);
}
示例6: VisitRecordDecl
void DeclPrinter::VisitRecordDecl(RecordDecl *D) {
if (!Policy.SuppressSpecifiers && D->isModulePrivate())
Out << "__module_private__ ";
Out << D->getKindName();
// HACK: clang 3.6 doesn't accept
// __attribute__((transparent_union)) in
// the normal location. -SJW
Attr *Extra = nullptr;
if (D->hasAttrs()) {
AttrVec &Attrs = D->getAttrs();
for (AttrVec::const_iterator i=Attrs.begin(), e=Attrs.end(); i!=e; ++i) {
Attr *A = *i;
if (A->getKind() == attr::TransparentUnion)
Extra = A;
else
A->printPretty(Out, Policy);
}
}
if (D->getIdentifier())
Out << ' ' << *D;
if (D->isCompleteDefinition()) {
Out << " {\n";
VisitDeclContext(D);
Indent() << "}";
}
if (Extra)
Extra->printPretty(Out, Policy);
}
示例7: main
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// MAIN PROGRAM START
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
int main()
{
Attr test;
test.Load();
test.Attrs1();
AStar();
}
示例8: runTest
/*
* Runs the test case.
*/
void runTest()
{
Document doc;
NodeList elementList;
Element firstNode;
Node testNode;
NamedNodeMap attributes;
Attr domesticAttr;
Attr setAttr;
Node setNode;
doc = (Document) baseT::load("staff", true);
elementList = doc.getElementsByTagName(SA::construct_from_utf8("address"));
firstNode = (Element) elementList.item(0);
domesticAttr = doc.createAttribute(SA::construct_from_utf8("domestic"));
domesticAttr.setValue(SA::construct_from_utf8("Yes"));
setAttr = firstNode.setAttributeNode(domesticAttr);
elementList = doc.getElementsByTagName(SA::construct_from_utf8("address"));
testNode = elementList.item(2);
attributes = testNode.getAttributes();
{
boolean success = false;
try {
setNode = attributes.setNamedItem(domesticAttr);
} catch (const DOMException& ex) {
success = (ex.code() == DOMException::INUSE_ATTRIBUTE_ERR);
}
assertTrue(success);
}
}
示例9: getAttributeNodeNS
const XMLString& Element::getAttributeNS(const XMLString& namespaceURI, const XMLString& localName) const
{
Attr* pAttr = getAttributeNodeNS(namespaceURI, localName);
if (pAttr)
return pAttr->getValue();
else
return EMPTY_STRING;
}
示例10: getAttributeNode
const XMLString& Element::getAttribute(const XMLString& name) const
{
Attr* pAttr = getAttributeNode(name);
if (pAttr)
return pAttr->getValue();
else
return EMPTY_STRING;
}
示例11: Attr
Node *
Attr::cloneNode(bool deep) const
{
Attr * attr = new Attr(*this);
if (deep) {
attr->setValue(getValue());
}
return attr;
}
示例12: update_attr
const void Node::update_attr(Attr &attr){
for( vector<Attr>::iterator it=__attrs.begin() ; it!=__attrs.end() ; it++ ){
if(it->name()==attr.name()){
__attrs.erase(it);
it--;
}
}
if(attr.length()>0)
__attrs.push_back(attr);
}
示例13: while
void Element::dispatchNodeInsertedIntoDocument()
{
AbstractContainerNode::dispatchNodeInsertedIntoDocument();
Attr* pAttr = _pFirstAttr;
while (pAttr)
{
pAttr->dispatchNodeInsertedIntoDocument();
pAttr = static_cast<Attr*>(pAttr->_pNext);
}
}
示例14: tr
void FVBoxField::setupAttributesMinMax( )
{
Attr * a;
a = am->updateAttr( tr("Values No."), QString("%1").arg( field->size() ) , QString("text") );
a->setEditable(false);
a = am->updateAttr( tr("Min. Value"), QString("%1").arg( field->min() ), QString("text") );
a->setEditable(false);
a = am->updateAttr( tr("Max. Value"), QString("%1").arg( field->max() ), QString("text") );
a->setEditable(false);
}
示例15: writeXML
string Web::writeXML(Node *currNode, string prefix)
{
string xmlOut;
Attr *currAttributes;
vector<string> attrKeys;
xmlOut += prefix + "<" + currNode->getName();
currAttributes = currNode->getAttrList();
attrKeys = currAttributes->getKeyList();
if(attrKeys.size() > 0)
{
for(int i = 0; i < attrKeys.size(); i++)
{
xmlOut += " " + attrKeys[i] + "=\"" + currAttributes->getAttr(attrKeys[i]) + "\"";
}
}
xmlOut += ">\n";
vector<string> children = currNode->getChildren();
int reqGrpCount = currNode->getNumReqGrp();
for(int i = 0; i < children.size(); i++)
{
xmlOut += writeXML(currNode->getChild(children[i]), prefix + '\t');
}
if(reqGrpCount > 0)
{
for(int i = 0; i < reqGrpCount; i++)
{
xmlOut += writeXML(currNode->getReqGrp(i), prefix + '\t');
}
}
if(currNode->getName() == "reqgrp")
{
vector<string> reqConcept = currNode->getReqConcept();
vector<string> reqParent = currNode->getReqParent();
for(int i = 0; i < reqConcept.size(); i++)
{
xmlOut += prefix + '\t' + "<req parent=\"" + reqParent[i] + "\">" + reqConcept[i] + "</req>\n";
}
}
xmlOut += prefix + "</" + currNode->getName() + ">\n";
return xmlOut;
}