Project Lucy has retired. For details please refer to its Attic page.
Clownfish::CharBuf – C API Documentation
Apache Lucy™

Clownfish::CharBuf

parcel Clownfish
class variable CFISH_CHARBUF
struct symbol cfish_CharBuf
class nickname cfish_CB
header file Clownfish/CharBuf.h

Name

Clownfish::CharBuf – Growable buffer holding Unicode characters.

Functions

new
cfish_CharBuf* // incremented
cfish_CB_new(
    size_t capacity
);

Return a new CharBuf.

capacity

Initial minimum capacity of the CharBuf, in bytes.

init
cfish_CharBuf*
cfish_CB_init(
    cfish_CharBuf *self,
    size_t capacity
);

Initialize a CharBuf.

capacity

Initial minimum capacity of the CharBuf, in bytes.

catf
void
cfish_CB_catf(
    cfish_CharBuf *self,
    char *pattern
);

Invokes VCatF() to concatenate formatted arguments. Note that this is only a function and not a method.

pattern

The format string.

Methods

Cat_Utf8
void
cfish_CB_Cat_Utf8(
    cfish_CharBuf *self,
    char *utf8,
    size_t size
);

Concatenate the passed-in string onto the end of the CharBuf.

utf8

Pointer to UTF-8 character data.

size

Size of UTF-8 character data in bytes.

Cat_Trusted_Utf8
void
cfish_CB_Cat_Trusted_Utf8(
    cfish_CharBuf *self,
    char *utf8,
    size_t size
);

Concatenate the supplied text onto the end of the CharBuf. Don’t check for UTF-8 validity.

utf8

Pointer to UTF-8 character data.

size

Size of UTF-8 character data in bytes.

Cat
void
cfish_CB_Cat(
    cfish_CharBuf *self,
    cfish_String *string
);

Concatenate the contents of String string onto the end of the caller.

string

The String to concatenate.

VCatF
void
cfish_CB_VCatF(
    cfish_CharBuf *self,
    char *pattern,
    va_list args
);

Concatenate formatted arguments. Similar to the printf family, but only accepts minimal options (just enough for decent error messages).

Objects:  %o
char*:    %s
integers: %i8 %i32 %i64 %u8 %u32 %u64
floats:   %f64
hex:      %x32

Note that all Clownfish Objects, including Strings, are printed via %o (which invokes To_String()).

pattern

The format string.

args

A va_list containing the arguments.

Cat_Char
void
cfish_CB_Cat_Char(
    cfish_CharBuf *self,
    int32_t code_point
);

Concatenate one Unicode character onto the end of the CharBuf.

code_point

The code point of the Unicode character.

Grow
void
cfish_CB_Grow(
    cfish_CharBuf *self,
    size_t capacity
);

Assign more memory to the CharBuf, if it doesn’t already have enough room to hold a string of size bytes. Cannot shrink the allocation.

capacity

The new minimum capacity of the ByteBuf.

Clear
void
cfish_CB_Clear(
    cfish_CharBuf *self
);

Clear the CharBuf.

Get_Size
size_t
cfish_CB_Get_Size(
    cfish_CharBuf *self
);

Return the size of the CharBuf’s content in bytes.

Clone
cfish_CharBuf* // incremented
cfish_CB_Clone(
    cfish_CharBuf *self
);

Return a clone of the object.

To_String
cfish_String* // incremented
cfish_CB_To_String(
    cfish_CharBuf *self
);

Return the content of the CharBuf as String.

Yield_String
cfish_String* // incremented
cfish_CB_Yield_String(
    cfish_CharBuf *self
);

Return the content of the CharBuf as String and clear the CharBuf. This is more efficient than To_String().

Inheritance

Clownfish::CharBuf is a Clownfish::Obj.