Reading And Writing From/To Streams | |
GWENHYWFAR_API int | GWEN_XML_ReadFile (GWEN_XMLNODE *n, const char *filepath, uint32_t flags) |
GWENHYWFAR_API int | GWEN_XML_ReadFromFastBuffer (GWEN_XML_CONTEXT *ctx, GWEN_FAST_BUFFER *fb) |
GWENHYWFAR_API int | GWEN_XML_ReadFromIo (GWEN_XML_CONTEXT *ctx, GWEN_IO_LAYER *io) |
GWENHYWFAR_API void | GWEN_XMLNode_AddNameSpace (GWEN_XMLNODE *n, const GWEN_XMLNODE_NAMESPACE *ns) |
GWENHYWFAR_API GWEN_XMLNODE_NAMESPACE * | GWEN_XMLNode_FindNameSpaceByName (const GWEN_XMLNODE *n, const char *s) |
GWENHYWFAR_API GWEN_XMLNODE_NAMESPACE * | GWEN_XMLNode_FindNameSpaceByUrl (const GWEN_XMLNODE *n, const char *s) |
GWENHYWFAR_API GWEN_XMLNODE * | GWEN_XMLNode_fromString (const char *s, int len, uint32_t flags) |
GWENHYWFAR_API GWEN_XMLNODE_NAMESPACE_LIST * | GWEN_XMLNode_GetNameSpaces (const GWEN_XMLNODE *n) |
GWENHYWFAR_API int | GWEN_XMLNode_Globalize (GWEN_XMLNODE *n) |
GWENHYWFAR_API int | GWEN_XMLNode_GlobalizeWithList (GWEN_XMLNODE *n, GWEN_XMLNODE_NAMESPACE_LIST *l, uint32_t *pLastId) |
GWENHYWFAR_API int | GWEN_XMLNode_NormalizeNameSpaces (GWEN_XMLNODE *n) |
GWENHYWFAR_API int | GWEN_XMLNode_toBuffer (const GWEN_XMLNODE *n, GWEN_BUFFER *buf, uint32_t flags) |
GWENHYWFAR_API int | GWEN_XMLNode_WriteFile (const GWEN_XMLNODE *n, const char *fname, uint32_t flags) |
GWENHYWFAR_API int | GWEN_XMLNode_WriteToStream (const GWEN_XMLNODE *n, GWEN_XML_CONTEXT *ctx, GWEN_IO_LAYER *io) |
Managing Nodes | |
GWENHYWFAR_API void | GWEN_XMLNode_AddChild (GWEN_XMLNODE *n, GWEN_XMLNODE *child) |
GWENHYWFAR_API void | GWEN_XMLNode_AddChildrenOnly (GWEN_XMLNODE *n, GWEN_XMLNODE *nn, int copythem) |
GWENHYWFAR_API GWEN_XMLNODE * | GWEN_XMLNode_FindNode (const GWEN_XMLNODE *n, GWEN_XMLNODE_TYPE t, const char *data) |
GWENHYWFAR_API void | GWEN_XMLNode_RemoveChildren (GWEN_XMLNODE *n) |
GWENHYWFAR_API void | GWEN_XMLNode_UnlinkChild (GWEN_XMLNODE *n, GWEN_XMLNODE *child) |
Managing Headers | |
Headers are special tags in XML files which describe the document (such as <?xml?> or <!DOCTYPE>). If the flag GWEN_XML_FLAGS_HANDLE_HEADERS is on upon reading of files these special toplevel tags are added to the current node's header list instead of the normal children node list. If the same flag is given when writing files the header tags of the given root node are written to the output stream before its children.
Header nodes are identified as nodes whose name begins with '?' or '!'. | |
GWENHYWFAR_API void | GWEN_XMLNode_AddHeader (GWEN_XMLNODE *root, GWEN_XMLNODE *nh) |
GWENHYWFAR_API void | GWEN_XMLNode_ClearHeaders (GWEN_XMLNODE *root) |
GWENHYWFAR_API void | GWEN_XMLNode_DelHeader (GWEN_XMLNODE *root, GWEN_XMLNODE *nh) |
GWENHYWFAR_API GWEN_XMLNODE * | GWEN_XMLNode_GetHeader (const GWEN_XMLNODE *n) |
Managing Properties/Attributes | |
A property (in XML notation this is called attribute) is given within a tag (in XML notation this is called element), like in this example:
<tag property="1" /> | |
GWENHYWFAR_API void | GWEN_XMLNode_CopyProperties (GWEN_XMLNODE *tn, const GWEN_XMLNODE *sn, int overwrite) |
GWENHYWFAR_API const char * | GWEN_XMLNode_GetProperty (const GWEN_XMLNODE *n, const char *name, const char *defaultValue) |
GWENHYWFAR_API void | GWEN_XMLNode_SetProperty (GWEN_XMLNODE *n, const char *name, const char *value) |
Usage Counter | |
The usage counter of a node is only used by applications, not by Gwenhywfar itself. So if the application does not set this counter it will always be zero.
An application could use this counter to check whether a given node is still in use by some parts of the application in order to free unused nodes. | |
GWENHYWFAR_API void | GWEN_XMLNode_DecUsage (GWEN_XMLNODE *n) |
GWENHYWFAR_API uint32_t | GWEN_XMLNode_GetUsage (const GWEN_XMLNODE *n) |
GWENHYWFAR_API void | GWEN_XMLNode_IncUsage (GWEN_XMLNODE *n) |
Debugging | |
GWENHYWFAR_API void | GWEN_XMLNode_Dump (const GWEN_XMLNODE *n, FILE *f, int ind) |
Constructors and Destructors | |
GWENHYWFAR_API GWEN_XMLNODE * | GWEN_XMLNode_dup (const GWEN_XMLNODE *n) |
GWENHYWFAR_API void | GWEN_XMLNode_free (GWEN_XMLNODE *n) |
GWENHYWFAR_API void | GWEN_XMLNode_freeAll (GWEN_XMLNODE *n) |
GWENHYWFAR_API GWEN_XMLNODE * | GWEN_XMLNode_new (GWEN_XMLNODE_TYPE t, const char *data) |
Iterating Through an XML Tree | |
GWENHYWFAR_API GWEN_XMLNODE * | GWEN_XMLNode_FindFirstTag (const GWEN_XMLNODE *n, const char *tname, const char *pname, const char *pvalue) |
GWENHYWFAR_API GWEN_XMLNODE * | GWEN_XMLNode_FindNextTag (const GWEN_XMLNODE *n, const char *tname, const char *pname, const char *pvalue) |
GWENHYWFAR_API GWEN_XMLNODE * | GWEN_XMLNode_GetChild (const GWEN_XMLNODE *n) |
GWENHYWFAR_API GWEN_XMLNODE * | GWEN_XMLNode_GetFirstData (const GWEN_XMLNODE *n) |
GWENHYWFAR_API GWEN_XMLNODE * | GWEN_XMLNode_GetFirstTag (const GWEN_XMLNODE *n) |
GWENHYWFAR_API GWEN_XMLNODE * | GWEN_XMLNode_GetNextData (const GWEN_XMLNODE *n) |
GWENHYWFAR_API GWEN_XMLNODE * | GWEN_XMLNode_GetNextTag (const GWEN_XMLNODE *n) |
GWENHYWFAR_API GWEN_XMLNODE * | GWEN_XMLNode_GetNodeByXPath (GWEN_XMLNODE *n, const char *path, uint32_t flags) |
GWENHYWFAR_API GWEN_XMLNODE * | GWEN_XMLNode_GetParent (const GWEN_XMLNODE *n) |
GWENHYWFAR_API int | GWEN_XMLNode_GetXPath (const GWEN_XMLNODE *n1, const GWEN_XMLNODE *n2, GWEN_BUFFER *nbuf) |
GWENHYWFAR_API int | GWEN_XMLNode_IsChildOf (const GWEN_XMLNODE *parent, const GWEN_XMLNODE *child) |
GWENHYWFAR_API GWEN_XMLNODE * | GWEN_XMLNode_Next (const GWEN_XMLNODE *n) |
Handling Tags As Variables | |
These functions look for a tag, read their first data element and return it as if it was a DB variable. This simplifies access to simple tags containing simple data tags only. E.g. if your XML structure is this: <test> <X> 15 </X> <Y> 10 </Y> </test> x=GWEN_XMLNode_GetIntValue(testNode, "X", 0); | |
GWENHYWFAR_API const char * | GWEN_XMLNode_GetCharValue (const GWEN_XMLNODE *n, const char *name, const char *defValue) |
GWENHYWFAR_API int | GWEN_XMLNode_GetIntValue (const GWEN_XMLNODE *n, const char *name, int defValue) |
GWENHYWFAR_API const char * | GWEN_XMLNode_GetLocalizedCharValue (const GWEN_XMLNODE *n, const char *name, const char *defValue) |
GWENHYWFAR_API void | GWEN_XMLNode_SetCharValue (GWEN_XMLNODE *n, const char *name, const char *value) |
GWENHYWFAR_API void | GWEN_XMLNode_SetIntValue (GWEN_XMLNODE *n, const char *name, int value) |
Type And Data | |
GWENHYWFAR_API const char * | GWEN_XMLNode_GetData (const GWEN_XMLNODE *n) |
GWENHYWFAR_API GWEN_XMLNODE_TYPE | GWEN_XMLNode_GetType (const GWEN_XMLNODE *n) |
GWENHYWFAR_API void | GWEN_XMLNode_SetData (GWEN_XMLNODE *n, const char *data) |
Read Flags | |
#define | GWEN_XML_FLAGS_DEFAULT |
#define | GWEN_XML_FLAGS_HANDLE_COMMENTS 0x0001 |
#define | GWEN_XML_FLAGS_HANDLE_HEADERS 0x0080 |
#define | GWEN_XML_FLAGS_HANDLE_NAMESPACES 0x0200 |
#define | GWEN_XML_FLAGS_HANDLE_OPEN_HTMLTAGS 0x0004 |
#define | GWEN_XML_FLAGS_INDENT 0x0002 |
#define | GWEN_XML_FLAGS_KEEP_BLANKS 0x0020 |
#define | GWEN_XML_FLAGS_KEEP_CNTRL 0x0010 |
#define | GWEN_XML_FLAGS_NO_CONDENSE 0x0008 |
#define | GWEN_XML_FLAGS_SIMPLE 0x0040 |
#define | GWEN_XML_FLAGS_TOLERANT_ENDTAGS 0x0100 |
Typedefs | |
typedef struct GWEN__XMLNODE | GWEN_XMLNODE |
typedef struct GWEN_XMLNODE_NAMESPACE | GWEN_XMLNODE_NAMESPACE |
Enumerations | |
enum | GWEN_XMLNODE_TYPE { GWEN_XMLNodeTypeTag = 0, GWEN_XMLNodeTypeData, GWEN_XMLNodeTypeComment } |
#define GWEN_XML_FLAGS_DEFAULT |
Value:
combination of other flags resembling the default flagsDefinition at line 114 of file xml.h.
Referenced by GWEN_LoadPluginDescrsByType().
#define GWEN_XML_FLAGS_HANDLE_COMMENTS 0x0001 |
if set then comments are read. Otherwise they are ignored when reading a file
Definition at line 64 of file xml.h.
Referenced by GWEN_XMLNode__WriteToStream().
#define GWEN_XML_FLAGS_HANDLE_HEADERS 0x0080 |
apply special treatment to toplevel header tags (such as <?xml>)
Definition at line 98 of file xml.h.
Referenced by GWEN_LoadPluginDescrsByType(), GWEN_XmlCtxStore_StartTag(), and GWEN_XMLNode_WriteToStream().
#define GWEN_XML_FLAGS_HANDLE_NAMESPACES 0x0200 |
Definition at line 109 of file xml.h.
Referenced by GWEN_XmlCtxStore_AddAttr(), and GWEN_XMLNode__WriteToStream().
#define GWEN_XML_FLAGS_HANDLE_OPEN_HTMLTAGS 0x0004 |
Let the parser accept some HTML which are known to be unclosed (e.g. the tag "BR" in HTML tags is never closed). If not set a "BR" tag without a corresponding "/BR" will produce an error.
Definition at line 77 of file xml.h.
Referenced by GWEN_LoadPluginDescrsByType().
#define GWEN_XML_FLAGS_INDENT 0x0002 |
Indent lines according to node level when writing nodes. This increases the readability of the resulting file.
Definition at line 70 of file xml.h.
Referenced by GWEN_XMLNode__WriteToStream().
#define GWEN_XML_FLAGS_KEEP_BLANKS 0x0020 |
#define GWEN_XML_FLAGS_KEEP_CNTRL 0x0010 |
If set then control characters (such as CR, LF) will not be removed from data.
Definition at line 89 of file xml.h.
Referenced by GWEN_XmlCtxStore_AddData().
#define GWEN_XML_FLAGS_NO_CONDENSE 0x0008 |
If set then data will not be condensed (e.g. multiple spaces will not be replaced by a single one).
Definition at line 83 of file xml.h.
Referenced by GWEN_XmlCtxStore_AddData().
#define GWEN_XML_FLAGS_TOLERANT_ENDTAGS 0x0100 |
If this flag is given this module will be more tolerant when encountering and end element (e.g. </html>). If the name of the end element does not match the currently open element then the element to be closed is searched above the currently open element. This works around problems with malformed XML files.
Definition at line 107 of file xml.h.
Referenced by GWEN_PluginDescription__GetLocalizedLongDescrByFormat(), GWEN_PluginDescription__GetLongDescrByFormat(), and GWEN_XmlCtxStore_StartTag().
typedef struct GWEN__XMLNODE GWEN_XMLNODE |
The abstract type XMLNODE. Each node is one node in the document tree and can represent different things, see GWEN_XMLNODE_TYPE.
typedef struct GWEN_XMLNODE_NAMESPACE GWEN_XMLNODE_NAMESPACE |
enum GWEN_XMLNODE_TYPE |
GWENHYWFAR_API int GWEN_XML_ReadFile | ( | GWEN_XMLNODE * | n, | |
const char * | filepath, | |||
uint32_t | flags | |||
) |
Reads all tags/elements from a file and adds them as children to the given node.
Definition at line 902 of file xmlrw.c.
References DBG_ERROR, DBG_INFO, GWEN_ERROR_IO, GWEN_Io_Layer_Disconnect(), GWEN_Io_Layer_free(), GWEN_Io_LayerFile_new(), GWEN_Io_Manager_RegisterLayer(), GWEN_IO_REQUEST_FLAGS_FORCE, GWEN_LOGDOMAIN, GWEN_XML__ReadAllFromIo(), GWEN_XmlCtx_free(), and GWEN_XmlCtxStore_new().
Referenced by GWEN_LoadPluginDescrsByType().
GWENHYWFAR_API int GWEN_XML_ReadFromFastBuffer | ( | GWEN_XML_CONTEXT * | ctx, | |
GWEN_FAST_BUFFER * | fb | |||
) |
Definition at line 787 of file xmlrw.c.
References GWEN_FAST_BUFFER::bufferReadPos, DBG_ERROR, DBG_INFO, GWEN_ERROR_EOF, GWEN_FASTBUFFER_PEEKBYTE, GWEN_LOGDOMAIN, GWEN_XML__ReadData(), GWEN_XML__ReadTag(), GWEN_XmlCtx_GetDepth(), GWEN_XmlCtx_GetFinishedElement(), GWEN_XmlCtx_GetFlags(), and GWEN_XmlCtx_ResetFinishedElement().
Referenced by GWEN_XML__ReadAllFromIo(), and GWEN_XML_ReadFromIo().
GWENHYWFAR_API int GWEN_XML_ReadFromIo | ( | GWEN_XML_CONTEXT * | ctx, | |
GWEN_IO_LAYER * | io | |||
) |
Reads a single element (and all its sub-elements) from an IO layer.
Definition at line 879 of file xmlrw.c.
References DBG_INFO, GWEN_FastBuffer_free(), GWEN_FastBuffer_new(), GWEN_LOGDOMAIN, GWEN_XML_BUFFERSIZE, GWEN_XML_ReadFromFastBuffer(), GWEN_XmlCtx_GetGuiId(), and GWEN_XmlCtx_GetTimeout().
GWENHYWFAR_API void GWEN_XMLNode_AddChild | ( | GWEN_XMLNODE * | n, | |
GWEN_XMLNODE * | child | |||
) |
Adds a node as a child to another one. This function does not make deep copies. Instead it takes over ownership of the new child.
n | node to which the new node is to be added (i.e. the node which becomes the parent of the second argument) | |
child | child which is to be added (this function takes over ownership of that node, so you MUST NOT free the node yourself) |
Definition at line 336 of file xml.c.
References GWEN_XMLNode_List_Add().
Referenced by GWEN_MsgEngine__ListElement(), GWEN_MsgEngine__ListGroup(), GWEN_MsgEngine_AddDefinitions(), GWEN_XmlCtxStore_AddData(), GWEN_XmlCtxStore_StartTag(), GWEN_XMLNode_AddChildrenOnly(), GWEN_XMLNode_dup(), GWEN_XMLNode_HandlePath(), and GWEN_XMLNode_SetCharValue().
GWENHYWFAR_API void GWEN_XMLNode_AddChildrenOnly | ( | GWEN_XMLNODE * | n, | |
GWEN_XMLNODE * | nn, | |||
int | copythem | |||
) |
Adds the children of the second argument as new children to the first one.
n | node which is to become parent of the second argument's children | |
nn | node whose children are to be moved. | |
copythem | if 0 then the children will be moved (leaving the node of the second argument without children), otherwise deep copies will be made and the node from the second argument will not be altered. co |
Definition at line 344 of file xml.c.
References GWEN_XMLNode_AddChild(), GWEN_XMLNode_dup(), GWEN_XMLNode_GetChild(), GWEN_XMLNode_Next(), and GWEN_XMLNode_UnlinkChild().
GWENHYWFAR_API void GWEN_XMLNode_AddHeader | ( | GWEN_XMLNODE * | root, | |
GWEN_XMLNODE * | nh | |||
) |
Adds a node as a header to the given root node.
Definition at line 1061 of file xml.c.
References GWEN_XMLNode_List_Add().
Referenced by GWEN_XmlCtxStore_StartTag(), and GWEN_XMLNode_dup().
GWENHYWFAR_API void GWEN_XMLNode_AddNameSpace | ( | GWEN_XMLNODE * | n, | |
const GWEN_XMLNODE_NAMESPACE * | ns | |||
) |
Definition at line 1131 of file xml.c.
References GWEN_XMLNode_NameSpace_dup(), and GWEN_XMLNode_NameSpace_List_Add().
Referenced by GWEN_XmlCtxStore_AddAttr().
GWENHYWFAR_API void GWEN_XMLNode_ClearHeaders | ( | GWEN_XMLNODE * | root | ) |
Clears the given root nodes' list of headers. All the tags in the header list are also freed.
Definition at line 1077 of file xml.c.
References GWEN_XMLNode_List_Clear().
GWENHYWFAR_API void GWEN_XMLNode_CopyProperties | ( | GWEN_XMLNODE * | tn, | |
const GWEN_XMLNODE * | sn, | |||
int | overwrite | |||
) |
This function copies the properties/attributes of one tag/element to another one.
tn | destination node (must be a tag/element) | |
sn | source node (must be a tag/element) | |
overwrite | if !=0 then existing properties/attributes in the destination node will be overwritten. |
Definition at line 493 of file xml.c.
References GWEN_Memory_dealloc(), GWEN_Memory_strdup(), GWEN_XMLProperty_add(), and GWEN_XMLProperty_dup().
Referenced by GWEN_MsgEngine__ListGroup().
GWENHYWFAR_API void GWEN_XMLNode_DecUsage | ( | GWEN_XMLNODE * | n | ) |
GWENHYWFAR_API void GWEN_XMLNode_DelHeader | ( | GWEN_XMLNODE * | root, | |
GWEN_XMLNODE * | nh | |||
) |
Removes a node from the given root nodes' header list. The header node is just removed from the list, not freed !
Definition at line 1069 of file xml.c.
References GWEN_XMLNode_List_Del().
GWENHYWFAR_API void GWEN_XMLNode_Dump | ( | const GWEN_XMLNODE * | n, | |
FILE * | f, | |||
int | ind | |||
) |
Dumps the content of the given XML node and all its children.
Definition at line 381 of file xml.c.
References DBG_ERROR, GWEN_LOGDOMAIN, GWEN_XMLNode_Dump(), GWEN_XMLNode_GetChild(), GWEN_XMLNode_Next(), GWEN_XMLNodeTypeComment, GWEN_XMLNodeTypeData, and GWEN_XMLNodeTypeTag.
Referenced by GWEN_MsgEngine__ReadGroup(), GWEN_MsgEngine__ReadValue(), GWEN_MsgEngine__WriteGroup(), GWEN_XMLNode_Dump(), and GWEN_XMLNode_Path_Dump().
GWENHYWFAR_API GWEN_XMLNODE* GWEN_XMLNode_dup | ( | const GWEN_XMLNODE * | n | ) |
Create and return a deep copy of the given node.
Definition at line 174 of file xml.c.
References GWEN_XMLNode_AddChild(), GWEN_XMLNode_AddHeader(), GWEN_XMLNode_dup(), GWEN_XMLNode_List_First(), GWEN_XMLNode_NameSpace_dup(), GWEN_XMLNode_NameSpace_List_Add(), GWEN_XMLNode_NameSpace_List_First(), GWEN_XMLNode_NameSpace_List_Next(), GWEN_XMLNode_new(), GWEN_XMLNode_Next(), GWEN_XMLProperty_add(), and GWEN_XMLProperty_dup().
Referenced by GWEN_MsgEngine__ListElement(), GWEN_MsgEngine__ListGroup(), GWEN_MsgEngine_AddDefinitions(), GWEN_MsgEngine_ListMessage(), GWEN_PluginDescription_dup(), GWEN_PluginDescription_new(), GWEN_XMLNode_AddChildrenOnly(), and GWEN_XMLNode_dup().
GWENHYWFAR_API GWEN_XMLNODE* GWEN_XMLNode_FindFirstTag | ( | const GWEN_XMLNODE * | n, | |
const char * | tname, | |||
const char * | pname, | |||
const char * | pvalue | |||
) |
Searches for the first matching tag/element below the given one. Lets say you have the following XML file:
<DEVICES> <DEVICE id="dev1" /> <DEVICE id="dev2" /> </DEVICES>
tag=GWEN_XMLNode_FindFirstTag(root, "DEVICE", "id", "dev2");
n | tag/element below which to search | |
tname | tag/element name (e.g. if the tag is "<TESTTAG>" then the tag name is "TESTTAG"). Wildcards (like "*") are allowed. | |
pname | name of the property/attribute to check (if 0 then no property/attribute comparison takes place). No wildcards allowed. | |
pvalue | optional value of the property/attribute to compare against, wildcards allowed. |
Definition at line 633 of file xml.c.
References GWEN_XMLNode_FindTag(), and GWEN_XMLNode_GetFirstTag().
Referenced by GWEN_LoadPluginDescrsByType(), GWEN_MsgEngine__GetGroup(), GWEN_PluginDescription__GetLocalizedLongDescrByFormat(), GWEN_PluginDescription__GetLongDescrByFormat(), GWEN_XMLNode_GetCharValue(), GWEN_XMLNode_GetLocalizedCharValue(), GWEN_XMLNode_GetXPath(), and GWEN_XMLNode_HandlePath().
GWENHYWFAR_API GWEN_XMLNODE_NAMESPACE* GWEN_XMLNode_FindNameSpaceByName | ( | const GWEN_XMLNODE * | n, | |
const char * | s | |||
) |
Definition at line 1091 of file xml.c.
References GWEN_XMLNode_NameSpace_GetName(), GWEN_XMLNode_NameSpace_List_First(), GWEN_XMLNode_NameSpace_List_Next(), and NULL.
GWENHYWFAR_API GWEN_XMLNODE_NAMESPACE* GWEN_XMLNode_FindNameSpaceByUrl | ( | const GWEN_XMLNODE * | n, | |
const char * | s | |||
) |
Definition at line 1111 of file xml.c.
References GWEN_XMLNode_NameSpace_GetUrl(), GWEN_XMLNode_NameSpace_List_First(), GWEN_XMLNode_NameSpace_List_Next(), and NULL.
GWENHYWFAR_API GWEN_XMLNODE* GWEN_XMLNode_FindNextTag | ( | const GWEN_XMLNODE * | n, | |
const char * | tname, | |||
const char * | pname, | |||
const char * | pvalue | |||
) |
Searches for the next matching tag/element after the given one one the same level (i.e. the returned element has the same parent node as the given element).
Definition at line 650 of file xml.c.
References GWEN_XMLNode_FindTag(), and GWEN_XMLNode_GetNextTag().
Referenced by GWEN_PluginDescription__GetLocalizedLongDescrByFormat(), GWEN_PluginDescription__GetLongDescrByFormat(), GWEN_XMLNode_GetCharValue(), GWEN_XMLNode_GetLocalizedCharValue(), GWEN_XMLNode_GetXPath(), and GWEN_XMLNode_HandlePath().
GWENHYWFAR_API GWEN_XMLNODE* GWEN_XMLNode_FindNode | ( | const GWEN_XMLNODE * | n, | |
GWEN_XMLNODE_TYPE | t, | |||
const char * | data | |||
) |
This is a very primitive function. It looks for a node of the given type and data matching the given one (case-insensitive) below the given node (i.e. if a node is returned it will be a child of the given one).
Definition at line 451 of file xml.c.
References DBG_DEBUG, GWEN_LOGDOMAIN, GWEN_XMLNode_GetChild(), and GWEN_XMLNode_Next().
Referenced by GWEN_MsgEngine_AddDefinitions().
GWENHYWFAR_API void GWEN_XMLNode_free | ( | GWEN_XMLNODE * | n | ) |
Free the given node (including its children nodes)
Definition at line 150 of file xml.c.
References GWEN_FREE_OBJECT, GWEN_LIST_FINI, GWEN_Memory_dealloc(), GWEN_XMLNode_List_free(), GWEN_XMLNode_NameSpace_List_free(), and GWEN_XMLProperty_freeAll().
Referenced by GWEN_LoadPluginDescrsByType(), GWEN_MsgEngine_free(), GWEN_MsgEngine_ListMessage(), GWEN_MsgEngine_SetDefinitions(), GWEN_PluginDescription_free(), GWEN_XMLNode_freeAll(), and GWEN_XMLNode_fromString().
GWENHYWFAR_API void GWEN_XMLNode_freeAll | ( | GWEN_XMLNODE * | n | ) |
Free the given node and all nodes besides this one. Hmm, this function should not be public, I think I will move it to xml_p.h.
Definition at line 163 of file xml.c.
References GWEN_XMLNode_free(), and GWEN_XMLNode_List_Next().
GWENHYWFAR_API GWEN_XMLNODE* GWEN_XMLNode_fromString | ( | const char * | s, | |
int | len, | |||
uint32_t | flags | |||
) |
Definition at line 937 of file xmlrw.c.
References DBG_INFO, GWEN_Io_Layer_Disconnect(), GWEN_Io_Layer_free(), GWEN_Io_LayerMemory_fromString(), GWEN_Io_Manager_RegisterLayer(), GWEN_IO_REQUEST_FLAGS_FORCE, GWEN_LOGDOMAIN, GWEN_XML__ReadAllFromIo(), GWEN_XmlCtx_free(), GWEN_XmlCtxStore_new(), GWEN_XMLNode_free(), GWEN_XMLNode_new(), GWEN_XMLNodeTypeTag, and NULL.
GWENHYWFAR_API const char* GWEN_XMLNode_GetCharValue | ( | const GWEN_XMLNODE * | n, | |
const char * | name, | |||
const char * | defValue | |||
) |
n | Node which is expected to contain a node of the specified name | |
name | name of the node below n to be looked up | |
defValue | default value to return if the tag did not exist |
Definition at line 667 of file xml.c.
References GWEN_XMLNode_FindFirstTag(), GWEN_XMLNode_FindNextTag(), and GWEN_XMLNode_GetFirstData().
Referenced by GWEN_XMLNode_GetIntValue().
GWENHYWFAR_API GWEN_XMLNODE* GWEN_XMLNode_GetChild | ( | const GWEN_XMLNODE * | n | ) |
INTERNAL. Descends in the XML tree to the first GWEN_XMLNODE below the given node. The returned node may be a tag/element node, or a property/attribute node, or a data node. You will probably prefer to use GWEN_XMLNode_GetFirstTag() instead of this function.
Definition at line 324 of file xml.c.
References GWEN_XMLNode_List_First().
Referenced by GWEN_MsgEngine__findInValues(), GWEN_MsgEngine__ListGroup(), GWEN_MsgEngine__ReadGroup(), GWEN_MsgEngine__ShowGroup(), GWEN_MsgEngine__WriteGroup(), GWEN_MsgEngine_AddDefinitions(), GWEN_MsgEngine_FindNodeByProperty(), GWEN_XMLNode__WriteToStream(), GWEN_XMLNode_AddChildrenOnly(), GWEN_XMLNode_Dump(), GWEN_XMLNode_FindNode(), GWEN_XMLNode_GetFirstOfType(), and GWEN_XMLNode_WriteToStream().
GWENHYWFAR_API const char* GWEN_XMLNode_GetData | ( | const GWEN_XMLNODE * | n | ) |
Returns the character data of the given node.
Definition at line 308 of file xml.c.
Referenced by GWEN_MsgEngine__findInValues(), GWEN_MsgEngine__GetGroup(), GWEN_MsgEngine__GetInline(), GWEN_MsgEngine__ListGroup(), GWEN_MsgEngine__ReadGroup(), GWEN_MsgEngine__ShowGroup(), GWEN_MsgEngine__WriteGroup(), GWEN_MsgEngine_AddDefinitions(), GWEN_MsgEngine_CreateMessageFromNode(), GWEN_MsgEngine_FindNodeByProperty(), GWEN_XmlCtxStore_AddAttr(), GWEN_XmlCtxStore_EndTag(), GWEN_XmlCtxStore_StartTag(), GWEN_XMLGL__GetNameSpaceByPrefix(), and GWEN_XMLNode_GetXPath().
GWENHYWFAR_API GWEN_XMLNODE* GWEN_XMLNode_GetFirstData | ( | const GWEN_XMLNODE * | n | ) |
Descends in the XML tree to the first children data node below the given node.
Different from GWEN_XMLNode_GetChild() this function only looks for another data node and not for a (more general) node.
Definition at line 584 of file xml.c.
References GWEN_XMLNode_GetFirstOfType(), and GWEN_XMLNodeTypeData.
Referenced by GWEN_MsgEngine__GetInline(), GWEN_XMLNode_GetCharValue(), and GWEN_XMLNode_GetLocalizedCharValue().
GWENHYWFAR_API GWEN_XMLNODE* GWEN_XMLNode_GetFirstTag | ( | const GWEN_XMLNODE * | n | ) |
Descends in the XML tree to the first children tag (in XML notation they are called elements) below the given node.
Different from GWEN_XMLNode_GetChild() this function only looks for another tag/element and not for a (more general) node. You will probably prefer this function instead of GWEN_XMLNode_GetChild().
Definition at line 567 of file xml.c.
References GWEN_XMLNode_GetFirstOfType(), and GWEN_XMLNodeTypeTag.
Referenced by GWEN_MsgEngine__GetGroup(), GWEN_XMLNode__CheckNameSpaceDecls1(), GWEN_XMLNode__CheckNameSpaceDecls3(), GWEN_XMLNode__SetNameSpaces(), and GWEN_XMLNode_FindFirstTag().
GWENHYWFAR_API GWEN_XMLNODE* GWEN_XMLNode_GetHeader | ( | const GWEN_XMLNODE * | n | ) |
Returns the first header tag of the given node. Use GWEN_XMLNode_Next to get the next header tag.
Definition at line 1054 of file xml.c.
References GWEN_XMLNode_List_First().
Referenced by GWEN_XMLNode_WriteToStream().
GWENHYWFAR_API int GWEN_XMLNode_GetIntValue | ( | const GWEN_XMLNODE * | n, | |
const char * | name, | |||
int | defValue | |||
) |
Internally calls GWEN_XMLNode_GetCharValue and interpretes the data as an integer which is then returned.
n | Node which is expected to contain a node of the specified name | |
name | name of the node below n to be looked up | |
defValue | default value to return if the tag did not exist |
Definition at line 756 of file xml.c.
References GWEN_XMLNode_GetCharValue().
GWENHYWFAR_API const char* GWEN_XMLNode_GetLocalizedCharValue | ( | const GWEN_XMLNODE * | n, | |
const char * | name, | |||
const char * | defValue | |||
) |
This function does the same as GWEN_XMLNode_GetCharValue, but it looks for an element with the attribute "lang" which matches the currently selected locale (e.g. "lang=de" for Germany). If there is no localized version of the given element then the first element of that name is used (withouth "lang" attribute). Therefore XML documents used with this function should contain unlocalized elements along with localized ones to provide a fallback.
n | Node which is expected to contain a node of the specified name | |
name | name of the node below n to be looked up | |
defValue | default value to return if the tag did not exist |
Definition at line 689 of file xml.c.
References DBG_DEBUG, GWEN_I18N_GetCurrentLocaleList(), GWEN_LOGDOMAIN, GWEN_StringList_FirstEntry(), GWEN_StringListEntry_Data(), GWEN_StringListEntry_Next(), GWEN_XMLNode_FindFirstTag(), GWEN_XMLNode_FindNextTag(), and GWEN_XMLNode_GetFirstData().
Referenced by GWEN_PluginDescription_new().
GWENHYWFAR_API GWEN_XMLNODE_NAMESPACE_LIST* GWEN_XMLNode_GetNameSpaces | ( | const GWEN_XMLNODE * | n | ) |
GWENHYWFAR_API GWEN_XMLNODE* GWEN_XMLNode_GetNextData | ( | const GWEN_XMLNODE * | n | ) |
Iterates on the same level in the XML tree from the given data node to the next one on the same level (i.e. the returned element has the same parent node as the given element). An XML element may have multiple data nodes as children, and you use this function to iterate through all of them.
Different from GWEN_XMLNode_Next() this function only looks for another data node and not for a (more general) node.
Definition at line 590 of file xml.c.
References GWEN_XMLNode_GetNextOfType(), GWEN_XMLNode_Next(), and GWEN_XMLNodeTypeData.
GWENHYWFAR_API GWEN_XMLNODE* GWEN_XMLNode_GetNextTag | ( | const GWEN_XMLNODE * | n | ) |
Iterates on the same level in the XML tree from the given tag (in XML notation they are called elements) to the next one on the same level (i.e. the returned element has the same parent node as the given element).
Different from GWEN_XMLNode_Next() this function only looks for another tag/element and not for a (more general) node. You will probably prefer this function instead of GWEN_XMLNode_Next().
Definition at line 573 of file xml.c.
References GWEN_XMLNode_GetNextOfType(), GWEN_XMLNode_Next(), and GWEN_XMLNodeTypeTag.
Referenced by GWEN_MsgEngine__GetGroup(), GWEN_XMLNode__CheckNameSpaceDecls1(), GWEN_XMLNode__CheckNameSpaceDecls3(), GWEN_XMLNode__SetNameSpaces(), GWEN_XMLNode_FindNextTag(), and GWEN_XMLNode_FindTag().
GWENHYWFAR_API GWEN_XMLNODE* GWEN_XMLNode_GetNodeByXPath | ( | GWEN_XMLNODE * | n, | |
const char * | path, | |||
uint32_t | flags | |||
) |
Locates a tag by its XPath. Currently attributes are not allowed, and the flag GWEN_PATH_FLAGS_VARIABLE is not supported. Supported types of XPaths are:
Definition at line 1043 of file xml.c.
References GWEN_Path_HandleWithIdx(), and GWEN_XMLNode_HandlePath().
GWENHYWFAR_API GWEN_XMLNODE* GWEN_XMLNode_GetParent | ( | const GWEN_XMLNODE * | n | ) |
Returns the parent node of the given node, or NULL if it already is the root node.
Definition at line 330 of file xml.c.
Referenced by GWEN_MsgEngine_GetGroup(), GWEN_MsgEngine_GetHighestTrustLevel(), GWEN_MsgEngine_SearchForProperty(), GWEN_XmlCtxStore_EndTag(), and GWEN_XmlCtxStore_StartTag().
GWENHYWFAR_API const char* GWEN_XMLNode_GetProperty | ( | const GWEN_XMLNODE * | n, | |
const char * | name, | |||
const char * | defaultValue | |||
) |
Returns the value of the given property/attribute (or the default value if the property/attribute does not exist or is empty).
n | node (must be a tag/element) | |
name | name of the property/attribute | |
defaultValue | default value to be returned if no value could be retrieved |
Definition at line 223 of file xml.c.
Referenced by GWEN_Crypt_Token_PluginManager_GetPluginDescrs(), GWEN_LoadPluginDescrsByType(), GWEN_MsgEngine__findInValues(), GWEN_MsgEngine__GetGroup(), GWEN_MsgEngine__GetInline(), GWEN_MsgEngine__ListElement(), GWEN_MsgEngine__ListGroup(), GWEN_MsgEngine__ReadGroup(), GWEN_MsgEngine__ReadValue(), GWEN_MsgEngine__SearchForValue(), GWEN_MsgEngine__ShowElement(), GWEN_MsgEngine__ShowGroup(), GWEN_MsgEngine__TransformValue(), GWEN_MsgEngine__WriteElement(), GWEN_MsgEngine__WriteGroup(), GWEN_MsgEngine__WriteValue(), GWEN_MsgEngine_FindNodeByProperty(), GWEN_MsgEngine_GetHighestTrustLevel(), GWEN_MsgEngine_ReadMessage(), GWEN_MsgEngine_SearchForProperty(), GWEN_PluginDescription__GetLocalizedLongDescrByFormat(), GWEN_PluginDescription__GetLongDescrByFormat(), GWEN_PluginDescription_new(), GWEN_XMLNode__CheckAndSetNameSpace(), GWEN_XMLNode_FindTag(), and GWEN_XMLNode_NormalizeNameSpaces().
GWENHYWFAR_API GWEN_XMLNODE_TYPE GWEN_XMLNode_GetType | ( | const GWEN_XMLNODE * | n | ) |
Returns the type of the given node.
Definition at line 369 of file xml.c.
Referenced by GWEN_MsgEngine__findInValues(), GWEN_MsgEngine__ListGroup(), GWEN_MsgEngine__ReadGroup(), GWEN_MsgEngine__ShowGroup(), GWEN_MsgEngine__WriteGroup(), GWEN_MsgEngine_AddDefinitions(), and GWEN_MsgEngine_FindNodeByProperty().
GWENHYWFAR_API uint32_t GWEN_XMLNode_GetUsage | ( | const GWEN_XMLNODE * | n | ) |
GWENHYWFAR_API int GWEN_XMLNode_GetXPath | ( | const GWEN_XMLNODE * | n1, | |
const GWEN_XMLNODE * | n2, | |||
GWEN_BUFFER * | nbuf | |||
) |
Definition at line 831 of file xml.c.
References DBG_ERROR, GWEN_Buffer_AppendBuffer(), GWEN_Buffer_AppendString(), GWEN_Buffer_free(), GWEN_Buffer_GetStart(), GWEN_Buffer_InsertByte(), GWEN_Buffer_InsertString(), GWEN_Buffer_new(), GWEN_Buffer_ReserveBytes(), GWEN_Buffer_Reset(), GWEN_LOGDOMAIN, GWEN_XMLNode_FindFirstTag(), GWEN_XMLNode_FindNextTag(), GWEN_XMLNode_GetData(), and GWEN_XMLNode_IsChildOf().
Referenced by GWEN_XMLNode__CheckNameSpaceDecls1().
GWENHYWFAR_API int GWEN_XMLNode_Globalize | ( | GWEN_XMLNODE * | n | ) |
Definition at line 237 of file xmlglobalize.c.
References DBG_INFO, GWEN_LOGDOMAIN, GWEN_XMLNode_GlobalizeWithList(), GWEN_XMLNode_NameSpace_List_free(), and GWEN_XMLNode_NameSpace_List_new().
GWENHYWFAR_API int GWEN_XMLNode_GlobalizeWithList | ( | GWEN_XMLNODE * | n, | |
GWEN_XMLNODE_NAMESPACE_LIST * | l, | |||
uint32_t * | pLastId | |||
) |
Definition at line 220 of file xmlglobalize.c.
References DBG_INFO, GWEN_LOGDOMAIN, GWEN_XMLGL__ClearNameSpaces(), and GWEN_XMLGL__SampleNameSpaces().
Referenced by GWEN_XMLNode_Globalize().
GWENHYWFAR_API void GWEN_XMLNode_IncUsage | ( | GWEN_XMLNODE * | n | ) |
GWENHYWFAR_API int GWEN_XMLNode_IsChildOf | ( | const GWEN_XMLNODE * | parent, | |
const GWEN_XMLNODE * | child | |||
) |
Checks whether the second node is a child of the first one.
Definition at line 814 of file xml.c.
Referenced by GWEN_XMLNode_GetXPath().
GWENHYWFAR_API GWEN_XMLNODE* GWEN_XMLNode_new | ( | GWEN_XMLNODE_TYPE | t, | |
const char * | data | |||
) |
Definition at line 135 of file xml.c.
References GWEN_LIST_INIT, GWEN_Memory_strdup(), GWEN_NEW_OBJECT, GWEN_XMLNode_List_new(), and GWEN_XMLNode_NameSpace_List_new().
Referenced by GWEN_LoadPluginDescrsByType(), GWEN_XmlCtxStore_AddData(), GWEN_XmlCtxStore_StartTag(), GWEN_XMLNode_dup(), GWEN_XMLNode_fromString(), GWEN_XMLNode_HandlePath(), and GWEN_XMLNode_SetCharValue().
GWENHYWFAR_API GWEN_XMLNODE* GWEN_XMLNode_Next | ( | const GWEN_XMLNODE * | n | ) |
INTERNAL. Iterates on the same level in the XML tree from the given node to the next one on the same level (i.e. the returned node has the same parent node as the given element). The returned node may be a tag/element node, or a property/attribute node, or a data node. You will probably prefer to use GWEN_XMLNode_GetNextTag() instead of this function.
Definition at line 375 of file xml.c.
References GWEN_XMLNode_List_Next().
Referenced by GWEN_MsgEngine__findInValues(), GWEN_MsgEngine__ListGroup(), GWEN_MsgEngine__ReadGroup(), GWEN_MsgEngine__ShowGroup(), GWEN_MsgEngine__WriteGroup(), GWEN_MsgEngine_AddDefinitions(), GWEN_MsgEngine_FindNodeByProperty(), GWEN_XMLNode__WriteToStream(), GWEN_XMLNode_AddChildrenOnly(), GWEN_XMLNode_Dump(), GWEN_XMLNode_dup(), GWEN_XMLNode_FindNode(), GWEN_XMLNode_GetFirstOfType(), GWEN_XMLNode_GetNextData(), GWEN_XMLNode_GetNextOfType(), GWEN_XMLNode_GetNextTag(), and GWEN_XMLNode_WriteToStream().
GWENHYWFAR_API int GWEN_XMLNode_NormalizeNameSpaces | ( | GWEN_XMLNODE * | n | ) |
This function removes unnecessary namespaces from the given node and all nodes below.
Definition at line 1527 of file xml.c.
References DBG_INFO, GWEN_LOGDOMAIN, GWEN_StringList2_free(), GWEN_StringList2_new(), GWEN_XMLNode__CheckNameSpaceDecls1(), GWEN_XMLNode__CheckNameSpaceDecls3(), and GWEN_XMLNode_GetProperty().
GWENHYWFAR_API void GWEN_XMLNode_RemoveChildren | ( | GWEN_XMLNODE * | n | ) |
Unlinks and frees all children of the given node.
Definition at line 486 of file xml.c.
References GWEN_XMLNode_List_Clear().
Referenced by GWEN_MsgEngine_ListMessage().
GWENHYWFAR_API void GWEN_XMLNode_SetCharValue | ( | GWEN_XMLNODE * | n, | |
const char * | name, | |||
const char * | value | |||
) |
Definition at line 739 of file xml.c.
References GWEN_XMLNode_AddChild(), GWEN_XMLNode_new(), GWEN_XMLNodeTypeData, and GWEN_XMLNodeTypeTag.
Referenced by GWEN_XMLNode_SetIntValue().
GWENHYWFAR_API void GWEN_XMLNode_SetData | ( | GWEN_XMLNODE * | n, | |
const char * | data | |||
) |
Set the character data of the given node to the given value. This function will create a deep copy of the character data.
Definition at line 314 of file xml.c.
References GWEN_Memory_dealloc(), and GWEN_Memory_strdup().
GWENHYWFAR_API void GWEN_XMLNode_SetIntValue | ( | GWEN_XMLNODE * | n, | |
const char * | name, | |||
int | value | |||
) |
GWENHYWFAR_API void GWEN_XMLNode_SetProperty | ( | GWEN_XMLNODE * | n, | |
const char * | name, | |||
const char * | value | |||
) |
Sets the value of a property/attribute. This property/attribute will be created if it does not exist and overwritten if it does.
n | node (must be a tag/element) | |
name | name of the property/attribute | |
value | new value of the property/attribute |
Definition at line 276 of file xml.c.
References GWEN_XMLNode__SetProperty().
Referenced by GWEN_MsgEngine__ListElement(), GWEN_MsgEngine__ListGroup(), and GWEN_XmlCtxStore_AddAttr().
GWENHYWFAR_API int GWEN_XMLNode_toBuffer | ( | const GWEN_XMLNODE * | n, | |
GWEN_BUFFER * | buf, | |||
uint32_t | flags | |||
) |
Definition at line 327 of file xmlrw.c.
References DBG_INFO, GWEN_Io_Layer_Disconnect(), GWEN_Io_Layer_DisconnectRecursively(), GWEN_Io_Layer_free(), GWEN_Io_LayerMemory_new(), GWEN_Io_Manager_RegisterLayer(), GWEN_IO_REQUEST_FLAGS_FORCE, GWEN_LOGDOMAIN, GWEN_XmlCtx_free(), GWEN_XmlCtxStore_new(), GWEN_XMLNode_WriteToStream(), and NULL.
Referenced by GWEN_PluginDescription__GetLocalizedLongDescrByFormat(), and GWEN_PluginDescription__GetLongDescrByFormat().
GWENHYWFAR_API void GWEN_XMLNode_UnlinkChild | ( | GWEN_XMLNODE * | n, | |
GWEN_XMLNODE * | child | |||
) |
Unlinks the given child node from its parent without freeing it. This function relinquishes the ownership of the child to the caller who thereby becomes responsible for freeing this node.
n | node which is suspected to be the parent of the second argument | |
child | node which is to be unlinked |
Definition at line 477 of file xml.c.
References GWEN_XMLNode_List_Del().
Referenced by GWEN_XMLNode_AddChildrenOnly().
GWENHYWFAR_API int GWEN_XMLNode_WriteFile | ( | const GWEN_XMLNODE * | n, | |
const char * | fname, | |||
uint32_t | flags | |||
) |
Writes a tag and all its subnodes to the given file.
Definition at line 279 of file xmlrw.c.
References DBG_ERROR, DBG_INFO, GWEN_ERROR_IO, GWEN_Io_Layer_Disconnect(), GWEN_Io_Layer_DisconnectRecursively(), GWEN_Io_Layer_free(), GWEN_Io_LayerFile_new(), GWEN_Io_Manager_RegisterLayer(), GWEN_IO_REQUEST_FLAGS_FORCE, GWEN_LOGDOMAIN, GWEN_XmlCtx_free(), GWEN_XmlCtx_GetGuiId(), GWEN_XmlCtxStore_new(), GWEN_XMLNode_WriteToStream(), and NULL.
GWENHYWFAR_API int GWEN_XMLNode_WriteToStream | ( | const GWEN_XMLNODE * | n, | |
GWEN_XML_CONTEXT * | ctx, | |||
GWEN_IO_LAYER * | io | |||
) |
Writes a tag and all its subnodes to the given io layer (which is expected to be of type GWEN_IO_LAYER_BUFFERED, see GWEN_Io_LayerBuffered_new).
Definition at line 187 of file xmlrw.c.
References DBG_INFO, GWEN_FASTBUFFER_FLUSH, GWEN_FastBuffer_free(), GWEN_FastBuffer_new(), GWEN_FASTBUFFER_WRITELINE, GWEN_LOGDOMAIN, GWEN_XML_FLAGS_HANDLE_HEADERS, GWEN_XmlCtx_GetFlags(), GWEN_XmlCtx_GetGuiId(), GWEN_XmlCtx_GetTimeout(), GWEN_XMLNode__WriteToStream(), GWEN_XMLNode_GetChild(), GWEN_XMLNode_GetHeader(), and GWEN_XMLNode_Next().
Referenced by GWEN_XMLNode_toBuffer(), and GWEN_XMLNode_WriteFile().