Estonian ID Card C-library
libdigidoc
DigiDocStack.h
1
#ifndef __DIGIDOC_STACK_H__
2
#define __DIGIDOC_STACK_H__
3
//==================================================
4
// FILE: DigiDocStack.h
5
// PROJECT: Digi Doc
6
// DESCRIPTION: Digi Doc functions for simple stack
7
// to keep track of xml parsing
8
// AUTHOR: Veiko Sinivee, S|E|B IT Partner Estonia
9
//==================================================
10
// Copyright (C) AS Sertifitseerimiskeskus
11
// This library is free software; you can redistribute it and/or
12
// modify it under the terms of the GNU Lesser General Public
13
// License as published by the Free Software Foundation; either
14
// version 2.1 of the License, or (at your option) any later version.
15
// This library is distributed in the hope that it will be useful,
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
// Lesser General Public License for more details.
19
// GNU Lesser General Public Licence is available at
20
// http://www.gnu.org/copyleft/lesser.html
21
//==========< HISTORY >=============================
22
// 09.09.2004 Veiko Sinivee
23
// Creation
24
//==================================================
25
26
#include <libxml/xmlreader.h>
27
#include <libdigidoc/DigiDocDefs.h>
28
29
#ifdef __cplusplus
30
extern
"C"
{
31
#endif
32
33
typedef
struct
ElementEntry_st
{
34
xmlChar* tag;
// xml elements tag
35
xmlChar* prefix;
// namespace local prefix
36
xmlChar* nsUri;
// namespace URI
37
// some important atributes
38
xmlChar* id;
// attribute "Id"
39
xmlChar* uri;
// attribute "URI"
40
xmlChar* content;
// attribute "ContentType"
41
void
* pNext;
// next element in list/stack
42
}
ElementEntry
;
43
44
//--------------------------------------------------
45
// Finds the last element on stack
46
// reader - XML reader cursor to current node
47
// pStack - address of stack begin. This one elemnt
48
// must exist, but might be initially empty
49
// return error code or ERR_OK
50
//--------------------------------------------------
51
ElementEntry
* ddocStackFindEnd(
ElementEntry
* pStack);
52
53
//--------------------------------------------------
54
// Push a new element info onto stack
55
// reader - XML reader cursor to current node
56
// pStack - address of stack begin. This one elemnt
57
// must exist, but might be initially empty
58
// pLastElem - address for new elements pointer.
59
// If not NULL then will be used to return the
60
// newly allocated elemnt, so you don't have to
61
// do a new search.
62
// return error code or ERR_OK
63
//--------------------------------------------------
64
int
ddocStackPushElement(
ElementEntry
* pStack, xmlTextReaderPtr reader,
65
ElementEntry
** pLastElem);
66
67
//--------------------------------------------------
68
// Push a new element info onto stack
69
// tagName - elements tag name, Possibly with ns-prefix
70
// atts - array of atributa names and values
71
// pStack - address of stack begin. This one elemnt
72
// must exist, but might be initially empty
73
// pLastElem - address for new elements pointer.
74
// If not NULL then will be used to return the
75
// newly allocated elemnt, so you don't have to
76
// do a new search.
77
// return error code or ERR_OK
78
//--------------------------------------------------
79
int
ddocStackPushElementSAX(
ElementEntry
* pStack,
const
xmlChar* tagName,
80
const
xmlChar** atts,
ElementEntry
** pLastElem);
81
82
//--------------------------------------------------
83
// Pop the last element from the stack
84
// pStack - address of stack begin. This one elemnt
85
// must exist, and will never be deleted.
86
// bCleanup - flag: 1=cleanup the whole stack, 0=just the last element
87
// return error code or ERR_OK
88
// pLastElem - address for new elements pointer.
89
// If not NULL then will be used to return the
90
// last element on stack.
91
//--------------------------------------------------
92
int
ddocStackPopElement(
ElementEntry
* pStack,
int
bCleanup,
93
ElementEntry
** pLastElem);
94
95
//--------------------------------------------------
96
// Retrieve the current/last/stack top elements tag (localname)
97
// pStack - address of stack begin.
98
//--------------------------------------------------
99
const
xmlChar* ddocStackCurrentTag(
ElementEntry
* pStack);
100
101
//--------------------------------------------------
102
// Retrieve the current/last/stack top elements ns prefix
103
// pStack - address of stack begin.
104
//--------------------------------------------------
105
const
xmlChar* ddocStackCurrentNsPrefix(
ElementEntry
* pStack);
106
107
//--------------------------------------------------
108
// Retrieve the current/last/stack top elements ns prefix
109
// pStack - address of stack begin.
110
//--------------------------------------------------
111
const
xmlChar* ddocStackCurrentNsUri(
ElementEntry
* pStack);
112
113
//--------------------------------------------------
114
// Checks if there is a parent element with the given
115
// localname on the stack.
116
// pStack - address of stack begin.
117
// return 1 if there is such a parent elem or 0 if not.
118
//--------------------------------------------------
119
int
ddocStackHasParentWithName(
ElementEntry
* pStack,
120
const
xmlChar* parentsName,
ElementEntry
* pCurrElem);
121
122
//--------------------------------------------------
123
// Checks if there is a parent element with the given
124
// localname on the stack.
125
// pStack - address of stack begin.
126
// return 1 if there is such a parent elem or 0 if not.
127
//--------------------------------------------------
128
ElementEntry
* ddocStackGetParentWithName(
ElementEntry
* pStack,
129
const
xmlChar* parentsName,
ElementEntry
* pCurrElem);
130
131
132
133
#ifdef __cplusplus
134
}
135
#endif
136
137
#endif // __DIGIDOC_STACK_H__
ElementEntry_st
Definition:
DigiDocStack.h:33
Generated on Fri Jan 28 2022 06:33:41 for Estonian ID Card C-library by
1.8.13