Cell

Cell — container for your data

Functions

Types and Values

struct libscols_cell

Description

An API to access and modify per-cell data and information. Note that cell is always part of the line. If you destroy (un-reference) a line than it destroys all line cells too.

Functions

scols_cell_copy_content ()

int
scols_cell_copy_content (struct libscols_cell *dest,
                         const struct libscols_cell *src);

Copy the contents of src into dest .

Parameters

dest

a pointer to a struct libscols_cell instance

 

src

a pointer to an immutable struct libscols_cell instance

 

Returns

0, a negative value in case of an error.


scols_cell_get_color ()

const char *
scols_cell_get_color (const struct libscols_cell *ce);

Parameters

ce

a pointer to a struct libscols_cell instance

 

Returns

the current color of ce .


scols_cell_get_data ()

const char *
scols_cell_get_data (const struct libscols_cell *ce);

Parameters

ce

a pointer to a struct libscols_cell instance

 

Returns

data in ce or NULL.


scols_cell_get_flags ()

int
scols_cell_get_flags (const struct libscols_cell *ce);

Parameters

ce

a pointer to a struct libscols_cell instance

 

Returns

the current flags or -1 in case of an error.


scols_cell_get_userdata ()

void *
scols_cell_get_userdata (struct libscols_cell *ce);

Parameters

ce

a pointer to a struct libscols_cell instance

 

Returns

user data


scols_cell_refer_data ()

int
scols_cell_refer_data (struct libscols_cell *ce,
                       char *str);

Adds a reference to str to ce . The pointer is deallocated by scols_reset_cell() or scols_unref_line(). This function is mostly designed for situations when the data for the cell are already composed in allocated memory (e.g. asprintf()) to avoid extra unnecessary strdup().

Parameters

ce

a pointer to a struct libscols_cell instance

 

str

data (used for scols_print_table())

 

Returns

0, a negative value in case of an error.


scols_cell_set_color ()

int
scols_cell_set_color (struct libscols_cell *ce,
                      const char *color);

Set the color of ce to color .

Parameters

ce

a pointer to a struct libscols_cell instance

 

color

color name or ESC sequence

 

Returns

0, a negative value in case of an error.


scols_cell_set_data ()

int
scols_cell_set_data (struct libscols_cell *ce,
                     const char *str);

Stores a copy of the str in ce , the old data are deallocated by free().

Parameters

ce

a pointer to a struct libscols_cell instance

 

str

data (used for scols_print_table())

 

Returns

0, a negative value in case of an error.


scols_cell_set_flags ()

int
scols_cell_set_flags (struct libscols_cell *ce,
                      int flags);

Note that cells in the table are always aligned by column flags. The cell flags are used for table title only (now).

Parameters

ce

a pointer to a struct libscols_cell instance

 

flags

SCOLS_CELL_FL_* flags

 

Returns

0, a negative value in case of an error.


scols_cell_set_userdata ()

int
scols_cell_set_userdata (struct libscols_cell *ce,
                         void *data);

Parameters

ce

a pointer to a struct libscols_cell instance

 

data

private user data

 

Returns

0, a negative value in case of an error.


scols_cmpstr_cells ()

int
scols_cmpstr_cells (struct libscols_cell *a,
                    struct libscols_cell *b,
                    void *data);

Compares cells data by strcmp(). The function is designed for scols_column_set_cmpfunc() and scols_sort_table().

Parameters

a

pointer to cell

 

b

pointer to cell

 

data

unused pointer to private data (defined by API)

 

Returns

follows strcmp() return values.


scols_reset_cell ()

int
scols_reset_cell (struct libscols_cell *ce);

Frees the cell's internal data and resets its status.

Parameters

ce

pointer to a struct libscols_cell instance

 

Returns

0, a negative value in case of an error.

Types and Values

struct libscols_cell

struct libscols_cell;

A cell - the smallest library object