-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsaxml.h
60 lines (49 loc) · 1.97 KB
/
saxml.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/* \copyright 2017 Zorxx Software. All rights reserved.
* \license This file is released under the MIT License. See the LICENSE file for details.
* \brief Embedded XML Parser
*/
#ifndef SAXML_H
#define SAXML_H
#include <stdint.h>
typedef void (*pfnStringHandler)(void *cookie, const char *szString);
typedef struct
{
void *cookie;
pfnStringHandler tagHandler;
pfnStringHandler tagEndHandler;
pfnStringHandler parameterHandler;
pfnStringHandler contentHandler;
pfnStringHandler attributeHandler;
} tSaxmlContext;
typedef void *tSaxmlParser;
#ifdef __cplusplus
extern "C" {
#endif
/*! \brief Create an XML parsing instance
* \param context Pointer to structure containing pointers to parsing handling
* functions, which are called when parsing events occur.
* \param maxStringSize Maximum number of characters for parsed strings. If the
* parser encounters a string longer than this, it will be
* truncated to this length when provided via the szString
* parameter of the corresponding pfnStringHandler function.
* \return parser instance
*/
tSaxmlParser saxml_Initialize(tSaxmlContext *context, const uint32_t maxStringSize);
/*! \brief Destroy an XML parsing instance
* \param parser tSaxmlParser instance, obtained from a call to saxml_Initialize
*/
void saxml_Deinitialize(tSaxmlParser parser);
/*! \brief Provide a single character to the XML parser. Based on the processing of this
* character, one of the pfnStringHandler functions may be called.
* \param parser tSaxmlParser instance, obtained from a call to saxml_Initialize
* \param character Character to process
*/
void saxml_HandleCharacter(tSaxmlParser parser, const char character);
/*! \brief Reset the parser to its initial state
* \param parser tSaxmlParser instance, obtained from a call to saxml_Initialize
*/
void saxml_Reset(tSaxmlParser parser);
#ifdef __cplusplus
};
#endif
#endif /* SAXML_H */