NCBI C++ ToolKit
|
Search Toolkit Book for xml::attributes
The xml::attributes class is used to access all the attributes of one xml::node. More...
#include <misc/xmlwrapp/attributes.hpp>
Classes | |
class | attr |
The xml::attributes::attr class is used to hold information about one attribute. More... | |
class | const_iterator |
Const Iterator class for accessing attribute pairs. More... | |
class | iterator |
Iterator class for accessing attribute pairs. More... | |
struct | pimpl |
Public Types | |
typedef std::size_t | size_type |
size type More... | |
Public Member Functions | |
attributes (void) | |
Create a new xml::attributes object with no attributes. More... | |
attributes (const attributes &other) | |
Copy construct a xml::attributes object. More... | |
attributes & | operator= (const attributes &other) |
Copy the given xml::attributes object into this one. More... | |
attributes (attributes &&other) | |
Moving constructor. More... | |
attributes & | operator= (attributes &&other) |
Moving assignment. More... | |
void | swap (attributes &other) |
Swap this xml::attributes object with another one. More... | |
virtual | ~attributes (void) |
Clean up after a xml::attributes object. More... | |
iterator | begin (void) |
Get an iterator that points to the first attribute. More... | |
const_iterator | begin (void) const |
Get a const_iterator that points to the first attribute. More... | |
iterator | end (void) |
Get an iterator that points one past the the last attribute. More... | |
const_iterator | end (void) const |
Get a const_iterator that points one past the last attribute. More... | |
void | insert (const char *name, const char *value, const ns *nspace=NULL) |
Add an attribute to the attributes list. More... | |
iterator | find (const char *name, const ns *nspace=NULL) |
Find the attribute with the given name and namespace. More... | |
const_iterator | find (const char *name, const ns *nspace=NULL) const |
Find the attribute with the given name and namespace. More... | |
iterator | erase (iterator to_erase) |
Erase the attribute that is pointed to by the given iterator. More... | |
size_type | erase (const char *name, const ns *nspace=NULL) |
Erase the attribute with the given name. More... | |
bool | empty (void) const |
Find out if there are any attributes in this xml::attributes object. More... | |
size_type | size (void) const |
Find out how many attributes there are in this xml::attributes object. More... | |
void | sort (void) |
Sorts the attributes in place. More... | |
Private Member Functions | |
attributes (int) | |
void | set_data (void *node) |
void * | get_data (void) |
Static Private Member Functions | |
static xml::ns | createUnsafeNamespace (void *libxml2RawNamespace) |
static void * | getUnsafeNamespacePointer (const xml::ns &name_space) |
Private Attributes | |
pimpl * | pimpl_ |
Friends | |
struct | impl::node_impl |
class | node |
The xml::attributes class is used to access all the attributes of one xml::node.
You can add, find and erase attributes by name, and for some member functions, use the provided iterator classes.
The iterator classes allow you to access one XML attribute. This is done using the xml::attributes::attr class interface.
Definition at line 78 of file attributes.hpp.
typedef std::size_t xml::attributes::size_type |
size type
Definition at line 80 of file attributes.hpp.
xml::attributes::attributes | ( | void | ) |
Create a new xml::attributes object with no attributes.
Definition at line 97 of file attributes.cpp.
xml::attributes::attributes | ( | const attributes & | other | ) |
Copy construct a xml::attributes object.
other | The xml::attributes object to copy from. |
Definition at line 105 of file attributes.cpp.
References pimpl_.
xml::attributes::attributes | ( | attributes && | other | ) |
Moving constructor.
other | The other attributes. |
Definition at line 124 of file attributes.cpp.
References NULL.
|
virtual |
Clean up after a xml::attributes object.
Definition at line 119 of file attributes.cpp.
References NULL.
|
explicitprivate |
Definition at line 101 of file attributes.cpp.
xml::attributes::iterator xml::attributes::begin | ( | void | ) |
Get an iterator that points to the first attribute.
Definition at line 160 of file attributes.cpp.
Referenced by GetBioSampleStatusFromNode(), and ProcessBiosampleStatusNode().
xml::attributes::const_iterator xml::attributes::begin | ( | void | ) | const |
Get a const_iterator that points to the first attribute.
Definition at line 167 of file attributes.cpp.
|
staticprivate |
Definition at line 144 of file attributes.cpp.
Referenced by xml::attributes::attr::get_namespace(), and xml::attributes::attr::set_namespace().
bool xml::attributes::empty | ( | void | ) | const |
Find out if there are any attributes in this xml::attributes object.
Definition at line 413 of file attributes.cpp.
xml::attributes::iterator xml::attributes::end | ( | void | ) |
Get an iterator that points one past the the last attribute.
Definition at line 174 of file attributes.cpp.
References NULL.
Referenced by GetBioSampleStatusFromNode(), CEntrezDB::GetUidAttr(), and ProcessBiosampleStatusNode().
xml::attributes::const_iterator xml::attributes::end | ( | void | ) | const |
Get a const_iterator that points one past the last attribute.
Definition at line 181 of file attributes.cpp.
References NULL.
xml::attributes::size_type xml::attributes::erase | ( | const char * | name, |
const ns * | nspace = NULL |
||
) |
Erase the attribute with the given name.
This will invalidate any iterators that are pointing to that attribute, as well as any pointers or references to that attribute.
This function does not throw any exceptions.
name | The name of the attribute to erase. The name may be qualified. If it is qualified then the namespace parameter must be NULL. |
nspace | The namespace of the atrribute to erase:
|
Definition at line 336 of file attributes.cpp.
References column, count, xml::impl::find_prop(), xml::ns::get_uri(), xml::ns::is_safe(), xml::ns::is_void(), NULL, string, and xml::ns::unsafe_ns_.
xml::attributes::iterator xml::attributes::erase | ( | iterator | to_erase | ) |
Erase the attribute that is pointed to by the given iterator.
This will invalidate any iterators for this attribute, as well as any pointers or references to it.
to_erase | An iterator that points to the attribute to erased. |
Definition at line 314 of file attributes.cpp.
References xml::impl::ait_impl::get(), xml::attributes::attr::is_default(), next(), xml::attributes::iterator::pimpl_, xml::attributes::attr::prop_, and xml::attributes::attr::xmlnode_.
xml::attributes::iterator xml::attributes::find | ( | const char * | name, |
const ns * | nspace = NULL |
||
) |
Find the attribute with the given name and namespace.
If the attribute is not found on the current node, the DTD will be searched for a default value. This is, of course, if there was a DTD parsed with the XML document. If the search comes to DTD and the namespace is provided then the only namespace prefix is taken into account.
name | The name of the attribute to find. The name could be given as a qualified name, e.g. 'prefix:attr_name'. If the name is qualified then the nspace argument must be NULL (otherwise an exception is generated) and the attribute search is namespace aware with an effective namespace identified by the given prefix. |
nspace | The namespace of the atrribute to find:
|
Definition at line 288 of file attributes.cpp.
References xml::impl::find_default_prop(), xml::impl::find_prop(), and NULL.
xml::attributes::const_iterator xml::attributes::find | ( | const char * | name, |
const ns * | nspace = NULL |
||
) | const |
Find the attribute with the given name and namespace.
If the attribute is not found on the current node, the DTD will be searched for a default value. This is, of course, if there was a DTD parsed with the XML document. If the search comes to DTD and the namespace is provided then the only namespace prefix is taken into account.
name | The name of the attribute to find. The name could be given as a qualified name, e.g. 'prefix:attr_name'. If the name is qualified then the nspace argument must be NULL (otherwise an exception is generated) and the attribute search is namespace aware with an effective namespace identified by the given prefix. |
nspace | The namespace of the atrribute to find:
|
Definition at line 301 of file attributes.cpp.
References xml::impl::find_default_prop(), xml::impl::find_prop(), and NULL.
|
private |
Definition at line 140 of file attributes.cpp.
Definition at line 148 of file attributes.cpp.
References xml::ns::unsafe_ns_.
Referenced by xml::attributes::attr::set_namespace().
Add an attribute to the attributes list.
If there is another attribute with the same name, it will be replaced with this one.
name | The name of the attribute to add. The name could be qualified. If it is qualified then the namespace parameter must be NULL. |
value | The value of the attribute to add. |
nspace | The namespace of the atrribute to insert:
|
Throws | exceptions in case of problems. |
Definition at line 188 of file attributes.cpp.
References column, xml::ns::get_prefix(), xml::ns::get_uri(), xml::ns::is_safe(), xml::ns::is_void(), kInsertError, NULL, string, xml::ns::unsafe_ns_, and rapidjson::value.
Referenced by CTabDelimitedValidator::_ReportXML(), AddContact(), AddStructuredCommentToAttributes(), xml::node::convert_to_nset(), PrintBioseqXML(), CFormatGuessApp::Run(), s_AddSamplePair(), CGapStatsApplication::x_PrintHistogram(), CGapStatsApplication::x_PrintSeqsForGapLengths(), and CGapStatsApplication::x_PrintSummaryView().
xml::attributes & xml::attributes::operator= | ( | attributes && | other | ) |
Moving assignment.
other | The other attributes. |
Definition at line 130 of file attributes.cpp.
xml::attributes & xml::attributes::operator= | ( | const attributes & | other | ) |
Copy the given xml::attributes object into this one.
other | The xml::attributes object to copy from. |
Definition at line 109 of file attributes.cpp.
|
private |
Definition at line 152 of file attributes.cpp.
xml::attributes::size_type xml::attributes::size | ( | void | ) | const |
Find out how many attributes there are in this xml::attributes object.
Definition at line 417 of file attributes.cpp.
References count.
void xml::attributes::sort | ( | void | ) |
Sorts the attributes in place.
Definition at line 432 of file attributes.cpp.
void xml::attributes::swap | ( | attributes & | other | ) |
Swap this xml::attributes object with another one.
other | The other xml::attributes object to swap with. |
Definition at line 115 of file attributes.cpp.
References pimpl_, and swap().
Referenced by xml::attributes::attr::operator=().
|
friend |
Definition at line 563 of file attributes.hpp.
|
friend |
Definition at line 564 of file attributes.hpp.
Referenced by xml::attributes::attr::set_data().
|
private |
Definition at line 547 of file attributes.hpp.
Referenced by attributes(), operator=(), and swap().