Revert "Remove leading underscores from identifiers directly in lexer"
[babeltrace.git] / include / babeltrace / ctf-text / types.h
CommitLineData
46322b33
MD
1#ifndef _BABELTRACE_CTF_TEXT_TYPES_H
2#define _BABELTRACE_CTF_TEXT_TYPES_H
3
4/*
5 * Common Trace Format (Text Output)
6 *
7 * Type header
8 *
9 * Copyright 2010 - 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 <sys/mman.h>
23#include <errno.h>
24#include <stdint.h>
25#include <unistd.h>
26#include <glib.h>
70bd0a12 27#include <babeltrace/babeltrace-internal.h>
46322b33 28#include <babeltrace/types.h>
1ae19169 29#include <babeltrace/format.h>
46322b33 30
1ae19169
MD
31/*
32 * Inherit from both struct stream_pos and struct trace_descriptor.
33 */
46322b33 34struct ctf_text_stream_pos {
1ae19169
MD
35 struct stream_pos parent;
36 struct trace_descriptor trace_descriptor;
46322b33 37 FILE *fp; /* File pointer. NULL if unset. */
1ae19169
MD
38 int depth;
39 int dummy; /* disable output */
31262354 40 int print_names; /* print field names */
fd3382e8 41 int field_nr;
8d8ed9af 42 uint64_t last_timestamp; /* to print delta */
81dee1bb 43 GString *string; /* Current string */
46322b33
MD
44};
45
1ae19169
MD
46static inline
47struct ctf_text_stream_pos *ctf_text_pos(struct stream_pos *pos)
48{
49 return container_of(pos, struct ctf_text_stream_pos, parent);
50}
51
46322b33 52/*
1ae19169 53 * Write only is supported for now.
46322b33 54 */
c5e74408
MD
55int ctf_text_integer_write(struct stream_pos *pos, struct definition *definition);
56int ctf_text_float_write(struct stream_pos *pos, struct definition *definition);
57int ctf_text_string_write(struct stream_pos *pos, struct definition *definition);
58int ctf_text_enum_write(struct stream_pos *pos, struct definition *definition);
59int ctf_text_struct_write(struct stream_pos *pos, struct definition *definition);
60int ctf_text_variant_write(struct stream_pos *pos, struct definition *definition);
61int ctf_text_array_write(struct stream_pos *pos, struct definition *definition);
62int ctf_text_sequence_write(struct stream_pos *pos, struct definition *definition);
46322b33 63
1ae19169
MD
64static inline
65void print_pos_tabs(struct ctf_text_stream_pos *pos)
66{
67 int i;
46322b33 68
1ae19169
MD
69 for (i = 0; i < pos->depth; i++)
70 fprintf(pos->fp, "\t");
71}
46322b33 72
d335f0f7
MD
73/*
74 * Check if the field must be printed.
75 */
76int print_field(struct definition *definition);
77
6743f229
MD
78static inline
79const char *rem_(const char *str)
80{
81 if (str[0] == '_')
82 return &str[1];
83 else
84 return str;
85}
86
46322b33 87#endif /* _BABELTRACE_CTF_TEXT_TYPES_H */
This page took 0.026886 seconds and 4 git commands to generate.