Ion C
C library for Ion
ion_reader.h
Go to the documentation of this file.
1 /*
2  * Copyright 2009-2016 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 
17 //
18 // defines for the readers, common, text and binary
19 //
20 #ifndef ION_READER_H_
21 #define ION_READER_H_
22 #include "ion_types.h"
23 #include "ion_stream.h"
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
39 typedef iERR (*ION_READER_CONTEXT_CALLBACK)(void *context, ION_COLLECTION *imports);
40 
46 
50  void *context;
51 
53 
54 
71 typedef struct _ion_reader_options
72 {
77 
82 
87 
92 
100 
105 
114 
121 
126 
131 
135  ION_CATALOG *pcatalog;
136 
145  decContext *decimal_context;
146 
151 
153 
154 //
155 // Ion Reader interface. Takes a byte buffer and length which
156 // may have text or binary content, returns handle to a reader.
157 //
158 
170 ION_API_EXPORT iERR ion_reader_open_buffer(hREADER *p_hreader
171  ,BYTE *buffer
172  ,SIZE buf_length
173  ,ION_READER_OPTIONS *p_options);
174 
221 ION_API_EXPORT iERR ion_reader_open_stream(hREADER *p_hreader
222  ,void *handler_state
223  ,ION_STREAM_HANDLER fn_input_handler
224  ,ION_READER_OPTIONS *p_options);
225 
240 ION_API_EXPORT iERR ion_reader_reset_stream(hREADER *p_hreader
241  ,void *handler_state
242  ,ION_STREAM_HANDLER fn_input_handler);
243 
265 ION_API_EXPORT iERR ion_reader_reset_stream_with_length(hREADER *p_hreader
266  ,void *handler_state
267  ,ION_STREAM_HANDLER fn_input_handler
268  ,POSITION length);
269 
270 ION_API_EXPORT iERR ion_reader_open (hREADER *p_hreader
271  ,ION_STREAM *p_stream
272  ,ION_READER_OPTIONS *p_options);
273 ION_API_EXPORT iERR ion_reader_get_catalog (hREADER hreader, hCATALOG *p_hcatalog);
274 
292 ION_API_EXPORT iERR ion_reader_seek (hREADER hreader
293  ,POSITION offset
294  ,SIZE length);
301 ION_API_EXPORT iERR ion_reader_set_symbol_table (hREADER hreader
302  ,hSYMTAB hsymtab);
307 ION_API_EXPORT iERR ion_reader_get_value_offset (hREADER hreader
308  ,POSITION *p_offset);
309 
338 ION_API_EXPORT iERR ion_reader_get_value_position (hREADER hreader
339  ,int64_t *p_offset
340  ,int32_t *p_line
341  ,int32_t *p_col_offset);
342 
356 ION_API_EXPORT iERR ion_reader_get_value_length (hREADER hreader
357  ,SIZE *p_length);
364 ION_API_EXPORT iERR ion_reader_get_symbol_table (hREADER hreader
365  ,hSYMTAB *p_hsymtab);
370 ION_API_EXPORT iERR ion_reader_next (hREADER hreader, ION_TYPE *p_value_type);
371 ION_API_EXPORT iERR ion_reader_step_in (hREADER hreader);
372 ION_API_EXPORT iERR ion_reader_step_out (hREADER hreader);
373 ION_API_EXPORT iERR ion_reader_get_depth (hREADER hreader, SIZE *p_depth);
374 
378 ION_API_EXPORT iERR ion_reader_get_type (hREADER hreader, ION_TYPE *p_value_type);
379 ION_API_EXPORT iERR ion_reader_has_any_annotations (hREADER hreader, BOOL *p_has_any_annotations);
380 ION_API_EXPORT iERR ion_reader_has_annotation (hREADER hreader, iSTRING annotation, BOOL *p_annotation_found);
381 ION_API_EXPORT iERR ion_reader_is_null (hREADER hreader, BOOL *p_is_null);
382 ION_API_EXPORT iERR ion_reader_is_in_struct (hREADER preader, BOOL *p_is_in_struct);
383 ION_API_EXPORT iERR ion_reader_get_field_name (hREADER hreader, iSTRING p_str);
384 ION_API_EXPORT iERR ion_reader_get_field_name_symbol(hREADER hreader, ION_SYMBOL **p_psymbol);
385 ION_API_EXPORT iERR ion_reader_get_annotations (hREADER hreader, iSTRING p_strs, SIZE max_count, SIZE *p_count);
386 ION_API_EXPORT iERR ion_reader_get_annotation_symbols(hREADER hreader, ION_SYMBOL *p_symbols, SIZE max_count, SIZE *p_count);
387 ION_API_EXPORT iERR ion_reader_get_annotation_count(hREADER hreader, SIZE *p_count);
388 ION_API_EXPORT iERR ion_reader_get_an_annotation (hREADER hreader, int idx, iSTRING p_strs);
389 ION_API_EXPORT iERR ion_reader_get_an_annotation_symbol(hREADER hreader, int idx, ION_SYMBOL *p_symbol);
390 ION_API_EXPORT iERR ion_reader_read_null (hREADER hreader, ION_TYPE *p_value);
391 ION_API_EXPORT iERR ion_reader_read_bool (hREADER hreader, BOOL *p_value);
392 
397 ION_API_EXPORT iERR ion_reader_read_int (hREADER hreader, int *p_value);
398 
403 ION_API_EXPORT iERR ion_reader_read_int32 (hREADER hreader, int32_t *p_value);
404 
409 ION_API_EXPORT iERR ion_reader_read_int64 (hREADER hreader, int64_t *p_value);
410 
414 ION_API_EXPORT iERR ion_reader_read_ion_int (hREADER hreader, ION_INT *p_value);
415 
420 ION_API_EXPORT iERR ion_reader_read_long (hREADER hreader, long *p_value);
421 ION_API_EXPORT iERR ion_reader_read_double (hREADER hreader, double *p_value);
422 
426 ION_API_EXPORT iERR ion_reader_read_decimal (hREADER hreader, decQuad *p_value);
427 ION_API_EXPORT iERR ion_reader_read_ion_decimal (hREADER hreader, ION_DECIMAL *p_value);
428 
432 ION_API_EXPORT iERR ion_reader_read_timestamp (hREADER hreader, iTIMESTAMP p_value);
433 
436 ION_API_EXPORT iERR ion_reader_read_ion_symbol(hREADER hreader, ION_SYMBOL *p_symbol);
437 
448 ION_API_EXPORT iERR ion_reader_get_string_length (hREADER hreader, SIZE *p_length); // note this may require the string value to be loaded in memory
449 ION_API_EXPORT iERR ion_reader_read_string (hREADER hreader, iSTRING p_value);
450 ION_API_EXPORT iERR ion_reader_read_partial_string (hREADER hreader, BYTE *p_buf, SIZE buf_max, SIZE *p_length);
451 
452 // TODO: move this to get_value_size, get_value_bytes, get_value_chuck that can read
453 // string, long int, decimal and timestamp values in addition to blob and clob
454 ION_API_EXPORT iERR ion_reader_get_lob_size (hREADER hreader, SIZE *p_length); // this may require the lob value to be loaded in memroy
455 ION_API_EXPORT iERR ion_reader_read_lob_bytes (hREADER hreader, BYTE *p_buf, SIZE buf_max, SIZE *p_length);
456 ION_API_EXPORT iERR ion_reader_read_lob_partial_bytes(hREADER hreader, BYTE *p_buf, SIZE buf_max, SIZE *p_length);
457 
469 ION_API_EXPORT iERR ion_reader_get_position (hREADER hreader, int64_t *p_bytes, int32_t *p_line, int32_t *p_offset);
470 
478 ION_API_EXPORT iERR ion_reader_close(hREADER hreader);
479 #ifdef __cplusplus
480 }
481 #endif
482 
483 #endif
ION_API_EXPORT iERR ion_reader_read_long(hREADER hreader, long *p_value)
ION_API_EXPORT iERR ion_reader_open_stream(hREADER *p_hreader, void *handler_state, ION_STREAM_HANDLER fn_input_handler, ION_READER_OPTIONS *p_options)
ION_API_EXPORT iERR ion_reader_read_int32(hREADER hreader, int32_t *p_value)
iERR(* ION_READER_CONTEXT_CALLBACK)(void *context, ION_COLLECTION *imports)
Definition: ion_reader.h:39
ION_API_EXPORT iERR ion_reader_get_value_offset(hREADER hreader, POSITION *p_offset)
ION_API_EXPORT iERR ion_reader_next(hREADER hreader, ION_TYPE *p_value_type)
ION_API_EXPORT iERR ion_reader_get_position(hREADER hreader, int64_t *p_bytes, int32_t *p_line, int32_t *p_offset)
ION_API_EXPORT iERR ion_reader_read_int(hREADER hreader, int *p_value)
ION_API_EXPORT iERR ion_reader_get_string_length(hREADER hreader, SIZE *p_length)
ION_API_EXPORT iERR ion_reader_read_ion_symbol(hREADER hreader, ION_SYMBOL *p_symbol)
ION_API_EXPORT iERR ion_reader_get_symbol_table(hREADER hreader, hSYMTAB *p_hsymtab)
ION_API_EXPORT iERR ion_reader_read_decimal(hREADER hreader, decQuad *p_value)
ION_API_EXPORT iERR ion_reader_read_timestamp(hREADER hreader, iTIMESTAMP p_value)
ION_API_EXPORT iERR ion_reader_read_int64(hREADER hreader, int64_t *p_value)
ION_API_EXPORT iERR ion_reader_set_symbol_table(hREADER hreader, hSYMTAB hsymtab)
ION_API_EXPORT iERR ion_reader_read_ion_int(hREADER hreader, ION_INT *p_value)
ION_API_EXPORT iERR ion_reader_reset_stream_with_length(hREADER *p_hreader, void *handler_state, ION_STREAM_HANDLER fn_input_handler, POSITION length)
ION_API_EXPORT iERR ion_reader_get_value_position(hREADER hreader, int64_t *p_offset, int32_t *p_line, int32_t *p_col_offset)
ION_API_EXPORT iERR ion_reader_open_buffer(hREADER *p_hreader, BYTE *buffer, SIZE buf_length, ION_READER_OPTIONS *p_options)
ION_API_EXPORT iERR ion_reader_seek(hREADER hreader, POSITION offset, SIZE length)
struct _ion_reader_options ION_READER_OPTIONS
ION_API_EXPORT iERR ion_reader_get_value_length(hREADER hreader, SIZE *p_length)
ION_API_EXPORT iERR ion_reader_get_type(hREADER hreader, ION_TYPE *p_value_type)
ION_API_EXPORT iERR ion_reader_close(hREADER hreader)
ION_API_EXPORT iERR ion_reader_reset_stream(hREADER *p_hreader, void *handler_state, ION_STREAM_HANDLER fn_input_handler)
struct ion_type * ION_TYPE
Definition: ion_types.h:69
Definition: ion_collection.h:72
Definition: ion_decimal.h:89
Definition: ion_int.h:100
Definition: ion_reader.h:41
void * context
Definition: ion_reader.h:50
ION_READER_CONTEXT_CALLBACK notify
Definition: ion_reader.h:45
Definition: ion_reader.h:72
SIZE user_value_threshold
Definition: ion_reader.h:113
int new_line_char
Definition: ion_reader.h:81
SIZE symbol_threshold
Definition: ion_reader.h:104
SIZE max_annotation_buffered
Definition: ion_reader.h:99
SIZE max_annotation_count
Definition: ion_reader.h:91
SIZE allocation_page_size
Definition: ion_reader.h:125
SIZE max_container_depth
Definition: ion_reader.h:86
ION_READER_CONTEXT_CHANGE_NOTIFIER context_change_notifier
Definition: ion_reader.h:150
BOOL return_system_values
Definition: ion_reader.h:76
BOOL skip_character_validation
Definition: ion_reader.h:130
ION_CATALOG * pcatalog
Definition: ion_reader.h:135
SIZE chunk_threshold
Definition: ion_reader.h:120
decContext * decimal_context
Definition: ion_reader.h:145
Definition: ion_string.h:40
Definition: ion_symbol_table.h:34
Definition: ion_timestamp.h:47