Top |
Functions
#define | VIPS_BUF_STATIC() |
void | vips_buf_rewind () |
void | vips_buf_destroy () |
void | vips_buf_init () |
void | vips_buf_set_static () |
void | vips_buf_set_dynamic () |
void | vips_buf_init_static () |
void | vips_buf_init_dynamic () |
gboolean | vips_buf_appendns () |
gboolean | vips_buf_appends () |
gboolean | vips_buf_appendf () |
gboolean | vips_buf_vappendf () |
gboolean | vips_buf_appendc () |
gboolean | vips_buf_appendsc () |
gboolean | vips_buf_appendgv () |
gboolean | vips_buf_append_size () |
gboolean | vips_buf_removec () |
gboolean | vips_buf_change () |
gboolean | vips_buf_is_empty () |
gboolean | vips_buf_is_full () |
const char * | vips_buf_all () |
const char * | vips_buf_firstline () |
gboolean | vips_buf_appendg () |
gboolean | vips_buf_appendd () |
int | vips_buf_len () |
Description
A message buffer you can append stuff to safely and quickly. If the message gets too long, you get "..." and truncation. Message buffers can be on the stack or heap.
For example:
1 2 3 4 5 6 7 8 9 10 11 |
char txt[256]; VipsBuf buf = VIPS_BUF_STATIC (txt); int i; vips_buf_appends (&buf, "Numbers are: "); for (i = 0; i < array_length; i++) { if (i > 0) vips_buf_appends (&buf, ", "); vips_buf_appendg (&buf, array[i]); } printf ("%s", vips_buf_all (&buf)); |
Functions
VIPS_BUF_STATIC()
#define VIPS_BUF_STATIC( TEXT )
Initialize a heap buffer. For example:
1 2 |
char txt[256]; VipsBuf buf = VIPS_BUF_STATIC (txt); |
vips_buf_destroy ()
void
vips_buf_destroy (VipsBuf *buf
);
Destroy a buffer. Only needed for heap buffers. Leaves the buffer in the _init state.
vips_buf_set_static ()
void vips_buf_set_static (VipsBuf *buf
,char *base
,int mx
);
Attach the buffer to a static memory area. The buffer needs to have been initialised. The memory area needs to be at least 4 bytes long.
vips_buf_set_dynamic ()
void vips_buf_set_dynamic (VipsBuf *buf
,int mx
);
Attach the buffer to a heap memory area. The buffer needs to have been initialised. The memory area needs to be at least 4 bytes long.
vips_buf_init_static ()
void vips_buf_init_static (VipsBuf *buf
,char *base
,int mx
);
Initialise and attach to a static memory area. VIPS_BUF_STATIC()
is usually
more convenient.
For example:
1 2 3 4 |
char txt[256]; VipsBuf buf; vips_buf_init_static (&buf, txt, 256); |
Static buffers don't need to be freed when they go out of scope, but their size must be set at compile-time.
vips_buf_init_dynamic ()
void vips_buf_init_dynamic (VipsBuf *buf
,int mx
);
Initialise and attach to a heap memory area. The memory area needs to be at least 4 bytes long.
1 2 3 |
VipsBuf buf; vips_buf_init_synamic (&buf, 256); |
Dynamic buffers must be freed with vips_buf_destroy()
, but their size can
be set at runtime.
vips_buf_appendns ()
gboolean vips_buf_appendns (VipsBuf *buf
,const char *str
,int sz
);
Append at most sz
chars from str
to buf
. sz
< 0 means unlimited. This
is the low-level append operation: functions like vips_buf_appendf()
build
on top of this.
vips_buf_appends ()
gboolean vips_buf_appends (VipsBuf *buf
,const char *str
);
Append the whole of str
to buf
.
vips_buf_appendf ()
gboolean vips_buf_appendf (VipsBuf *buf
,const char *fmt
,...
);
Format the string and append to buf
.
vips_buf_vappendf ()
gboolean vips_buf_vappendf (VipsBuf *buf
,const char *fmt
,va_list ap
);
Append to buf
, args as
.vprintf()
vips_buf_appendc ()
gboolean vips_buf_appendc (VipsBuf *buf
,char ch
);
Append a single character ch
to buf
.
vips_buf_appendgv ()
gboolean vips_buf_appendgv (VipsBuf *buf
,GValue *value
);
Format and append a GValue as a printable thing. We display text line "3144 bytes of binary data" for BLOBs like icc-profile-data.
Use vips_image_get_as_string()
to make a text representation of a field.
That will base64-encode blobs, for example.
vips_buf_append_size ()
gboolean vips_buf_append_size (VipsBuf *buf
,size_t n
);
Turn a number of bytes into a sensible string ... eg "12", "12KB", "12MB", "12GB" etc.
vips_buf_removec ()
gboolean vips_buf_removec (VipsBuf *buf
,char ch
);
Remove the last character, if it's ch
.
vips_buf_change ()
gboolean vips_buf_change (VipsBuf *buf
,const char *o
,const char *n
);
Swap the rightmost occurence of o
for n
.
vips_buf_all ()
const char *
vips_buf_all (VipsBuf *buf
);
Return the contents of the buffer as a C string.
vips_buf_firstline ()
const char *
vips_buf_firstline (VipsBuf *buf
);
Trim to just the first line (excluding "\n").
vips_buf_appendg ()
gboolean vips_buf_appendg (VipsBuf *buf
,double g
);
Append a double, non-localised. Useful for config files etc.
vips_buf_appendd ()
gboolean vips_buf_appendd (VipsBuf *buf
,int d
);
Append a number. If the number is -ve, add brackets. Needed for building function arguments.