Main Page
Classes
Files
Examples
File List
File Members
include
xqc.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2008, Matthias Brantner, John Snelson
3
* All rights reserved.
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions are met:
7
*
8
* * Redistributions of source code must retain the above copyright notice,
9
* this list of conditions and the following disclaimer.
10
* * Redistributions in binary form must reproduce the above copyright
11
* notice, this list of conditions and the following disclaimer in the
12
* documentation and/or other materials provided with the distribution.
13
* * Neither the name of the developers nor the names of contributors may be
14
* used to endorse or promote products derived from this software without
15
* specific prior written permission.
16
*
17
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
* POSSIBILITY OF SUCH DAMAGE.
28
*/
29
30
#ifndef _XQUERY_C_API_H
31
#define _XQUERY_C_API_H
32
33
/* Include stdio for FILE */
34
#include <stdio.h>
35
36
#ifdef __cplusplus
37
extern
"C"
{
38
#endif
39
41
#define XQC_VERSION_NUMBER 1
42
43
typedef
struct
XQC_Implementation_s
XQC_Implementation
;
44
typedef
struct
XQC_StaticContext_s
XQC_StaticContext
;
45
typedef
struct
XQC_Expression_s
XQC_Expression
;
46
typedef
struct
XQC_DynamicContext_s
XQC_DynamicContext
;
47
typedef
struct
XQC_Sequence_s
XQC_Sequence
;
48
typedef
struct
XQC_InputStream_s
XQC_InputStream
;
49
typedef
struct
XQC_ErrorHandler_s
XQC_ErrorHandler
;
50
55
typedef
enum
{
56
XQC_NO_ERROR
= 0,
57
XQC_END_OF_SEQUENCE
,
58
XQC_NO_CURRENT_ITEM
,
59
XQC_PARSE_ERROR
,
60
XQC_INVALID_ARGUMENT
,
61
XQC_NOT_NODE
,
62
63
XQC_INTERNAL_ERROR
,
64
XQC_NOT_IMPLEMENTED
,
65
69
XQC_UNRECOGNIZED_ENCODING
,
70
71
XQC_STATIC_ERROR
,
72
XQC_TYPE_ERROR
,
73
XQC_DYNAMIC_ERROR
,
74
XQC_SERIALIZATION_ERROR
75
}
XQC_Error
;
76
81
struct
XQC_InputStream_s
{
88
const
char
*
encoding
;
89
93
void
*
user_data
;
94
108
unsigned
int (*
read
)(
XQC_InputStream
*stream,
void
*buffer,
unsigned
int
length);
109
116
void (*
free
)(
XQC_InputStream
*stream);
117
};
118
131
struct
XQC_ErrorHandler_s
{
132
136
void
*
user_data
;
137
156
void (*
error
)(
XQC_ErrorHandler
*handler,
XQC_Error
error
,
const
char
*error_uri,
157
const
char
*error_localname,
const
char
*description,
XQC_Sequence
*error_object);
158
};
159
160
typedef
enum
{
161
XQC_EMPTY_TYPE
= 0,
162
163
XQC_DOCUMENT_TYPE
,
164
XQC_ELEMENT_TYPE
,
165
XQC_ATTRIBUTE_TYPE
,
166
XQC_TEXT_TYPE
,
167
XQC_PROCESSING_INSTRUCTION_TYPE
,
168
XQC_COMMENT_TYPE
,
169
XQC_NAMESPACE_TYPE
,
170
171
XQC_ANY_SIMPLE_TYPE
,
172
XQC_ANY_URI_TYPE
,
173
XQC_BASE_64_BINARY_TYPE
,
174
XQC_BOOLEAN_TYPE
,
175
XQC_DATE_TYPE
,
176
XQC_DATE_TIME_TYPE
,
177
XQC_DAY_TIME_DURATION_TYPE
,
178
XQC_DECIMAL_TYPE
,
179
XQC_DOUBLE_TYPE
,
180
XQC_DURATION_TYPE
,
181
XQC_FLOAT_TYPE
,
182
XQC_G_DAY_TYPE
,
183
XQC_G_MONTH_TYPE
,
184
XQC_G_MONTH_DAY_TYPE
,
185
XQC_G_YEAR_TYPE
,
186
XQC_G_YEAR_MONTH_TYPE
,
187
XQC_HEX_BINARY_TYPE
,
188
XQC_NOTATION_TYPE
,
189
XQC_QNAME_TYPE
,
190
XQC_STRING_TYPE
,
191
XQC_TIME_TYPE
,
192
XQC_UNTYPED_ATOMIC_TYPE
,
193
XQC_YEAR_MONTH_DURATION_TYPE
194
195
}
XQC_ItemType
;
196
207
struct
XQC_Implementation_s
{
208
225
XQC_Error
(*
create_context
)(
XQC_Implementation
*implementation,
XQC_StaticContext
**context);
226
244
XQC_Error
(*
prepare
)(
XQC_Implementation
*implementation,
const
char
*string,
245
const
XQC_StaticContext
*context,
XQC_Expression
**expression);
246
266
XQC_Error
(*
prepare_file
)(
XQC_Implementation
*implementation, FILE *file,
267
const
XQC_StaticContext
*context,
XQC_Expression
**expression);
268
290
XQC_Error
(*
prepare_stream
)(
XQC_Implementation
*implementation,
XQC_InputStream
*stream,
291
const
XQC_StaticContext
*context,
XQC_Expression
**expression);
292
294
300
301
XQC_Error
(*
parse_document
)(
XQC_Implementation
*implementation,
302
const
char
*string,
XQC_Sequence
**sequence);
304
XQC_Error
(*
parse_document_file
)(
XQC_Implementation
*implementation,
305
FILE *file,
XQC_Sequence
**sequence);
307
XQC_Error
(*
parse_document_stream
)(
XQC_Implementation
*implementation,
308
XQC_InputStream
*stream,
XQC_Sequence
**sequence);
309
311
317
XQC_Error
(*
create_empty_sequence
)(
XQC_Implementation
*implementation,
318
XQC_Sequence
**sequence);
319
XQC_Error
(*
create_singleton_sequence
)(
XQC_Implementation
*implementation,
320
XQC_ItemType
type,
const
char
*value,
321
XQC_Sequence
**sequence);
322
XQC_Error
(*
create_string_sequence
)(
XQC_Implementation
*implementation,
323
const
char
*values[],
unsigned
int
count,
324
XQC_Sequence
**sequence);
325
XQC_Error
(*
create_integer_sequence
)(
XQC_Implementation
*implementation,
326
int
values[],
unsigned
int
count,
327
XQC_Sequence
**sequence);
328
XQC_Error
(*
create_double_sequence
)(
XQC_Implementation
*implementation,
329
double
values[],
unsigned
int
count,
330
XQC_Sequence
**sequence);
331
333
343
void
*(*get_interface)(
const
XQC_Implementation
*implementation,
const
char
*name);
344
351
void (*
free
)(
XQC_Implementation
*implementation);
352
};
353
359
typedef
enum
{
XQC_XPATH2_0
,
XQC_XPATH1_0
}
XQC_XPath1Mode
;
360
364
typedef
enum
{
XQC_ORDERED
,
XQC_UNORDERED
}
XQC_OrderingMode
;
365
370
typedef
enum
{
XQC_EMPTY_GREATEST
,
XQC_EMPTY_LEAST
}
XQC_OrderEmptyMode
;
371
376
typedef
enum
{
XQC_INHERIT_NS
,
XQC_NO_INHERIT_NS
}
XQC_InheritMode
;
377
382
typedef
enum
{
XQC_PRESERVE_NS
,
XQC_NO_PRESERVE_NS
}
XQC_PreserveMode
;
383
387
typedef
enum
{
XQC_PRESERVE_SPACE
,
XQC_STRIP_SPACE
}
XQC_BoundarySpaceMode
;
388
392
typedef
enum
{
XQC_PRESERVE_CONS
,
XQC_STRIP_CONS
}
XQC_ConstructionMode
;
393
404
struct
XQC_StaticContext_s
{
405
420
XQC_Error
421
(*
create_child_context
)(
XQC_StaticContext
*context,
XQC_StaticContext
**child_context);
422
434
XQC_Error
435
(*
declare_ns
)(
XQC_StaticContext
*context,
const
char
*prefix,
const
char
*uri);
436
448
XQC_Error
449
(*
get_ns_by_prefix
)(
XQC_StaticContext
*context,
const
char
*prefix,
const
char
**result_ns);
450
460
XQC_Error
461
(*
set_default_element_and_type_ns
)(
XQC_StaticContext
*context,
const
char
*uri);
462
471
XQC_Error
472
(*
get_default_element_and_type_ns
)(
XQC_StaticContext
*context,
const
char
**uri);
473
483
XQC_Error
484
(*
set_default_function_ns
)(
XQC_StaticContext
*context,
const
char
*uri);
485
495
XQC_Error
496
(*
get_default_function_ns
)(
XQC_StaticContext
*context,
const
char
**uri);
497
507
XQC_Error
508
(*
set_xpath_compatib_mode
)(
XQC_StaticContext
*context,
XQC_XPath1Mode
mode);
509
519
XQC_Error
520
(*
get_xpath_compatib_mode
)(
XQC_StaticContext
*context,
XQC_XPath1Mode
* mode);
521
531
XQC_Error
532
(*
set_construction_mode
)(
XQC_StaticContext
*context,
XQC_ConstructionMode
mode);
533
543
XQC_Error
544
(*
get_construction_mode
)(
XQC_StaticContext
*context,
XQC_ConstructionMode
* mode);
545
555
XQC_Error
556
(*
set_ordering_mode
)(
XQC_StaticContext
*context,
XQC_OrderingMode
mode);
557
567
XQC_Error
568
(*
get_ordering_mode
)(
XQC_StaticContext
*context,
XQC_OrderingMode
* mode);
569
580
XQC_Error
581
(*
set_default_order_empty_sequences
)(
XQC_StaticContext
*context,
XQC_OrderEmptyMode
mode);
582
593
XQC_Error
594
(*
get_default_order_empty_sequences
)(
XQC_StaticContext
*context,
XQC_OrderEmptyMode
* mode);
595
605
XQC_Error
606
(*
set_boundary_space_policy
)(
XQC_StaticContext
*context,
XQC_BoundarySpaceMode
mode);
607
617
XQC_Error
618
(*
get_boundary_space_policy
)(
XQC_StaticContext
*context,
XQC_BoundarySpaceMode
* mode);
619
630
XQC_Error
631
(*
set_copy_ns_mode
)(
XQC_StaticContext
*context,
XQC_PreserveMode
preserve,
XQC_InheritMode
inherit);
632
644
XQC_Error
645
(*
get_copy_ns_mode
)(
XQC_StaticContext
*context,
XQC_PreserveMode
* preserve,
XQC_InheritMode
* inherit);
646
656
XQC_Error
657
(*
set_base_uri
)(
XQC_StaticContext
*context,
const
char
*base_uri);
658
668
XQC_Error
669
(*
get_base_uri
)(
XQC_StaticContext
*context,
const
char
**base_uri);
670
671
XQC_Error
(*
set_error_handler
)(
XQC_StaticContext
*context,
XQC_ErrorHandler
*handler);
672
XQC_Error
(*
get_error_handler
)(
const
XQC_StaticContext
*context,
XQC_ErrorHandler
**handler);
673
683
void
*(*get_interface)(
const
XQC_StaticContext
*context,
const
char
*name);
684
691
void (*
free
)(
XQC_StaticContext
*context);
692
};
693
707
struct
XQC_Expression_s
{
708
720
XQC_Error
(*
create_context
)(
const
XQC_Expression
*expression,
XQC_DynamicContext
**context);
721
738
XQC_Error
(*
execute
)(
const
XQC_Expression
*expression,
const
XQC_DynamicContext
*context,
XQC_Sequence
**sequence);
739
749
void
*(*get_interface)(
const
XQC_Expression
*expression,
const
char
*name);
750
757
void (*
free
)(
XQC_Expression
*expression);
758
};
759
760
struct
XQC_DynamicContext_s
{
779
XQC_Error
(*
set_variable
)(
XQC_DynamicContext
*context,
const
char
*uri,
const
char
*name,
780
XQC_Sequence
*value);
781
782
XQC_Error
(*
get_variable
)(
const
XQC_DynamicContext
*context,
const
char
*uri,
const
char
*name,
783
XQC_Sequence
**value);
784
802
XQC_Error
(*
set_context_item
)(
XQC_DynamicContext
*context,
XQC_Sequence
*value);
803
804
XQC_Error
(*
get_context_item
)(
const
XQC_DynamicContext
*context,
XQC_Sequence
**value);
805
811
XQC_Error
(*
set_implicit_timezone
)(
XQC_DynamicContext
*context,
int
timezone);
812
XQC_Error
(*
get_implicit_timezone
)(
const
XQC_DynamicContext
*context,
int
*timezone);
813
814
XQC_Error
(*
set_error_handler
)(
XQC_DynamicContext
*context,
XQC_ErrorHandler
*handler);
815
XQC_Error
(*
get_error_handler
)(
const
XQC_DynamicContext
*context,
XQC_ErrorHandler
**handler);
816
826
void
*(*get_interface)(
const
XQC_DynamicContext
*context,
const
char
*name);
827
834
void (*
free
)(
XQC_DynamicContext
*context);
835
};
836
843
struct
XQC_Sequence_s
{
854
XQC_Error
(*
next
)(
XQC_Sequence
*sequence);
855
871
XQC_Error
(*
item_type
)(
const
XQC_Sequence
*sequence,
XQC_ItemType
*type);
872
886
XQC_Error
(*
type_name
)(
const
XQC_Sequence
*sequence,
const
char
**uri,
const
char
**name);
887
901
XQC_Error
(*
string_value
)(
const
XQC_Sequence
*sequence,
const
char
**value);
902
915
XQC_Error
(*
integer_value
)(
const
XQC_Sequence
*sequence,
int
*value);
916
929
XQC_Error
(*
double_value
)(
const
XQC_Sequence
*sequence,
double
*value);
930
945
XQC_Error
(*
node_name
)(
const
XQC_Sequence
*sequence,
const
char
**uri,
const
char
**name);
946
958
void
*(*get_interface)(
const
XQC_Sequence
*sequence,
const
char
*name);
959
966
void (*
free
)(
XQC_Sequence
*sequence);
967
};
968
969
#ifdef __cplusplus
970
}
971
#endif
972
973
#endif
Generated on Thu Jun 12 2014 19:58:01 for XQilla XQC API by
1.8.3.1