c-snippets  clob

The "clob" API is a dynamically-resizing "blob" (binary large object) class conceptually derived from code in the Fossil source tree (their APIs are also very similar, but this is a re-implementation for licensing reasons). Its primary uses are:

  • Creating and management of dynamic strings. (This is especially easy in conjunction with vappendf.)
  • Output buffering. This is sometimes useful, e.g., when building up output across several different functions.
  • Has some support for compressing/decompressing blobs. Not on-the-fly de/compression, but useful nonetheless.

The original intention of this class was to provide output buffering support for the cgi3 toolkit.

It's used something like this:

Clob * c;
clob_init( &c, 0, 0 );
clob_appendf( c, "Hello, %s!", "world");
...
clob_finalize( c );

clob_appendf() is based on vappendf() and therefor uses its extensions.