ITK  4.3.0
Insight Segmentation and Registration Toolkit
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
itk::DOMNode Class Reference

#include <itkDOMNode.h>

+ Inheritance diagram for itk::DOMNode:
+ Collaboration diagram for itk::DOMNode:

Detailed Description

Class to represent a node in a Document Object Model (DOM) tree structure.

A DOM is a structured document representation, in our case parsed from an XML stream (i.e. a file or a string). It is a tree structure in which each node has links to its children nodes and to its parent node (if it is not the root). This class serves as a base node corresponding to an XML tag that only contains attributes (no content for the tag itself).

Note
We reserve the use of the attribute "id" (all combinations of upper and lower case) for uniquely identifying an XML structure among its siblings. That is, we assume that this tag is unique among all siblings in an XML tree structure. If it is not unique, the user may not be able to correctly retrieve a node by function GetChildByID(), or to search for a node using Find() with a query string that is based on "id".

Definition at line 52 of file itkDOMNode.h.

Public Types

typedef std::pair< const
AttributeKeyType,
AttributeValueType
AttributeItemType
 
typedef std::string AttributeKeyType
 
typedef std::list
< AttributeItemType
AttributesListType
 
typedef std::string AttributeValueType
 
typedef std::vector< DOMNode * > ChildrenListType
 
typedef std::vector< const
DOMNode * > 
ConstChildrenListType
 
typedef SmartPointer< const SelfConstPointer
 
typedef int IdentifierType
 
typedef int OffsetType
 
typedef SmartPointer< SelfPointer
 
typedef DOMNode Self
 
typedef std::vcl_size_t SizeType
 
typedef Object Superclass
 
- Public Types inherited from itk::Object
typedef SmartPointer< const SelfConstPointer
 
typedef SmartPointer< SelfPointer
 
typedef Object Self
 
typedef LightObject Superclass
 
- Public Types inherited from itk::LightObject
typedef SmartPointer< const SelfConstPointer
 
typedef SmartPointer< SelfPointer
 
typedef LightObject Self
 

Public Member Functions

virtual void AddChild (DOMNode *node, IdentifierType i=0)
 
virtual void AddChildAtBegin (DOMNode *node)
 
virtual void AddChildAtEnd (DOMNode *node)
 
virtual void AddTextChild (const std::string &text, IdentifierType i=0)
 
virtual void AddTextChildAtBegin (const std::string &text)
 
virtual void AddTextChildAtEnd (const std::string &text)
 
virtual ::itk::LightObject::Pointer CreateAnother (void) const
 
virtual void GetAllAttributes (AttributesListType &output, bool keepOriginalOrder=true) const
 
virtual void GetAllChildren (ChildrenListType &output)
 
virtual void GetAllChildren (ConstChildrenListType &output) const
 
virtual std::string GetAttribute (const std::string &key) const
 
virtual void GetChildren (const std::string &tag, ChildrenListType &output)
 
virtual void GetChildren (const std::string &tag, ConstChildrenListType &output) const
 
virtual const char * GetNameOfClass () const
 
virtual SizeType GetNumberOfChildren () const
 
virtual std::string GetPath () const
 
virtual bool HasAttribute (const std::string &key) const
 
virtual void RemoveAllAttributes ()
 
virtual void RemoveAllAttributesAndChildren ()
 
virtual void RemoveAllChildren ()
 
virtual void RemoveAttribute (const std::string &key)
 
virtual void RemoveChild (IdentifierType i=0)
 
virtual void SetAttribute (const std::string &key, const std::string &value)
 
virtual void SetChild (DOMNode *node, IdentifierType i=0)
 
virtual void SetTextChild (const std::string &text, IdentifierType i=0)
 
virtual bool ShareRoot (const DOMNode *node) const
 
virtual void SetParent (DOMNode *node)
 
DOMNodeGetParent ()
 
const DOMNodeGetParent () const
 
