Top |
#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 () |
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:
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));
#define VIPS_BUF_STATIC( TEXT )
Initialize a heap buffer. For example:
char txt[256]; VipsBuf buf = VIPS_BUF_STATIC (txt);
void
vips_buf_destroy (VipsBuf *buf
);
Destroy a buffer. Only needed for heap buffers. Leaves the buffer in the _init state.
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.
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.
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:
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.
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.
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.
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.
gboolean vips_buf_appends (VipsBuf *buf
,const char *str
);
Append the whole of str
to buf
.
gboolean vips_buf_appendf (VipsBuf *buf
,const char *fmt
,...
);
Format the string and append to buf
.
gboolean vips_buf_vappendf (VipsBuf *buf
,const char *fmt
,va_list ap
);
Append to buf
, args as
.vprintf()
gboolean vips_buf_appendc (VipsBuf *buf
,char ch
);
Append a single character ch
to buf
.
gboolean vips_buf_appendgv (VipsBuf *buf
,GValue *value
);
Format and append a GValue with g_strdup_value_contents()
.
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.
gboolean vips_buf_removec (VipsBuf *buf
,char ch
);
Remove the last character, if it's ch
.
gboolean vips_buf_change (VipsBuf *buf
,const char *o
,const char *n
);
Swap the rightmost occurence of o
for n
.
const char *
vips_buf_all (VipsBuf *buf
);
Return the contents of the buffer as a C string.
const char *
vips_buf_firstline (VipsBuf *buf
);
Trim to just the first line (excluding "\n").
gboolean vips_buf_appendg (VipsBuf *buf
,double g
);
Append a double, non-localised. Useful for config files etc.
gboolean vips_buf_appendd (VipsBuf *buf
,int d
);
Append a number. If the number is -ve, add brackets. Needed for building function arguments.