Top | ![]() |
![]() |
![]() |
![]() |
GXmlGomObjectGXmlGomObject — A GXml Object Model (GOM) represents a GXmlDomElement. It has attributes and children. All object's properties are handled as attributes if they are basic types like integers, strings, enums and others; GXmlSerializableProperty objects are handled as attributes too. If object's attribute is a GObject it is handled as node's child, but only if it is a GXmlGomElement object, other wise it is ignored when this object is used as GXmlDomNode in XML documents. |
GList * | gxml_gom_object_get_properties_list () |
GParamSpec * | gxml_gom_object_find_property_name () |
GParamSpec * | gxml_gom_object_find_object_property_name () |
GList * | gxml_gom_object_get_property_element_list () |
gchar * | gxml_gom_object_get_property_string () |
gchar * | gxml_gom_object_get_attribute () |
gboolean | gxml_gom_object_set_attribute () |
GXmlDomElement * | gxml_gom_object_get_child () |
GXmlDomElementList * | gxml_gom_object_find_elements () |
gboolean | gxml_gom_object_remove_attribute () |
gboolean | gxml_gom_object_set_instance_property () |
void | gxml_gom_object_clean_property_elements () |
GList *
gxml_gom_object_get_properties_list (GXmlGomObject *self
);
Returns a list with all properties' nick with "::" prefix. Nick name, with "::" prefix will be used on serialization to an attribute's name.
GParamSpec * gxml_gom_object_find_property_name (GXmlGomObject *self
,const gchar *pname
);
Returns property's GParamSpec based on given nick. This function is case insensitive.
GParamSpec * gxml_gom_object_find_object_property_name (GXmlGomObject *self
,const gchar *pname
);
Returns a GXmlGomObject or a GXmlGomCollection property's GParamSpec based on given name. This method is case insensitive.
This method will check if nick's name is equal than given name in order to avoid use canonical names like "your-name" if your property is your_name; so you can se nick to "YourName" to find and instantiate it.
GList *
gxml_gom_object_get_property_element_list
(GXmlGomObject *self
);
Returns a list of names for all GXmlDomElement present as object's properties.
gchar * gxml_gom_object_get_property_string (GXmlGomObject *self
,GParamSpec *prop
);
Returns an string representation of an Object's property.
gchar * gxml_gom_object_get_attribute (GXmlGomObject *self
,const gchar *name
);
Search for properties in objects, it should be an GObject's property. If found a property with given name its value is returned as string representation.
If property is a GXmlGomProperty returned value is a string representation according with object implementation.
If given property name is not found, then gxml_dom_element_get_attribute()
is called.
By default all GObject are children of this object, see gxml_gom_object_get_child()
gboolean gxml_gom_object_set_attribute (GXmlGomObject *self
,const gchar *name
,const gchar *val
);
Search for a GObject property with given name, if found, given string representation is used as value to property, using any required transformation from string.
By default all GObject are children of this object.
GXmlDomElement * gxml_gom_object_get_child (GXmlGomObject *self
,const gchar *name
);
Search a GObject property with given name and returns it, if it is a GXmlDomElement. If not found, gxml_dom_element_get_elements_by_tag_name()
is called, returning first node found. Tag name to use, is the given name parameter.
self |
the GXmlGomObject instance |
|
name |
. a name of this object's property of type GXmlDomElement or first GXmlDomNode with that name in child nodes. . |
[in] |
GXmlDomElementList * gxml_gom_object_find_elements (GXmlGomObject *self
,const gchar *name
);
From a given property name of type GXmlGomElement, search all child nodes with node's local name equal to property.
gboolean gxml_gom_object_remove_attribute (GXmlGomObject *self
,const gchar *name
);
Search for a property and set it to null if possible returning true, if value can't be removed or located, returns false without change.
gboolean gxml_gom_object_set_instance_property (GXmlGomObject *self
,const gchar *name
);
Convenient method to set an instance of given property's name and initialize according to have same "owner-document" and set its "parent-node" to this appending it as a child. If property is a GXmlGomCollection it is initialize to use this as its "element".
Instance is set ot object's property.
Property should be a GXmlGomElement or GXmlGomCollection
While an object could be created and set to a Object's property, it is not correctly initialized by default. This method helps in the process.
If Object's property has been set, this method overwrite it.
1 2 3 4 5 6 7 8 9 10 |
class NodeA : GomObject { construct { try { initialize ("NodeA"); } catch { warning ("Can't initialize); } } class NodeB : GomObject { public NodeA node { get; set; } } var nb = new NodeB (); nb.create_instance_property ("node"); assert (nb.node != null); |
Returns: true if property has been set and initialized, false otherwise.
void gxml_gom_object_clean_property_elements (GXmlGomObject *self
,const gchar *name
,GError **error
);
Utility method to remove all instances of a property being child elements of object. Is useful if you have a GXmlGomElement property, it should be just one child of this type and you want to overwrite it.
In this example you have defined an element MyClass to be child of MyParentClass, but it should have just one element, once you set child_elements it calls gxml_gom_object_clean_property_elements()
using property's canonicals name.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
public class MyClass : GomElement { public string name { get; set; } } public class MyParentClass : GomElement { private Myclass _child_elements = null; public MyClass child_elements { get { return _child_elements; } set { try { clean_property_elements ("child-elements"); _child_elements = value; append_child (_child_elements); } catch (GLib.Error e) { warning (e.message); } } } } |
GXmlDomError will be returned in error
if property is not a GXmlGomElement.
self |
the GXmlGomObject instance |
|
name |
. property name to search value type, use canonical names. . |
[in] |
error |
location to store the error occuring, or |
typedef struct _GXmlGomObject GXmlGomObject;
A GXml Object Model (GOM) represents a GXmlDomElement. It has attributes and children. All object's properties are handled as attributes if they are basic types like integers, strings, enums and others; GXmlSerializableProperty objects are handled as attributes too. If object's attribute is a GObject it is handled as node's child, but only if it is a GXmlGomElement object, other wise it is ignored when this object is used as GXmlDomNode in XML documents.
struct GXmlGomObjectIface { GTypeInterface parent_iface; GList* (*get_properties_list) (GXmlGomObject* self); GParamSpec* (*find_property_name) (GXmlGomObject* self, const gchar* pname); GParamSpec* (*find_object_property_name) (GXmlGomObject* self, const gchar* pname); GList* (*get_property_element_list) (GXmlGomObject* self); gchar* (*get_property_string) (GXmlGomObject* self, GParamSpec* prop); gchar* (*get_attribute) (GXmlGomObject* self, const gchar* name); gboolean (*set_attribute) (GXmlGomObject* self, const gchar* name, const gchar* val); GXmlDomElement* (*get_child) (GXmlGomObject* self, const gchar* name); GXmlDomElementList* (*find_elements) (GXmlGomObject* self, const gchar* name); gboolean (*remove_attribute) (GXmlGomObject* self, const gchar* name); gboolean (*set_instance_property) (GXmlGomObject* self, const gchar* name); void (*clean_property_elements) (GXmlGomObject* self, const gchar* name, GError** error); };
Interface for creating GXmlGomObject implementations.
the parent interface structure |
||
virtual method called by |
||
virtual method called by |
||
virtual method called by |
||
virtual method called by |
||
virtual method called by |
||
virtual method called by |
||
virtual method called by |
||
virtual method called by |
||
virtual method called by |
||
virtual method called by |
||
virtual method called by |
||
virtual method called by |