Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

skElementObject Class Reference

This object is a container for an element, and exposes an interface to it to Simkin The class implements methods from the Executable interface. More...

#include <skElementObject.h>

Inheritance diagram for skElementObject:

skExecutable skiExecutable List of all members.

Public Member Functions

IMPORT_C skElementObject ()
 Default Constructor.

IMPORT_C skElementObject (const skString &location, skElement *elem, bool created)
 Constructor which takes an Element.

virtual IMPORT_C ~skElementObject ()
 Destructor.

IMPORT_C int executableType () const
 Returns ELEMENT_TYPE indicating the element is an ElementObject.

IMPORT_C int intValue () const
IMPORT_C float floatValue () const
IMPORT_C bool boolValue () const
IMPORT_C Char charValue () const
IMPORT_C skString strValue () const
virtual IMPORT_C bool setValue (const skString &name, const skString &attribute, const skRValue &return_value)
 sets the value of an item in the element.

virtual IMPORT_C bool setValueAt (const skRValue &array_index, const skString &attribute, const skRValue &value)
 Sets a value within the nth element of the element.

virtual IMPORT_C bool getValue (const skString &name, const skString &attribute, skRValue &value)
 Retrieves a field from the .

virtual IMPORT_C bool getValueAt (const skRValue &array_index, const skString &attribute, skRValue &value)
 Retrieves the nth value from within the element.

virtual IMPORT_C bool method (const skString &name, skRValueArray &args, skRValue &ret, skExecutableContext &ctxt)
 this method attempts to execute a method stored in the .

IMPORT_C bool equals (const skiExecutable *o) const
 tests for equality with another object, using a deep comparison if the other object is an ElementObject, otherwise comparing string values

IMPORT_C void copyItemsInto (skElement *other)
 Clears the other element and does a deep copy of the children of this node into that one.

virtual IMPORT_C void setAddIfNotPresent (bool enable)
 sets the flag controlling whether new elements are created as they are accessed

virtual IMPORT_C bool getAddIfNotPresent ()
 this returns the value of the flag controlling whether new elements are created as they are accessed

IMPORT_C skElementgetElement ()
 This method returns the Element being held by the object.

IMPORT_C const skElementgetElement () const
 This method returns the Element being held by the object.

IMPORT_C void setAttribute (skString name, const skString &value)
 Sets an attribute on this node.

IMPORT_C skString getAttribute (const skString &name) const
 This method returns the value of an attribute attached to this element.

IMPORT_C skString getAttribute (const TDesC &name) const
 This method returns the value of an attribute attached to this element.

IMPORT_C skString getLocation () const
 This function returns the location associated with this object (typically a file name).

IMPORT_C void setLocation (const skString &location)
 This function sets the location associated with this object (typically a file name).

IMPORT_C skExecutableIteratorcreateIterator (const skString &qualifier)
 This function returns an skExecutableIterator object which is used in the for each statement.

IMPORT_C skExecutableIteratorcreateIterator ()
 This function returns an skExecutableIterator object which is used in the for each statement.

virtual IMPORT_C skString getSource (const skString &location)
 Returns the source code for the given method.

virtual IMPORT_C void getInstanceVariables (skRValueTable &table)
 This method returns the instance variables for this object.

virtual IMPORT_C void getAttributes (skRValueTable &table)
 This method returns the attributes for this object.

virtual IMPORT_C void setElement (const skString &location, skElement *element, bool created=false)
 This method updates the associated element and clears the parse tree cache.

IMPORT_C void setElement (const TDesC &location, skElement *element, bool created=false)
 This method updates the associated element and clears the parse tree cache.

virtual IMPORT_C skElementObject * createElementObject (const skString &location, skElement *element, bool created)
 This method creates a new Element object to wrap an element.


Static Public Member Functions

IMPORT_C skString getData (skElement *element)
 retrieves the text data from an element

IMPORT_C void setData (skElement *element, const skString &data)
 sets the text data for a node by looking for the first CDATA and TEXT child node