virtual void SetName (std::string &_arg)
 
virtual const std::string & GetName ()
 
virtual void SetID (std::string &_arg)
 
virtual const std::string & GetID ()
 
virtual DOMNodeGetChild (IdentifierType i=0)
 
virtual const DOMNodeGetChild (IdentifierType i=0) const
 
virtual DOMNodeGetChild (const std::string &tag, IdentifierType i=0)
 
virtual const DOMNodeGetChild (const std::string &tag, IdentifierType i=0) const
 
virtual DOMNodeGetChildByID (const std::string &value)
 
virtual const DOMNodeGetChildByID (const std::string &value) const
 
virtual DOMNodeGetSibling (OffsetType i)
 
virtual const DOMNodeGetSibling (OffsetType i) const
 
virtual DOMNodeGetRoot ()
 
virtual const DOMNodeGetRoot () const
 
virtual DOMNodeFind (const std::string &path)
 
virtual const DOMNodeFind (const std::string &path) const
 
virtual DOMTextNodeGetTextChild (IdentifierType i=0)
 
virtual const DOMTextNodeGetTextChild (IdentifierType i=0) const
 
- Public Member Functions inherited from itk::Object
unsigned long AddObserver (const EventObject &event, Command *)
 
unsigned long AddObserver (const EventObject &event, Command *) const
 
virtual void DebugOff () const
 
virtual void DebugOn () const
 
CommandGetCommand (unsigned long tag)
 
bool GetDebug () const
 
MetaDataDictionaryGetMetaDataDictionary (void)
 
const MetaDataDictionaryGetMetaDataDictionary (void) const
 
virtual ModifiedTimeType GetMTime () const
 
virtual const TimeStampGetTimeStamp () const
 
bool HasObserver (const EventObject &event) const
 
void InvokeEvent (const EventObject &)
 
void InvokeEvent (const EventObject &) const
 
virtual void Modified () const
 
virtual void Register () const
 
void RemoveAllObservers ()
 
void RemoveObserver (unsigned long tag)
 
void SetDebug (bool debugFlag) const
 
void SetMetaDataDictionary (const MetaDataDictionary &rhs)
 
virtual void SetReferenceCount (int)
 
virtual void UnRegister () const
 
- Public Member Functions inherited from itk::LightObject
virtual void Delete ()
 
virtual int GetReferenceCount () const
 
 itkCloneMacro (Self)
 
void Print (std::ostream &os, Indent indent=0) const
 

Static Public Member Functions

static Pointer New ()
 
- Static Public Member Functions inherited from itk::Object
static bool GetGlobalWarningDisplay ()
 
static void GlobalWarningDisplayOff ()
 
static void GlobalWarningDisplayOn ()
 
static Pointer New ()
 
static void SetGlobalWarningDisplay (bool flag)
 
- Static Public Member Functions inherited from itk::LightObject
static void BreakOnError ()
 
static Pointer New ()
 

Protected Member Functions

 DOMNode ()
 
- Protected Member Functions inherited from itk::Object
 Object ()
 
bool PrintObservers (std::ostream &os, Indent indent) const
 
virtual void PrintSelf (std::ostream &os, Indent indent) const
 
virtual void SetTimeStamp (const TimeStamp &time)
 
virtual ~Object ()
 
- Protected Member Functions inherited from itk::LightObject
virtual LightObject::Pointer InternalClone () const
 
 LightObject ()
 
virtual void PrintHeader (std::ostream &os, Indent indent) const
 
virtual void PrintTrailer (std::ostream &os, Indent indent) const
 
virtual ~LightObject ()
 

Private Types

typedef std::map
< AttributeKeyType,
AttributeValueType
AttributesContainer
 
typedef std::vector< PointerChildrenContainer
 
typedef std::list
< AttributeItemType * > 
OrderedAttributesContainer
 

Private Member Functions

 DOMNode (const Self &)
 
void operator= (const Self &)
 

