| Top |
FpiByteWriterFpiByteWriter — Writes different integer, string and floating point types to a memory buffer and allows reading |
FpiByteWriter provides a byte writer and reader that can write/read different integer and floating point types to/from a memory buffer. It provides functions for writing/reading signed/unsigned, little/big endian integers of 8, 16, 24, 32 and 64 bits and functions for reading little/big endian floating points numbers of 32 and 64 bits. It also provides functions to write/read NUL-terminated strings in various character encodings.
FpiByteWriter *
fpi_byte_writer_new (void);
Creates a new, empty FpiByteWriter instance
Free-function: fpi_byte_writer_free
[skip]
FpiByteWriter * fpi_byte_writer_new_with_size (guint size,gboolean fixed);
Creates a new FpiByteWriter instance with the given initial data size.
Free-function: fpi_byte_writer_free
[skip]
FpiByteWriter * fpi_byte_writer_new_with_data (guint8 *data,guint size,gboolean initialized);
Creates a new FpiByteWriter instance with the given
memory area. If initialized
is TRUE it is possible to
read size
bytes from the FpiByteWriter from the beginning.
Free-function: fpi_byte_writer_free
[skip]
void
fpi_byte_writer_init (FpiByteWriter *writer);
Initializes writer
to an empty instance
void fpi_byte_writer_init_with_size (FpiByteWriter *writer,guint size,gboolean fixed);
Initializes writer
with the given initial data size.
writer |
FpiByteWriter instance |
|
size |
Initial size of data |
|
fixed |
If |
void fpi_byte_writer_init_with_data (FpiByteWriter *writer,guint8 *data,guint size,gboolean initialized);
Initializes writer
with the given
memory area. If initialized
is TRUE it is possible to
read size
bytes from the FpiByteWriter from the beginning.
writer |
FpiByteWriter instance |
|
data |
Memory area for writing. |
[array length=size][transfer none] |
size |
Size of |
|
initialized |
If |
void
fpi_byte_writer_reset (FpiByteWriter *writer);
Resets writer
and frees the data if it's
owned by writer
.
guint8 *
fpi_byte_writer_reset_and_get_data (FpiByteWriter *writer);
Resets writer
and returns the current data.
Free-function: g_free
void
fpi_byte_writer_free (FpiByteWriter *writer);
Frees writer
and all memory allocated by it.
guint8 *
fpi_byte_writer_free_and_get_data (FpiByteWriter *writer);
Frees writer
and all memory allocated by it except
the current data, which is returned.
Free-function: g_free
guint
fpi_byte_writer_get_remaining (const FpiByteWriter *writer);
Returns the remaining size of data that can still be written. If -1 is returned the remaining size is only limited by system resources.
gboolean fpi_byte_writer_ensure_free_space (FpiByteWriter *writer,guint size);
Checks if enough free space from the current write cursor is available and reallocates if necessary.
gboolean fpi_byte_writer_put_uint8 (FpiByteWriter *writer,guint8 val);
Writes a unsigned 8 bit integer to writer
.
gboolean fpi_byte_writer_put_uint16_be (FpiByteWriter *writer,guint16 val);
Writes a unsigned big endian 16 bit integer to writer
.
gboolean fpi_byte_writer_put_uint24_be (FpiByteWriter *writer,guint32 val);
Writes a unsigned big endian 24 bit integer to writer
.
gboolean fpi_byte_writer_put_uint32_be (FpiByteWriter *writer,guint32 val);
Writes a unsigned big endian 32 bit integer to writer
.
gboolean fpi_byte_writer_put_uint64_be (FpiByteWriter *writer,guint64 val);
Writes a unsigned big endian 64 bit integer to writer
.
gboolean fpi_byte_writer_put_uint16_le (FpiByteWriter *writer,guint16 val);
Writes a unsigned little endian 16 bit integer to writer
.
gboolean fpi_byte_writer_put_uint24_le (FpiByteWriter *writer,guint32 val);
Writes a unsigned little endian 24 bit integer to writer
.
gboolean fpi_byte_writer_put_uint32_le (FpiByteWriter *writer,guint32 val);
Writes a unsigned little endian 32 bit integer to writer
.
gboolean fpi_byte_writer_put_uint64_le (FpiByteWriter *writer,guint64 val);
Writes a unsigned little endian 64 bit integer to writer
.
gboolean fpi_byte_writer_put_int8 (FpiByteWriter *writer,gint8 val);
Writes a signed 8 bit integer to writer
.
gboolean fpi_byte_writer_put_int16_be (FpiByteWriter *writer,gint16 val);
Writes a signed big endian 16 bit integer to writer
.
gboolean fpi_byte_writer_put_int24_be (FpiByteWriter *writer,gint32 val);
Writes a signed big endian 24 bit integer to writer
.
gboolean fpi_byte_writer_put_int32_be (FpiByteWriter *writer,gint32 val);
Writes a signed big endian 32 bit integer to writer
.
gboolean fpi_byte_writer_put_int64_be (FpiByteWriter *writer,gint64 val);
Writes a signed big endian 64 bit integer to writer
.
gboolean fpi_byte_writer_put_int16_le (FpiByteWriter *writer,gint16 val);
Writes a signed little endian 16 bit integer to writer
.
gboolean fpi_byte_writer_put_int24_le (FpiByteWriter *writer,gint32 val);
Writes a signed little endian 24 bit integer to writer
.
gboolean fpi_byte_writer_put_int32_le (FpiByteWriter *writer,gint32 val);
Writes a signed little endian 32 bit integer to writer
.
gboolean fpi_byte_writer_put_int64_le (FpiByteWriter *writer,gint64 val);
Writes a signed little endian 64 bit integer to writer
.
gboolean fpi_byte_writer_put_float32_be (FpiByteWriter *writer,gfloat val);
Writes a big endian 32 bit float to writer
.
gboolean fpi_byte_writer_put_float64_be (FpiByteWriter *writer,gdouble val);
Writes a big endian 64 bit float to writer
.
gboolean fpi_byte_writer_put_float32_le (FpiByteWriter *writer,gfloat val);
Writes a little endian 32 bit float to writer
.
gboolean fpi_byte_writer_put_float64_le (FpiByteWriter *writer,gdouble val);
Writes a little endian 64 bit float to writer
.
gboolean fpi_byte_writer_put_string_utf8 (FpiByteWriter *writer,const gchar *data);
Writes a NUL-terminated UTF8 string to writer
(including the terminator).
gboolean fpi_byte_writer_put_string_utf16 (FpiByteWriter *writer,const guint16 *data);
Writes a NUL-terminated UTF16 string to writer
(including the terminator).
writer |
FpiByteWriter instance |
|
data |
UTF16 string to write. |
[transfer none][array zero-terminated=1] |
gboolean fpi_byte_writer_put_string_utf32 (FpiByteWriter *writer,const guint32 *data);
Writes a NUL-terminated UTF32 string to writer
(including the terminator).
writer |
FpiByteWriter instance |
|
data |
UTF32 string to write. |
[transfer none][array zero-terminated=1] |
gboolean fpi_byte_writer_put_data (FpiByteWriter *writer,const guint8 *data,guint size);
Writes size
bytes of data
to writer
.
writer |
FpiByteWriter instance |
|
data |
Data to write. |
[transfer none][array length=size] |
size |
Size of |
gboolean fpi_byte_writer_fill (FpiByteWriter *writer,guint8 value,guint size);
Writes size
bytes containing value
to writer
.
writer |
FpiByteWriter instance |
|
value |
Value to be written |
|
size |
Number of bytes to be written |
typedef struct {
FpiByteReader parent;
guint alloc_size;
gboolean fixed;
gboolean owned;
} FpiByteWriter;
A byte writer instance.
FpiByteReader |
FpiByteReader parent |
|
Allocation size of the data |
||
If |
||
If |