parser-private.h (2540B)
1 /* 2 * libdivecomputer 3 * 4 * Copyright (C) 2008 Jef Driesen 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 19 * MA 02110-1301 USA 20 */ 21 22 #ifndef PARSER_PRIVATE_H 23 #define PARSER_PRIVATE_H 24 25 #include <libdivecomputer/context.h> 26 #include <libdivecomputer/parser.h> 27 28 #define DEF_DENSITY_FRESH 1000.0 29 #define DEF_DENSITY_SALT 1025.0 30 #define DEF_ATMOSPHERIC ATM 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif /* __cplusplus */ 35 36 struct dc_parser_t; 37 struct dc_parser_vtable_t; 38 39 typedef struct dc_parser_vtable_t dc_parser_vtable_t; 40 41 struct dc_parser_t { 42 const dc_parser_vtable_t *vtable; 43 dc_context_t *context; 44 unsigned char *data; 45 unsigned int size; 46 }; 47 48 struct dc_parser_vtable_t { 49 size_t size; 50 51 dc_family_t type; 52 53 dc_status_t (*set_clock) (dc_parser_t *parser, unsigned int devtime, dc_ticks_t systime); 54 55 dc_status_t (*set_atmospheric) (dc_parser_t *parser, double atmospheric); 56 57 dc_status_t (*set_density) (dc_parser_t *parser, double density); 58 59 dc_status_t (*datetime) (dc_parser_t *parser, dc_datetime_t *datetime); 60 61 dc_status_t (*field) (dc_parser_t *parser, dc_field_type_t type, unsigned int flags, void *value); 62 63 dc_status_t (*samples_foreach) (dc_parser_t *parser, dc_sample_callback_t callback, void *userdata); 64 65 dc_status_t (*destroy) (dc_parser_t *parser); 66 }; 67 68 dc_parser_t * 69 dc_parser_allocate (dc_context_t *context, const dc_parser_vtable_t *vtable, const unsigned char data[], size_t size); 70 71 void 72 dc_parser_deallocate (dc_parser_t *parser); 73 74 int 75 dc_parser_isinstance (dc_parser_t *parser, const dc_parser_vtable_t *vtable); 76 77 typedef struct sample_statistics_t { 78 unsigned int divetime; 79 double maxdepth; 80 } sample_statistics_t; 81 82 #define SAMPLE_STATISTICS_INITIALIZER {0, 0.0} 83 84 void 85 sample_statistics_cb (dc_sample_type_t type, const dc_sample_value_t *value, void *userdata); 86 87 #ifdef __cplusplus 88 } 89 #endif /* __cplusplus */ 90 #endif /* PARSER_PRIVATE_H */