1 /*
 2  * XmlUtil.h
 3  *
 4  *  Created on: 2008-10-26
 5  *      Author: mr@marcelruff.info
 6  */
 7 
 8 #ifndef XMLUTIL_H_
 9 #define XMLUTIL_H_
10 
11 #include <util/basicDefs.h>
12 
13 #ifdef __cplusplus
14 #ifndef XMLBLASTER_C_COMPILE_AS_CPP /* 'g++ -DXMLBLASTER_C_COMPILE_AS_CPP ...' allows to compile the lib as C++ code */
15 extern "C" {
16 #endif
17 #endif
18 
19 /**
20  * Unescape e.g. "&lt;" to "<"
21  * @param xml The char * must be writeable, it can NOT be on the stack like 'char *xml="HELLO";'
22  * @param newLen out parameter If the unescaped char * containes '\0' (is binary) you need newLen
23  * @return the modified xml (same pointer as given xml, nothing is allocated)
24  */
25 Dll_Export extern char *xmlBlasterUnEscapeXml(char * const xml, int *newLen);
26 
27 /**
28  * @param len The length of xml
29  * @param bytes The binary data, does not need to be '\0' terminated
30  * @return Is zero terminated, must be freed with xmlBlasterFree(p)
31  */
32 Dll_Export extern char* xmlBlasterEscapeXmlBytes(int len, const char *bytes);
33 Dll_Export extern char* xmlBlasterEscapeXml(const char *xml);
34 
35 /**
36  * @return must be freed with xmlBlasterFree(p)
37  */
38 Dll_Export extern char* xmlBlasterEscapeCSV(const char *csv);
39 
40 /**
41  * Unescape "&comma;" to ","
42  * @param csv The char * must be writeable, it can NOT be on the stack like 'char *xml="HELLO";'
43  * @param newLen out parameter If the unescaped char * containes '\0' (is binary) you need newLen
44  * @return the modified csv (same pointer as given csv, nothing is allocated)
45  */
46 Dll_Export extern char *xmlBlasterUnEscapeCSV(char * const csv, int *newLen);
47 
48 
49 /**
50  * Find the given attribute from the given tag from the given xml string and return its value.
51  * @param xml The xml string to parse
52  * @param tag For example "node" for a tag &lt;node id='heron'>
53  * @param attributeName "id"
54  * @return 'heron' null if none is found, you need to free it
55  * with xmlBlasterFree(p);
56  */
57 Dll_Export extern char *xmlBlasterExtractAttributeValue(const char * const xml,
58       const char * const tag, const char * const attributeName);
59 Dll_Export extern long xmlBlasterExtractAttributeLong(const char * const xml,
60       const char * const tag, const char * const attributeName, long defaultValue);
61 
62 
63 /**
64  * Find the given attribute from the given tag from the given xml string and return
65  * the <b>tags value</b>.
66  * @param xml The xml string to parse
67  * @param tag For example "node" for a tag &lt;node id='heron'>Good day&lt;/node>
68  * @param attributeName "id"
69  * @param attributeValue Can be 0
70  * @return 'Good day' null if none is found, you need to free it with xmlBlasterFree(p);
71  */
72 Dll_Export extern char *xmlBlasterExtractTagValueWithAttribute(const char * const xml,
73       const char * const tag, const char * const attributeName,
74       const char * const attributeValue);
75 /**
76  * Find the first given tag and return its value.
77  * @param xml The xml string to parse
78  * @param tag For example "node" for a tag &lt;node id='heron'>Good day&lt;/node>
79  * @return 'Good day' null if none is found, you need to free it with xmlBlasterFree(p);
80  */
81 Dll_Export extern char *xmlBlasterExtractTagValue(const char * const xml,
82       const char * const tag);
83 
84 Dll_Export extern char *xmlBlasterReadBinaryFile(const char *name, int *len);
85 
86 
87 #ifdef __cplusplus
88 #ifndef XMLBLASTER_C_COMPILE_AS_CPP
89 }
90 #endif
91 #endif
92 
93 #endif /* XMLUTIL_H_ */


syntax highlighted by Code2HTML, v. 0.9.1