IMPORT_C skElementfindChild (skElement *parent, const skString &tagname)
 returns a child element

IMPORT_C skElementfindChild (skElement *parent, const TDesC &tagname)
 returns a child element

IMPORT_C skElementfindChild (skElement *parent, int index)
 returns the nth child element

IMPORT_C skElementfindChild (skElement *parent, const skString &tagname, const skString &attribute, const skString &value)
 returns a child element with the given attribute set to the given value

IMPORT_C skElementfindChild (skElement *parent, const TDesC &tagname, const TDesC &attribute, const skString &value)
 returns a child element with the given attribute set to the given value

IMPORT_C int countChildren (skElement *parent)
 this method returns the number of element children of the given element


Detailed Description

This object is a container for an element, and exposes an interface to it to Simkin The class implements methods from the Executable interface.

The methods getValue, setValue and method all search for matching element tags within the document. Only the first matching tag is used. The class uses the Simkin XML DOM classes.

The class supports the following fields:

The class supports the following methods:


Constructor & Destructor Documentation

IMPORT_C skElementObject::skElementObject const skString location,
skElement elem,
bool  created
 

Constructor which takes an Element.

Parameters:
location - used to identify the source of the document in error messages
elem - the element to be stored
created - if true, this object will destroy the associated skElement object in its destructor


Member Function Documentation

IMPORT_C bool skElementObject::boolValue  )  const [virtual]
 

Returns:
the value of the element text data as a boolean

Reimplemented from skExecutable.

IMPORT_C Char skElementObject::charValue  )  const [virtual]
 

Returns:
the first character of the element text data

Reimplemented from skExecutable.

IMPORT_C void skElementObject::copyItemsInto skElement other  ) 
 

Clears the other element and does a deep copy of the children of this node into that one.

Parameters:
other - the element into which our children will be copied
Exceptions:
Symbian - a leaving function

virtual IMPORT_C skElementObject* skElementObject::createElementObject const skString location,
skElement element,
bool  created
[virtual]
 

This method creates a new Element object to wrap an element.

Override this for special behaviour in derived classes. In this method, the newly created object inherits this object's m_AddIfNotPresent flag

Parameters:
location the location of this element
element the DOM element to associate with the object
created set this to true if the new skElementObject should delete the element in its destructor
Exceptions:
Symbian - a leaving function

IMPORT_C skExecutableIterator* skElementObject::createIterator  )  [virtual]
 

This function returns an skExecutableIterator object which is used in the for each statement.

It will iterate over *all* children of this element

Exceptions:
Symbian - a leaving function

Reimplemented from skExecutable.

IMPORT_C skExecutableIterator* skElementObject::createIterator const skString qualifier  )  [virtual]
 

This function returns an skExecutableIterator object which is used in the for each statement.

It will iterate over elements with the given tag.

Parameters:
qualifier tag - only elements with this tag will appear in the iteration
Exceptions:
Symbian - a leaving function

Reimplemented from skExecutable.

IMPORT_C bool skElementObject::equals const skiExecutable o  )  const [virtual]
 

tests for equality with another object, using a deep comparison if the other object is an ElementObject, otherwise comparing string values

Returns:
true if the data in both elements is the same

Reimplemented from skExecutable.

IMPORT_C int skElementObject::executableType  )  const [virtual]
 

Returns ELEMENT_TYPE indicating the element is an ElementObject.

Returns:
the type as element

Reimplemented from skExecutable.

IMPORT_C skElement* skElementObject::findChild skElement parent,
const TDesC &  tagname,
const TDesC &  attribute,
const skString value
[static]
 

returns a child element with the given attribute set to the given value

Remarks:
only available in Symbian version
Parameters:
parent the parent element
tagname the tag name of the element
attribute name of the attribute
value value of the named attribute
Returns:
the first element child of the parent with the matching tag name and attribute value, or null if not found

IMPORT_C skElement* skElementObject::findChild skElement parent,
const skString tagname,
const skString attribute,
const skString value
[static]
 

