FragmentObject::FragmentObject(u_str s) : DataItem(),fragment(nullptr) { fragment = frag_doc->createDocumentFragment(); if ( ! s.empty() ) { DOMText* vt = frag_doc->createTextNode(pcx(s.c_str())); fragment->appendChild(vt); } }
FragmentObject::FragmentObject(const std::string s) : DataItem(),fragment(nullptr) { fragment = frag_doc->createDocumentFragment(); if ( ! s.empty() ) { u_str tt; XML::Manager::transcode(s,tt); DOMText* vt = frag_doc->createTextNode(pcx(tt.c_str())); fragment->appendChild(vt); } }
bool Manager::attribute(const DOMNode* n,const u_str attrname) { bool result=false; if (n != nullptr && !attrname.empty() && n->getNodeType() == DOMNode::ELEMENT_NODE ) { DOMElement* enod = (DOMElement*)n; DOMAttr* enoda = enod->getAttributeNode(pcx(attrname.c_str())); if (enoda != nullptr) { const XMLCh* x_attrval = enoda->getNodeValue(); if (x_attrval != nullptr && x_attrval[0] != 0 ) { result = true; //only true if result is not empty. } } } return result; }
bool Manager::attribute(const DOMNode* n,const u_str attrname, std::string& attrval) { bool result=false; if (n != nullptr && !attrname.empty() && n->getNodeType() == DOMNode::ELEMENT_NODE ) { DOMElement* enod = (DOMElement*)n; DOMAttr* enoda = enod->getAttributeNode(pcx(attrname.c_str())); if (enoda != nullptr) { const XMLCh* x_attrval = enoda->getNodeValue(); if (x_attrval != nullptr && x_attrval[0] != 0 ) { char* value = (char*)TranscodeToStr(x_attrval,"UTF-8").adopt(); size_t vl = strlen(value); attrval.reserve(vl); attrval.assign(value,vl); XMLString::release(&value); //delete attr; result = true; //only true if result is not empty. } } } return result; }
/* ==================== VIRTUAL methods. =========== */ void FragmentObject::append(DataItem*& s) { if (s != nullptr) { DOMNode* n = nullptr; XMLObject* x = dynamic_cast<XMLObject*>(s); if (x != nullptr) { DOMNode* nbase; x->take(nbase); DOMNode::NodeType nt = nbase->getNodeType(); switch (nt) { case DOMNode::DOCUMENT_NODE: { const DOMDocument* d = static_cast<const DOMDocument*>(nbase); if (d != nullptr) { const DOMNode* de = d->getDocumentElement(); if (de != nullptr) { n = frag_doc->importNode(de,true); //importNode always takes a copy - returns DOMNode* inod = new node pointer. } delete d; } } break; default: { n = frag_doc->importNode(nbase,true); //importNode always takes a copy - returns DOMNode* inod = new node pointer. nbase->release(); } break; } } else { FragmentObject* y = dynamic_cast<FragmentObject*>(s); if (y != nullptr) { y->take(n); } else { std::string str = *s; if ( ! str.empty() ) { u_str tt; XML::Manager::transcode(str,tt); n = frag_doc->createTextNode(pcx(tt.c_str())); } } } fragment->appendChild(n); delete s; } }
int main() { X x; Y<X> px(&x); Y<X const> pcx(&x); hpx::util::mem_fn(&X::f0)(px); hpx::util::mem_fn(&X::g0)(pcx); hpx::util::mem_fn(&X::f1)(px, 1); hpx::util::mem_fn(&X::g1)(pcx, 1); hpx::util::mem_fn(&X::f2)(px, 1, 2); hpx::util::mem_fn(&X::g2)(pcx, 1, 2); hpx::util::mem_fn(&X::f3)(px, 1, 2, 3); hpx::util::mem_fn(&X::g3)(pcx, 1, 2, 3); hpx::util::mem_fn(&X::f4)(px, 1, 2, 3, 4); hpx::util::mem_fn(&X::g4)(pcx, 1, 2, 3, 4); hpx::util::mem_fn(&X::f5)(px, 1, 2, 3, 4, 5); hpx::util::mem_fn(&X::g5)(pcx, 1, 2, 3, 4, 5); hpx::util::mem_fn(&X::f6)(px, 1, 2, 3, 4, 5, 6); hpx::util::mem_fn(&X::g6)(pcx, 1, 2, 3, 4, 5, 6); hpx::util::mem_fn(&X::f7)(px, 1, 2, 3, 4, 5, 6, 7); hpx::util::mem_fn(&X::g7)(pcx, 1, 2, 3, 4, 5, 6, 7); hpx::util::mem_fn(&X::f8)(px, 1, 2, 3, 4, 5, 6, 7, 8); hpx::util::mem_fn(&X::g8)(pcx, 1, 2, 3, 4, 5, 6, 7, 8); HPX_TEST(hash == 2155); return hpx::util::report_errors(); }