Private Attributes

AttributesContainer m_Attributes
 
ChildrenContainer m_Children
 
std::string m_ID
 
std::string m_Name
 
OrderedAttributesContainer m_OrderedAttributes
 
DOMNodem_Parent
 

Additional Inherited Members

- Protected Types inherited from itk::LightObject
typedef int InternalReferenceCountType
 
- Protected Attributes inherited from itk::LightObject
InternalReferenceCountType m_ReferenceCount
 
SimpleFastMutexLock m_ReferenceCountLock
 

Member Typedef Documentation

Definition at line 76 of file itkDOMNode.h.

typedef std::string itk::DOMNode::AttributeKeyType

An attribute is a pair of <key,value>, both key and value are strings.

Definition at line 73 of file itkDOMNode.h.

Internally the attributes are stored in a map.

Definition at line 245 of file itkDOMNode.h.

Container to return the attributes of a DOM node.

Definition at line 79 of file itkDOMNode.h.

typedef std::string itk::DOMNode::AttributeValueType

Definition at line 74 of file itkDOMNode.h.

typedef std::vector<Pointer> itk::DOMNode::ChildrenContainer
private

Internally the children are stored in a vector.

Definition at line 241 of file itkDOMNode.h.

typedef std::vector<DOMNode*> itk::DOMNode::ChildrenListType

Container to return all or a subset of the children of a DOM node.

Definition at line 66 of file itkDOMNode.h.

typedef std::vector<const DOMNode*> itk::DOMNode::ConstChildrenListType

Definition at line 70 of file itkDOMNode.h.

Definition at line 60 of file itkDOMNode.h.

Definition at line 82 of file itkDOMNode.h.

Definition at line 83 of file itkDOMNode.h.

Container to keep the inserting orders of the attributes.

Definition at line 249 of file itkDOMNode.h.

Definition at line 59 of file itkDOMNode.h.

Standard class typedefs.

Definition at line 57 of file itkDOMNode.h.

typedef std::vcl_size_t itk::DOMNode::SizeType

Definition at line 81 of file itkDOMNode.h.

Definition at line 58 of file itkDOMNode.h.

Constructor & Destructor Documentation

itk::DOMNode::DOMNode ( )
protected
itk::DOMNode::DOMNode ( const Self )
private

Member Function Documentation

virtual void itk::DOMNode::AddChild ( DOMNode node,
IdentifierType  i = 0 
)
virtual

Add a child in front of another child (throw exception if not able to add).

virtual void itk::DOMNode::AddChildAtBegin ( DOMNode node)
virtual

Add a child in front of the children list (throw exception if not able to add).

virtual void itk::DOMNode::AddChildAtEnd ( DOMNode node)
virtual

Add a child at the end of the children list (throw exception if not able to add).

virtual void itk::DOMNode::AddTextChild ( const std::string &  text,
IdentifierType  i = 0 
)
virtual

Generate a text node from a string and add/insert it as a child (see AddChild(node,i)).

virtual void itk::DOMNode::AddTextChildAtBegin ( const std::string &  text)
virtual

Generate a text node from a string and add/insert in front of all children.

virtual void itk::DOMNode::AddTextChildAtEnd ( const std::string &  text)
virtual

Generate a text node from a string and add/insert at the end of all children.

virtual::itk::LightObject::Pointer itk::DOMNode::CreateAnother ( void  ) const
virtual

Create an object from an instance, potentially deferring to a factory. This method allows you to create an instance of an object that is exactly the same type as the referring object. This is useful in cases where an object has been cast back to a base class.

Reimplemented from itk::Object.

Reimplemented in itk::DOMTextNode.

virtual DOMNode* itk::DOMNode::Find ( const std::string &  path)
virtual

The following function finds a child or sibling or relative using a query string or path. A path or QueryString consists of multiple following items that are separated by '/':

