Skip to content

7.2 Data structure of liblouis tables

The data structure TranslationTableHeader is defined by a typedef statement in louis.h. To find the beginning, search for the word ‘header’. As its name implies, this is actually the table header. Data are placed in the ruleArea array, which is the last item defined in this structure. This array is declared with a length of 1 and is expanded as needed. The table header consists mostly of arrays of pointers of size HASHNUM. These pointers are actually offsets into ruleArea and point to chains of items which have been placed in the same hash bucket by a simple hashing algorithm. HASHNUM should be a prime and is currently 1123. The structure of the table was chosen to optimize speed rather than memory usage.

The first part of the table contains miscellaneous information, such as the number of passes and whether various opcodes have been used. It also contains the amount of memory allocated to the table and the amount actually used.

The next section contains pointers to various braille indicators and begins with capitalSign. The rules pointed to contain the dot pattern for the indicator and an opcode which is used by the back-translator but does not appear in the list of opcodes. The braille indicators also include various kinds of emphasis, such as italic and bold and information about the length of emphasized phrases. The latter is contained directly in the table item instead of in a rule.

After the braille indicators comes information about when a letter sign should be used.

Next is an array of size HASHNUM which points to character definitions. These are created by the character-definition opcodes.

Following this is a similar array pointing to definitions of single-cell dot patterns. This is also created from the character-definition opcodes. If a character definition contains a multi-cell dot pattern this is compiled into ordinary forward and backward rules. If such a multi-cell dot pattern contains a single cell which has not previously been defined that cell is placed in this array, but is given the attribute space.

Next come arrays that map characters to single-cell dot patterns and dots to characters. These are created from both character-definition opcodes and display opcodes.

Next is an array of size 256 which maps characters in this range to dot patterns which may consist of multiple cells. It is used, for example, to map ‘{’ to dots 456-246. These mappings are created by the compdots or the comp6 opcode (see comp6).

Next are two small arrays that held pointers to chains of rules produced by the swapcd opcode (see swapcd) and the swapdd opcode (see swapdd) and by some multipass, context and correct opcodes.

Now we get to an array of size HASHNUM which points to chains of rules for forward translation.

Following this is a similar array for back-translation.

Finally is the ruleArea, an array of variable size to which various structures are mapped and to which almost everything else points.