returns a child element with the given attribute set to the given value

Parameters:
parent the parent element
tagname the tag name of the element
attribute name of the attribute
value value of the named attribute
Returns:
the first element child of the parent with the matching tag name and attribute value, or null if not found

IMPORT_C skElement* skElementObject::findChild skElement parent,
int  index
[static]
 

returns the nth child element

Parameters:
parent the parent element
index the index of the element
Returns:
the matching element or null if outside the current list ot items

IMPORT_C skElement* skElementObject::findChild skElement parent,
const TDesC &  tagname
[static]
 

returns a child element

Remarks:
only available in Symbian version
Parameters:
parent the parent element
tagname the tag name of the element
Returns:
the first element child of the parent with the matching tag name, or null if not found

IMPORT_C skElement* skElementObject::findChild skElement parent,
const skString tagname
[static]
 

returns a child element

Parameters:
parent the parent element
tagname the tag name of the element
Returns:
the first element child of the parent with the matching tag name, or null if not found

IMPORT_C float skElementObject::floatValue  )  const [virtual]
 

Returns:
the value of the element text data as a float

Reimplemented from skExecutable.

virtual IMPORT_C bool skElementObject::getAddIfNotPresent  )  [virtual]
 

this returns the value of the flag controlling whether new elements are created as they are accessed

Returns:
true if the feature is enabled, otherwise false (the default)

IMPORT_C skString skElementObject::getAttribute const TDesC &  name  )  const
 

This method returns the value of an attribute attached to this element.

Remarks:
only available in Symbian version
Returns:
the value of the given attribute

IMPORT_C skString skElementObject::getAttribute const skString name  )  const
 

This method returns the value of an attribute attached to this element.

Returns:
the value of the given attribute
Exceptions:
Symbian - a leaving function

virtual IMPORT_C void skElementObject::getAttributes skRValueTable table  )  [virtual]
 

This method returns the attributes for this object.

Parameters:
table a table to filled with the values of the attributes
Exceptions:
Symbian - a leaving function

Reimplemented from skExecutable.

IMPORT_C skString skElementObject::getData skElement element  )  [static]
 

retrieves the text data from an element

Parameters:
element 
Returns:
the text from a child node of type CDATA or TEXT
Exceptions:
Symbian - a leaving function

IMPORT_C const skElement* skElementObject::getElement  )  const
 

This method returns the Element being held by the object.

Returns:
the underlying Element

IMPORT_C skElement* skElementObject::getElement  ) 
 

This method returns the Element being held by the object.

Returns:
the underlying Element

virtual IMPORT_C void skElementObject::getInstanceVariables skRValueTable table  )  [virtual]
 

This method returns the instance variables for this object.

Parameters:
table a table to filled with references to the instance variables
Exceptions:
Symbian - a leaving function

Reimplemented from skExecutable.

virtual IMPORT_C skString skElementObject::getSource const skString location  )  [virtual]
 

Returns the source code for the given method.

Exceptions:
Symbian - a leaving function

Reimplemented from skExecutable.

virtual IMPORT_C bool skElementObject::getValue const skString name,
const skString attribute,
skRValue value
[virtual]
 

Retrieves a field from the .

The first sub-element matching the tag is found. The value returned is an ElementObject, unless the attrib value is specified. It also supports the following built-in field:

"nodename" - returns the tag name of this element

If the m_AddIfNotPresent flag is true, a new item will be added if one is not already present.

Parameters:
name - the tag name containing the data
attribute - the attribute name to retrieve
value - the RValue to containing the value to be set
Returns:
true if the method was found, false otherwise
Exceptions:
Symbian - a leaving function

Reimplemented from skExecutable.

virtual IMPORT_C bool skElementObject::getValueAt const skRValue array_index,
const skString attribute,
skRValue value
[virtual]
 

Retrieves the nth value from within the element.

If the array index falls within the range of the number of children of this element, a new ElementObject encapsulating the child is returned. If the m_AddIfNotPresent flag is true, a new item with the tag name "array_item" will be added if one is not already present

