xmlnode_ = xmlNewNode(0,
reinterpret_cast<constxmlChar*
>(
"blank"));
72 if(!xmlnode_)
throwstd::bad_alloc();
79xmlnode_ = xmlCopyNode(other.
xmlnode_, 2);
80 if(!xmlnode_)
throwstd::bad_alloc();
87{
if(owner_ && xmlnode_) xmlFreeNode(xmlnode_); }
102pimpl_ =
new pimpl(0);
127other.pimpl_ =
NULL;
131 if(
this!= &other) {
135other.pimpl_ =
NULL;
141 returnpimpl_->xmlnode_;
145 return xml::ns(libxml2RawNamespace);
153xmlNodePtr x =
static_cast<xmlNodePtr
>(
node);
156pimpl_->owner_ =
false;
157pimpl_->xmlnode_ = x;
162pimpl_->xmlnode_->properties,
169pimpl_->xmlnode_->properties,
190 if( (!name) || (!
value))
192 "insert must not be NULL");
193 if(name[0] ==
'\0')
196 boolonly_whitespaces =
true;
197 const char* current = name;
198 while(*current !=
'\0') {
199 if(memchr(
" \t\n\r", *current, 4) ==
NULL) {
200only_whitespaces =
false;
205 if(only_whitespaces)
207 "of only whitespace characters");
210 const char*
column= strchr(name,
':');
218 if(*(
column+ 1) ==
'\0')
221 throw xml::exception(
"an attribute may not have a default namespace");
224xmlNsPtr resolved_ns = xmlSearchNs(pimpl_->xmlnode_->doc,
226 reinterpret_cast<constxmlChar*
>(prefix.c_str()));
230 if(xmlSetNsProp(pimpl_->xmlnode_,
232 reinterpret_cast<constxmlChar*
>(
column+ 1),
233 reinterpret_cast<constxmlChar*
>(
value)) ==
NULL)
239 if(xmlSetProp(pimpl_->xmlnode_,
240 reinterpret_cast<constxmlChar*
>(name),
241 reinterpret_cast<constxmlChar*
>(
value)) ==
NULL)
248 throw xml::exception(
"cannot specify both a qualified name and a namespace");
252 if(xmlSetProp(pimpl_->xmlnode_,
253 reinterpret_cast<constxmlChar*
>(name),
254 reinterpret_cast<constxmlChar*
>(
value)) ==
NULL)
260 throw xml::exception(
"an attribute may not have a default namespace");
263 if(xmlSetNsProp(pimpl_->xmlnode_,
264 reinterpret_cast<xmlNsPtr
>(nspace->
unsafe_ns_),
265 reinterpret_cast<constxmlChar*
>(name),
266 reinterpret_cast<constxmlChar*
>(
value)) ==
NULL)
273xmlNsPtr resolved_ns = xmlSearchNsByHref(pimpl_->xmlnode_->doc,
275 reinterpret_cast<constxmlChar*
>(nspace->
get_uri()));
278 "cannot resolve namespace");
280 if(xmlSetNsProp(pimpl_->xmlnode_,
282 reinterpret_cast<constxmlChar*
>(name),
283 reinterpret_cast<constxmlChar*
>(
value)) ==
NULL)
290xmlAttrPtr prop =
find_prop(pimpl_->xmlnode_, name, nspace);
292 return iterator(pimpl_->xmlnode_, prop,
false,
true);
296 return iterator(pimpl_->xmlnode_, dtd_prop,
true,
true);
298 return iterator(pimpl_->xmlnode_,
NULL,
false,
true);
302 const ns*nspace)
const{
303xmlAttrPtr prop =
find_prop(pimpl_->xmlnode_, name, nspace);
320 "not initialized or belongs to another node attributes");
323 if(to_erase == end())
329xmlAttrPtr prop_to_erase =
static_cast<xmlAttrPtr
>(to_erase.
pimpl_->
get()->
prop_);
332xmlUnsetNsProp(pimpl_->xmlnode_, prop_to_erase->ns, prop_to_erase->name);
341 const char*
column= strchr(name,
':');
347 if(*(
column+ 1) ==
'\0')
351xmlNsPtr resolved_ns = xmlSearchNs(pimpl_->xmlnode_->doc,
353 reinterpret_cast<constxmlChar*
>(prefix.c_str()));
357 if(xmlUnsetNsProp(pimpl_->xmlnode_,
359 reinterpret_cast<constxmlChar*
>(
column+ 1)) == 0)
367 while(att !=
NULL) {
369xmlUnlinkNode(
reinterpret_cast<xmlNodePtr
>(att));
381 if(xmlUnsetProp(pimpl_->xmlnode_,
382 reinterpret_cast<constxmlChar*
>(name)) == 0)
388 if(xmlUnsetNsProp(pimpl_->xmlnode_,
389 reinterpret_cast<xmlNsPtr
>(nspace->
unsafe_ns_),
390 reinterpret_cast<constxmlChar*
>(name)) == 0)
396xmlNsPtr resolved_ns = xmlSearchNsByHref(pimpl_->xmlnode_->doc,
398 reinterpret_cast<constxmlChar*
>(nspace->
get_uri()));
406 while(xmlUnsetNsProp(pimpl_->xmlnode_,
408 reinterpret_cast<constxmlChar*
>(name)) == 0)
414 returnpimpl_->xmlnode_->properties == 0;
420xmlAttrPtr prop = pimpl_->xmlnode_->properties;
421 while(prop != 0) { ++
count; prop = prop->next; }
427 booloperator() (
constxmlAttrPtr & lhs,
constxmlAttrPtr & rhs)
const{
428 return strcmp(
reinterpret_cast<const char*
>(lhs->name),
429 reinterpret_cast<const char*
>(rhs->name)) < 0;
433std::list<xmlAttrPtr> attrs;
434xmlAttrPtr prop = pimpl_->xmlnode_->properties;
438attrs.push_back(prop);
446xmlAttrPtr cur =
NULL;
449 for(std::list<xmlAttrPtr>::const_iterator k = attrs.begin();
450k != attrs.end(); ++k) {
454pimpl_->xmlnode_->properties = cur;
This file defines the xml::ait_impl class.
const char * kInsertError
This file contains the definition of the xml::attributes class.
bool is_default(void) const
Test if the attribute is default.
Const Iterator class for accessing attribute pairs.
Iterator class for accessing attribute pairs.
The xml::attributes class is used to access all the attributes of one xml::node.
std::size_t size_type
size type
size_type size(void) const
Find out how many attributes there are in this xml::attributes object.
iterator erase(iterator to_erase)
Erase the attribute that is pointed to by the given iterator.
void swap(attributes &other)
Swap this xml::attributes object with another one.
attributes(void)
Create a new xml::attributes object with no attributes.
iterator find(const char *name, const ns *nspace=NULL)
Find the attribute with the given name and namespace.
iterator begin(void)
Get an iterator that points to the first attribute.
static xml::ns createUnsafeNamespace(void *libxml2RawNamespace)
static void * getUnsafeNamespacePointer(const xml::ns &name_space)
void sort(void)
Sorts the attributes in place.
attributes & operator=(const attributes &other)
Copy the given xml::attributes object into this one.
iterator end(void)
Get an iterator that points one past the the last attribute.
void set_data(void *node)
bool empty(void) const
Find out if there are any attributes in this xml::attributes object.
virtual ~attributes(void)
Clean up after a xml::attributes object.
void insert(const char *name, const char *value, const ns *nspace=NULL)
Add an attribute to the attributes list.
This exception class is thrown by xmlwrapp for all runtime XML-related errors along with the xml::par...
attributes::attr * get(void)
The xml::node class is used to hold information about one XML node.
The xml::ns class is used to access and handle namespaces of nodes and attributes.
const char * get_prefix(void) const
Get the namespace prefix.
const char * get_uri(void) const
Get the namespace URI.
bool is_safe(void) const
Check if the object is safe i.e.
bool is_void(void) const
If a node or an attribute has no namespace, then a namespace with empty prefix and empty URI is retur...
static DLIST_TYPE *DLIST_NAME() prev(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
static DLIST_TYPE *DLIST_NAME() next(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
static const char * column
void swap(NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair1, NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair2)
This file contains the definition of the xml::exception class.
const GenericPointer< typename T::ValueType > T2 value
int strcmp(const char *str1, const char *str2)
phantom_attr * find_default_prop(xmlNodePtr xmlnode, const char *name, const ns *nspace)
xmlAttrPtr find_prop(xmlNodePtr xmlnode, const char *name, const ns *nspace)
pimpl(const pimpl &other)
pimpl & operator=(const pimpl &)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4