#include <nedelement.h>
Inheritance diagram for NEDElement:
An instance of a NEDElement subclass represent an XML element. NEDElement provides a DOM-like, generic access to the tree; subclasses additionally provide a typed interface.
Public Member Functions | |
Constructor, destructor | |
NEDElement () | |
NEDElement (NEDElement *parent) | |
virtual | ~NEDElement () |
Common properties | |
virtual const char * | getTagName () const =0 |
virtual int | getTagCode () const =0 |
virtual long | getId () const |
virtual void | setId (long id) |
virtual const char * | getSourceLocation () const |
virtual void | setSourceLocation (const char *loc) |
Generic access to attributes (Methods have to be redefined in subclasses!) | |
virtual void | applyDefaults () |
virtual int | getNumAttributes () const =0 |
virtual const char * | getAttributeName (int k) const =0 |
virtual int | lookupAttribute (const char *attr) const |
virtual const char * | getAttribute (int k) const =0 |
virtual const char * | getAttribute (const char *attr) const |
virtual void | setAttribute (int k, const char *value)=0 |
virtual void | setAttribute (const char *attr, const char *value) |
virtual const char * | getAttributeDefault (int k) const =0 |
virtual const char * | getAttributeDefault (const char *attr) const |
Generic access to children and siblings | |
virtual NEDElement * | getParent () const |
virtual NEDElement * | getFirstChild () const |
virtual NEDElement * | getLastChild () const |
virtual NEDElement * | getNextSibling () const |
virtual NEDElement * | getPrevSibling () const |
virtual void | appendChild (NEDElement *node) |
virtual void | insertChildBefore (NEDElement *where, NEDElement *newnode) |
virtual NEDElement * | removeChild (NEDElement *node) |
virtual NEDElement * | getFirstChildWithTag (int tagcode) const |
virtual NEDElement * | getNextSiblingWithTag (int tagcode) const |
virtual int | getNumChildren () const |
virtual int | getNumChildrenWithTag (int tagcode) const |
Utility functions | |
NEDElement * | getFirstChildWithAttribute (int tagcode, const char *attr, const char *attrvalue=NULL) |
NEDElement * | getParentWithTag (int tagcode) |
User data | |
virtual void | setUserData (NEDElementUserData *data) |
virtual NEDElementUserData * | getUserData () const |
Static Protected Member Functions | |
static bool | stringToBool (const char *s) |
static const char * | boolToString (bool b) |
static int | stringToEnum (const char *s, const char *vals[], int nums[], int n) |
static const char * | enumToString (int b, const char *vals[], int nums[], int n) |
|
Constructor.
|
|
Constructor. Takes parent element. |
|
Destructor. Destroys children too. |
|
Appends the given element at the end of the child element list. The node pointer passed should not be NULL. |
|
Sets every attribute to its default value (as returned by getAttributeDefault()). Attributes without a default value are not affected. This method is called from the constructors of derived classes. |
|
|
|
|
|
Returns the value of the attribute with the given name. Relies on lookupAttribute() and getAttribute(). It returns NULL if the given attribute is not found. |
|
Pure virtual method, it should be redefined in subclasses to return the value of the kth attribute (i.e. the attribute with the name getAttributeName(k)). It should return NULL if k is out of range (i.e. negative or greater than getNumAttributes()). Implemented in NedFilesNode, NedFileNode, ImportNode, ImportedFileNode, ChannelNode, ChannelAttrNode, NetworkNode, SimpleModuleNode, CompoundModuleNode, ParamsNode, ParamNode, GatesNode, GateNode, MachinesNode, MachineNode, SubmodulesNode, SubmoduleNode, SubstparamsNode, SubstparamNode, GatesizesNode, GatesizeNode, SubstmachinesNode, SubstmachineNode, ConnectionsNode, ConnectionNode, ConnAttrNode, ForLoopNode, LoopVarNode, DisplayStringNode, ExpressionNode, OperatorNode, FunctionNode, ParamRefNode, IdentNode, ConstNode, CplusplusNode, StructDeclNode, ClassDeclNode, MessageDeclNode, EnumDeclNode, EnumNode, EnumFieldsNode, EnumFieldNode, MessageNode, ClassNode, StructNode, FieldsNode, FieldNode, PropertiesNode, PropertyNode, and UnknownNode. |
|
Returns the default value of the given attribute, as defined in the DTD. Relies on lookupAttribute() and getAttributeDefault(). It returns NULL if the given attribute is not found. |
|
Pure virtual method, it should be redefined in subclasses to return the default value of the kth attribute, as defined in the DTD. It should return NULL if k is out of range (i.e. negative or greater than getNumAttributes()). Implemented in NedFilesNode, NedFileNode, ImportNode, ImportedFileNode, ChannelNode, ChannelAttrNode, NetworkNode, SimpleModuleNode, CompoundModuleNode, ParamsNode, ParamNode, GatesNode, GateNode, MachinesNode, MachineNode, SubmodulesNode, SubmoduleNode, SubstparamsNode, SubstparamNode, GatesizesNode, GatesizeNode, SubstmachinesNode, SubstmachineNode, ConnectionsNode, ConnectionNode, ConnAttrNode, ForLoopNode, LoopVarNode, DisplayStringNode, ExpressionNode, OperatorNode, FunctionNode, ParamRefNode, IdentNode, ConstNode, CplusplusNode, StructDeclNode, ClassDeclNode, MessageDeclNode, EnumDeclNode, EnumNode, EnumFieldsNode, EnumFieldNode, MessageNode, ClassNode, StructNode, FieldsNode, FieldNode, PropertiesNode, PropertyNode, and UnknownNode. |
|
Pure virtual method, it should be redefined in subclasses to return the name of the kth attribute as defined in the DTD. It should return NULL if k is out of range (i.e. negative or greater than getNumAttributes()). Implemented in NedFilesNode, NedFileNode, ImportNode, ImportedFileNode, ChannelNode, ChannelAttrNode, NetworkNode, SimpleModuleNode, CompoundModuleNode, ParamsNode, ParamNode, GatesNode, GateNode, MachinesNode, MachineNode, SubmodulesNode, SubmoduleNode, SubstparamsNode, SubstparamNode, GatesizesNode, GatesizeNode, SubstmachinesNode, SubstmachineNode, ConnectionsNode, ConnectionNode, ConnAttrNode, ForLoopNode, LoopVarNode, DisplayStringNode, ExpressionNode, OperatorNode, FunctionNode, ParamRefNode, IdentNode, ConstNode, CplusplusNode, StructDeclNode, ClassDeclNode, MessageDeclNode, EnumDeclNode, EnumNode, EnumFieldsNode, EnumFieldNode, MessageNode, ClassNode, StructNode, FieldsNode, FieldNode, PropertiesNode, PropertyNode, and UnknownNode. |
|
Returns pointer to the first child element, or NULL if this element has no children.
|
|
Returns find first child element with the give tagcode and the given attribute (optionally) having the given value. Returns NULL if not found. |
|
Returns pointer to the first child element with the given tag code, or NULL if this element has no such children.
|
|
Returns a unique id, originally set by the contructor.
|
|
Returns pointer to the last child element, or NULL if this element has no children.
|
|
Returns pointer to the next sibling of this element (i.e. the next child in the parent element). Returns NULL if there're no subsequent elements. getFirstChild() and getNextSibling() can be used to loop through the child list:
for (NEDElement *child=node->getFirstChild(); child; child = child->getNextSibling()) { ... } |
|
Returns pointer to the next sibling of this element with the given tag code. Return NULL if there're no such subsequent elements. getFirstChildWithTag() and getNextSiblingWithTag() are a convient way to loop through elements with a certain tag code in the child list:
for (NEDElement *child=node->getFirstChildWithTag(tagcode); child; child = child->getNextSiblingWithTag(tagcode)) { ... } |
|
Pure virtual method, it should be redefined in subclasses to return the number of attributes defined in the DTD.
Implemented in NedFilesNode, NedFileNode, ImportNode, ImportedFileNode, ChannelNode, ChannelAttrNode, NetworkNode, SimpleModuleNode, CompoundModuleNode, ParamsNode, ParamNode, GatesNode, GateNode, MachinesNode, MachineNode, SubmodulesNode, SubmoduleNode, SubstparamsNode, SubstparamNode, GatesizesNode, GatesizeNode, SubstmachinesNode, SubstmachineNode, ConnectionsNode, ConnectionNode, ConnAttrNode, ForLoopNode, LoopVarNode, DisplayStringNode, ExpressionNode, OperatorNode, FunctionNode, ParamRefNode, IdentNode, ConstNode, CplusplusNode, StructDeclNode, ClassDeclNode, MessageDeclNode, EnumDeclNode, EnumNode, EnumFieldsNode, EnumFieldNode, MessageNode, ClassNode, StructNode, FieldsNode, FieldNode, PropertiesNode, PropertyNode, and UnknownNode. |
|
Returns the number of child elements.
|
|
Returns the number of child elements with the given tag code.
|
|
Returns the parent element, or NULL if this element has no parent.
|
|
Climb up in the element tree until it finds an element with the given tagcode. Returns NULL if not found. |
|
Returns pointer to the previous sibling of this element (i.e. the previous child in the parent element). Returns NULL if there're no elements before this one. |
|
Returns a string containing a file/line position showing where this element originally came from.
|
|
Overridden in subclasses to return the numeric code (NED_xxx) of the XML element the class represents.
Implemented in NedFilesNode, NedFileNode, ImportNode, ImportedFileNode, ChannelNode, ChannelAttrNode, NetworkNode, SimpleModuleNode, CompoundModuleNode, ParamsNode, ParamNode, GatesNode, GateNode, MachinesNode, MachineNode, SubmodulesNode, SubmoduleNode, SubstparamsNode, SubstparamNode, GatesizesNode, GatesizeNode, SubstmachinesNode, SubstmachineNode, ConnectionsNode, ConnectionNode, ConnAttrNode, ForLoopNode, LoopVarNode, DisplayStringNode, ExpressionNode, OperatorNode, FunctionNode, ParamRefNode, IdentNode, ConstNode, CplusplusNode, StructDeclNode, ClassDeclNode, MessageDeclNode, EnumDeclNode, EnumNode, EnumFieldsNode, EnumFieldNode, MessageNode, ClassNode, StructNode, FieldsNode, FieldNode, PropertiesNode, PropertyNode, and UnknownNode. |
|
Overridden in subclasses to return the name of the XML element the class represents.
Implemented in NedFilesNode, NedFileNode, ImportNode, ImportedFileNode, ChannelNode, ChannelAttrNode, NetworkNode, SimpleModuleNode, CompoundModuleNode, ParamsNode, ParamNode, GatesNode, GateNode, MachinesNode, MachineNode, SubmodulesNode, SubmoduleNode, SubstparamsNode, SubstparamNode, GatesizesNode, GatesizeNode, SubstmachinesNode, SubstmachineNode, ConnectionsNode, ConnectionNode, ConnAttrNode, ForLoopNode, LoopVarNode, DisplayStringNode, ExpressionNode, OperatorNode, FunctionNode, ParamRefNode, IdentNode, ConstNode, CplusplusNode, StructDeclNode, ClassDeclNode, MessageDeclNode, EnumDeclNode, EnumNode, EnumFieldsNode, EnumFieldNode, MessageNode, ClassNode, StructNode, FieldsNode, FieldNode, PropertiesNode, PropertyNode, and UnknownNode. |
|
Return pointer to the user data object, or NULL if setUserData() has not been called yet.
|
|
Inserts the given element just before the specified child element in the child element list. The where element must be a child of this element. The node pointer passed should not be NULL. |
|
Returns the index of the given attribute. It returns -1 if the attribute is not found. Relies on getNumAttributes() and getAttributeName(). |
|
Removes the given element from the child element list. The pointer passed should be a child of this element. |
|
Sets the value of the attribute with the given name. Relies on lookupAttribute() and setAttribute(). If the given attribute is not found, the call has no effect. |
|
|
Unique id assigned by the constructor can be overwritten here.
|
|
Sets location string (a string containing a file/line position showing where this element originally came from). Called by the (NED/XML) parser. |
|
Replaces user data object with the given one.
|
|
|
|
|