Contents

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

Defining Tables Inline

Once you are comfortable with using external Python modules to define tables, you might also want to try a different method. We may define tables inline,

//FILE: /include/example/example.hpp
//...
/*TABCPP_OPEN
from tabcpp import *

tables = [
    {
        'name': 'Points',
        'fields': [
            field('float', 'x'),
            field('float', 'y')
        ],
        'key': key('auto', 'int', 'id')
    }
]
TABCPP_CLOSE*/
            

Running the command,

 $ tabcpp.sh create include/example example.hpp 

will then create a new header file example_tables.hpp, defining the table.

We can also choose to dump the table code in the same header as the inline Python. To indicate where this should be done, place comments //TABLE_BEGIN <table-name> and //TABLE_END <table-name>, and use the command,
$ tabcpp.sh realise include/example example.hpp 
Previous: Interacting with Tables ;