Line

Line — line API

Synopsis

struct              libscols_line;
struct libscols_line * scols_copy_line                  (struct libscols_line *ln);
int                 scols_line_add_child                (struct libscols_line *ln,
                                                         struct libscols_line *child);
int                 scols_line_alloc_cells              (struct libscols_line *ln,
                                                         size_t n);
void                scols_line_free_cells               (struct libscols_line *ln);
struct libscols_cell * scols_line_get_cell              (struct libscols_line *ln,
                                                         size_t n);
const char *        scols_line_get_color                (struct libscols_line *ln);
struct libscols_cell * scols_line_get_column_cell       (struct libscols_line *ln,
                                                         struct libscols_column *cl);
size_t              scols_line_get_ncells               (struct libscols_line *ln);
struct libscols_line * scols_line_get_parent            (struct libscols_line *ln);
void *              scols_line_get_userdata             (struct libscols_line *ln);
int                 scols_line_has_children             (struct libscols_line *ln);
int                 scols_line_next_child               (struct libscols_line *ln,
                                                         struct libscols_iter *itr,
                                                         struct libscols_line **chld);
int                 scols_line_refer_data               (struct libscols_line *ln,
                                                         size_t n,
                                                         char *data);
int                 scols_line_remove_child             (struct libscols_line *ln,
                                                         struct libscols_line *child);
int                 scols_line_set_color                (struct libscols_line *ln,
                                                         const char *color);
int                 scols_line_set_data                 (struct libscols_line *ln,
                                                         size_t n,
                                                         const char *data);
int                 scols_line_set_userdata             (struct libscols_line *ln,
                                                         void *data);
struct libscols_line * scols_new_line                   (void);
void                scols_ref_line                      (struct libscols_line *ln);
void                scols_unref_line                    (struct libscols_line *ln);

Description

An API to access and modify per-line data and information.

Details

struct libscols_line

struct libscols_line;

A line - an array of cells


scols_copy_line ()

struct libscols_line * scols_copy_line                  (struct libscols_line *ln);

ln :

a pointer to a struct libscols_cell instance

Returns :

A newly allocated copy of ln, NULL in case of an error.

scols_line_add_child ()

int                 scols_line_add_child                (struct libscols_line *ln,
                                                         struct libscols_line *child);

Sets child as a child of ln.

ln :

a pointer to a struct libscols_line instance

child :

a pointer to a struct libscols_line instance

Returns :

0, a negative value in case of an error.

scols_line_alloc_cells ()

int                 scols_line_alloc_cells              (struct libscols_line *ln,
                                                         size_t n);

Allocates space for n cells. This function is optional, and libsmartcols automatically allocates necessary cells according to number of columns in the table when you add the line to the table. See scols_table_add_line().

ln :

a pointer to a struct libscols_line instance

n :

the number of elements

Returns :

0, a negative value in case of an error.

scols_line_free_cells ()

void                scols_line_free_cells               (struct libscols_line *ln);

Frees the allocated cells referenced to by ln.

ln :

a pointer to a struct libscols_line instance

scols_line_get_cell ()

struct libscols_cell * scols_line_get_cell              (struct libscols_line *ln,
                                                         size_t n);

ln :

a pointer to a struct libscols_line instance

n :

cell number to retrieve

Returns :

the n-th cell in ln, NULL in case of an error.

scols_line_get_color ()

const char *        scols_line_get_color                (struct libscols_line *ln);

ln :

a pointer to a struct libscols_line instance

Returns :

ln's color string, NULL in case of an error.

scols_line_get_column_cell ()

struct libscols_cell * scols_line_get_column_cell       (struct libscols_line *ln,
                                                         struct libscols_column *cl);

Like scols_line_get_cell() by cell is referenced by column.

ln :

a pointer to a struct libscols_line instance

cl :

pointer to cell

Returns :

the n-th cell in ln, NULL in case of an error.

scols_line_get_ncells ()

size_t              scols_line_get_ncells               (struct libscols_line *ln);

ln :

a pointer to a struct libscols_line instance

Returns :

ln's number of cells

scols_line_get_parent ()

struct libscols_line * scols_line_get_parent            (struct libscols_line *ln);

ln :

a pointer to a struct libscols_line instance

Returns :

a pointer to ln's parent, NULL in case it has no parent or if there was an error.

scols_line_get_userdata ()

void *              scols_line_get_userdata             (struct libscols_line *ln);

ln :

a pointer to a struct libscols_line instance

Returns :

0, a negative value in case of an error.

scols_line_has_children ()

int                 scols_line_has_children             (struct libscols_line *ln);

ln :

a pointer to a struct libscols_line instance

Returns :

1 if ln has any children, otherwise 0.

scols_line_next_child ()

int                 scols_line_next_child               (struct libscols_line *ln,
                                                         struct libscols_iter *itr,
                                                         struct libscols_line **chld);

Finds the next child and returns a pointer to it via chld.

ln :

a pointer to a struct libscols_line instance

itr :

a pointer to a struct libscols_iter instance

chld :

a pointer to a pointer to a struct libscols_line instance

Returns :

0, a negative value in case of an error.

scols_line_refer_data ()

int                 scols_line_refer_data               (struct libscols_line *ln,
                                                         size_t n,
                                                         char *data);

ln :

a pointer to a struct libscols_cell instance

n :

number of the cell which will refer to data

data :

actual data to refer to

Returns :

0, a negative value in case of an error.

scols_line_remove_child ()

int                 scols_line_remove_child             (struct libscols_line *ln,
                                                         struct libscols_line *child);

Removes child as a child of ln.

ln :

a pointer to a struct libscols_line instance

child :

a pointer to a struct libscols_line instance

Returns :

0, a negative value in case of an error.

scols_line_set_color ()

int                 scols_line_set_color                (struct libscols_line *ln,
                                                         const char *color);

ln :

a pointer to a struct libscols_line instance

color :

color name or ESC sequence

Returns :

0, a negative value in case of an error.

scols_line_set_data ()

int                 scols_line_set_data                 (struct libscols_line *ln,
                                                         size_t n,
                                                         const char *data);

ln :

a pointer to a struct libscols_cell instance

n :

number of the cell, whose data is to be set

data :

actual data to set

Returns :

0, a negative value in case of an error.

scols_line_set_userdata ()

int                 scols_line_set_userdata             (struct libscols_line *ln,
                                                         void *data);

Binds data to ln.

ln :

a pointer to a struct libscols_line instance

data :

user data

Returns :

0, a negative value in case of an error.

scols_new_line ()

struct libscols_line * scols_new_line                   (void);

Note that the line is allocated without cells, the cells will be allocated later when you add the line to the table. If you want to use the line without table then you have to explicitly allocate the cells by scols_line_alloc_cells().

Returns :

a pointer to a new struct libscols_line instance.

scols_ref_line ()

void                scols_ref_line                      (struct libscols_line *ln);

Increases the refcount of ln.

ln :

a pointer to a struct libscols_line instance

scols_unref_line ()

void                scols_unref_line                    (struct libscols_line *ln);

Decreases the refcount of ln. When the count falls to zero, the instance is automatically deallocated.

ln :

a pointer to a struct libscols_line instance