CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

cstool/tokenlist.h File Reference

Token list helper macros. More...

#include <CS_TOKEN_ITEM_FILE>

Go to the source code of this file.

Token list helper macros

The macros here provide an easy way to automatically build a token list useful for e.g.

parsers. The list of tokens have to be declared in an external file, surrounded by 'CS_TOKEN_LIST_TOKEN()'. The name of the file (full path!) has to be put in a macro named CS_TOKEN_ITEM_FILE. Optionally, the name of the function to init the token table can be set via CS_INIT_TOKEN_TABLE_NAME, default is 'init_token_table'. Note that the user defines CS_TOKEN_ITEM_FILE and CS_INIT_TOKEN_TABLE_NAME won't be undefined by this file; hence, if you want to build multiple token lists, you have to redefine those macros and include tokenlist.h again.

Example (from a real-world use): fire.tok:

 CS_TOKEN_LIST_TOKEN(PALETTE)
 // ... 

fire.h:

 class csFireLoader
 {
  csStringHash tokens;
 #define CS_TOKEN_ITEM_FILE "plugins/proctex/standard/fire.tok"
 #include "cstool/tokenlist.h"
 // ...
 };

fire.cpp:



#define CS_TOKEN_LIST_TOKEN(X)   XMLTOKEN_ ## X,
 A token list entry.

#define CS_TOKEN_LIST_TOKEN(X)
 A token list entry.

#define CS_INIT_TOKEN_TABLE_NAME_DEFAULT
 A token list entry.

#define CS_INIT_TOKEN_TABLE_NAME   init_token_table
 A token list entry.

enum  
 A token list entry. More...

void CS_INIT_TOKEN_TABLE_NAME (csStringHash &t)
 A token list entry.


Detailed Description

Token list helper macros.

Definition in file tokenlist.h.


Generated for Crystal Space by doxygen 1.2.18