Parameters:
array_index - the identifier of the item - this might be a string, integer or any other legal value
attribute - the attribute name to retrived (may be blank)
value - the value to be retrieved
Returns:
true if the field was found, false if the field could not found
Exceptions:
Symbian - a leaving function

Reimplemented from skExecutable.

IMPORT_C int skElementObject::intValue  )  const [virtual]
 

Returns:
the value of the element text data as an integer

Reimplemented from skExecutable.

virtual IMPORT_C bool skElementObject::method const skString name,
skRValueArray args,
skRValue ret,
skExecutableContext ctxt
[virtual]
 

this method attempts to execute a method stored in the .

It searches for an element whose tag matches the method name and if found passes the text for the tag through to the interpeter.

The method also supports the following methods to Simkin scripts:

  • dump - writes the whole Object out to the tracer (useful for debugging)
  • enumerate([name]) - returns an skElementObjectEnumerator which enumerates over the child elements of this element. If no tag name is passed the enumerator lists all the children. A tag name can be passed to show only children with the matching tag name.
Parameters:
name the name of the method
args an array of arguments to the method
ret the object to receive the result of the method call
ctxt context object to receive errors
Returns:
true if the method was found, false otherwise
Exceptions:
Symbian - a leaving function
skParseException - if a syntax error is encountered while the script is running
skRuntimeException - if an error occurs while the script is running

Reimplemented from skExecutable.

virtual IMPORT_C void skElementObject::setAddIfNotPresent bool  enable  )  [virtual]
 

sets the flag controlling whether new elements are created as they are accessed

Parameters:
enable enables this feature (which by default is disabled)

IMPORT_C void skElementObject::setData skElement element,
const skString data
[static]
 

sets the text data for a node by looking for the first CDATA and TEXT child node

Parameters:
element the element to be changed
data the data to be set
Exceptions:
Symbian - a leaving function

IMPORT_C void skElementObject::setElement const TDesC &  location,
skElement element,
bool  created = false
 

This method updates the associated element and clears the parse tree cache.

Remarks:
only available in Symbian version
Parameters:
location the location of this element
element - the new Element
created - set to true if this object will delete the element at the end

virtual IMPORT_C void skElementObject::setElement const skString location,
skElement element,
bool  created = false
[virtual]
 

This method updates the associated element and clears the parse tree cache.

Parameters:
location the location of this element
element - the new Element
created - set to true if this object will delete the element at the end

virtual IMPORT_C bool skElementObject::setValue const skString name,
const skString attribute,
const skRValue return_value
[virtual]
 

sets the value of an item in the element.

The first sub-element matching the tag is found. If the value passed is an element, it is first copied. If the m_AddIfNotPresent flag is true, a new item will be added if one is not already present

Parameters:
name - the name of the element tag to set (null if it's the overall element)
attribute - the name of the attribute to set (null to set text for the element)
return_value - the RValue to receive the value
Returns:
true if the field was found, false otherwise
Exceptions:
Symbian - a leaving function

Reimplemented from skExecutable.

virtual IMPORT_C bool skElementObject::setValueAt const skRValue array_index,
const skString attribute,
const skRValue value
[virtual]
 

Sets a value within the nth element of the element.

If the m_AddIfNotPresent flag is true, a new item with the tag name "array_item" will be added if one is not already present.

Parameters:
array_index - the identifier of the item - this might be a string, integer or any other legal value
attribute - the attribute name to set (may be blank)
value - the value to be set
Returns:
true if the field was changed, false if the field could not be set or found
Exceptions:
Symbian - a leaving function

Reimplemented from skExecutable.

IMPORT_C skString skElementObject::strValue  )  const [virtual]
 

Returns:
the value of the element text data as a string

Reimplemented from skExecutable.


The documentation for this class was generated from the following file:
Generated on Fri Dec 17 20:28:27 2004 for Simkin C++ for Symbian by doxygen1.3