Grouping

Grouping — lines grouing

Functions

Description

Lines groups manipulation API. The grouping API can be used to create M:N relations between lines and on tree-like output it prints extra chart to visualize these relations. The group has unlimited number of members and group childs. See libsmartcols/sample/grouping* for more details.

Functions

scols_line_link_group ()

int
scols_line_link_group (struct libscols_line *ln,
                       struct libscols_line *member,
                       int id);

Define ln as child of group represented by group member . The line ln cannot be child of any other line. It's possible to create group->child or parent->child relationship, but no both for the same line (child).

The id is not used for now, use 0. The plan is to use it to support multi-group membership in future.

Parameters

ln

line instance

 

member

group member

 

id

group identifier (unused, not implemented yet))

 

Returns

0, a negative value in case of an error.

Since: 2.34


scols_table_group_lines ()

int
scols_table_group_lines (struct libscols_table *tb,
                         struct libscols_line *ln,
                         struct libscols_line *member,
                         int id);

This function add line ln to group of lines represented by member . If the group is not yet defined (member is not member of any group) than a new one is allocated.

The ln maybe a NULL -- in this case only a new group is allocated if not defined yet.

Note that the same line cannot be member of more groups (not implemented yet). The child of any group can be member of another group.

The id is not used for now, use 0. The plan is to use it to support multi-group membership in future.

Parameters

tb

a pointer to a struct libscols_table instance

 

ln

new group member

 

member

group member

 

id

group identifier (unused, not implemented yet), use zero.

 

Returns

0, a negative value in case of an error.

Since: 2.34