-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNAVFoundation.XmlQuery.h.axi
More file actions
195 lines (165 loc) · 6.2 KB
/
NAVFoundation.XmlQuery.h.axi
File metadata and controls
195 lines (165 loc) · 6.2 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
PROGRAM_NAME='NAVFoundation.XmlQuery.h'
/*
_ _ _ ___ __
| \ | | ___ _ __ __ _ __ _| |_ ___ / \ \ / /
| \| |/ _ \| '__/ _` |/ _` | __/ _ \ / _ \ \ / /
| |\ | (_) | | | (_| | (_| | || __// ___ \ V /
|_| \_|\___/|_| \__, |\__,_|\__\___/_/ \_\_/
|___/
MIT License
Copyright (c) 2010-2026 Norgate AV
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#IF_NOT_DEFINED __NAV_FOUNDATION_XML_QUERY_H__
#DEFINE __NAV_FOUNDATION_XML_QUERY_H__ 'NAVFoundation.XmlQuery.h'
DEFINE_CONSTANT
/**
* @constant NAV_XML_QUERY_MAX_TOKENS
* @description Maximum number of tokens that can be produced by the query lexer.
* Each component in a query path (dots, identifiers, brackets) requires one token.
* Increase this value if working with very long query paths.
* @default 50
*/
constant integer NAV_XML_QUERY_MAX_TOKENS = 50
/**
* @constant NAV_XML_QUERY_MAX_IDENTIFIER_LENGTH
* @description Maximum length of an identifier (element name) in a query path.
* @default 64
*/
constant integer NAV_XML_QUERY_MAX_IDENTIFIER_LENGTH = 64
/**
* @constant NAV_XML_QUERY_MAX_PATH_STEPS
* @description Maximum number of path steps in a query.
* Each navigation step (element access or array index) requires one path step.
* @default 25
*/
constant integer NAV_XML_QUERY_MAX_PATH_STEPS = 25
// =============================================================================
// Query Token Types
// =============================================================================
/**
* @constant NAV_XML_QUERY_TOKEN_DOT
* @description Token type for the dot operator (.) in query syntax.
* Used to access element properties and navigate the XML tree.
* @example .root.child
*/
constant integer NAV_XML_QUERY_TOKEN_DOT = 1
/**
* @constant NAV_XML_QUERY_TOKEN_IDENTIFIER
* @description Token type for identifiers (element names) in query syntax.
* @example .root or .root.child
*/
constant integer NAV_XML_QUERY_TOKEN_IDENTIFIER = 2
/**
* @constant NAV_XML_QUERY_TOKEN_LEFT_BRACKET
* @description Token type for left bracket ([) in query syntax.
* Used to begin array index access.
* @example .[1]
*/
constant integer NAV_XML_QUERY_TOKEN_LEFT_BRACKET = 3
/**
* @constant NAV_XML_QUERY_TOKEN_RIGHT_BRACKET
* @description Token type for right bracket (]) in query syntax.
* Used to end array index access.
* @example .[1]
*/
constant integer NAV_XML_QUERY_TOKEN_RIGHT_BRACKET = 4
/**
* @constant NAV_XML_QUERY_TOKEN_NUMBER
* @description Token type for numeric indices in query syntax.
* @example .items[2]
*/
constant integer NAV_XML_QUERY_TOKEN_NUMBER = 5
/**
* @constant NAV_XML_QUERY_TOKEN_AT
* @description Token type for the at sign (@) in query syntax.
* Used as prefix for attribute access.
* @example .root.@id
*/
constant integer NAV_XML_QUERY_TOKEN_AT = 6
// =============================================================================
// Query Path Step Types
// =============================================================================
/**
* @constant NAV_XML_QUERY_STEP_ROOT
* @description Path step type representing the root of the document.
* Used when the query is just "." with no further navigation.
* @example .
*/
constant integer NAV_XML_QUERY_STEP_ROOT = 1
/**
* @constant NAV_XML_QUERY_STEP_ELEMENT
* @description Path step type for child element access.
* Navigates to a child element by name.
* @example .root.child
*/
constant integer NAV_XML_QUERY_STEP_ELEMENT = 2
/**
* @constant NAV_XML_QUERY_STEP_ARRAY_INDEX
* @description Path step type for indexed element access.
* Navigates to a specific child by index (1-based).
* @example .items[2]
*/
constant integer NAV_XML_QUERY_STEP_ARRAY_INDEX = 3
/**
* @constant NAV_XML_QUERY_STEP_ATTRIBUTE
* @description Path step type for attribute access.
* Accesses an attribute value.
* @example .root.@id
*/
constant integer NAV_XML_QUERY_STEP_ATTRIBUTE = 4
DEFINE_TYPE
/**
* @struct _NAVXmlQueryToken
* @description Represents a single token produced by the query lexer.
* Used internally to parse jq-like query syntax into executable steps.
*
* @property {integer} type - The token type (NAV_XML_QUERY_TOKEN_*\)
* @property {char[]} identifier - Element or attribute name for IDENTIFIER tokens
* @property {integer} number - Array index for NUMBER tokens
*
* @example
* // Query ".root.child[2]" produces tokens:
* // DOT, IDENTIFIER("root"), DOT, IDENTIFIER("child"), LEFT_BRACKET, NUMBER(2), RIGHT_BRACKET
*/
struct _NAVXmlQueryToken {
integer type
char identifier[NAV_XML_QUERY_MAX_IDENTIFIER_LENGTH]
integer number
}
/**
* @struct _NAVXmlQueryPathStep
* @description Represents a single step in a query execution path.
*
* Each step describes one navigation operation in the query.
*
* @property {integer} type - The step type (NAV_XML_QUERY_STEP_*\)
* @property {char[]} elementName - Element or attribute name
* @property {integer} arrayIndex - Array index for indexed access (1-based)
*
* @example
* // Query ".root.child[2]" produces steps:
* // 1. STEP_ELEMENT(elementName="root")
* // 2. STEP_ELEMENT(elementName="child")
* // 3. STEP_ARRAY_INDEX(arrayIndex=2)
*/
struct _NAVXmlQueryPathStep {
integer type
char elementName[NAV_XML_QUERY_MAX_IDENTIFIER_LENGTH]
integer arrayIndex
}
#END_IF // __NAV_FOUNDATION_XML_QUERY_H__