*     -[n]           : an older sibling by distance 1 (when omitted) or n;
*     +[n]           : a younger sibling by distance 1 (when omitted) or n;
*     n              : a child at index n;
*     <tag>[:n]      : a child at index 0 (when omitted) or n after filtering children with a tag name;
*     ![:n]          : a child at index 0 (when omitted) or n within all text children;
*     :<id>          : a child by id;
*     .              : current node;
*     ..             : parent node;
*     /<rpath>       : absolute path (denote apath), search from the root.
* 

The method returns NULL if queried node does not exist.

virtual const DOMNode* itk::DOMNode::Find ( const std::string &  path) const
virtual

The following function finds a child or sibling or relative using a query string or path. A path or QueryString consists of multiple following items that are separated by '/':

*     -[n]           : an older sibling by distance 1 (when omitted) or n;
*     +[n]           : a younger sibling by distance 1 (when omitted) or n;
*     n              : a child at index n;
*     <tag>[:n]      : a child at index 0 (when omitted) or n after filtering children with a tag name;
*     ![:n]          : a child at index 0 (when omitted) or n within all text children;
*     :<id>          : a child by id;
*     .              : current node;
*     ..             : parent node;
*     /<rpath>       : absolute path (denote apath), search from the root.
* 

The method returns NULL if queried node does not exist.

virtual void itk::DOMNode::GetAllAttributes ( AttributesListType output,
bool  keepOriginalOrder = true 
) const
virtual

Return all attributes, in the order of being parsed or added (default), or alphabetic order of the attribute keys (keepOriginalOrder = false).

virtual void itk::DOMNode::GetAllChildren ( ChildrenListType output)
virtual

Return all children.

virtual void itk::DOMNode::GetAllChildren ( ConstChildrenListType output) const
virtual

Return all children for read-only access.

virtual std::string itk::DOMNode::GetAttribute ( const std::string &  key) const
virtual

Retrieve an attribute by key (return an empty string if not found).

virtual DOMNode* itk::DOMNode::GetChild ( IdentifierType  i = 0)
virtual

Retrieve a child by index (return NULL if i is out of range).

virtual const DOMNode* itk::DOMNode::GetChild ( IdentifierType  i = 0) const
virtual

Retrieve a child by index (return NULL if i is out of range).

virtual DOMNode* itk::DOMNode::GetChild ( const std::string &  tag,
IdentifierType  i = 0 
)
virtual

Retrieve a child by tag name and an index (multiple children can have a same tag name, return NULL if no such child).

virtual const DOMNode* itk::DOMNode::GetChild ( const std::string &  tag,
IdentifierType  i = 0 
) const
virtual

Retrieve a child by tag name and an index (multiple children can have a same tag name, return NULL if no such child).

virtual DOMNode* itk::DOMNode::GetChildByID ( const std::string &  value)
virtual

Retrieve a child by its unique "id" attribute value (return NULL if not found).

virtual const DOMNode* itk::DOMNode::GetChildByID ( const std::string &  value) const
virtual

Retrieve a child by its unique "id" attribute value (return NULL if not found).

virtual void itk::DOMNode::GetChildren ( const std::string &  tag,
ChildrenListType output 
)
virtual

Return all children of a same tag name.

virtual void itk::DOMNode::GetChildren ( const std::string &  tag,
ConstChildrenListType output 
) const
virtual

Return all children of a same tag name for read-only access.

virtual const std::string& itk::DOMNode::GetID ( )
virtual

Retrieve the special attribute "id" of this node.

virtual const std::string& itk::DOMNode::GetName ( )
virtual

Retrieve the tag name of this node.

virtual const char* itk::DOMNode::GetNameOfClass ( ) const
virtual

Run-time type information (and related methods).

Reimplemented from itk::Object.

Reimplemented in itk::DOMTextNode.

virtual SizeType itk::DOMNode::GetNumberOfChildren ( ) const
virtual

Get number of children.

DOMNode* itk::DOMNode::GetParent ( )

