libfprint/fpi-byte-writer.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* GStreamer byte writer | ||
| 2 | * | ||
| 3 | * Copyright (C) 2009 Sebastian Dröge <sebastian.droege@collabora.co.uk>. | ||
| 4 | * | ||
| 5 | * This library is free software; you can redistribute it and/or | ||
| 6 | * modify it under the terms of the GNU Library General Public | ||
| 7 | * License as published by the Free Software Foundation; either | ||
| 8 | * version 2 of the License, or (at your option) any later version. | ||
| 9 | * | ||
| 10 | * This library is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 13 | * Library General Public License for more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU Library General Public | ||
| 16 | * License along with this library; if not, write to the | ||
| 17 | * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, | ||
| 18 | * Boston, MA 02110-1301, USA. | ||
| 19 | */ | ||
| 20 | |||
| 21 | #pragma once | ||
| 22 | |||
| 23 | #include "fpi-byte-reader.h" | ||
| 24 | #include <string.h> | ||
| 25 | |||
| 26 | G_BEGIN_DECLS | ||
| 27 | |||
| 28 | #define FPI_BYTE_WRITER(writer) ((FpiByteWriter *) (writer)) | ||
| 29 | |||
| 30 | /** | ||
| 31 | * FpiByteWriter: | ||
| 32 | * @parent: #FpiByteReader parent | ||
| 33 | * @alloc_size: Allocation size of the data | ||
| 34 | * @fixed: If %TRUE no reallocations are allowed | ||
| 35 | * @owned: If %FALSE no reallocations are allowed and copies of data are returned | ||
| 36 | * | ||
| 37 | * A byte writer instance. | ||
| 38 | */ | ||
| 39 | typedef struct { | ||
| 40 | FpiByteReader parent; | ||
| 41 | |||
| 42 | guint alloc_size; | ||
| 43 | |||
| 44 | gboolean fixed; | ||
| 45 | gboolean owned; | ||
| 46 | |||
| 47 | /* < private > */ | ||
| 48 | } FpiByteWriter; | ||
| 49 | |||
| 50 | |||
| 51 | FpiByteWriter * fpi_byte_writer_new (void) G_GNUC_MALLOC; | ||
| 52 | |||
| 53 | |||
| 54 | FpiByteWriter * fpi_byte_writer_new_with_size (guint size, gboolean fixed) G_GNUC_MALLOC; | ||
| 55 | |||
| 56 | |||
| 57 | FpiByteWriter * fpi_byte_writer_new_with_data (guint8 *data, guint size, gboolean initialized) G_GNUC_MALLOC; | ||
| 58 | |||
| 59 | |||
| 60 | void fpi_byte_writer_init (FpiByteWriter *writer); | ||
| 61 | |||
| 62 | |||
| 63 | void fpi_byte_writer_init_with_size (FpiByteWriter *writer, guint size, gboolean fixed); | ||
| 64 | |||
| 65 | |||
| 66 | void fpi_byte_writer_init_with_data (FpiByteWriter *writer, guint8 *data, | ||
| 67 | guint size, gboolean initialized); | ||
| 68 | |||
| 69 | void fpi_byte_writer_free (FpiByteWriter *writer); | ||
| 70 | |||
| 71 | |||
| 72 | guint8 * fpi_byte_writer_free_and_get_data (FpiByteWriter *writer); | ||
| 73 | |||
| 74 | |||
| 75 | void fpi_byte_writer_reset (FpiByteWriter *writer); | ||
| 76 | |||
| 77 | |||
| 78 | guint8 * fpi_byte_writer_reset_and_get_data (FpiByteWriter *writer); | ||
| 79 | |||
| 80 | |||
| 81 | GBytes * fpi_byte_writer_reset_and_get_bytes (FpiByteWriter *writer); | ||
| 82 | |||
| 83 | /** | ||
| 84 | * fpi_byte_writer_get_pos: | ||
| 85 | * @writer: #FpiByteWriter instance | ||
| 86 | * | ||
| 87 | * Returns: The current position of the read/write cursor | ||
| 88 | */ | ||
| 89 | /** | ||
| 90 | * fpi_byte_writer_set_pos: | ||
| 91 | * @writer: #FpiByteWriter instance | ||
| 92 | * @pos: new position | ||
| 93 | * | ||
| 94 | * Sets the current read/write cursor of @writer. The new position | ||
| 95 | * can only be between 0 and the current size. | ||
| 96 | * | ||
| 97 | * Returns: %TRUE if the new position could be set | ||
| 98 | */ | ||
| 99 | /** | ||
| 100 | * fpi_byte_writer_get_size: | ||
| 101 | * @writer: #FpiByteWriter instance | ||
| 102 | * | ||
| 103 | * Returns: The current, initialized size of the data | ||
| 104 | */ | ||
| 105 | static inline guint | ||
| 106 | 780 | fpi_byte_writer_get_pos (const FpiByteWriter *writer) | |
| 107 | { | ||
| 108 | 780 | return fpi_byte_reader_get_pos ((const FpiByteReader *) writer); | |
| 109 | } | ||
| 110 | |||
| 111 | static inline gboolean | ||
| 112 | 723 | fpi_byte_writer_set_pos (FpiByteWriter *writer, guint pos) | |
| 113 | { | ||
| 114 | 723 | return fpi_byte_reader_set_pos (FPI_BYTE_READER (writer), pos); | |
| 115 | } | ||
| 116 | |||
| 117 | static inline gboolean | ||
| 118 | 780 | fpi_byte_writer_change_pos (FpiByteWriter *writer, gint pos) | |
| 119 | { | ||
| 120 | 780 | pos = fpi_byte_writer_get_pos (writer) + pos; | |
| 121 | |||
| 122 |
1/2✓ Branch 3 → 4 taken 780 times.
✗ Branch 3 → 5 not taken.
|
780 | if (pos < 0) |
| 123 | return FALSE; | ||
| 124 | |||
| 125 | 780 | return fpi_byte_reader_set_pos (FPI_BYTE_READER (writer), pos); | |
| 126 | } | ||
| 127 | |||
| 128 | static inline guint | ||
| 129 | 9 | fpi_byte_writer_get_size (const FpiByteWriter *writer) | |
| 130 | { | ||
| 131 | 9 | return fpi_byte_reader_get_size ((const FpiByteReader *) writer); | |
| 132 | } | ||
| 133 | |||
| 134 | |||
| 135 | guint fpi_byte_writer_get_remaining (const FpiByteWriter *writer); | ||
| 136 | |||
| 137 | |||
| 138 | gboolean fpi_byte_writer_ensure_free_space (FpiByteWriter *writer, guint size); | ||
| 139 | |||
| 140 | |||
| 141 | gboolean fpi_byte_writer_put_uint8 (FpiByteWriter *writer, guint8 val); | ||
| 142 | |||
| 143 | |||
| 144 | gboolean fpi_byte_writer_put_int8 (FpiByteWriter *writer, gint8 val); | ||
| 145 | |||
| 146 | |||
| 147 | gboolean fpi_byte_writer_put_uint16_be (FpiByteWriter *writer, guint16 val); | ||
| 148 | |||
| 149 | |||
| 150 | gboolean fpi_byte_writer_put_uint16_le (FpiByteWriter *writer, guint16 val); | ||
| 151 | |||
| 152 | |||
| 153 | gboolean fpi_byte_writer_put_int16_be (FpiByteWriter *writer, gint16 val); | ||
| 154 | |||
| 155 | |||
| 156 | gboolean fpi_byte_writer_put_int16_le (FpiByteWriter *writer, gint16 val); | ||
| 157 | |||
| 158 | |||
| 159 | gboolean fpi_byte_writer_put_uint24_be (FpiByteWriter *writer, guint32 val); | ||
| 160 | |||
| 161 | |||
| 162 | gboolean fpi_byte_writer_put_uint24_le (FpiByteWriter *writer, guint32 val); | ||
| 163 | |||
| 164 | |||
| 165 | gboolean fpi_byte_writer_put_int24_be (FpiByteWriter *writer, gint32 val); | ||
| 166 | |||
| 167 | |||
| 168 | gboolean fpi_byte_writer_put_int24_le (FpiByteWriter *writer, gint32 val); | ||
| 169 | |||
| 170 | |||
| 171 | gboolean fpi_byte_writer_put_uint32_be (FpiByteWriter *writer, guint32 val); | ||
| 172 | |||
| 173 | |||
| 174 | gboolean fpi_byte_writer_put_uint32_le (FpiByteWriter *writer, guint32 val); | ||
| 175 | |||
| 176 | |||
| 177 | gboolean fpi_byte_writer_put_int32_be (FpiByteWriter *writer, gint32 val); | ||
| 178 | |||
| 179 | |||
| 180 | gboolean fpi_byte_writer_put_int32_le (FpiByteWriter *writer, gint32 val); | ||
| 181 | |||
| 182 | |||
| 183 | gboolean fpi_byte_writer_put_uint64_be (FpiByteWriter *writer, guint64 val); | ||
| 184 | |||
| 185 | |||
| 186 | gboolean fpi_byte_writer_put_uint64_le (FpiByteWriter *writer, guint64 val); | ||
| 187 | |||
| 188 | |||
| 189 | gboolean fpi_byte_writer_put_int64_be (FpiByteWriter *writer, gint64 val); | ||
| 190 | |||
| 191 | |||
| 192 | gboolean fpi_byte_writer_put_int64_le (FpiByteWriter *writer, gint64 val); | ||
| 193 | |||
| 194 | |||
| 195 | gboolean fpi_byte_writer_put_float32_be (FpiByteWriter *writer, gfloat val); | ||
| 196 | |||
| 197 | |||
| 198 | gboolean fpi_byte_writer_put_float32_le (FpiByteWriter *writer, gfloat val); | ||
| 199 | |||
| 200 | |||
| 201 | gboolean fpi_byte_writer_put_float64_be (FpiByteWriter *writer, gdouble val); | ||
| 202 | |||
| 203 | |||
| 204 | gboolean fpi_byte_writer_put_float64_le (FpiByteWriter *writer, gdouble val); | ||
| 205 | |||
| 206 | |||
| 207 | gboolean fpi_byte_writer_put_data (FpiByteWriter *writer, const guint8 *data, guint size); | ||
| 208 | |||
| 209 | |||
| 210 | gboolean fpi_byte_writer_put_bytes (FpiByteWriter *writer, const GBytes *bytes); | ||
| 211 | |||
| 212 | |||
| 213 | gboolean fpi_byte_writer_fill (FpiByteWriter *writer, guint8 value, guint size); | ||
| 214 | |||
| 215 | |||
| 216 | gboolean fpi_byte_writer_put_string_utf8 (FpiByteWriter *writer, const gchar *data); | ||
| 217 | |||
| 218 | |||
| 219 | gboolean fpi_byte_writer_put_string_utf16 (FpiByteWriter *writer, const guint16 *data); | ||
| 220 | |||
| 221 | |||
| 222 | gboolean fpi_byte_writer_put_string_utf32 (FpiByteWriter *writer, const guint32 *data); | ||
| 223 | |||
| 224 | /** | ||
| 225 | * fpi_byte_writer_put_string: | ||
| 226 | * @writer: #FpiByteWriter instance | ||
| 227 | * @data: (in) (array zero-terminated=1): Null terminated string | ||
| 228 | * | ||
| 229 | * Write a NUL-terminated string to @writer (including the terminator). The | ||
| 230 | * string is assumed to be in an 8-bit encoding (e.g. ASCII,UTF-8 or | ||
| 231 | * ISO-8859-1). | ||
| 232 | * | ||
| 233 | * Returns: %TRUE if the string could be written | ||
| 234 | */ | ||
| 235 | #define fpi_byte_writer_put_string(writer, data) \ | ||
| 236 | fpi_byte_writer_put_string_utf8(writer, data) | ||
| 237 | |||
| 238 | static inline guint | ||
| 239 | 18 | fpi_byte_writer_next_pow2 (guint n) | |
| 240 | { | ||
| 241 | 18 | guint ret = 16; | |
| 242 | |||
| 243 | /* We start with 16, smaller allocations make no sense */ | ||
| 244 | |||
| 245 |
2/2✓ Branch 8 → 7 taken 19 times.
✓ Branch 8 → 9 taken 18 times.
|
37 | while (ret < n && ret > 0) |
| 246 | 19 | ret <<= 1; | |
| 247 | |||
| 248 |
1/2✓ Branch 9 → 10 taken 18 times.
✗ Branch 9 → 11 not taken.
|
18 | return ret ? ret : n; |
| 249 | } | ||
| 250 | |||
| 251 | static inline gboolean | ||
| 252 | 2248 | fpi_byte_writer_ensure_free_space_inline (FpiByteWriter * writer, guint size) | |
| 253 | { | ||
| 254 | 2248 | gpointer data; | |
| 255 | |||
| 256 |
2/2✓ Branch 2 → 3 taken 18 times.
✓ Branch 2 → 14 taken 2230 times.
|
2248 | if (G_LIKELY (size <= writer->alloc_size - writer->parent.byte)) |
| 257 | return TRUE; | ||
| 258 |
2/4✓ Branch 3 → 4 taken 18 times.
✗ Branch 3 → 14 not taken.
✓ Branch 4 → 5 taken 18 times.
✗ Branch 4 → 14 not taken.
|
18 | if (G_UNLIKELY (writer->fixed || !writer->owned)) |
| 259 | return FALSE; | ||
| 260 |
1/2✓ Branch 5 → 6 taken 18 times.
✗ Branch 5 → 14 not taken.
|
18 | if (G_UNLIKELY (writer->parent.byte > G_MAXUINT - size)) |
| 261 | return FALSE; | ||
| 262 | |||
| 263 | 18 | writer->alloc_size = fpi_byte_writer_next_pow2 (writer->parent.byte + size); | |
| 264 | 18 | data = g_try_realloc ((guint8 *) writer->parent.data, writer->alloc_size); | |
| 265 |
1/2✓ Branch 12 → 13 taken 18 times.
✗ Branch 12 → 14 not taken.
|
18 | if (G_UNLIKELY (data == NULL)) |
| 266 | return FALSE; | ||
| 267 | |||
| 268 | 18 | writer->parent.data = (guint8 *) data; | |
| 269 | |||
| 270 | 18 | return TRUE; | |
| 271 | } | ||
| 272 | |||
| 273 | #define __FPI_BYTE_WRITER_CREATE_WRITE_FUNC(bits,type,name,write_func) \ | ||
| 274 | static inline void \ | ||
| 275 | fpi_byte_writer_put_##name##_unchecked (FpiByteWriter *writer, type val) \ | ||
| 276 | { \ | ||
| 277 | guint8 *write_data; \ | ||
| 278 | \ | ||
| 279 | write_data = (guint8 *) writer->parent.data + writer->parent.byte; \ | ||
| 280 | write_func (write_data, val); \ | ||
| 281 | writer->parent.byte += bits/8; \ | ||
| 282 | writer->parent.size = MAX (writer->parent.size, writer->parent.byte); \ | ||
| 283 | } \ | ||
| 284 | \ | ||
| 285 | static inline gboolean \ | ||
| 286 | fpi_byte_writer_put_##name##_inline (FpiByteWriter *writer, type val) \ | ||
| 287 | { \ | ||
| 288 | g_return_val_if_fail (writer != NULL, FALSE); \ | ||
| 289 | \ | ||
| 290 | if (G_UNLIKELY (!fpi_byte_writer_ensure_free_space_inline(writer, bits/8))) \ | ||
| 291 | return FALSE; \ | ||
| 292 | \ | ||
| 293 | fpi_byte_writer_put_##name##_unchecked (writer, val); \ | ||
| 294 | \ | ||
| 295 | return TRUE; \ | ||
| 296 | } | ||
| 297 | |||
| 298 |
2/4✗ Branch 2 → 3 not taken.
✓ Branch 2 → 4 taken 70 times.
✓ Branch 5 → 6 taken 70 times.
✗ Branch 5 → 7 not taken.
|
70 | __FPI_BYTE_WRITER_CREATE_WRITE_FUNC (8, guint8, uint8, FP_WRITE_UINT8) |
| 299 | ✗ | __FPI_BYTE_WRITER_CREATE_WRITE_FUNC (8, gint8, int8, FP_WRITE_UINT8) | |
| 300 | ✗ | __FPI_BYTE_WRITER_CREATE_WRITE_FUNC (16, guint16, uint16_le, FP_WRITE_UINT16_LE) | |
| 301 |
2/4✗ Branch 2 → 3 not taken.
✓ Branch 2 → 4 taken 688 times.
✓ Branch 5 → 6 taken 688 times.
✗ Branch 5 → 7 not taken.
|
688 | __FPI_BYTE_WRITER_CREATE_WRITE_FUNC (16, guint16, uint16_be, FP_WRITE_UINT16_BE) |
| 302 | ✗ | __FPI_BYTE_WRITER_CREATE_WRITE_FUNC (16, gint16, int16_le, FP_WRITE_UINT16_LE) | |
| 303 | ✗ | __FPI_BYTE_WRITER_CREATE_WRITE_FUNC (16, gint16, int16_be, FP_WRITE_UINT16_BE) | |
| 304 | ✗ | __FPI_BYTE_WRITER_CREATE_WRITE_FUNC (24, guint32, uint24_le, FP_WRITE_UINT24_LE) | |
| 305 | ✗ | __FPI_BYTE_WRITER_CREATE_WRITE_FUNC (24, guint32, uint24_be, FP_WRITE_UINT24_BE) | |
| 306 | ✗ | __FPI_BYTE_WRITER_CREATE_WRITE_FUNC (24, gint32, int24_le, FP_WRITE_UINT24_LE) | |
| 307 | ✗ | __FPI_BYTE_WRITER_CREATE_WRITE_FUNC (24, gint32, int24_be, FP_WRITE_UINT24_BE) | |
| 308 | ✗ | __FPI_BYTE_WRITER_CREATE_WRITE_FUNC (32, guint32, uint32_le, FP_WRITE_UINT32_LE) | |
| 309 | ✗ | __FPI_BYTE_WRITER_CREATE_WRITE_FUNC (32, guint32, uint32_be, FP_WRITE_UINT32_BE) | |
| 310 | ✗ | __FPI_BYTE_WRITER_CREATE_WRITE_FUNC (32, gint32, int32_le, FP_WRITE_UINT32_LE) | |
| 311 | ✗ | __FPI_BYTE_WRITER_CREATE_WRITE_FUNC (32, gint32, int32_be, FP_WRITE_UINT32_BE) | |
| 312 | ✗ | __FPI_BYTE_WRITER_CREATE_WRITE_FUNC (64, guint64, uint64_le, FP_WRITE_UINT64_LE) | |
| 313 | ✗ | __FPI_BYTE_WRITER_CREATE_WRITE_FUNC (64, guint64, uint64_be, FP_WRITE_UINT64_BE) | |
| 314 | ✗ | __FPI_BYTE_WRITER_CREATE_WRITE_FUNC (64, gint64, int64_le, FP_WRITE_UINT64_LE) | |
| 315 | ✗ | __FPI_BYTE_WRITER_CREATE_WRITE_FUNC (64, gint64, int64_be, FP_WRITE_UINT64_BE) | |
| 316 | |||
| 317 | ✗ | __FPI_BYTE_WRITER_CREATE_WRITE_FUNC (32, gfloat, float32_be, FP_WRITE_FLOAT_BE) | |
| 318 | ✗ | __FPI_BYTE_WRITER_CREATE_WRITE_FUNC (32, gfloat, float32_le, FP_WRITE_FLOAT_LE) | |
| 319 | ✗ | __FPI_BYTE_WRITER_CREATE_WRITE_FUNC (64, gdouble, float64_be, FP_WRITE_DOUBLE_BE) | |
| 320 | ✗ | __FPI_BYTE_WRITER_CREATE_WRITE_FUNC (64, gdouble, float64_le, FP_WRITE_DOUBLE_LE) | |
| 321 | |||
| 322 | #undef __FPI_BYTE_WRITER_CREATE_WRITE_FUNC | ||
| 323 | |||
| 324 | static inline void | ||
| 325 | 1490 | fpi_byte_writer_put_data_unchecked (FpiByteWriter * writer, const guint8 * data, | |
| 326 | guint size) | ||
| 327 | { | ||
| 328 | 1490 | memcpy ((guint8 *) & writer->parent.data[writer->parent.byte], data, size); | |
| 329 | 1490 | writer->parent.byte += size; | |
| 330 | 1490 | writer->parent.size = MAX (writer->parent.size, writer->parent.byte); | |
| 331 | 1490 | } | |
| 332 | |||
| 333 | static inline gboolean | ||
| 334 | 1490 | fpi_byte_writer_put_data_inline (FpiByteWriter * writer, const guint8 * data, | |
| 335 | guint size) | ||
| 336 | { | ||
| 337 |
1/2✗ Branch 2 → 3 not taken.
✓ Branch 2 → 4 taken 1490 times.
|
1490 | g_return_val_if_fail (writer != NULL, FALSE); |
| 338 | |||
| 339 |
1/2✓ Branch 5 → 6 taken 1490 times.
✗ Branch 5 → 8 not taken.
|
1490 | if (G_UNLIKELY (!fpi_byte_writer_ensure_free_space_inline (writer, size))) |
| 340 | return FALSE; | ||
| 341 | |||
| 342 | 1490 | fpi_byte_writer_put_data_unchecked (writer, data, size); | |
| 343 | |||
| 344 | 1490 | return TRUE; | |
| 345 | } | ||
| 346 | |||
| 347 | static inline gboolean | ||
| 348 | fpi_byte_writer_put_bytes_inline (FpiByteWriter * writer, const GBytes * bytes) | ||
| 349 | { | ||
| 350 | g_return_val_if_fail (writer != NULL, FALSE); | ||
| 351 | g_return_val_if_fail (bytes != NULL, FALSE); | ||
| 352 | const guint8 *data; | ||
| 353 | gsize size; | ||
| 354 | |||
| 355 | data = g_bytes_get_data ((GBytes *) bytes, &size); | ||
| 356 | return fpi_byte_writer_put_data_inline (writer, data, size); | ||
| 357 | } | ||
| 358 | |||
| 359 | static inline void | ||
| 360 | ✗ | fpi_byte_writer_fill_unchecked (FpiByteWriter * writer, guint8 value, guint size) | |
| 361 | { | ||
| 362 | ✗ | memset ((guint8 *) & writer->parent.data[writer->parent.byte], value, size); | |
| 363 | ✗ | writer->parent.byte += size; | |
| 364 | ✗ | writer->parent.size = MAX (writer->parent.size, writer->parent.byte); | |
| 365 | ✗ | } | |
| 366 | |||
| 367 | static inline gboolean | ||
| 368 | ✗ | fpi_byte_writer_fill_inline (FpiByteWriter * writer, guint8 value, guint size) | |
| 369 | { | ||
| 370 | ✗ | g_return_val_if_fail (writer != NULL, FALSE); | |
| 371 | |||
| 372 | ✗ | if (G_UNLIKELY (!fpi_byte_writer_ensure_free_space_inline (writer, size))) | |
| 373 | return FALSE; | ||
| 374 | |||
| 375 | ✗ | fpi_byte_writer_fill_unchecked (writer, value, size); | |
| 376 | |||
| 377 | ✗ | return TRUE; | |
| 378 | } | ||
| 379 | |||
| 380 | #ifndef FPI_BYTE_WRITER_DISABLE_INLINES | ||
| 381 | |||
| 382 | /* we use defines here so we can add the G_LIKELY() */ | ||
| 383 | |||
| 384 | #define fpi_byte_writer_ensure_free_space(writer, size) \ | ||
| 385 | G_LIKELY (fpi_byte_writer_ensure_free_space_inline (writer, size)) | ||
| 386 | #define fpi_byte_writer_put_uint8(writer, val) \ | ||
| 387 | G_LIKELY (fpi_byte_writer_put_uint8_inline (writer, val)) | ||
| 388 | #define fpi_byte_writer_put_int8(writer, val) \ | ||
| 389 | G_LIKELY (fpi_byte_writer_put_int8_inline (writer, val)) | ||
| 390 | #define fpi_byte_writer_put_uint16_be(writer, val) \ | ||
| 391 | G_LIKELY (fpi_byte_writer_put_uint16_be_inline (writer, val)) | ||
| 392 | #define fpi_byte_writer_put_uint16_le(writer, val) \ | ||
| 393 | G_LIKELY (fpi_byte_writer_put_uint16_le_inline (writer, val)) | ||
| 394 | #define fpi_byte_writer_put_int16_be(writer, val) \ | ||
| 395 | G_LIKELY (fpi_byte_writer_put_int16_be_inline (writer, val)) | ||
| 396 | #define fpi_byte_writer_put_int16_le(writer, val) \ | ||
| 397 | G_LIKELY (fpi_byte_writer_put_int16_le_inline (writer, val)) | ||
| 398 | #define fpi_byte_writer_put_uint24_be(writer, val) \ | ||
| 399 | G_LIKELY (fpi_byte_writer_put_uint24_be_inline (writer, val)) | ||
| 400 | #define fpi_byte_writer_put_uint24_le(writer, val) \ | ||
| 401 | G_LIKELY (fpi_byte_writer_put_uint24_le_inline (writer, val)) | ||
| 402 | #define fpi_byte_writer_put_int24_be(writer, val) \ | ||
| 403 | G_LIKELY (fpi_byte_writer_put_int24_be_inline (writer, val)) | ||
| 404 | #define fpi_byte_writer_put_int24_le(writer, val) \ | ||
| 405 | G_LIKELY (fpi_byte_writer_put_int24_le_inline (writer, val)) | ||
| 406 | #define fpi_byte_writer_put_uint32_be(writer, val) \ | ||
| 407 | G_LIKELY (fpi_byte_writer_put_uint32_be_inline (writer, val)) | ||
| 408 | #define fpi_byte_writer_put_uint32_le(writer, val) \ | ||
| 409 | G_LIKELY (fpi_byte_writer_put_uint32_le_inline (writer, val)) | ||
| 410 | #define fpi_byte_writer_put_int32_be(writer, val) \ | ||
| 411 | G_LIKELY (fpi_byte_writer_put_int32_be_inline (writer, val)) | ||
| 412 | #define fpi_byte_writer_put_int32_le(writer, val) \ | ||
| 413 | G_LIKELY (fpi_byte_writer_put_int32_le_inline (writer, val)) | ||
| 414 | #define fpi_byte_writer_put_uint64_be(writer, val) \ | ||
| 415 | G_LIKELY (fpi_byte_writer_put_uint64_be_inline (writer, val)) | ||
| 416 | #define fpi_byte_writer_put_uint64_le(writer, val) \ | ||
| 417 | G_LIKELY (fpi_byte_writer_put_uint64_le_inline (writer, val)) | ||
| 418 | #define fpi_byte_writer_put_int64_be(writer, val) \ | ||
| 419 | G_LIKELY (fpi_byte_writer_put_int64_be_inline (writer, val)) | ||
| 420 | #define fpi_byte_writer_put_int64_le(writer, val) \ | ||
| 421 | G_LIKELY (fpi_byte_writer_put_int64_le_inline (writer, val)) | ||
| 422 | |||
| 423 | #define fpi_byte_writer_put_float32_be(writer, val) \ | ||
| 424 | G_LIKELY (fpi_byte_writer_put_float32_be_inline (writer, val)) | ||
| 425 | #define fpi_byte_writer_put_float32_le(writer, val) \ | ||
| 426 | G_LIKELY (fpi_byte_writer_put_float32_le_inline (writer, val)) | ||
| 427 | #define fpi_byte_writer_put_float64_be(writer, val) \ | ||
| 428 | G_LIKELY (fpi_byte_writer_put_float64_be_inline (writer, val)) | ||
| 429 | #define fpi_byte_writer_put_float64_le(writer, val) \ | ||
| 430 | G_LIKELY (fpi_byte_writer_put_float64_le_inline (writer, val)) | ||
| 431 | |||
| 432 | #define fpi_byte_writer_put_data(writer, data, size) \ | ||
| 433 | G_LIKELY (fpi_byte_writer_put_data_inline (writer, data, size)) | ||
| 434 | #define fpi_byte_writer_put_data_static(writer, data) \ | ||
| 435 | G_LIKELY (fpi_byte_writer_put_data_inline (writer, data, sizeof (data))) | ||
| 436 | #define fpi_byte_writer_put_bytes(writer, bytes) \ | ||
| 437 | G_LIKELY (fpi_byte_writer_put_bytes_inline (writer, bytes)) | ||
| 438 | #define fpi_byte_writer_fill(writer, val, size) \ | ||
| 439 | G_LIKELY (fpi_byte_writer_fill_inline (writer, val, size)) | ||
| 440 | |||
| 441 | #endif | ||
| 442 | |||
| 443 | G_DEFINE_AUTOPTR_CLEANUP_FUNC (FpiByteWriter, fpi_byte_writer_free); | ||
| 444 | 1477 | G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (FpiByteWriter, fpi_byte_writer_reset); | |
| 445 | |||
| 446 | G_END_DECLS | ||
| 447 |