gattrib

s_table.c File Reference

Functions to manipulate the TABLE structure. More...

#include <config.h>
#include <stdio.h>
#include <math.h>
#include <libgeda/libgeda.h>
#include "../include/struct.h"
#include "../include/prototype.h"
#include "../include/globals.h"
Include dependency graph for s_table.c:

Go to the source code of this file.

Functions

TABLE ** s_table_new (int rows, int cols)
 Create a new table.
TABLE ** s_table_resize (TABLE **table, int rows, int old_cols, int new_cols)
 Resize a TABLE.
void s_table_destroy (TABLE **table, int row_count, int col_count)
 Destroy a table.
int s_table_get_index (STRING_LIST *local_list, char *local_string)
 Get a string index number.
STRING_LISTs_table_create_attrib_pair (gchar *row_name, TABLE **table, STRING_LIST *row_list, int num_attribs)
 Create attribute pair.
void s_table_add_toplevel_comp_items_to_comp_table (const GList *obj_list)
 Add components to the component table.
void s_table_add_toplevel_pin_items_to_pin_table (const GList *obj_list)
 Add pins to pin table.
void s_table_gtksheet_to_all_tables ()
 Push spreadsheet data to TABLEs.
void s_table_gtksheet_to_table (GtkSheet *local_gtk_sheet, STRING_LIST *master_row_list, STRING_LIST *master_col_list, TABLE **local_table, int num_rows, int num_cols)
 Extract attributes from gtksheet into TABLE.

Detailed Description

This file holds functions involved in manipulating the TABLE structure, which is subsidiary to SHEET_DATA. TABLE is a 2 dimensional array of structs; each struct corresponds to the data about an element in a single cell of the spreadsheet.

Todo:
TABLE should also store its dimensions in its own data structure to save carrying the dimensions around separately.

Definition in file s_table.c.


Function Documentation

TABLE** s_table_new ( int  rows,
int  cols 
)

This is the table creator. It returns a pointer to an initialized TABLE struct. As calling args, it needs the number of rows and cols to allocate. The table is a dynamically allocated 2D array of structs. To access data in a cell in the table, you reference (for example): ((sheet_data->comp_table)[i][j]).attrib_value (Parens used only for clarity. It works without parens.)

Parameters:
rowsNumber of rows required in the new table
colsNumber of columns required in the new table
Returns:
a pointer to an initialized TABLE struct.

Definition at line 68 of file s_table.c.

TABLE** s_table_resize ( TABLE **  table,
int  rows,
int  old_cols,
int  new_cols 
)

This function recreates the table with a new size. It can only increase the number of cols. You can't increase the number of rows since gattrib doesn't allow you to input new components. Decreasing the number of cols is also TBD.

Parameters:
tableTable to resize
rowsNumber of rows in the table
old_colsNumber of columns previously in the table
new_colsNumber of columns required in the table
Returns:
a pointer to the resized table
Todo:
The row and column information could be stored in the TABLE struct.

Definition at line 115 of file s_table.c.

void s_table_destroy ( TABLE **  table,
int  row_count,
int  col_count 
)

This function destroys the old table. Use it after reading in a new page to get rid of the old table before building a new one.

Parameters:
tableTable to destroy
row_countNumber of rows in table
col_countNumber of columns in table

Definition at line 153 of file s_table.c.

int s_table_get_index ( STRING_LIST local_list,
char *  local_string 
)

This function returns the index number when given a STRING_LIST and a string to match. It finds the index number by iterating through the master list.

Parameters:
local_list
local_string
Returns:
the index of the string

Definition at line 191 of file s_table.c.

STRING_LIST* s_table_create_attrib_pair ( gchar *  row_name,
TABLE **  table,
STRING_LIST row_list,
int  num_attribs 
)

This function takes a table, a row list, and a row name, and returns a list holding name=value pairs for all attribs pertainent to that particular row. If the row holds no attribs, it just returns NULL.

Parameters:
row_nameName of the row to search for
tableTable to be searched
row_listlist of rows
num_attribs
Returns:
STRING_LIST of name=value pairs

Definition at line 228 of file s_table.c.

Here is the call graph for this function:

void s_table_add_toplevel_comp_items_to_comp_table ( const GList *  obj_list)

This fcn iterates over adds all objects found on this page looking for components. When it finds a component, it finds all component attribs and sticks them in the TABLE.

Parameters:
obj_listpointer to GList containing objects on this page

Definition at line 275 of file s_table.c.

Here is the call graph for this function:

void s_table_add_toplevel_pin_items_to_pin_table ( const GList *  obj_list)

This function iterates over adds all items found on this page looking for pins. WHen it finds a pin, it gathers all pin attribs and sticks them into the pin table.

Parameters:
obj_listList of objects on page

Definition at line 482 of file s_table.c.

Here is the call graph for this function:

void s_table_gtksheet_to_all_tables ( )

This function traverses the spreadsheet, extracts the attribs from the cells, and places them back into TABLE. This is the first step in saving out a project.

Definition at line 603 of file s_table.c.

Here is the call graph for this function:

void s_table_gtksheet_to_table ( GtkSheet local_gtk_sheet,
STRING_LIST master_row_list,
STRING_LIST master_col_list,
TABLE **  local_table,
int  num_rows,
int  num_cols 
)

This function does the actual heavy lifting of looping through the spreadsheet, extracting the attribs from the cells, and placing them back into TABLE. This is the first step in saving out a project.

Parameters:
local_gtk_sheetGtkSheet to save
master_row_listSTRING_LIST of rows
master_col_listSTRING_LIST of columns
local_tableTABLE structure to fill
num_rowsNumber of rows in table
num_colsNumber of columns in table

Definition at line 678 of file s_table.c.

Here is the call graph for this function:

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines