Fixed-Width Character Sequences

A sequence declared as sequence<char<N>> contains fixed-width byte arrays, not single C char values and not necessarily zero-terminated strings. Its iterator carries N as elem_size. Each application buffer must provide exactly that many bytes per logical element.

Functions for these sequences use the _char suffix rather than a generated TYPE suffix. Typed logical traversal still hides plain versus RLE storage.

Logical I/O

    MCO_RET mco_seq_next_char(
            mco_seq_iterator_h iterator,
            void* value);

    MCO_RET mco_seq_get_char(
            mco_seq_iterator_h input,
            void* buf,
            mco_size_t* size);

    MCO_RET mco_seq_get_nullable_char(
            mco_seq_iterator_h input,
            void* buf,
            mco_size_t* size,
            mco_bitmap_word_t* null_bitmap);

On entry, size is the buffer capacity in elements; on return, it is the number of elements written. Use mco_seq_get_char() for non-nullable input. Use mco_seq_get_nullable_char() for nullable input; it preserves positions and sets one bit per NULL element.

Application Buffers

    MCO_RET mco_seq_unget_char(
            mco_seq_iterator_h result,
            void const* buf,
            mco_size_t buf_size,
            mco_size_t elem_size);

    MCO_RET mco_seq_unget_nullable_char(
            mco_seq_iterator_h result,
            void const* buf,
            mco_size_t buf_size,
            mco_size_t elem_size,
            mco_bitmap_word_t const* null_bitmap);

buf_size is the number of elements and elem_size is the width of one element in bytes. The functions do not copy buf or null_bitmap. Keep both alive and unchanged until every dependent pipeline has finished. Do not call mco_seq_free_buffer() for these source iterators.

Construction and Transformation

The following functions follow the contracts of their typed counterparts, while retaining the fixed element width in the iterator:

Character Callbacks

Character callbacks receive the element width because values are byte arrays. A value-producing callback writes exactly elem_size bytes to result.

    typedef void (*mco_seq_func_char_ptr_t)(
            char* result, char const* arg, mco_size_t elem_size);
    typedef void (*mco_seq_func2_char_ptr_t)(
            char* result, char const* arg1, char const* arg2,
            mco_size_t elem_size);
    typedef mco_seq_bool (*mco_seq_cond_char_ptr_t)(
            char const* arg, mco_size_t elem_size);

    MCO_RET mco_seq_func_char(
            mco_seq_iterator_h result,
            mco_seq_iterator_h input,
            mco_seq_func_char_ptr_t func);
    MCO_RET mco_seq_func2_char(
            mco_seq_iterator_h result,
            mco_seq_iterator_h left,
            mco_seq_iterator_h right,
            mco_seq_func2_char_ptr_t func);
    MCO_RET mco_seq_cond_char(
            mco_seq_iterator_h result,
            mco_seq_iterator_h input,
            mco_seq_cond_char_ptr_t func);

The context forms are mco_seq_func_ctx_char(), mco_seq_func2_ctx_char(), and mco_seq_cond_ctx_char(). Their callback types are mco_seq_func_ctx_char_ptr_t, mco_seq_func2_ctx_char_ptr_t, and mco_seq_cond_ctx_char_ptr_t; each adds void* ctx as the final callback argument.

Safety Rules