#include <arcane/core/XmlNode.h>
Public Types | |
| enum | eType { ELEMENT = 1 , ATTRIBUTE = 2 , TEXT = 3 , CDATA_SECTION = 4 , ENTITY_REFERENCE = 5 , ENTITY = 6 , PROCESSING_INSTRUCTION = 7 , COMMENT = 8 , DOCUMENT = 9 , DOCUMENT_TYPE = 10 , DOCUMENT_FRAGMENT = 11 , NOTATION = 12 } |
| NodeType An integer indicating which type of node this is. More... | |
| typedef XmlNode | value_type |
| Type of the elements in the array. | |
| typedef XmlNodeIterator | iterator |
| Type of the iterator over an element in the array. | |
| typedef XmlNodeConstIterator | const_iterator |
| Type of the constant iterator over an element in the array. | |
| typedef value_type * | pointer |
| Type pointer of an element in the array. | |
| typedef const value_type * | const_pointer |
| Type constant pointer of an element in the array. | |
| typedef value_type & | reference |
| Type reference of an element in the array. | |
| typedef const value_type & | const_reference |
| Type constant reference of an element in the array. | |
| typedef Integer | size_type |
| Type indexing the array. | |
| typedef int | difference_type |
| Type of a distance between iterator elements in the array. | |
| typedef IterT< XmlNode > | iter |
| Type of an iterator over the entire array. | |
| typedef ConstIterT< XmlNode > | const_iter |
| Type of a constant iterator over the entire array. | |
Public Member Functions | |
| XmlNode (IRessourceMng *m, const dom::Node &node) | |
| XmlNode (IRessourceMng *m) | |
| iterator | begin () |
| Returns an iterator over the first element of the array. | |
| iterator | end () |
| Returns an iterator over the first element after the end of the array. | |
| const_iterator | begin () const |
| Returns a constant iterator over the first element of the array. | |
| const_iterator | end () const |
| Returns a constant iterator over the first element after the end of the array. | |
| eType | type () const |
| Node type. | |
| String | name () const |
| Node name. | |
| String | xpathFullName () const |
| XPath name of the node with its ancestors. | |
| bool | isNamed (const String &name) const |
| True if the element name is name. | |
| String | value () const |
| Node value. | |
| Integer | valueAsInteger (bool throw_exception=false) const |
| Node value converted to integer. | |
| Int64 | valueAsInt64 (bool throw_exception=false) const |
| Node value converted to 64-bit integer. 0 if conversion fails. | |
| bool | valueAsBoolean (bool throw_exception=false) const |
| Node value converted to boolean. | |
| Real | valueAsReal (bool throw_exception=false) const |
| Node value converted to real number. If conversion fails, if throw_exception is false returns 0.0, otherwise throws an exception. | |
| void | setValue (const String &value) |
| Sets the node value. | |
| String | attrValue (const String &name, bool throw_exception=false) const |
| Value of attribute name. | |
| void | setAttrValue (const String &name, const String &value) |
| Sets the attribute name to the value value. | |
| XmlNode | attr (const String &name, bool throw_exception=false) const |
| Returns the attribute of name name. | |
| XmlNode | forceAttr (const String &name) |
| Returns the attribute of name name. If no attribute with this name exists, an attribute with the null string as value is created and returned. | |
| void | removeAttr (const String &name) const |
| Removes the attribute of name name from this node. If this node is not an element, nothing is done. | |
| XmlNode | documentElement () const |
| Returns the document element. | |
| XmlNode | ownerElement () const |
| Returns the owning element of this attribute. | |
| void | clear () |
| Deletes all child nodes. | |
| XmlNode | child (const String &name) const |
| Child node of this node with name name. | |
| XmlNode | expectedChild (const String &name) const |
| Child node of this node with name name. | |
| XmlNodeList | children (const String &name) const |
| Set of child nodes of this node having the name name. | |
| XmlNodeList | children () const |
| Set of child nodes of this node. | |
| XmlNode | parent () const |
| Parent of this node (null if none). | |
| void | append (const XmlNode &child_node) |
| Adds child_node as a child of this node. | |
| void | remove (const XmlNode &child_node) |
| Removes the child node child_node. | |
| void | replace (const XmlNode &new_node, XmlNode &ref_node) |
| Replaces the child node ref_node with the node new_node. | |
| void | remove () |
| Removes this node from the document. | |
| XmlNode | front () const |
| First child. | |
| XmlNode | last () const |
| Last child. | |
| XmlNode | next () const |
| Next node (nextSibling()). | |
| XmlNode | prev () const |
| Previous node (previousSibling()). | |
| XmlNode | nextWithName (const String &name) const |
| Returns the next node after this node having the name name. | |
| XmlNode | prevWithName (const String &name) const |
| Returns the previous node before this node having the name name. | |
| XmlNode | nextSameType () const |
| Returns the next node of the same type. | |
| XmlNode | prevSameType () const |
| Returns the previous node of the same type. | |
| void | operator++ () |
| void | operator-- () |
| bool | null () const |
| True if the node is null. | |
| bool | operator! () const |
| dom::Node | domNode () const |
| void | assignDomNode (const dom::Node &node) |
| XmlNode | insertAfter (const XmlNode &new_child, const XmlNode &ref_node) |
Inserts a node. Inserts the node new_child after the node ref_node. If new_child is null, does nothing. If ref_node is null, new_child is added to the end (like append()). Otherwise, ref_node must be a child of this node and new_child is inserted after ref_node. On success, returns the added node (new_child), otherwise the null node. | |
| XmlNode | childWithAttr (const String &elem_name, const String &attr_name, const String &attr_value) const |
| Returns the child of this node having the name elem_name and an attribute of name attr_name with value attr_value. | |
| XmlNode | childWithNameAttr (const String &elem_name, const String &attr_value) const |
Returns the child of this node having the name elem_name and an attribute of name "name" with value attr_value. | |
| XmlNode | xpathNode (const String &xpath_expr) const |
| Returns a node from an XPath expression. | |
| XmlNode | createNode (eType type, const String &name, const String &value) |
| Creates a node of a given type. | |
| XmlNode | createNode (eType type, const String &name_or_value) |
| Creates a node of a given type. | |
| XmlNode | createText (const String &value) |
| Creates a text node. | |
| XmlNode | createElement (const String &name) |
| XmlNode | createAndAppendElement (const String &name) |
| XmlNode | createAndAppendElement (const String &name, const String &value) |
| XmlNode | ownerDocument () const |
| IRessourceMng * | rm () const |
Protected Member Functions | |
| String | _value () const |
| XmlNode | _build (const dom::Node &node) const |
| XmlNode | _nullNode () const |
| void | _setNode (const dom::Node &n) |
| void | _throwBadConvert (const char *type_name, const String &value) const |
Node of a DOM tree.
This class is used for all types of DOM nodes and allows them to be manipulated more simply than with the DOM without having to perform type conversions.
Each node can be considered a container in the sense of the STL.
| typedef ConstIterT<XmlNode> Arcane::XmlNode::const_iter |
| typedef const value_type* Arcane::XmlNode::const_pointer |
| typedef const value_type& Arcane::XmlNode::const_reference |
| typedef int Arcane::XmlNode::difference_type |
| typedef IterT<XmlNode> Arcane::XmlNode::iter |
| typedef value_type* Arcane::XmlNode::pointer |
| typedef value_type& Arcane::XmlNode::reference |
| typedef Integer Arcane::XmlNode::size_type |
| typedef XmlNode Arcane::XmlNode::value_type |
NodeType An integer indicating which type of node this is.
|
inline |
|
inlineexplicit |
|
protected |
Definition at line 678 of file XmlNode.cc.
|
protected |
Definition at line 63 of file XmlNode.cc.
|
inlineprotected |
|
inlineprotected |
Definition at line 410 of file XmlNode.cc.
|
protected |
Definition at line 526 of file XmlNode.cc.
|
inline |
Adds child_node as a child of this node.
The node is added after all children.
Definition at line 276 of file XmlNode.h.
Referenced by insertAfter().
| void Arcane::XmlNode::assignDomNode | ( | const dom::Node & | node | ) |
Definition at line 537 of file XmlNode.cc.
| XmlNode Arcane::XmlNode::attr | ( | const String & | name, |
| bool | throw_exception = false ) const |
Returns the attribute of name name.
If the attribute does not exist, if throw_exception is false returns a null node, otherwise throws an exception.
Definition at line 256 of file XmlNode.cc.
References ARCANE_THROW, name(), null(), and xpathFullName().
Referenced by forceAttr(), Arcane::Hdf5VariableReaderHelper2::open(), Arcane::Hdf5VariableReaderHelper::open(), and ownerElement().
Value of attribute name.
If the attribute does not exist, if throw_exception is false returns the null string, otherwise throws an exception.
Definition at line 233 of file XmlNode.cc.
References ARCANE_THROW, name(), Arcane::String::null(), and xpathFullName().
Referenced by Arcane::Hdf5VariableReaderHelper::open(), and Arcane::CaseOptions::read().
|
inline |
Returns an iterator over the first element of the array.
Definition at line 100 of file XmlNodeIterator.h.
Referenced by Arcane::XmlElementContentChecker::check(), child(), children(), and children().
|
inline |
Returns a constant iterator over the first element of the array.
Definition at line 112 of file XmlNodeIterator.h.
| XmlNode Arcane::XmlNode::child | ( | const String & | name | ) | const |
Child node of this node with name name.
If multiple nodes with this name exist, returns the first one. If the node is not found, returns a null node
Definition at line 72 of file XmlNode.cc.
References begin(), and end().
Referenced by expectedChild(), and remove().
| XmlNodeList Arcane::XmlNode::children | ( | ) | const |
Set of child nodes of this node.
Definition at line 117 of file XmlNode.cc.
References Arcane::Array< T >::add(), begin(), and end().
| XmlNodeList Arcane::XmlNode::children | ( | const String & | name | ) | const |
Set of child nodes of this node having the name name.
Definition at line 101 of file XmlNode.cc.
References Arcane::Array< T >::add(), begin(), and end().
Referenced by Arcane::CaseOptionMultiExtended::_search(), Arcane::Hdf5VariableReaderHelper2::open(), and Arcane::Hdf5VariableReaderHelper::open().
| XmlNode Arcane::XmlNode::childWithAttr | ( | const String & | elem_name, |
| const String & | attr_name, | ||
| const String & | attr_value ) const |
Returns the child of this node having the name elem_name and an attribute of name attr_name with value attr_value.
Definition at line 488 of file XmlNode.cc.
References name(), and null().
Referenced by childWithNameAttr().
| XmlNode Arcane::XmlNode::childWithNameAttr | ( | const String & | elem_name, |
| const String & | attr_value ) const |
Returns the child of this node having the name elem_name and an attribute of name "name" with value attr_value.
Definition at line 508 of file XmlNode.cc.
References childWithAttr().
| void Arcane::XmlNode::clear | ( | ) |
Deletes all child nodes.
Definition at line 301 of file XmlNode.cc.
| XmlNode Arcane::XmlNode::createAndAppendElement | ( | const String & | name | ) |
Definition at line 608 of file XmlNode.cc.
Definition at line 597 of file XmlNode.cc.
| XmlNode Arcane::XmlNode::createElement | ( | const String & | name | ) |
Definition at line 588 of file XmlNode.cc.
Creates a node of a given type.
If type() is not DOCUMENT_NODE, it uses ownerDocument() as factory.
Definition at line 653 of file XmlNode.cc.
References ARCANE_THROW, ELEMENT, name(), setValue(), TEXT, type(), and value().
Referenced by createText().
Creates a node of a given type.
If type() is not DOCUMENT_NODE, it uses ownerDocument() as factory.
Definition at line 619 of file XmlNode.cc.
References ARCANE_THROW, ELEMENT, TEXT, and type().
| XmlNode Arcane::XmlNode::createText | ( | const String & | value | ) |
Creates a text node.
| value | value of the text node. |
Definition at line 644 of file XmlNode.cc.
References createNode(), TEXT, and value().
| XmlNode Arcane::XmlNode::documentElement | ( | ) | const |
Returns the document element.
Definition at line 564 of file XmlNode.cc.
Referenced by Arcane::Hdf5VariableReaderHelper2::open(), and Arcane::Hdf5VariableReaderHelper::open().
|
inline |
Returns an iterator over the first element after the end of the array.
Definition at line 106 of file XmlNodeIterator.h.
Referenced by Arcane::XmlElementContentChecker::check(), child(), children(), and children().
|
inline |
Returns a constant iterator over the first element after the end of the array.
Definition at line 118 of file XmlNodeIterator.h.
| XmlNode Arcane::XmlNode::expectedChild | ( | const String & | name | ) | const |
Child node of this node with name name.
If multiple nodes with this name exist, returns the first one. If the node is not found, throws an exception.
Definition at line 87 of file XmlNode.cc.
References ARCANE_FATAL, child(), null(), and xpathFullName().
| XmlNode Arcane::XmlNode::forceAttr | ( | const String & | name | ) |
Returns the attribute of name name. If no attribute with this name exists, an attribute with the null string as value is created and returned.
Definition at line 274 of file XmlNode.cc.
|
inline |
| XmlNode Arcane::XmlNode::insertAfter | ( | const XmlNode & | new_child, |
| const XmlNode & | ref_node ) |
Inserts a node. Inserts the node new_child after the node ref_node. If new_child is null, does nothing. If ref_node is null, new_child is added to the end (like append()). Otherwise, ref_node must be a child of this node and new_child is inserted after ref_node. On success, returns the added node (new_child), otherwise the null node.
Definition at line 546 of file XmlNode.cc.
| bool Arcane::XmlNode::isNamed | ( | const String & | name | ) | const |
True if the element name is name.
Definition at line 198 of file XmlNode.cc.
References name().
Referenced by nextWithName(), and prevWithName().
|
inline |
| String Arcane::XmlNode::name | ( | ) | const |
Node name.
Definition at line 140 of file XmlNode.cc.
Referenced by attr(), attrValue(), childWithAttr(), createNode(), forceAttr(), isNamed(), nextWithName(), prevWithName(), removeAttr(), setAttrValue(), Arcane::XmlElement::XmlElement(), Arcane::XmlElement::XmlElement(), and xpathFullName().
|
inline |
Next node (nextSibling()).
Definition at line 288 of file XmlNode.h.
Referenced by insertAfter(), nextSameType(), and nextWithName().
| XmlNode Arcane::XmlNode::nextSameType | ( | ) | const |
Returns the next node of the same type.
Definition at line 369 of file XmlNode.cc.
| XmlNode Arcane::XmlNode::nextWithName | ( | const String & | name | ) | const |
|
inline |
True if the node is null.
Definition at line 303 of file XmlNode.h.
Referenced by Arcane::CaseOptionMultiExtended::_search(), Arcane::CaseOptionMultiSimpleT< T >::_search(), attr(), childWithAttr(), clear(), expectedChild(), insertAfter(), nextSameType(), nextWithName(), prevSameType(), prevWithName(), replace(), value(), valueAsBoolean(), valueAsInt64(), valueAsInteger(), valueAsReal(), and xpathFullName().
| XmlNode Arcane::XmlNode::ownerElement | ( | ) | const |
Returns the owning element of this attribute.
Definition at line 576 of file XmlNode.cc.
References attr().
Referenced by xpathFullName().
|
inline |
Parent of this node (null if none).
Definition at line 270 of file XmlNode.h.
Referenced by remove(), Arcane::XmlElement::XmlElement(), Arcane::XmlElement::XmlElement(), and xpathFullName().
|
inline |
Previous node (previousSibling()).
Definition at line 290 of file XmlNode.h.
Referenced by prevSameType(), and prevWithName().
| XmlNode Arcane::XmlNode::prevSameType | ( | ) | const |
Returns the previous node of the same type.
Definition at line 384 of file XmlNode.cc.
| XmlNode Arcane::XmlNode::prevWithName | ( | const String & | name | ) | const |
| void Arcane::XmlNode::remove | ( | ) |
Removes this node from the document.
Definition at line 315 of file XmlNode.cc.
References parent().
Referenced by clear().
| void Arcane::XmlNode::remove | ( | const XmlNode & | child_node | ) |
| void Arcane::XmlNode::removeAttr | ( | const String & | name | ) | const |
Removes the attribute of name name from this node. If this node is not an element, nothing is done.
Definition at line 291 of file XmlNode.cc.
References name().
| void Arcane::XmlNode::replace | ( | const XmlNode & | new_node, |
| XmlNode & | ref_node ) |
Replaces the child node ref_node with the node new_node.
Definition at line 399 of file XmlNode.cc.
References null().
|
inline |
Sets the attribute name to the value value.
Definition at line 247 of file XmlNode.cc.
References name(), and value().
Referenced by Arcane::UnitTestServiceAdapter< T >::executeTest(), and Arcane::ManualHdf5VariableWriter::notifyEndWrite().
| void Arcane::XmlNode::setValue | ( | const String & | value | ) |
Sets the node value.
This method is only valid for ELEMENT_NODE or ATTRIBUTE_NODE. For elements, it deletes all children and adds a single TEXT_NODE child containing the value value
Definition at line 218 of file XmlNode.cc.
References Arcane::dom::Node::ELEMENT_NODE.
Referenced by createNode().
| XmlNode::eType Arcane::XmlNode::type | ( | ) | const |
Node type.
Definition at line 131 of file XmlNode.cc.
Referenced by Arcane::XmlElementContentChecker::check(), createNode(), createNode(), nextSameType(), and prevSameType().
| String Arcane::XmlNode::value | ( | ) | const |
Node value.
For an element, it is the concatenation of the values of each of its child nodes of type TEXT, CDATA_SECTION or ENTITY_REFERENCE. For nodes other than elements, it is the value of the Node::nodeValue() method of the DOM.
Definition at line 207 of file XmlNode.cc.
References null().
Referenced by Arcane::CaseOptionMultiExtended::_search(), Arcane::CaseOptionMultiSimpleT< T >::_search(), Arcane::XmlElementContentChecker::check(), createNode(), createText(), setAttrValue(), valueAsBoolean(), valueAsInt64(), valueAsInteger(), valueAsReal(), and Arcane::XmlElement::XmlElement().
| bool Arcane::XmlNode::valueAsBoolean | ( | bool | throw_exception = false | ) | const |
Node value converted to boolean.
A value of false or 0 corresponds to false. A value of true or 1 corresponds to true. If conversion fails, if throw_exception is false returns false, otherwise throws an exception.
Definition at line 420 of file XmlNode.cc.
References ARCANE_THROW, null(), value(), and xpathFullName().
| Int64 Arcane::XmlNode::valueAsInt64 | ( | bool | throw_exception = false | ) | const |
Node value converted to 64-bit integer. 0 if conversion fails.
If conversion fails, if throw_exception is false returns 0, otherwise throws an exception.
Definition at line 456 of file XmlNode.cc.
| Integer Arcane::XmlNode::valueAsInteger | ( | bool | throw_exception = false | ) | const |
Node value converted to integer.
If conversion fails, if throw_exception is false returns 0, otherwise throws an exception.
Definition at line 440 of file XmlNode.cc.
| Real Arcane::XmlNode::valueAsReal | ( | bool | throw_exception = false | ) | const |
Node value converted to real number. If conversion fails, if throw_exception is false returns 0.0, otherwise throws an exception.
Definition at line 472 of file XmlNode.cc.
References null(), and value().
Referenced by Arcane::Hdf5VariableReaderHelper2::open(), and Arcane::Hdf5VariableReaderHelper::open().
| String Arcane::XmlNode::xpathFullName | ( | ) | const |
XPath name of the node with its ancestors.
Definition at line 151 of file XmlNode.cc.
References Arcane::StringBuilder::append(), Arcane::dom::Node::ATTRIBUTE_NODE, Arcane::dom::Node::ELEMENT_NODE, front(), name(), null(), ownerElement(), parent(), and xpathFullName().
Referenced by Arcane::CaseOptionError::addInvalidTypeError(), Arcane::CaseOptionError::addInvalidTypeError(), Arcane::CaseOptionError::addOptionNotFoundError(), attr(), attrValue(), Arcane::XmlElementContentChecker::check(), expectedChild(), Arcane::Hdf5VariableReaderHelper2::open(), Arcane::Hdf5VariableReaderHelper::open(), Arcane::CaseOptions::read(), valueAsBoolean(), and xpathFullName().
| XmlNode Arcane::XmlNode::xpathNode | ( | const String & | xpath_expr | ) | const |
Returns a node from an XPath expression.
| xpath_expr | XPath expression. |
Definition at line 517 of file XmlNode.cc.