### Struct

# Vips Buf

#### Description [src]

    struct VipsBuf {
      /* No available fields */
    }

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));

#### Instance methods

###### vips_buf_all

Return the contents of the buffer as a C string.

###### vips_buf_append_size

Turn a number of bytes into a sensible string … eg “12”, “12KB”, “12MB”, “12GB” etc.

###### vips_buf_appendc

Append a single character `ch` to `buf`.

###### vips_buf_appendd

Append a number. If the number is -ve, add brackets. Needed for building function arguments.

###### vips_buf_appendf

Format the string and append to `buf`.

###### vips_buf_appendg

Append a double, non-localised. Useful for config files etc.

###### vips_buf_appendgv

Format and append a `GValue` as a printable thing. We display text like “3144 bytes of binary data” for BLOBs like icc-profile-data.

###### vips_buf_appendns

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

Append the whole of `str` to `buf`.

###### vips_buf_change

Swap the rightmost occurrence of `o` for `n`.

###### vips_buf_destroy

Destroy a buffer. Only needed for heap buffers. Leaves the buffer in the _init state.

###### vips_buf_firstline

Trim to just the first line (excluding “\n”).

###### vips_buf_init

Initialize a buffer.

###### vips_buf_init_dynamic

Initialise and attach to a heap memory area. The memory area needs to be at least 4 bytes long.

###### vips_buf_init_static

Initialise and attach to a static memory area. `VIPS_BUF_STATIC()` is usually more convenient.

###### vips_buf_is_empty

No description available.

###### vips_buf_is_full

No description available.

###### vips_buf_len

No description available.

###### vips_buf_removec

Remove the last character, if it’s `ch`.

###### vips_buf_rewind

Reset the buffer to the empty string.

###### vips_buf_set_dynamic

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_set_static

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_vappendf

Append to `buf`, args as `vprintf()`.