X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=include%2Fbabeltrace%2Fctf-text%2Ftypes.h;h=d69af90523220b33ee03dc18b3fd039583add267;hp=1e48b93c6821fb1ba3ec9805bc4b16ef68be8fda;hb=c462e188f3e7819c7bc74f671038cdbf36e8c3c0;hpb=46322b331aefc5739efd841df72d1928e35050e6 diff --git a/include/babeltrace/ctf-text/types.h b/include/babeltrace/ctf-text/types.h index 1e48b93c..d69af905 100644 --- a/include/babeltrace/ctf-text/types.h +++ b/include/babeltrace/ctf-text/types.h @@ -17,6 +17,14 @@ * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ #include @@ -24,58 +32,56 @@ #include #include #include -#include +#include #include +#include +/* + * Inherit from both struct stream_pos and struct trace_descriptor. + */ struct ctf_text_stream_pos { - struct trace_descriptor parent; + struct stream_pos parent; + struct trace_descriptor trace_descriptor; FILE *fp; /* File pointer. NULL if unset. */ + int depth; + int dummy; /* disable output */ + int print_names; /* print field names */ + int field_nr; + uint64_t last_real_timestamp; /* to print delta */ + uint64_t last_cycles_timestamp; /* to print delta */ + GString *string; /* Current string */ }; +static inline +struct ctf_text_stream_pos *ctf_text_pos(struct stream_pos *pos) +{ + return container_of(pos, struct ctf_text_stream_pos, parent); +} + /* - * IMPORTANT: All lengths (len) and offsets (start, end) are expressed in bits, - * *not* in bytes. - * - * All write primitives, as well as read for dynamically sized entities, can - * receive a NULL ptr/dest parameter. In this case, no write is performed, but - * the size is returned. + * Write only is supported for now. */ +int ctf_text_integer_write(struct stream_pos *pos, struct definition *definition); +int ctf_text_float_write(struct stream_pos *pos, struct definition *definition); +int ctf_text_string_write(struct stream_pos *pos, struct definition *definition); +int ctf_text_enum_write(struct stream_pos *pos, struct definition *definition); +int ctf_text_struct_write(struct stream_pos *pos, struct definition *definition); +int ctf_text_variant_write(struct stream_pos *pos, struct definition *definition); +int ctf_text_array_write(struct stream_pos *pos, struct definition *definition); +int ctf_text_sequence_write(struct stream_pos *pos, struct definition *definition); -void ctf_text_uint_write(struct stream_pos *pos, - const struct declaration_integer *integer_declaration, - uint64_t v); -void ctf_text_int_write(struct stream_pos *pos, - const struct declaration_integer *integer_declaration, - int64_t v); - -void ctf_text_double_write(struct stream_pos *pos, - const struct declaration_float *dest, - double v); -void ctf_text_ldouble_write(struct stream_pos *pos, - const struct declaration_float *dest, - long double v); +static inline +void print_pos_tabs(struct ctf_text_stream_pos *pos) +{ + int i; -void ctf_text_string_write(struct stream_pos *dest, const char *src, - const struct declaration_string *string_declaration); + for (i = 0; i < pos->depth; i++) + fprintf(pos->fp, "\t"); +} -void ctf_text_enum_write(struct stream_pos *pos, - const struct declaration_enum *dest, - GQuark q); -void ctf_text_struct_begin(struct stream_pos *pos, - const struct declaration_struct *struct_declaration); -void ctf_text_struct_end(struct stream_pos *pos, - const struct declaration_struct *struct_declaration); -void ctf_text_variant_begin(struct stream_pos *pos, - const struct declaration_variant *variant_declaration); -void ctf_text_variant_end(struct stream_pos *pos, - const struct declaration_variant *variant_declaration); -void ctf_text_array_begin(struct stream_pos *pos, - const struct declaration_array *array_declaration); -void ctf_text_array_end(struct stream_pos *pos, - const struct declaration_array *array_declaration); -void ctf_text_sequence_begin(struct stream_pos *pos, - const struct declaration_sequence *sequence_declaration); -void ctf_text_sequence_end(struct stream_pos *pos, - const struct declaration_sequence *sequence_declaration); +/* + * Check if the field must be printed. + */ +int print_field(struct definition *definition); #endif /* _BABELTRACE_CTF_TEXT_TYPES_H */