XMLTag Class Reference

#include <XMLTag.hpp>

Collaboration diagram for XMLTag:

Collaboration graph
[legend]

List of all members.

Public Member Functions

ReferenceCounting< XMLAttributefindAttribute (const std::string &name, const std::string &defaultValue="") const
void close (const std::string &name)
void add (ReferenceCounting< XMLAttribute > xmlAttribute)
void add (ReferenceCounting< XMLContentBase > xmlContent)
ReferenceCounting< XMLContentBasecontent ()
ConstReferenceCounting
< XMLContentBase
content () const
const std::string & name () const
 XMLTag (const std::string &name)

Private Types

typedef std::map< std::string,
ReferenceCounting
< XMLAttribute > > 
AttributeList

Private Attributes

const std::string __name
AttributeList __attributes
ReferenceCounting< XMLContentBase__content

Friends

std::ostream & operator<< (std::ostream &os, const XMLTag &xmlTag)


Detailed Description

Definition at line 42 of file XMLTag.hpp.


Member Typedef Documentation

typedef std::map<std::string, ReferenceCounting<XMLAttribute> > XMLTag::AttributeList [private]

Definition at line 46 of file XMLTag.hpp.


Constructor & Destructor Documentation

XMLTag::XMLTag ( const std::string &  name  )  [inline]

Constructor

Parameters:
name name of the tag to build

Definition at line 183 of file XMLTag.hpp.

00184     : __name(name),
00185       __content(0)
00186   {
00187     ;
00188   }


Member Function Documentation

ReferenceCounting<XMLAttribute> XMLTag::findAttribute ( const std::string &  name,
const std::string &  defaultValue = "" 
) const [inline]

Looks for an attribute according to its name

Parameters:
name name of the attribute
defaultValue value to use if attribute is not found
Returns:
a pointer to the attribute

Definition at line 66 of file XMLTag.hpp.

References __attributes, ErrorHandler::normal, and stringify().

00068   {
00069     AttributeList::const_iterator attribute = __attributes.find(name);
00070     if (attribute == __attributes.end()) {
00071       if (defaultValue.size() == 0) {
00072         throw ErrorHandler(__FILE__,__LINE__,
00073                            "cannot find mandatory attribute '"+name+"' into <"+stringify(*this)+">",
00074                            ErrorHandler::normal);
00075       } else {
00076         return new XMLAttribute(name,defaultValue);
00077       }
00078     }
00079 
00080     return attribute->second;
00081   }

Here is the call graph for this function:

void XMLTag::close ( const std::string &  name  )  [inline]

Closes a tag checking that the closure fits the opening

Parameters:
name closed tag name

Definition at line 108 of file XMLTag.hpp.

References __name, and ErrorHandler::normal.

00109   {
00110     if (__name != name) {
00111       throw ErrorHandler(__FILE__,__LINE__,
00112                          "tag <"+__name+"> closed by </"+name+">",
00113                          ErrorHandler::normal);
00114     }
00115   }

void XMLTag::add ( ReferenceCounting< XMLAttribute xmlAttribute  )  [inline]

Adds an attribute to a tag

Parameters:
xmlAttribute given attribute

Definition at line 122 of file XMLTag.hpp.

References __attributes, __name, and ErrorHandler::normal.

Referenced by WriterVTK::__proceed().

00123   {
00124     if (__attributes.find(xmlAttribute->name()) != __attributes.end()) {
00125       throw ErrorHandler(__FILE__,__LINE__,
00126                          "duplicated attribute '"+
00127                          xmlAttribute->name()+
00128                          "' in tag '"+__name+'\'',
00129                          ErrorHandler::normal);
00130     }
00131     __attributes[xmlAttribute->name()] = xmlAttribute;
00132   }

void XMLTag::add ( ReferenceCounting< XMLContentBase xmlContent  )  [inline]

Adds a content

Parameters:
xmlContent given content

Definition at line 139 of file XMLTag.hpp.

References __content, and ASSERT.

00140   {
00141     ASSERT(__content == 0);
00142     __content = xmlContent;
00143   }

ReferenceCounting<XMLContentBase> XMLTag::content (  )  [inline]

Access to the content of the tag

Returns:
__content

Definition at line 151 of file XMLTag.hpp.

References __content.

00152   {
00153     return __content;
00154   }

ConstReferenceCounting<XMLContentBase> XMLTag::content (  )  const [inline]

Read only access to the content of the tag

Returns:
__content

Definition at line 162 of file XMLTag.hpp.

References __content.

00163   {
00164     return __content;
00165   }

const std::string& XMLTag::name (  )  const [inline]

Gets the tag name

Returns:
__name

Definition at line 173 of file XMLTag.hpp.

References __name.

00174   {
00175     return __name;
00176   }


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const XMLTag xmlTag 
) [friend]

Writes a tag to a stream

Parameters:
os given output stream
xmlTag the tag to write
Returns:
os

Definition at line 91 of file XMLTag.hpp.

00093   {
00094     os << xmlTag.__name;
00095     for (AttributeList::const_iterator i = xmlTag.__attributes.begin();
00096          i != xmlTag.__attributes.end(); ++i) {
00097       os << ' ' << i->second->name() << "=\""
00098          << i->second->value() << '"';
00099     }
00100     return os;
00101   }


Member Data Documentation

const std::string XMLTag::__name [private]

name of the tag

Definition at line 49 of file XMLTag.hpp.

Referenced by add(), close(), and name().

list of attributes

Definition at line 51 of file XMLTag.hpp.

Referenced by add(), and findAttribute().

content of the tag if any

Definition at line 54 of file XMLTag.hpp.

Referenced by add(), and content().


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

Generated on Wed Nov 19 00:18:17 2008 for FreeFEM3D (aka ff3d) by  doxygen 1.5.6