Configuration 4 GNU (CFG)


Node

PrevNext

Name

Node -- The base class of the Config4GNU node type hierarchy.

Synopsis



#define     NODE                            (obj)
#define     NODE_CLASS                      (klass)
#define     IS_NODE                         (obj)
#define     IS_NODE_CLASS                   (obj)
#define     NODE_GET_CLASS                  (obj)
GType       node_get_type                   (void);
const gchar* node_get_name                  (Node *me);
GList*      node_get_children               (Node *me);
GList*      node_get_properties             (Node *me);
void        node_apply                      (Node *me);
Property*   node_add_property               (Node *me,
                                             const char *name,
                                             const char *value);
void        node_remove_property            (Node *me,
                                             Property *property);
Node*       node_find_node                  (Node *me,
                                             char *path);
Property*   node_find_property              (Node *me,
                                             char *path);
Node*       node_new                        (const char *node_type,
                                             const char *uri);
#define     node_get_display_name           (node)

Object Hierarchy


  GObject
   +----Node

Properties


  "name"                 gchararray           : Read

Description

The Node type is the base type of all nodes in Config4GNU. A node represents an element of configuration. It may be a specific section of a configuration file, or it may be an entire configuration. In fact, it may represent all of the configuration on a given computer.

A configuration node exists as part of a tree of nodes. Each node can have zero or more children nodes. Nodes also have parent nodes, unless it is a root node. A root node is the starting point of a configuration tree.

Some nodes refer to just a part of a configuration file. Other nodes refer to a whole file, and delegate the parts of the file to child nodes. For example, the XMLFileNode reads in an XML document from an external "parser," then creates child nodes to refer to the sections of the XML document. ComputerNode is an example of this type of node, for it reads in the config4gnu.xml file and creates nodes for the elements it finds within.

Each node has zero or more properties associated with it. See Property for more information.

Details

NODE()

#define NODE(obj)      (G_TYPE_CHECK_INSTANCE_CAST ((obj), node_get_type(), Node))

Casts an object to type Node, warning if it's not of type Node.

obj :An object of type Node or descending from Node.

NODE_CLASS()

#define NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), node_get_type(), NodeClass))

Casts a class to type NodeClass.

klass :A class of type NodeClass or descending from NodeClass.

IS_NODE()

#define IS_NODE(obj)      (G_TYPE_CHECK_INSTANCE_TYPE ((obj), node_get_type()))

Returns TRUE if the given object is of type Node, FALSE otherwise. (Object can be subclass of Node.)

obj :An object of any type.

IS_NODE_CLASS()

#define IS_NODE_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), node_get_type()))

Returns TRUE if the given class is a NodeClass, FALSE otherwise.

obj :A class structure of any type.

NODE_GET_CLASS()

#define NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), node_get_type(), NodeClass))

Given an object, return the NodeClass structure.

obj :An object of type Node or descending from Node.

node_get_type ()

GType       node_get_type                   (void);

Registers the Node type if necessary.

Returns : the GObject type identifier for Node.

node_get_name ()

const gchar* node_get_name                  (Node *me);

Access the name for a given node. By itself, the Node class does not implement this function. The XMLNode behavior is to return the value of the sectionname attribute.

me : a Node
Returns : the name of the node.

node_get_children ()

GList*      node_get_children               (Node *me);

Access the children for a given node. By itself, the Node class does not implement this function. The XMLNode behavior is to parse all of the child entities in the XML, creating new nodes for each non-property element it finds.

me : a Node
Returns : A linked-list of child nodes. Use g_object_ref() if you want to keep a pointer to one of these nodes.

node_get_properties ()

GList*      node_get_properties             (Node *me);

Access the properties for a given node. By itself, the Node class does not implement this function. The XMLNode behavior is to parse all of the child entities in the XML, creating new properties for each property element it finds.

me : a Node
Returns : A linked list of properties. Use g_object_ref() on each property you want to reference.

node_apply ()

void        node_apply                      (Node *me);

Applies user's changes to the underlying data store. For instance, a XMLFileNode will output the changed XML document to the program that writes the configuration.

me : a Node

node_add_property ()

Property*   node_add_property               (Node *me,
                                             const char *name,
                                             const char *value);

Creates a new property and adds it to the current node.

me : a Node
name : the name of the property to create.
value : the initial value to assign to the created property.
Returns : the new Property

node_remove_property ()

void        node_remove_property            (Node *me,
                                             Property *property);

Removes the specified property from the current node.

me : a Node
property : the Property to remove from the node.

node_find_node ()

Node*       node_find_node                  (Node *me,
                                             char *path);

Returns a Node pointer for a node relative to the current node, described by a path.

me : a Node
path : a path in the format {nodename}/{nodename}/{nodename}/..., where each node name is the case-sensitive match of the sectionname of the node. The first part of the path refers to the first child, and second part for the grandchild, etc. {nodename} may also contain an index in brackets. By default the index is zero, i.e. {nodename}[0] which refers to the first match. To find the second match use {nodename}[1], etc.
Returns : a Node

node_find_property ()

Property*   node_find_property              (Node *me,
                                             char *path);

Returns a pointer to a Property, given a path. The resulting Property is not referenced, so be sure to use g_object_ref() if you plan on maintaining a pointer to it. For nodepath, see node_find_node(). The first property that matches with a case-sensitive comparison is returned.

me : a Node
path : a string in the form {nodepath}.{propertyname}
Returns : a Property

node_new ()

Node*       node_new                        (const char *node_type,
                                             const char *uri);

Creates a new instance of Node corresponding to the given type and uri.

node_type : type of the node, e.g. "inifile".
uri : the URI namespace of the node-type. Can be NULL.
Returns : a new Node. Use g_object_unref() when finished with it.

node_get_display_name()

#define node_get_display_name(node)   node_get_name(node)

A synonym for node_get_name().

node :A Node

Properties

"name" (gchararray : Read)

The name of the node.

PrevHomeNext
API ReferenceUpProperty

SourceForge Logo