a209b47d0cdc1f169ce71b544a339bf98f7a8965
4 * Enumeration mapping strings (quarks) from/to integers.
6 * Copyright (c) 2010 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #include <babeltrace/ctf/types.h>
27 GQuark
ctf_enum_read(struct stream_pos
*pos
,
28 const struct type_class_enum
*src
)
30 struct type_class_bitfield
*bitfield_class
= &src
->p
;
31 struct type_class_integer
*int_class
= &bitfield_class
->p
;
33 if (!int_class
->signedness
) {
36 v
= ctf_bitfield_unsigned_read(pos
, bitfield_class
);
37 return enum_uint_to_quark(src
, v
);
41 v
= fsrc
->bitfield_signed_read(pos
, bitfield_class
);
42 return enum_int_to_quark(src
, v
);
46 size_t ctf_enum_write(struct stream_pos
*pos
,
47 const struct type_class_enum
*dest
,
50 struct type_class_bitfield
*bitfield_class
= &dest
->p
;
51 struct type_class_integer
*int_class
= &bitfield_class
->p
;
53 if (!int_class
->signedness
) {
56 v
= enum_quark_to_uint(dest
, q
);
57 return ctf_bitfield_unsigned_write(pos
, bitfield_class
, v
);
61 v
= enum_quark_to_int(dest
, q
);
62 return ctf_bitfield_signed_write(pos
, bitfield_class
, v
);
This page took 0.031753 seconds and 3 git commands to generate.