📄 dom++.cpp
字号:
{ this->data = soap_strdup(soap, data); return *this;}/******************************************************************************/soap_dom_element &soap_dom_element::set(void *node, int type){ this->node = node; this->type = type; return *this;}/******************************************************************************/soap_dom_element &soap_dom_element::add(struct soap_dom_element *elt){ elt->prnt = this; for (struct soap_dom_element *e = elts; e; e = e->next) { if (!e->next) { e->next = elt; return *this; } } elts = elt; return *this;}/******************************************************************************/soap_dom_element &soap_dom_element::add(struct soap_dom_element &elt){ return add(&elt);}/******************************************************************************/soap_dom_element &soap_dom_element::add(struct soap_dom_attribute *att){ for (struct soap_dom_attribute *a = atts; a; a = a->next) { if (!a->next) { a->next = att; return *this; } } atts = att; return *this;}/******************************************************************************/soap_dom_element &soap_dom_element::add(struct soap_dom_attribute &att){ return add(&att);}/******************************************************************************/soap_dom_element_iterator soap_dom_element::begin(){ soap_dom_element_iterator iter(this); return iter;}/******************************************************************************/soap_dom_element_iterator soap_dom_element::end(){ soap_dom_element_iterator iter(NULL); return iter;}/******************************************************************************/soap_dom_element_iterator soap_dom_element::find(const char *nstr, const char *name){ soap_dom_element_iterator iter(this); iter.nstr = nstr; iter.name = name; if (name && soap_tag_cmp(this->name, name)) return ++iter; if (nstr && this->nstr && soap_tag_cmp(this->nstr, nstr)) return ++iter; return iter;}/******************************************************************************/soap_dom_element_iterator soap_dom_element::find(int type){ soap_dom_element_iterator iter(this); iter.type = type; if (this->type != type) return ++iter; return iter;}/******************************************************************************/void soap_dom_element::unlink(){ soap_unlink(soap, this); soap_unlink(soap, nstr); soap_unlink(soap, name); soap_unlink(soap, data); soap_unlink(soap, wide); if (elts) elts->unlink(); if (atts) elts->unlink(); if (next) next->unlink(); node = NULL; type = 0;}/******************************************************************************\ * * soap_dom_attribute class *\******************************************************************************/soap_dom_attribute::soap_dom_attribute(){ this->soap = NULL; this->next = NULL; this->nstr = NULL; this->name = NULL; this->data = NULL; this->wide = NULL;}/******************************************************************************/soap_dom_attribute::soap_dom_attribute(struct soap *soap){ this->soap = soap; this->next = NULL; this->nstr = NULL; this->name = NULL; this->data = NULL; this->wide = NULL;}/******************************************************************************/soap_dom_attribute::soap_dom_attribute(struct soap *soap, const char *nstr, const char *name, const char *data){ this->soap = soap; this->next = NULL; this->nstr = soap_strdup(soap, nstr); this->name = soap_strdup(soap, name); this->data = soap_strdup(soap, data); this->wide = NULL;}/******************************************************************************/soap_dom_attribute::~soap_dom_attribute(){ }/******************************************************************************/soap_dom_attribute_iterator soap_dom_attribute::begin(){ soap_dom_attribute_iterator iter(this); return iter;}/******************************************************************************/soap_dom_attribute_iterator soap_dom_attribute::end(){ soap_dom_attribute_iterator iter(NULL); return iter;}/******************************************************************************/soap_dom_attribute_iterator soap_dom_attribute::find(const char *nstr, const char *name){ soap_dom_attribute_iterator iter(this); iter.nstr = nstr; iter.name = name; if (name && soap_tag_cmp(this->name, name)) return ++iter; if (nstr && this->nstr && soap_tag_cmp(this->nstr, nstr)) return ++iter; return iter;}/******************************************************************************/void soap_dom_attribute::unlink(){ soap_unlink(soap, this); soap_unlink(soap, nstr); soap_unlink(soap, name); soap_unlink(soap, data); soap_unlink(soap, wide); if (next) next->unlink();}/******************************************************************************\ * * soap_dom_element_iterator class *\******************************************************************************/soap_dom_element_iterator::soap_dom_element_iterator(){ elt = NULL; nstr = NULL; name = NULL; type = 0;}/******************************************************************************/soap_dom_element_iterator::soap_dom_element_iterator(struct soap_dom_element *elt){ this->elt = elt; nstr = NULL; name = NULL; type = 0;}/******************************************************************************/soap_dom_element_iterator::~soap_dom_element_iterator(){ }/******************************************************************************/bool soap_dom_element_iterator::operator==(const soap_dom_element_iterator &iter) const{ return this->elt == iter.elt;}/******************************************************************************/bool soap_dom_element_iterator::operator!=(const soap_dom_element_iterator &iter) const{ return this->elt != iter.elt;}/******************************************************************************/struct soap_dom_element &soap_dom_element_iterator::operator*() const{ return *this->elt;}/******************************************************************************/soap_dom_element_iterator &soap_dom_element_iterator::operator++(){ while (elt) { elt = soap_dom_next_element(elt); if (!elt) break; if (name && elt->name) { if (!soap_tag_cmp(elt->name, name)) { if (nstr && elt->nstr) { if (!soap_tag_cmp(elt->nstr, nstr)) break; } else break; } } else if (type) { if (elt->type == type) break; } else break; } return *this;}/******************************************************************************\ * * soap_dom_attribute_iterator class *\******************************************************************************/soap_dom_attribute_iterator::soap_dom_attribute_iterator(){ att = NULL; nstr = NULL; name = NULL;}/******************************************************************************/soap_dom_attribute_iterator::soap_dom_attribute_iterator(struct soap_dom_attribute *att){ this->att = att; nstr = NULL; name = NULL;}/******************************************************************************/soap_dom_attribute_iterator::~soap_dom_attribute_iterator(){ }/******************************************************************************/bool soap_dom_attribute_iterator::operator==(const soap_dom_attribute_iterator &iter) const{ return this->att == iter.att;}/******************************************************************************/bool soap_dom_attribute_iterator::operator!=(const soap_dom_attribute_iterator &iter) const{ return this->att != iter.att;}/******************************************************************************/struct soap_dom_attribute &soap_dom_attribute_iterator::operator*() const{ return *this->att;}/******************************************************************************/soap_dom_attribute_iterator &soap_dom_attribute_iterator::operator++(){ while (att) { att = soap_dom_next_attribute(att); if (!att) break; if (name && att->name) { if (!soap_tag_cmp(att->name, name)) { if (nstr && att->nstr) { if (!soap_tag_cmp(att->nstr, nstr)) break; } else break; } } else break; } return *this;}/******************************************************************************\ * * I/O *\******************************************************************************/#ifndef UNDER_CEstd::ostream &operator<<(std::ostream &o, const struct soap_dom_element &e){ if (!e.soap) { struct soap soap; soap_init2(&soap, SOAP_IO_DEFAULT, SOAP_XML_GRAPH); soap_serialize_xsd__anyType(&soap, &e); soap_begin_send(&soap); soap_out_xsd__anyType(&soap, NULL, 0, &e, NULL); soap_end_send(&soap); soap_end(&soap); soap_done(&soap); } else { std::ostream *os = e.soap->os; e.soap->os = &o; short omode = e.soap->omode; soap_set_omode(e.soap, SOAP_XML_GRAPH); soap_serialize_xsd__anyType(e.soap, &e); soap_begin_send(e.soap); soap_out_xsd__anyType(e.soap, NULL, 0, &e, NULL); soap_end_send(e.soap); e.soap->os = os; e.soap->omode = omode; } return o;}/******************************************************************************/std::istream &operator>>(std::istream &i, struct soap_dom_element &e){ if (!e.soap) e.soap = soap_new(); std::istream *is = e.soap->is; e.soap->is = &i; if (soap_begin_recv(e.soap) || !soap_in_xsd__anyType(e.soap, NULL, &e, NULL) || soap_end_recv(e.soap)) { /* handle error? Note: e.soap->error is set and app should check */ } e.soap->is = is; return i;}#endif#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -