Ion C
C library for Ion
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 
63 #define ION_EXTRACTOR_MAX_PATH_LENGTH_DEFAULT DEFAULT_WRITER_STACK_DEPTH
64 
69 #define ION_EXTRACTOR_MAX_NUM_PATHS_DEFAULT 16
70 
80 #ifndef ION_EXTRACTOR_MAX_PATH_LENGTH
81  #define ION_EXTRACTOR_MAX_PATH_LENGTH ION_EXTRACTOR_MAX_PATH_LENGTH_DEFAULT
82 #else
83  #if ION_EXTRACTOR_MAX_PATH_LENGTH > ION_EXTRACTOR_MAX_PATH_LENGTH_LIMIT
84  #undef ION_EXTRACTOR_MAX_PATH_LENGTH
85  #define ION_EXTRACTOR_MAX_PATH_LENGTH ION_EXTRACTOR_MAX_PATH_LENGTH_LIMIT
86  #elif ION_EXTRACTOR_MAX_PATH_LENGTH < 1
87  #undef ION_EXTRACTOR_MAX_PATH_LENGTH
88  #define ION_EXTRACTOR_MAX_PATH_LENGTH ION_EXTRACTOR_MAX_PATH_LENGTH_DEFAULT
89  #endif
90 #endif
91 
101 #ifndef ION_EXTRACTOR_MAX_NUM_PATHS
102  #define ION_EXTRACTOR_MAX_NUM_PATHS ION_EXTRACTOR_MAX_NUM_PATHS_DEFAULT
103 #else
104  #if ION_EXTRACTOR_MAX_NUM_PATHS > ION_EXTRACTOR_MAX_NUM_PATHS_LIMIT
105  #undef ION_EXTRACTOR_MAX_NUM_PATHS
106  #define ION_EXTRACTOR_MAX_NUM_PATHS ION_EXTRACTOR_MAX_NUM_PATHS_LIMIT
107  #elif ION_EXTRACTOR_MAX_NUM_PATHS < 1
108  #undef ION_EXTRACTOR_MAX_NUM_PATHS
109  #define ION_EXTRACTOR_MAX_NUM_PATHS ION_EXTRACTOR_MAX_NUM_PATHS_DEFAULT
110  #endif
111 #endif
112 
113 #ifdef __cplusplus
114 extern "C" {
115 #endif
116 
123 typedef uint16_t ION_EXTRACTOR_SIZE;
124 
128 typedef struct _ion_extractor_options {
137 
146 
159 
166 
168 
172 typedef struct _ion_extractor ION_EXTRACTOR;
173 
178 
182 typedef struct _ion_extractor_path_descriptor ION_EXTRACTOR_PATH_DESCRIPTOR;
183 
188 
199 typedef int_fast16_t ION_EXTRACTOR_CONTROL;
200 
204 static inline ION_EXTRACTOR_CONTROL ion_extractor_control_step_out(int n)
205 {
206  return (ION_EXTRACTOR_CONTROL) n;
207 }
208 
212 static inline ION_EXTRACTOR_CONTROL ion_extractor_control_next()
213 {
214  return ion_extractor_control_step_out(0);
215 }
216 
244 typedef iERR (*ION_EXTRACTOR_CALLBACK)(hREADER reader, hPATH matched_path, void *user_context,
245  ION_EXTRACTOR_CONTROL *p_control);
246 
256 ION_API_EXPORT iERR ion_extractor_open(hEXTRACTOR *extractor, ION_EXTRACTOR_OPTIONS *options);
257 
276 ION_API_EXPORT iERR ion_extractor_path_create(hEXTRACTOR extractor, ION_EXTRACTOR_SIZE path_length,
277  ION_EXTRACTOR_CALLBACK callback, void *user_context,
278  hPATH *p_path);
279 
291 ION_API_EXPORT iERR ion_extractor_path_append_field(hPATH path, ION_STRING *value);
292 
302 ION_API_EXPORT iERR ion_extractor_path_append_ordinal(hPATH path, POSITION value);
303 
312 ION_API_EXPORT iERR ion_extractor_path_append_wildcard(hPATH path);
313 
348  void *user_context, BYTE *ion_data, SIZE ion_data_length,
349  hPATH *p_path);
350 
366 ION_API_EXPORT iERR ion_extractor_match(hEXTRACTOR extractor, hREADER reader);
367 
372 ION_API_EXPORT iERR ion_extractor_close(hEXTRACTOR extractor);
373 
374 #ifdef __cplusplus
375 }
376 #endif
377 
378 #endif //ION_EXTRACTOR_H
ION_EXTRACTOR_PATH_DESCRIPTOR * hPATH
Definition: ion_extractor.h:187
int_fast16_t ION_EXTRACTOR_CONTROL
Definition: ion_extractor.h:199
ION_API_EXPORT iERR ion_extractor_close(hEXTRACTOR extractor)
uint16_t ION_EXTRACTOR_SIZE
Definition: ion_extractor.h:123
iERR(* ION_EXTRACTOR_CALLBACK)(hREADER reader, hPATH matched_path, void *user_context, ION_EXTRACTOR_CONTROL *p_control)
Definition: ion_extractor.h:244
ION_API_EXPORT iERR ion_extractor_path_append_wildcard(hPATH path)
ION_EXTRACTOR * hEXTRACTOR
Definition: ion_extractor.h:177
struct _ion_extractor_options ION_EXTRACTOR_OPTIONS
struct _ion_extractor_path_descriptor ION_EXTRACTOR_PATH_DESCRIPTOR
Definition: ion_extractor.h:182
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:172
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:128
bool match_case_insensitive
Definition: ion_extractor.h:165
bool match_relative_paths
Definition: ion_extractor.h:158
ION_EXTRACTOR_SIZE max_path_length
Definition: ion_extractor.h:136
ION_EXTRACTOR_SIZE max_num_paths
Definition: ion_extractor.h:145
Definition: ion_string.h:40