wocky Reference Manual | ||||
---|---|---|---|---|
Top | Description |
#include <wocky/wocky-node.h> enum WockyNodeBuildTag; WockyNode; gboolean (*wocky_node_each_attr_func) (const gchar *key
,const gchar *value
,const gchar *pref
,const gchar *ns
,gpointer user_data
); gboolean (*wocky_node_each_child_func) (WockyNode *node
,gpointer user_data
); void wocky_node_each_attribute (WockyNode *node
,wocky_node_each_attr_func func
,gpointer user_data
); void wocky_node_each_child (WockyNode *node
,wocky_node_each_child_func func
,gpointer user_data
); const gchar * wocky_node_get_attribute (WockyNode *node
,const gchar *key
); const gchar * wocky_node_get_attribute_ns (WockyNode *node
,const gchar *key
,const gchar *ns
); void wocky_node_set_attribute (WockyNode *node
,const gchar *key
,const gchar *value
); void wocky_node_set_attribute_ns (WockyNode *node
,const gchar *key
,const gchar *value
,const gchar *ns
); void wocky_node_set_attribute_n (WockyNode *node
,const gchar *key
,const gchar *value
,gsize value_size
); void wocky_node_set_attribute_n_ns (WockyNode *node
,const gchar *key
,const gchar *value
,gsize value_size
,const gchar *ns
); const gchar * wocky_node_attribute_ns_get_prefix_from_urn (const gchar *urn
); const gchar * wocky_node_attribute_ns_get_prefix_from_quark (GQuark ns
); void wocky_node_attribute_ns_set_prefix (GQuark ns
,const gchar *prefix
); WockyNode * wocky_node_get_child (WockyNode *node
,const gchar *name
); WockyNode * wocky_node_get_child_ns (WockyNode *node
,const gchar *name
,const gchar *ns
); WockyNode * wocky_node_get_first_child (WockyNode *node
); WockyNode * wocky_node_get_first_child_ns (WockyNode *node
,const gchar *ns
); const gchar * wocky_node_get_content_from_child (WockyNode *node
,const gchar *name
); const gchar * wocky_node_get_content_from_child_ns (WockyNode *node
,const gchar *name
,const gchar *ns
); WockyNode * wocky_node_add_child (WockyNode *node
,const gchar *name
); WockyNode * wocky_node_add_child_ns (WockyNode *node
,const gchar *name
,const gchar *ns
); WockyNode * wocky_node_add_child_ns_q (WockyNode *node
,const gchar *name
,GQuark ns
); WockyNode * wocky_node_add_child_with_content (WockyNode *node
,const gchar *name
,const char *content
); WockyNode * wocky_node_add_child_with_content_ns (WockyNode *node
,const gchar *name
,const gchar *content
,const gchar *ns
); WockyNode * wocky_node_add_child_with_content_ns_q (WockyNode *node
,const gchar *name
,const gchar *content
,GQuark ns
); const gchar * wocky_node_get_ns (WockyNode *node
); gboolean wocky_node_has_ns (WockyNode *node
,const gchar *ns
); gboolean wocky_node_has_ns_q (WockyNode *node
,GQuark ns
); const gchar * wocky_node_get_language (WockyNode *node
); void wocky_node_set_language (WockyNode *node
,const gchar *lang
); void wocky_node_set_language_n (WockyNode *node
,const gchar *lang
,gsize lang_size
); void wocky_node_set_content (WockyNode *node
,const gchar *content
); void wocky_node_append_content (WockyNode *node
,const gchar *content
); void wocky_node_append_content_n (WockyNode *node
,const gchar *content
,gsize size
); gchar * wocky_node_to_string (WockyNode *node
); WockyNode * wocky_node_new (const char *name
,const gchar *ns
); void wocky_node_free (WockyNode *node
); gboolean wocky_node_equal (WockyNode *node0
,WockyNode *node1
); gboolean wocky_node_is_superset (WockyNode *node
,WockyNode *subset
); WockyNodeIter; void wocky_node_iter_init (WockyNodeIter *iter
,WockyNode *node
,const gchar *name
,const gchar *ns
); gboolean wocky_node_iter_next (WockyNodeIter *iter
,WockyNode **next
); void wocky_node_add_build (WockyNode *node
,...
); void wocky_node_add_build_va (WockyNode *node
,va_list va
); void wocky_node_add_node_tree (WockyNode *node
,WockyNodeTree *tree
); void wocky_node_init (void
); void wocky_node_deinit (void
);
Low level representation of a XMPP node. Provides ways to set various parameters on the node, such as content, language, namespaces and prefixes. It also offers methods to lookup children of a node.
typedef enum { WOCKY_NODE_START = '(', WOCKY_NODE_TEXT = '$', WOCKY_NODE_END = ')', WOCKY_NODE_ATTRIBUTE = '@', WOCKY_NODE_XMLNS = ':', WOCKY_NODE_ASSIGN_TO = '*' } WockyNodeBuildTag;
typedef struct { gchar *name; gchar *content; /* Private */ gchar *language; GQuark ns; GSList *attributes; GSList *children; } WockyNode;
gboolean (*wocky_node_each_attr_func) (const gchar *key
,const gchar *value
,const gchar *pref
,const gchar *ns
,gpointer user_data
);
Specifies the type of functions passed to wocky_node_each_attribute()
.
|
the attribute's key |
|
the attribute's value |
|
the attribute's prefix |
|
the attribute's namespace |
|
user data passed to wocky_node_each_attribute()
|
Returns : |
FALSE to stop further attributes from being examined.
|
gboolean (*wocky_node_each_child_func) (WockyNode *node
,gpointer user_data
);
Specifies the type of functions passed to wocky_node_each_child()
.
|
a WockyNode |
|
user data passed to wocky_node_each_child()
|
Returns : |
FALSE to stop further children from being examined.
|
void wocky_node_each_attribute (WockyNode *node
,wocky_node_each_attr_func func
,gpointer user_data
);
Calls a function for each attribute of a WockyNode.
|
a WockyNode |
|
the function to be called on each node's attribute |
|
user data to pass to the function |
void wocky_node_each_child (WockyNode *node
,wocky_node_each_child_func func
,gpointer user_data
);
Calls a function for each child of a WockyNode.
|
a WockyNode |
|
the function to be called on each node's child |
|
user data to pass to the function |
const gchar * wocky_node_get_attribute (WockyNode *node
,const gchar *key
);
Returns the value of an attribute in a WockyNode.
const gchar * wocky_node_get_attribute_ns (WockyNode *node
,const gchar *key
,const gchar *ns
);
Returns the value of an attribute in a WockyNode, limiting the search
within a specific namespace. If the namespace is NULL
, this is equivalent
to wocky_node_get_attribute()
.
void wocky_node_set_attribute (WockyNode *node
,const gchar *key
,const gchar *value
);
Sets an attribute in a WockyNode to a specific value.
|
a WockyNode |
|
the attribute name to set |
|
the value to set |
void wocky_node_set_attribute_ns (WockyNode *node
,const gchar *key
,const gchar *value
,const gchar *ns
);
Sets an attribute in a WockyNode, within a specific namespace.
If the namespace is NULL
, this is equivalent to
wocky_node_set_attribute()
.
void wocky_node_set_attribute_n (WockyNode *node
,const gchar *key
,const gchar *value
,gsize value_size
);
Sets a new attribute to a WockyNode, with the supplied values.
|
a WockyNode |
|
the attribute to set |
|
the value to set |
|
the number of bytes of value to set as a value
|
void wocky_node_set_attribute_n_ns (WockyNode *node
,const gchar *key
,const gchar *value
,gsize value_size
,const gchar *ns
);
Sets a new attribute to a WockyNode, with the supplied values.
If the namespace is NULL
, this is equivalent to
wocky_node_set_attribute_n()
.
const gchar * wocky_node_attribute_ns_get_prefix_from_urn
(const gchar *urn
);
Gets the prefix of the namespace identified by the URN.
|
a string containing an URN |
Returns : |
a string containing the prefix of the namespace urn .
|
const gchar * wocky_node_attribute_ns_get_prefix_from_quark
(GQuark ns
);
Gets the prefix of the namespace identified by the quark.
|
a quark corresponding to an XML namespace URN |
Returns : |
a string containing the prefix of the namespace ns .
|
void wocky_node_attribute_ns_set_prefix (GQuark ns
,const gchar *prefix
);
Sets a desired prefix for a namespace.
|
a GQuark |
|
a string containing the desired prefix |
WockyNode * wocky_node_get_child (WockyNode *node
,const gchar *name
);
Gets a child of a node, searching by name.
WockyNode * wocky_node_get_child_ns (WockyNode *node
,const gchar *name
,const gchar *ns
);
Gets the child of a node, searching by name and limiting the search
to the specified namespace.
If the namespace is NULL
, this is equivalent to wocky_node_get_child()
WockyNode * wocky_node_get_first_child (WockyNode *node
);
Convenience function to return the first child of a WockyNode.
WockyNode * wocky_node_get_first_child_ns (WockyNode *node
,const gchar *ns
);
Returns the first child of node
whose namespace is ns
, saving you the
bother of faffing around with a WockyNodeIter.
const gchar * wocky_node_get_content_from_child (WockyNode *node
,const gchar *name
);
Retrieves the content from a child of a node, if it exists.
const gchar * wocky_node_get_content_from_child_ns (WockyNode *node
,const gchar *name
,const gchar *ns
);
Retrieves the content from a child of a node, if it exists.
WockyNode * wocky_node_add_child (WockyNode *node
,const gchar *name
);
Adds a WockyNode with the specified name to an already existing node.
WockyNode * wocky_node_add_child_ns (WockyNode *node
,const gchar *name
,const gchar *ns
);
Adds a WockyNode with the specified name to an already existing node,
under the specified namespace. If the namespace is NULL
, this is equivalent
to wocky_node_add_child()
.
WockyNode * wocky_node_add_child_ns_q (WockyNode *node
,const gchar *name
,GQuark ns
);
Adds a WockyNode with the specified name to an already existing node,
under the specified namespace. If the namespace is 0, this is equivalent
to wocky_node_add_child()
.
WockyNode * wocky_node_add_child_with_content (WockyNode *node
,const gchar *name
,const char *content
);
Adds a WockyNode with the specified name and containing the specified content to an already existing node.
WockyNode * wocky_node_add_child_with_content_ns (WockyNode *node
,const gchar *name
,const gchar *content
,const gchar *ns
);
Adds a WockyNode with the specified name and the specified content
to an already existing node, under the specified namespace.
If the namespace is NULL
, this is equivalent to
wocky_node_add_child_with_content()
.
WockyNode * wocky_node_add_child_with_content_ns_q (WockyNode *node
,const gchar *name
,const gchar *content
,GQuark ns
);
Adds a WockyNode with the specified name and the specified content
to an already existing node, under the specified namespace.
If the namespace is 0, this is equivalent to
wocky_node_add_child_with_content()
.
const gchar * wocky_node_get_ns (WockyNode *node
);
Gets the namespace of a WockyNode
|
a WockyNode |
Returns : |
a string containing the namespace of the node. |
gboolean wocky_node_has_ns (WockyNode *node
,const gchar *ns
);
|
|
|
|
Returns : |
gboolean wocky_node_has_ns_q (WockyNode *node
,GQuark ns
);
|
|
|
|
Returns : |
const gchar * wocky_node_get_language (WockyNode *node
);
Gets the language of a WockyNode
|
a WockyNode |
Returns : |
a string containing the language of the node. |
void wocky_node_set_language (WockyNode *node
,const gchar *lang
);
Sets the language of a WockyNode.
void wocky_node_set_language_n (WockyNode *node
,const gchar *lang
,gsize lang_size
);
Sets the language of a WockyNode.
|
a WockyNode |
|
a language |
|
the length of lang , in bytes.
|
void wocky_node_set_content (WockyNode *node
,const gchar *content
);
Sets the content of a WockyNode.
|
a WockyNode |
|
the content to set to the node |
void wocky_node_append_content (WockyNode *node
,const gchar *content
);
Appends some content to the content of a WockyNode.
|
a WockyNode |
|
the content to append to the node |
void wocky_node_append_content_n (WockyNode *node
,const gchar *content
,gsize size
);
Appends a specified number of content bytes to the content of a WockyNode.
|
a WockyNode |
|
the content to append to the node |
|
the size of the content to append |
gchar * wocky_node_to_string (WockyNode *node
);
Obtains a string representation of a WockyNode.
|
a WockyNode |
Returns : |
a newly allocated string containing a serialization of the node. |
WockyNode * wocky_node_new (const char *name
,const gchar *ns
);
Convenience function which creates a WockyNode and sets its
name to name
.
|
the node's name (may not be NULL) |
|
the nodes namespace (may not be NULL) |
Returns : |
a newly allocated WockyNode. |
void wocky_node_free (WockyNode *node
);
Convenience function that frees the passed in WockyNode and all of its children.
|
a WockyNode. |
gboolean wocky_node_equal (WockyNode *node0
,WockyNode *node1
);
Compares two WockyNodes for equality.
void wocky_node_iter_init (WockyNodeIter *iter
,WockyNode *node
,const gchar *name
,const gchar *ns
);
Initializes an iterator that can be used to iterate over the children of
node
, filtered by name
and ns
1 2 3 4 5 6 7 8 9 10 |
WockyNodeIter iter; WockyNode *child; wocky_node_iter_init (&iter, wocky_stanza_get_top_node (stanza), "payload-type", WOCKY_XMPP_NS_JINGLE_RTP); while (wocky_node_iter_next (iter, &child)) { /* do something with the child */ } |
gboolean wocky_node_iter_next (WockyNodeIter *iter
,WockyNode **next
);
Advances iter to the next child that matches its filter. if FALSE
is
returned next is not set and the iterator becomes invalid
|
an initialized WockyNodeIter |
|
a location to store the next child |
Returns : |
FALSE if the last child has been reached
|
void wocky_node_add_build (WockyNode *node
,...
);
Add a node subtree to an existing parent node.
The above examples adds the following subtree under the given node:
<body> Telepathy rocks! </body>
|
The node under which to add a new subtree |
|
the description of the stanza to build,
terminated with NULL
|
void wocky_node_add_node_tree (WockyNode *node
,WockyNodeTree *tree
);
Copies the nodes from tree
adds them as a child of node
.
|
A node |
|
The node tree to add |
void wocky_node_init (void
);
Initializes the caches used by WockyNode. This should be always called before using WockyNode structs.
void wocky_node_deinit (void
);
Releases all the resources used by the WockyNode caches.