Welcome to NYCU CSIT Mirror site

Cell

Cell

Cell — cell API

Synopsis

struct              libscols_cell;
int                 scols_cell_copy_content             (struct libscols_cell *dest,
                                                         const struct libscols_cell *src);
const char *        scols_cell_get_color                (const struct libscols_cell *ce);
const char *        scols_cell_get_data                 (const struct libscols_cell *ce);
void *              scols_cell_get_userdata             (struct libscols_cell *ce);
int                 scols_cell_refer_data               (struct libscols_cell *ce,
                                                         char *str);
int                 scols_cell_set_color                (struct libscols_cell *ce,
                                                         const char *color);
int                 scols_cell_set_data                 (struct libscols_cell *ce,
                                                         const char *str);
int                 scols_cell_set_userdata             (struct libscols_cell *ce,
                                                         void *data);
int                 scols_cmpstr_cells                  (struct libscols_cell *a,
                                                         struct libscols_cell *b,
                                                         void *data);
int                 scols_reset_cell                    (struct libscols_cell *ce);

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.

Details

struct libscols_cell

struct libscols_cell;

A cell - the smallest library object


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.

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

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

ce :

a pointer to a struct libscols_cell instance

Returns :

data in ce or NULL.

scols_cell_get_userdata ()

void *              scols_cell_get_userdata             (struct libscols_cell *ce);

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().

ce :

a pointer to a struct libscols_cell instance

str :

data (used for scols_printtable())

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.

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.

ce :

a pointer to a struct libscols_cell instance

str :

data (used for scols_printtable())

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

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().

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.

ce :

pointer to a struct libscols_cell instance

Returns :

0, a negative value in case of an error.