Ion C
C library for Ion
Loading...
Searching...
No Matches
ion_extractor.h
Go to the documentation of this file.
1/*
2 * Copyright 2012-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License").
5 * You may not use this file except in compliance with the License.
6 * A copy of the License is located at:
7 *
8 * http://aws.amazon.com/apache2.0/
9 *
10 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
12 * language governing permissions and limitations under the License.
13 */
14
21#ifndef ION_EXTRACTOR_H
22#define ION_EXTRACTOR_H
23
24#include "ion.h"
25#include <stdbool.h>
26
27#ifdef ION_EXTRACTOR_MAX_PATH_LENGTH_LIMIT
28 #undef ION_EXTRACTOR_MAX_PATH_LENGTH_LIMIT
29#endif
30
31#ifdef ION_EXTRACTOR_MAX_NUM_PATHS_LIMIT
32 #undef ION_EXTRACTOR_MAX_NUM_PATHS_LIMIT
33#endif
34
40#define ION_EXTRACTOR_MAX_PATH_LENGTH_LIMIT UINT16_MAX
41
47#define ION_EXTRACTOR_MAX_NUM_PATHS_LIMIT UINT16_MAX
48
49#ifdef ION_EXTRACTOR_MAX_PATH_LENGTH_DEFAULT
50 #undef ION_EXTRACTOR_MAX_PATH_LENGTH_DEFAULT
51#endif
52
53#ifdef ION_EXTRACTOR_MAX_NUM_PATHS_DEFAULT
54 #undef ION_EXTRACTOR_MAX_NUM_PATHS_DEFAULT
55#endif
56
64#define ION_EXTRACTOR_MAX_PATH_LENGTH_DEFAULT DEFAULT_WRITER_STACK_DEPTH
65
70#define ION_EXTRACTOR_MAX_NUM_PATHS_DEFAULT 16
71
81#ifndef ION_EXTRACTOR_MAX_PATH_LENGTH
82 #define ION_EXTRACTOR_MAX_PATH_LENGTH ION_EXTRACTOR_MAX_PATH_LENGTH_DEFAULT
83#else
84 #if ION_EXTRACTOR_MAX_PATH_LENGTH > ION_EXTRACTOR_MAX_PATH_LENGTH_LIMIT
85 #undef ION_EXTRACTOR_MAX_PATH_LENGTH
86 #define ION_EXTRACTOR_MAX_PATH_LENGTH ION_EXTRACTOR_MAX_PATH_LENGTH_LIMIT
87 #elif ION_EXTRACTOR_MAX_PATH_LENGTH < 1
88 #undef ION_EXTRACTOR_MAX_PATH_LENGTH
89 #define ION_EXTRACTOR_MAX_PATH_LENGTH ION_EXTRACTOR_MAX_PATH_LENGTH_DEFAULT
90 #endif
91#endif
92
102#ifndef ION_EXTRACTOR_MAX_NUM_PATHS
103 #define ION_EXTRACTOR_MAX_NUM_PATHS ION_EXTRACTOR_MAX_NUM_PATHS_DEFAULT
104#else
105 #if ION_EXTRACTOR_MAX_NUM_PATHS > ION_EXTRACTOR_MAX_NUM_PATHS_LIMIT
106 #undef ION_EXTRACTOR_MAX_NUM_PATHS
107 #define ION_EXTRACTOR_MAX_NUM_PATHS ION_EXTRACTOR_MAX_NUM_PATHS_LIMIT
108 #elif ION_EXTRACTOR_MAX_NUM_PATHS < 1
109 #undef ION_EXTRACTOR_MAX_NUM_PATHS
110 #define ION_EXTRACTOR_MAX_NUM_PATHS ION_EXTRACTOR_MAX_NUM_PATHS_DEFAULT
111 #endif
112#endif
113
114#ifdef __cplusplus
115extern "C" {
116#endif
117
124typedef uint16_t ION_EXTRACTOR_SIZE;
125
169
173typedef struct _ion_extractor ION_EXTRACTOR;
174
179
183typedef struct _ion_extractor_path_descriptor ION_EXTRACTOR_PATH_DESCRIPTOR;
184
189
200typedef int_fast16_t ION_EXTRACTOR_CONTROL;
201
205static inline ION_EXTRACTOR_CONTROL ion_extractor_control_step_out(int n)
206{
207 return (ION_EXTRACTOR_CONTROL) n;
208}
209
213static inline ION_EXTRACTOR_CONTROL ion_extractor_control_next()
214{
215 return ion_extractor_control_step_out(0);
216}
217
245typedef iERR (*ION_EXTRACTOR_CALLBACK)(hREADER reader, hPATH matched_path, void *user_context,
246 ION_EXTRACTOR_CONTROL *p_control);
247
257ION_API_EXPORT iERR ion_extractor_open(hEXTRACTOR *extractor, ION_EXTRACTOR_OPTIONS *options);
258
277ION_API_EXPORT iERR ion_extractor_path_create(hEXTRACTOR extractor, ION_EXTRACTOR_SIZE path_length,
278 ION_EXTRACTOR_CALLBACK callback, void *user_context,
279 hPATH *p_path);
280
292ION_API_EXPORT iERR ion_extractor_path_append_field(hPATH path, ION_STRING *value);
293
303ION_API_EXPORT iERR ion_extractor_path_append_ordinal(hPATH path, POSITION value);
304
314
349 void *user_context, BYTE *ion_data, SIZE ion_data_length,
350 hPATH *p_path);
351
367ION_API_EXPORT iERR ion_extractor_match(hEXTRACTOR extractor, hREADER reader);
368
373ION_API_EXPORT iERR ion_extractor_close(hEXTRACTOR extractor);
374
375#ifdef __cplusplus
376}
377#endif
378
379#endif //ION_EXTRACTOR_H
ION_EXTRACTOR_PATH_DESCRIPTOR * hPATH
Definition ion_extractor.h:188
int_fast16_t ION_EXTRACTOR_CONTROL
Definition ion_extractor.h:200
ION_API_EXPORT iERR ion_extractor_close(hEXTRACTOR extractor)
uint16_t ION_EXTRACTOR_SIZE
Definition ion_extractor.h:124
iERR(* ION_EXTRACTOR_CALLBACK)(hREADER reader, hPATH matched_path, void *user_context, ION_EXTRACTOR_CONTROL *p_control)
Definition ion_extractor.h:245
ION_API_EXPORT iERR ion_extractor_path_append_wildcard(hPATH path)
ION_EXTRACTOR * hEXTRACTOR
Definition ion_extractor.h:178
struct _ion_extractor_options ION_EXTRACTOR_OPTIONS
struct _ion_extractor_path_descriptor ION_EXTRACTOR_PATH_DESCRIPTOR
Definition ion_extractor.h:183
ION_API_EXPORT iERR ion_extractor_open(hEXTRACTOR *extractor, ION_EXTRACTOR_OPTIONS *options)
ION_API_EXPORT iERR ion_extractor_path_append_field(hPATH path, ION_STRING *value)
ION_API_EXPORT iERR ion_extractor_path_create_from_ion(hEXTRACTOR extractor, ION_EXTRACTOR_CALLBACK callback, void *user_context, BYTE *ion_data, SIZE ion_data_length, hPATH *p_path)
struct _ion_extractor ION_EXTRACTOR
Definition ion_extractor.h:173
ION_API_EXPORT iERR ion_extractor_path_create(hEXTRACTOR extractor, ION_EXTRACTOR_SIZE path_length, ION_EXTRACTOR_CALLBACK callback, void *user_context, hPATH *p_path)
ION_API_EXPORT iERR ion_extractor_path_append_ordinal(hPATH path, POSITION value)
ION_API_EXPORT iERR ion_extractor_match(hEXTRACTOR extractor, hREADER reader)
Definition ion_extractor.h:129
bool match_case_insensitive
Definition ion_extractor.h:166
bool match_relative_paths
Definition ion_extractor.h:159
ION_EXTRACTOR_SIZE max_path_length
Definition ion_extractor.h:137
ION_EXTRACTOR_SIZE max_num_paths
Definition ion_extractor.h:146
Definition ion_string.h:40