| 1 | #ifndef _BABELTRACE_FORMAT_H |
| 2 | #define _BABELTRACE_FORMAT_H |
| 3 | |
| 4 | /* |
| 5 | * BabelTrace |
| 6 | * |
| 7 | * Trace Format Header |
| 8 | * |
| 9 | * Copyright 2010, 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
| 10 | * |
| 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 12 | * of this software and associated documentation files (the "Software"), to deal |
| 13 | * in the Software without restriction, including without limitation the rights |
| 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 15 | * copies of the Software, and to permit persons to whom the Software is |
| 16 | * furnished to do so, subject to the following conditions: |
| 17 | * |
| 18 | * The above copyright notice and this permission notice shall be included in |
| 19 | * all copies or substantial portions of the Software. |
| 20 | */ |
| 21 | |
| 22 | #include <babeltrace/types.h> |
| 23 | #include <stdint.h> |
| 24 | #include <glib.h> |
| 25 | |
| 26 | struct format { |
| 27 | GQuark name; |
| 28 | |
| 29 | uint64_t (*uint_read)(struct stream_pos *pos, |
| 30 | const struct declaration_integer *integer_declaration); |
| 31 | int64_t (*int_read)(struct stream_pos *pos, |
| 32 | const struct declaration_integer *integer_declaration); |
| 33 | void (*uint_write)(struct stream_pos *pos, |
| 34 | const struct declaration_integer *integer_declaration, |
| 35 | uint64_t v); |
| 36 | void (*int_write)(struct stream_pos *pos, |
| 37 | const struct declaration_integer *integer_declaration, |
| 38 | int64_t v); |
| 39 | |
| 40 | void (*float_copy)(struct stream_pos *destp, |
| 41 | struct stream_pos *srcp, |
| 42 | const struct declaration_float *float_declaration); |
| 43 | double (*double_read)(struct stream_pos *pos, |
| 44 | const struct declaration_float *float_declaration); |
| 45 | void (*double_write)(struct stream_pos *pos, |
| 46 | const struct declaration_float *float_declaration, |
| 47 | double v); |
| 48 | |
| 49 | void (*string_copy)(struct stream_pos *dest, struct stream_pos *src, |
| 50 | const struct declaration_string *string_declaration); |
| 51 | void (*string_read)(char **dest, struct stream_pos *src, |
| 52 | const struct declaration_string *string_declaration); |
| 53 | void (*string_write)(struct stream_pos *dest, const char *src, |
| 54 | const struct declaration_string *string_declaration); |
| 55 | void (*string_free_temp)(char *string); |
| 56 | |
| 57 | /* |
| 58 | * enum_read returns a GArray of GQuark. Must be released with |
| 59 | * g_array_unref(). |
| 60 | */ |
| 61 | GArray *(*enum_read)(struct stream_pos *pos, |
| 62 | const struct declaration_enum *src); |
| 63 | void (*enum_write)(struct stream_pos *pos, |
| 64 | const struct declaration_enum *dest, |
| 65 | GQuark q); |
| 66 | void (*struct_begin)(struct stream_pos *pos, |
| 67 | const struct declaration_struct *struct_declaration); |
| 68 | void (*struct_end)(struct stream_pos *pos, |
| 69 | const struct declaration_struct *struct_declaration); |
| 70 | void (*variant_begin)(struct stream_pos *pos, |
| 71 | const struct declaration_variant *variant_declaration); |
| 72 | void (*variant_end)(struct stream_pos *pos, |
| 73 | const struct declaration_variant *variant_declaration); |
| 74 | void (*array_begin)(struct stream_pos *pos, |
| 75 | const struct declaration_array *array_declaration); |
| 76 | void (*array_end)(struct stream_pos *pos, |
| 77 | const struct declaration_array *array_declaration); |
| 78 | void (*sequence_begin)(struct stream_pos *pos, |
| 79 | const struct declaration_sequence *sequence_declaration); |
| 80 | void (*sequence_end)(struct stream_pos *pos, |
| 81 | const struct declaration_sequence *sequence_declaration); |
| 82 | }; |
| 83 | |
| 84 | struct format *bt_lookup_format(GQuark qname); |
| 85 | int bt_register_format(struct format *format); |
| 86 | |
| 87 | /* TBD: format unregistration */ |
| 88 | |
| 89 | #endif /* _BABELTRACE_FORMAT_H */ |