Contents

Introduction Getting Started More About Table Construction Interacting With Tables Inline Tables
Tabular-C++: Overview and Guide
Matthew Smith

More About Table Construction

Tables are very versatile, but before we can take advantage of them we should know how to construct them to our liking in Tabular-C++. So we shall now go over all the details of how our tables are constructed in Python.

Table Module

Tabular-C++ users can use Python modules to define their tables. The tables are expressed as Python dicts, and an arbitary number of these are placed in an array called tables. The constructor script tabcpp.sh will go through each table and insert appropriate C++ code in a nominated header file.

Table Name

The 'name' of a table should agree with the name given in the header file by the comments //TABLE_BEGIN <name> and //TABLE_END <name>.

Fields

The columns of our table are refered to as fields. A field is a Python dict e.g.,

 {'type': 'float', 'name': 'height'} 

but we may also construct this with a function defined in the tabcpp Python module,

 tabcpp.field('float', 'height') 

Fields are given together in the table dict, in an array under the key 'fields'. All field datatypes must be avaiable at the location indicated in the target header file.

Keys

Every row in a table can be identified by its unique key value. There are two major types of key:

In the Python module, keys are given by a dict e.g.

 {'type': 'auto', 'datatype': 'short', 'name': id}

or use a function from tabcpp,

 tabcpp.key('auto', 'short', 'id') 

The key is given in the table dict under the key 'key'.

Inserting the Table in a Header File

Code insersion is performed using the tabcpp.sh script, which wraps the real workhorse construct_table.py. You shoud ensure that the table Python module and the target header file are in the same directory. The command syntax is,

 $ tabcpp.sh load <path-to-table> <header-name> <table-python-module-name> 

In the target header file, it is necessary to have the header tabcpp.hpp is included. Otherwise the table code will give an error.

Previous: Introduction ; Next: Interacting With Tables