Separatista
Separatista::Element Class Referenceabstract
Inheritance diagram for Separatista::Element:
Separatista::BranchElement Separatista::ChoiceElement Separatista::LeafElement Separatista::SeparatistaDocument Separatista::AttributedLeafElement

Classes

class  TagKey
 
struct  TagKeyRange
 

Public Types

enum  ErrorOptions { ThrowExceptions = 0, ClearValue, AcceptValue }
 
typedef std::map< const TagKey, Element * > TagKeyMap
 

Public Member Functions

const ElementDescriptorgetElementDescriptor () const
 
virtual IOErrorCode toDOMDocument (xercesc::DOMDocument *pDOMDocument, xercesc::DOMElement *pDOMParent, const ErrorOptions errorOptions=ThrowExceptions) const =0
 
virtual void fromDOMDocument (xercesc::DOMElement *pDOMElement, const ErrorOptions errorOptions=ThrowExceptions)=0
 
void addElementListener (ElementListener *pElementListener)
 
void removeElementListener (ElementListener *pElementListener)
 
const wchar_t * getTag () const
 
virtual ElementgetElementByTag (const wchar_t *pTagName, size_t nIndex=0) const
 
virtual ElementcreateElementByTag (const wchar_t *pTagName, size_t nIndex=0)
 
virtual void destroyElement (Element *pChildElement)
 
virtual const wchar_t * getTextValue () const
 
virtual void setValue (const wchar_t *pValue, const ErrorOptions errorOptions=ThrowExceptions)
 
virtual const wchar_t * getAttributeValue (const wchar_t *pAttributeName) const
 
virtual void setAttributeValue (const wchar_t *pAttributeName, const wchar_t *pValue)
 
time_t getDateValue () const
 
void setValue (const time_t Value, bool bWithTime=false, const ErrorOptions errorOptions=ThrowExceptions)
 
int getIntValue () const
 
void setValue (const int Value, const ErrorOptions errorOptions=ThrowExceptions)
 
double getDoubleValue () const
 
void setValue (const double d, const ErrorOptions errorOptions=ThrowExceptions)
 
bool isEmpty () const
 
virtual TagKeyRange getAllByTagName (const wchar_t *pTagName)
 

Protected Member Functions

 Element (const ChildElementDescriptor *pChildElementDescriptor)
 
virtual ~Element ()
 
ElementgetParentElement () const
 
void onElementValueChanged (const wchar_t *pNewValue)
 Calls a registered ElementListener's elementValueChanged.
 
void onElementCreated (Element *pChildElement)
 Calls a registered ElementListener's elementCreated.
 
void onElementDeleted ()
 Calls a registered ElementListener's elementDeleted.
 

Static Protected Member Functions

static void deleteElement (Element *pChildElement)
 

Member Enumeration Documentation

◆ ErrorOptions

Options how to handle errors when reading (fromDOMDocument) or writing (toDOMDocument) Separatista files.

Enumerator
ThrowExceptions 

Throw exceptions, default.

ClearValue 

Leave an empty value for the node.

AcceptValue 

Accept erronous values.

Constructor & Destructor Documentation

◆ Element()

Element::Element ( const ChildElementDescriptor pChildElementDescriptor)
protected

Construct a new Element

Parameters
pElementDescriptorThe element descriptor to load the element from.

◆ ~Element()

Element::~Element ( )
protectedvirtual

Protected destructor to protect the object from being destroyed by non Element derived classes.

Member Function Documentation

◆ addElementListener()

void Element::addElementListener ( ElementListener pElementListener)

Add an elementlistener. Will be notified of changes to the element.

Parameters
pElementListenerThe elementlistener to register.
See also
ElementListener

◆ createElementByTag()

Element * Element::createElementByTag ( const wchar_t *  pTagName,
size_t  nIndex = 0 
)
virtual

Returns or creates the child element by tag name. If the element already exists, this function return the existing element. If not, it will create the element.

Returns
A pointer to the child element. Will not return NULL. If the element isn't supported an UnsupportedTagException is thrown.
Exceptions
ElementExceptionif the element doesn't support having child elements.
UnsupportedTagExceptionif the requested tag isn't supported by Separatista

Reimplemented in Separatista::ChoiceElement, and Separatista::BranchElement.

◆ deleteElement()

void Element::deleteElement ( Element pChildElement)
staticprotected

Method to make it possible for derived classes to delete Elements. Calls pChildElement->onElementDeleted()

See also
Element::onElementDeleted

◆ destroyElement()

void Element::destroyElement ( Element pChildElement)
virtual

Destroys the child element.

Exceptions
ElementExceptionif the element doesn't support having child elements.

Reimplemented in Separatista::ChoiceElement, and Separatista::BranchElement.

◆ fromDOMDocument()

virtual void Separatista::Element::fromDOMDocument ( xercesc::DOMElement *  pDOMElement,
const ErrorOptions  errorOptions = ThrowExceptions 
)
pure virtual

Tries to load it's value from the document element.

Parameters
DocumentIteratorThe document iterator to call to continue reading or get value from.

Implemented in Separatista::ChoiceElement, Separatista::LeafElement, Separatista::AttributedLeafElement, and Separatista::BranchElement.

◆ getAllByTagName()

Element::TagKeyRange Element::getAllByTagName ( const wchar_t *  pTagName)
virtual

Returns a range containing a begin iterator and an end iterator.

Exceptions
ElementExceptionIf this element doesn't support having child elements.

Reimplemented in Separatista::BranchElement.

◆ getAttributeValue()

const wchar_t * Element::getAttributeValue ( const wchar_t *  pAttributeName) const
virtual

Get the element's attribute value

Parameters
pAttributeNameThe name of the attribute
Returns
The value as text or NULL
Exceptions
ElementExceptionif the element doesn't support having attributes.

Reimplemented in Separatista::AttributedLeafElement.

◆ getDateValue()

time_t Element::getDateValue ( ) const

Returns the value of the text node converted to date

Returns
-1 on error

◆ getDoubleValue()

double Element::getDoubleValue ( ) const

Get the value of a text node converted to double

◆ getElementByTag()

Element * Element::getElementByTag ( const wchar_t *  pTagName,
size_t  nIndex = 0 
) const
virtual

Returns the child element by tag name and index.

Returns
A pointer to the child element or NULL if not present or unsupported.
Exceptions
ElementExceptionif the element doesn't support having child elements.

Reimplemented in Separatista::ChoiceElement, and Separatista::BranchElement.

◆ getElementDescriptor()

const ElementDescriptor * Element::getElementDescriptor ( ) const

Get the ElementDescriptor for this element

◆ getIntValue()

int Element::getIntValue ( ) const

Get the value of a text node converted to int

◆ getParentElement()

Element* Separatista::Element::getParentElement ( ) const
protected

Get the parent element The parent element or NULL if no parent was found in the ElementDescriptor

◆ getTag()

const wchar_t * Element::getTag ( ) const

Returns the tag name

◆ getTextValue()

const wchar_t * Element::getTextValue ( ) const
virtual

Get the element's value as text.

Returns
A pointer to the text value or NULL if no value was set.
Exceptions
ElementExceptionif the element doesn't support having values.

Reimplemented in Separatista::LeafElement.

◆ isEmpty()

bool Element::isEmpty ( ) const

Returns true if the element text is empty

◆ removeElementListener()

void Element::removeElementListener ( ElementListener pElementListener)

Remove a registered elementlistener.

Parameters
pElementListenerThe ElementListener to remove.
See also
ElementListener

◆ setAttributeValue()

void Element::setAttributeValue ( const wchar_t *  pAttributeName,
const wchar_t *  pValue 
)
virtual

Set the element's attribute value

Parameters
pAttributeNameThe name of the attribute
pValueThe (new) value to set
Exceptions
ElementExceptionif the elements doesn't support having attributes.

Reimplemented in Separatista::AttributedLeafElement.

◆ setValue() [1/4]

void Element::setValue ( const wchar_t *  pValue,
const ErrorOptions  errorOptions = ThrowExceptions 
)
virtual

Set the element's value as text.

Exceptions
ElementExceptionif the element doesn't support having values.

Reimplemented in Separatista::LeafElement.

◆ setValue() [2/4]

void Element::setValue ( const time_t  Value,
bool  bWithTime = false,
const ErrorOptions  errorOptions = ThrowExceptions 
)

Set the value of a text node by a time_t

Parameters
bWithTimeWether the time should be included or not

◆ setValue() [3/4]

void Element::setValue ( const int  Value,
const ErrorOptions  errorOptions = ThrowExceptions 
)

Set the value of a text node by an int

◆ setValue() [4/4]

void Element::setValue ( const double  d,
const ErrorOptions  errorOptions = ThrowExceptions 
)

Set the value of a text node conveted to double

◆ toDOMDocument()

virtual IOErrorCode Separatista::Element::toDOMDocument ( xercesc::DOMDocument *  pDOMDocument,
xercesc::DOMElement *  pDOMParent,
const ErrorOptions  errorOptions = ThrowExceptions 
) const
pure virtual

Abstract method to call to write an element to a DOMDocument.

Parameters
pDocumentThe DOMDocument to create the element for.
pParentThe DOMElement to append the element to.
Returns
Pointer to the new created DOMElement, or NULL
See also
createElement

Implemented in Separatista::ChoiceElement, Separatista::SeparatistaDocument, Separatista::LeafElement, Separatista::AttributedLeafElement, and Separatista::BranchElement.


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