Mercurial > pidgin
comparison libpurple/xmlnode.h @ 32819:2c6510167895 default tip
propagate from branch 'im.pidgin.pidgin.2.x.y' (head 3315c5dfbd0ad16511bdcf865e5b07c02d07df24)
to branch 'im.pidgin.pidgin' (head cbd1eda6bcbf0565ae7766396bb8f6f419cb6a9a)
| author | Elliott Sales de Andrade <qulogic@pidgin.im> |
|---|---|
| date | Sat, 02 Jun 2012 02:30:49 +0000 |
| parents | 98520ee78f12 |
| children |
comparison
equal
deleted
inserted
replaced
| 32818:01ff09d4a463 | 32819:2c6510167895 |
|---|---|
| 26 #ifndef _PURPLE_XMLNODE_H_ | 26 #ifndef _PURPLE_XMLNODE_H_ |
| 27 #define _PURPLE_XMLNODE_H_ | 27 #define _PURPLE_XMLNODE_H_ |
| 28 | 28 |
| 29 #include <glib.h> | 29 #include <glib.h> |
| 30 | 30 |
| 31 #ifdef __cplusplus | |
| 32 extern "C" { | |
| 33 #endif | |
| 34 | |
| 35 /** | 31 /** |
| 36 * The valid types for an xmlnode | 32 * The valid types for an xmlnode |
| 37 */ | 33 */ |
| 38 typedef enum _XMLNodeType | 34 typedef enum |
| 39 { | 35 { |
| 40 XMLNODE_TYPE_TAG, /**< Just a tag */ | 36 XMLNODE_TYPE_TAG, /**< Just a tag */ |
| 41 XMLNODE_TYPE_ATTRIB, /**< Has attributes */ | 37 XMLNODE_TYPE_ATTRIB, /**< Has attributes */ |
| 42 XMLNODE_TYPE_DATA /**< Has data */ | 38 XMLNODE_TYPE_DATA /**< Has data */ |
| 43 } XMLNodeType; | 39 } XMLNodeType; |
| 59 xmlnode *next; /**< The next node or @c NULL. */ | 55 xmlnode *next; /**< The next node or @c NULL. */ |
| 60 char *prefix; /**< The namespace prefix if any. */ | 56 char *prefix; /**< The namespace prefix if any. */ |
| 61 GHashTable *namespace_map; /**< The namespace map. */ | 57 GHashTable *namespace_map; /**< The namespace map. */ |
| 62 }; | 58 }; |
| 63 | 59 |
| 60 G_BEGIN_DECLS | |
| 61 | |
| 64 /** | 62 /** |
| 65 * Creates a new xmlnode. | 63 * Creates a new xmlnode. |
| 66 * | 64 * |
| 67 * @param name The name of the node. | 65 * @param name The name of the node. |
| 68 * | 66 * |
| 155 * @param attr The name of the attribute. | 153 * @param attr The name of the attribute. |
| 156 * @param value The value of the attribute. | 154 * @param value The value of the attribute. |
| 157 */ | 155 */ |
| 158 void xmlnode_set_attrib(xmlnode *node, const char *attr, const char *value); | 156 void xmlnode_set_attrib(xmlnode *node, const char *attr, const char *value); |
| 159 | 157 |
| 160 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_XMLNODE_C_) | 158 /** |
| 161 /** | 159 * Sets a namespaced attribute for a node |
| 162 * Sets a prefixed attribute for a node | |
| 163 * | 160 * |
| 164 * @param node The node to set an attribute for. | 161 * @param node The node to set an attribute for. |
| 165 * @param attr The name of the attribute to set | 162 * @param attr The name of the attribute to set |
| 166 * @param prefix The prefix of the attribute to ste | 163 * @param xmlns The namespace of the attribute to set |
| 164 * @param prefix The prefix of the attribute to set | |
| 167 * @param value The value of the attribute | 165 * @param value The value of the attribute |
| 168 * | |
| 169 * @deprecated Use xmlnode_set_attrib_full instead. | |
| 170 */ | |
| 171 void xmlnode_set_attrib_with_prefix(xmlnode *node, const char *attr, const char *prefix, const char *value); | |
| 172 | |
| 173 /** | |
| 174 * Sets a namespaced attribute for a node | |
| 175 * | |
| 176 * @param node The node to set an attribute for. | |
| 177 * @param attr The name of the attribute to set | |
| 178 * @param xmlns The namespace of the attribute to ste | |
| 179 * @param value The value of the attribute | |
| 180 * | |
| 181 * @deprecated Use xmlnode_set_attrib_full instead. | |
| 182 */ | |
| 183 void xmlnode_set_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns, const char *value); | |
| 184 #endif /* PURPLE_DISABLE_DEPRECATED */ | |
| 185 | |
| 186 /** | |
| 187 * Sets a namespaced attribute for a node | |
| 188 * | |
| 189 * @param node The node to set an attribute for. | |
| 190 * @param attr The name of the attribute to set | |
| 191 * @param xmlns The namespace of the attribute to ste | |
| 192 * @param prefix The prefix of the attribute to ste | |
| 193 * @param value The value of the attribute | |
| 194 * | |
| 195 * @since 2.6.0 | |
| 196 */ | 166 */ |
| 197 void xmlnode_set_attrib_full(xmlnode *node, const char *attr, const char *xmlns, | 167 void xmlnode_set_attrib_full(xmlnode *node, const char *attr, const char *xmlns, |
| 198 const char *prefix, const char *value); | 168 const char *prefix, const char *value); |
| 199 | 169 |
| 200 /** | 170 /** |
| 247 * Returns the namespace of a node | 217 * Returns the namespace of a node |
| 248 * | 218 * |
| 249 * @param node The node to get the namepsace from | 219 * @param node The node to get the namepsace from |
| 250 * @return The namespace of this node | 220 * @return The namespace of this node |
| 251 */ | 221 */ |
| 252 const char *xmlnode_get_namespace(xmlnode *node); | 222 const char *xmlnode_get_namespace(const xmlnode *node); |
| 223 | |
| 224 /** | |
| 225 * Returns the current default namespace. The default | |
| 226 * namespace is the current namespace which applies to child | |
| 227 * elements which are unprefixed and which do not contain their | |
| 228 * own namespace. | |
| 229 * | |
| 230 * For example, given: | |
| 231 * \verbatim | |
| 232 * <iq type='get' xmlns='jabber:client' xmlns:ns1='http://example.org/ns1'> | |
| 233 * <ns1:element><child1/></ns1:element> | |
| 234 * </iq> | |
| 235 * \endverbatim | |
| 236 * | |
| 237 * The default namespace of all nodes (including 'child1') is "jabber:client", | |
| 238 * though the namespace for 'element' is "http://example.org/ns1". | |
| 239 * | |
| 240 * @param node The node for which to return the default namespace | |
| 241 * @return The default namespace of this node | |
| 242 */ | |
| 243 const char *xmlnode_get_default_namespace(const xmlnode *node); | |
| 244 | |
| 245 /** | |
| 246 * Returns the defined namespace for a prefix. | |
| 247 * | |
| 248 * @param node The node from which to start the search. | |
| 249 * @param prefix The prefix for which to return the associated namespace. | |
| 250 * @return The namespace for this prefix. | |
| 251 */ | |
| 252 const char *xmlnode_get_prefix_namespace(const xmlnode *node, const char *prefix); | |
| 253 | 253 |
| 254 /** | 254 /** |
| 255 * Sets the prefix of a node | 255 * Sets the prefix of a node |
| 256 * | 256 * |
| 257 * @param node The node to qualify | 257 * @param node The node to qualify |
| 266 * @return The prefix of this node | 266 * @return The prefix of this node |
| 267 */ | 267 */ |
| 268 const char *xmlnode_get_prefix(const xmlnode *node); | 268 const char *xmlnode_get_prefix(const xmlnode *node); |
| 269 | 269 |
| 270 /** | 270 /** |
| 271 * Remove all element prefixes from an xmlnode tree. The prefix's | |
| 272 * namespace is transformed into the default namespace for an element. | |
| 273 * | |
| 274 * Note that this will not necessarily remove all prefixes in use | |
| 275 * (prefixed attributes may still exist), and that this usage may | |
| 276 * break some applications (SOAP / XPath apparently often rely on | |
| 277 * the prefixes having the same name. | |
| 278 * | |
| 279 * @param node The node from which to strip prefixes | |
| 280 */ | |
| 281 void xmlnode_strip_prefixes(xmlnode *node); | |
| 282 | |
| 283 /** | |
| 271 * Gets the parent node. | 284 * Gets the parent node. |
| 272 * | 285 * |
| 273 * @param child The child node. | 286 * @param child The child node. |
| 274 * | 287 * |
| 275 * @return The parent or NULL. | 288 * @return The parent or NULL. |
| 276 * | |
| 277 * @since 2.6.0 | |
| 278 */ | 289 */ |
| 279 xmlnode *xmlnode_get_parent(const xmlnode *child); | 290 xmlnode *xmlnode_get_parent(const xmlnode *child); |
| 280 | 291 |
| 281 /** | 292 /** |
| 282 * Returns the node in a string of xml. | 293 * Returns the node in a string of xml. |
| 341 * the user if the file cannot be read. | 352 * the user if the file cannot be read. |
| 342 * @param process The subsystem that is calling xmlnode_from_file. Used as | 353 * @param process The subsystem that is calling xmlnode_from_file. Used as |
| 343 * the category for debugging. | 354 * the category for debugging. |
| 344 * | 355 * |
| 345 * @return The new node or NULL if an error occurred. | 356 * @return The new node or NULL if an error occurred. |
| 346 * | |
| 347 * @since 2.6.0 | |
| 348 */ | 357 */ |
| 349 xmlnode *xmlnode_from_file(const char *dir, const char *filename, | 358 xmlnode *xmlnode_from_file(const char *dir, const char *filename, |
| 350 const char *description, const char *process); | 359 const char *description, const char *process); |
| 351 | 360 |
| 352 #ifdef __cplusplus | 361 G_END_DECLS |
| 353 } | |
| 354 #endif | |
| 355 | 362 |
| 356 #endif /* _PURPLE_XMLNODE_H_ */ | 363 #endif /* _PURPLE_XMLNODE_H_ */ |
| 364 |