Retrieve the parent node.

const DOMNode* itk::DOMNode::GetParent ( ) const

Retrieve the parent node.

virtual std::string itk::DOMNode::GetPath ( ) const
virtual

Return the path of this node within its root, in the form of a query string that uses only indices.

virtual DOMNode* itk::DOMNode::GetRoot ( )
virtual

Return the root node.

virtual const DOMNode* itk::DOMNode::GetRoot ( ) const
virtual

Return the root node.

virtual DOMNode* itk::DOMNode::GetSibling ( OffsetType  i)
virtual

Retrieve an older or younger sibling by distance (return NULL if no such sibling).

virtual const DOMNode* itk::DOMNode::GetSibling ( OffsetType  i) const
virtual

Retrieve an older or younger sibling by distance (return NULL if no such sibling).

virtual DOMTextNode* itk::DOMNode::GetTextChild ( IdentifierType  i = 0)
virtual

Get a child and cast it to a text node (return NULL if out of range or not a text node).

virtual const DOMTextNode* itk::DOMNode::GetTextChild ( IdentifierType  i = 0) const
virtual

Get a child and cast it to a text node (return NULL if out of range or not a text node).

virtual bool itk::DOMNode::HasAttribute ( const std::string &  key) const
virtual

Check whether has an attribute.

static Pointer itk::DOMNode::New ( )
static

Method for creation through the object factory.

void itk::DOMNode::operator= ( const Self )
private
virtual void itk::DOMNode::RemoveAllAttributes ( )
virtual

Remove all attributes.

virtual void itk::DOMNode::RemoveAllAttributesAndChildren ( )
virtual

Remove all attributes and children.

virtual void itk::DOMNode::RemoveAllChildren ( )
virtual

Remove all children.

virtual void itk::DOMNode::RemoveAttribute ( const std::string &  key)
virtual

Remove an attribute by key (throw exception if not found).

virtual void itk::DOMNode::RemoveChild ( IdentifierType  i = 0)
virtual

Remove a child by index (throw exception if not able to remove).

virtual void itk::DOMNode::SetAttribute ( const std::string &  key,
const std::string &  value 
)
virtual

Add or replace an attribute.

virtual void itk::DOMNode::SetChild ( DOMNode node,
IdentifierType  i = 0 
)
virtual

Replace a child (throw exception if not able to replace).

virtual void itk::DOMNode::SetID ( std::string &  _arg)
virtual

Retrieve the special attribute "id" of this node.

virtual void itk::DOMNode::SetName ( std::string &  _arg)
virtual

Retrieve the tag name of this node.

Referenced by itk::DOMTextNode::DOMTextNode().

virtual void itk::DOMNode::SetParent ( DOMNode node)
virtual

Retrieve the parent node.

virtual void itk::DOMNode::SetTextChild ( const std::string &  text,
IdentifierType  i = 0 
)
virtual

Generate a text node from a string and replace a child with it (see SetChild(node,i).

virtual bool itk::DOMNode::ShareRoot ( const DOMNode node) const
virtual

Test whether the input node and this node share the same root.

Member Data Documentation

AttributesContainer itk::DOMNode::m_Attributes
private

Definition at line 246 of file itkDOMNode.h.

ChildrenContainer itk::DOMNode::m_Children
private

Definition at line 242 of file itkDOMNode.h.

std::string itk::DOMNode::m_ID
private

The special attribute "id" of this node.

Definition at line 238 of file itkDOMNode.h.

std::string itk::DOMNode::m_Name
private

The XML tag of this node.

Definition at line 235 of file itkDOMNode.h.

OrderedAttributesContainer itk::DOMNode::m_OrderedAttributes
private

Definition at line 250 of file itkDOMNode.h.

DOMNode* itk::DOMNode::m_Parent
private

The parent node that this node was placed into.

Definition at line 232 of file itkDOMNode.h.


The documentation for this class was generated from the following file: