<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>Crystal Space 1.2.1: cstool/tokenlist.h File Reference (Crystal Space 1.2.1 Public API Reference)</title> <link href="tabs.css" rel="stylesheet" type="text/css"> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body> <table border="0" cellpadding="0" cellspacing="0" width="100%" class="head"> <tr height="59"> <td class="head" width="202" valign="bottom" style="padding-left:0;"><a href="http://www.crystalspace3d.org/"><img src="csblur.png" width="236" height="59" alt="CrystalSpace" border="0"></a></td> <td class="head"><h2>Public API Reference</h2></td> </tr> <tr height="11"> <td colspan="2" class="headshadow" valign="top" style="padding-left:0;"><img src="csblurb.png" width="236" height="11" alt="" border="0"></td> </tr> </table> <div class="content"> <!-- Generated by Doxygen 1.5.3 --> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="classes.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> </ul> </div> <h1>cstool/tokenlist.h File Reference</h1>Token list helper macros. <a href="#_details">More...</a> <p> <code>#include <CS_TOKEN_ITEM_FILE></code><br> <p> <a href="tokenlist_8h-source.html">Go to the source code of this file.</a><table border="0" cellpadding="0" cellspacing="0"> <tr><td></td></tr> <tr><td colspan="2"><br><h2>Token list helper macros</h2></td></tr> <tr><td colspan="2">The macros here provide an easy way to automatically build a token list useful for e.g.<p> parsers. The list of tokens have to be declared in an external file, with each token the argument to a '<a class="el" href="shaderprogram_8h.html#9541699c44bf57b577cb08459670f72e">CS_TOKEN_LIST_TOKEN()</a>' invocation. 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 initialize the token table can be set via <a class="el" href="group__util.html#gefa1013fce216adfcd909ad4d32e8a29" title="Name of the token table initialization method.">CS_INIT_TOKEN_TABLE_NAME</a>; the default is 'InitTokenTable'. In addition to invoking the initialization function to populate the string hash, an enumeration is also created. Elements of the enumeration are named XMLTOKEN_FOO (where 'FOO' represents the argument to <a class="el" href="shaderprogram_8h.html#9541699c44bf57b577cb08459670f72e">CS_TOKEN_LIST_TOKEN()</a>). If you prefer a prefix other than 'XMLTOKEN_', define <a class="el" href="group__util.html#g0f2ffdc7e3f54d850a1bed0e78235d62" title="Prefix for the generated enumeration value.">CS_TOKEN_LIST_TOKEN_PREFIX</a> with the prefix of your choice. As a convenience, in addition to entries for each <a class="el" href="group__util.html#g340f3d6933db2951eaf1eebe704a81c8" title="A token list entry.">CS_TOKEN_LIST_TOKEN</a> invocation, a final item is added to the enumeration with the name provided by <a class="el" href="group__util.html#g766e6c4bb4775a5ed1eb2cce10a3a968" title="Name for the "token count" enumeration value.">CS_TOKEN_LIST_TOKEN_LAST</a>. If you do not #define this macro, then the name XMLTOKEN_TOKEN_COUNT is given to the last item in the enumeration. This value will equate to the count of items in the enumeration (not including this automatically added item).<p> Note that the client defines CS_TOKEN_ITEM_FILE, <a class="el" href="group__util.html#gefa1013fce216adfcd909ad4d32e8a29" title="Name of the token table initialization method.">CS_INIT_TOKEN_TABLE_NAME</a>, <a class="el" href="group__util.html#g0f2ffdc7e3f54d850a1bed0e78235d62" title="Prefix for the generated enumeration value.">CS_TOKEN_LIST_TOKEN_PREFIX</a>, and <a class="el" href="group__util.html#g766e6c4bb4775a5ed1eb2cce10a3a968" title="Name for the "token count" enumeration value.">CS_TOKEN_LIST_TOKEN_LAST</a>, and they will not be undefined by this file; hence, if you want to build multiple token lists, you may redefine those macros and include <<a class="el" href="tokenlist_8h.html" title="Token list helper macros.">cstool/tokenlist.h</a>> again.<p> The code generated by the macros has a dependency on <a class="el" href="classcsString.html" title="Thin wrapper around csStringFast<> with its default buffer size.">csString</a>, thus the <<a class="el" href="csstring_8h.html" title="String utility class.">csutil/csstring.h</a>> header must be included in files that use the token list helpers.<p> Example (from a real-world use): fire.tok: <div class="fragment"><pre class="fragment"> <a class="code" href="shaderprogram_8h.html#9541699c44bf57b577cb08459670f72e">CS_TOKEN_LIST_TOKEN</a>(PALETTE) ... </pre></div><p> fire.h: <div class="fragment"><pre class="fragment"><span class="preprocessor"> #include <<a class="code" href="csstring_8h.html" title="String utility class.">csutil/csstring.h</a>></span> <span class="keyword">class </span>csFireLoader { <a class="code" href="classcsStringHash.html" title="A string-to-ID hash table.">csStringHash</a> tokens; <span class="preprocessor"> #define CS_TOKEN_ITEM_FILE "plugins/proctex/standard/fire.tok"</span> <span class="preprocessor"></span><span class="preprocessor"> #include "<a class="code" href="tokenlist_8h.html" title="Token list helper macros.">cstool/tokenlist.h</a>"</span> ... }; </pre></div><p> fire.cpp: <div class="fragment"><pre class="fragment"> csFireLoader::csFireLoader(<a class="code" href="structiBase.html" title="This is the basic interface: all other interfaces should be derived from this one...">iBase</a> *p) { InitTokenTable (tokens); <span class="comment">// ...</span> } <a class="code" href="classcsPtr.html" title="A pointer encapsulator.">csPtr<iBase></a> csFireLoader::Parse (<a class="code" href="structiDocumentNode.html" title="Representation of a node in a document.">iDocumentNode</a>* node, <a class="code" href="structiLoaderContext.html" title="This interface gives the context for the loader.">iLoaderContext</a>* ldr_context, <a class="code" href="structiBase.html" title="This is the basic interface: all other interfaces should be derived from this one...">iBase</a>* context) { <span class="comment">// ...</span> <a class="code" href="group__util.html#gbe4f44c93bfeee85c507a999dccf21dd" title="An identifier for a string.">csStringID</a> <span class="keywordtype">id</span> = tokens.Request (child->GetValue ()); <span class="keywordflow">switch</span> (<span class="keywordtype">id</span>) { <span class="keywordflow">case</span> XMLTOKEN_PALETTE: <span class="comment">// ...</span> <span class="keywordflow">break</span>; } <span class="comment">// ...</span> } </pre></div> <br><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__util.html#g997d7681d14447f53b90d413ddd24763">CS_INIT_TOKEN_TABLE_NAME</a> InitTokenTable</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Name of the token table initialization method. <a href="group__util.html#g997d7681d14447f53b90d413ddd24763"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__util.html#gde6cf86db0aca82244ca4a269ff4f34e">CS_INIT_TOKEN_TABLE_NAME_DEFAULT</a></td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Name of the token table initialization method. <a href="group__util.html#gde6cf86db0aca82244ca4a269ff4f34e"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__util.html#g7e911f2c2d1e7ab00c006b89946849f7">CS_TOKEN_LIST_PASTE</a>(X, Y) CS_TOKEN_LIST_PASTE1(X,Y)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Name of the token table initialization method. <a href="group__util.html#g7e911f2c2d1e7ab00c006b89946849f7"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__util.html#g6a9d9631d2d1ef3c41cf390eee7f48c7">CS_TOKEN_LIST_PASTE1</a>(X, Y) X ## Y</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Name of the token table initialization method. <a href="group__util.html#g6a9d9631d2d1ef3c41cf390eee7f48c7"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__util.html#g340f3d6933db2951eaf1eebe704a81c8">CS_TOKEN_LIST_TOKEN</a>(X)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">A token list entry. <a href="group__util.html#g340f3d6933db2951eaf1eebe704a81c8"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__util.html#g340f3d6933db2951eaf1eebe704a81c8">CS_TOKEN_LIST_TOKEN</a>(X) CS_TOKEN_LIST_PASTE(CS_TOKEN_LIST_TOKEN_PREFIX,X),</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">A token list entry. <a href="group__util.html#g340f3d6933db2951eaf1eebe704a81c8"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__util.html#g0f9fa2abfaa7c80c98fa47a4694f93d0">CS_TOKEN_LIST_TOKEN_FINAL</a>(X) CS_TOKEN_LIST_PASTE(CS_TOKEN_LIST_TOKEN_PREFIX,X)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Name of the token table initialization method. <a href="group__util.html#g0f9fa2abfaa7c80c98fa47a4694f93d0"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__util.html#g766e6c4bb4775a5ed1eb2cce10a3a968">CS_TOKEN_LIST_TOKEN_LAST</a> TOKEN_COUNT</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Name for the "token count" enumeration value. <a href="group__util.html#g766e6c4bb4775a5ed1eb2cce10a3a968"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__util.html#gde9f10d4f1887ff30f41f7d5f93d750a">CS_TOKEN_LIST_TOKEN_LAST_DEFAULT</a></td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Name of the token table initialization method. <a href="group__util.html#gde9f10d4f1887ff30f41f7d5f93d750a"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__util.html#g0f2ffdc7e3f54d850a1bed0e78235d62">CS_TOKEN_LIST_TOKEN_PREFIX</a> XMLTOKEN_</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Prefix for the generated enumeration value. <a href="group__util.html#g0f2ffdc7e3f54d850a1bed0e78235d62"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__util.html#gaecc28f8e85d5e6865a691f862409d24">CS_TOKEN_LIST_TOKEN_PREFIX_DEFAULT</a></td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Name of the token table initialization method. <a href="group__util.html#gaecc28f8e85d5e6865a691f862409d24"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">enum </td><td class="memItemRight" valign="bottom"></td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Name of the token table initialization method. <a href="group__util.html#g16685eea158879e41b101ca3634de462">More...</a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">static void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__util.html#gefa1013fce216adfcd909ad4d32e8a29">CS_INIT_TOKEN_TABLE_NAME</a> (<a class="el" href="classcsStringHash.html">csStringHash</a> &t)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Name of the token table initialization method. <a href="group__util.html#gefa1013fce216adfcd909ad4d32e8a29"></a><br></td></tr> </table> <hr><a name="_details"></a><h2>Detailed Description</h2> Token list helper macros. <p> <p>Definition in file <a class="el" href="tokenlist_8h-source.html">tokenlist.h</a>.</p> <hr size="1"><address><small>Generated for Crystal Space 1.2.1 by <a href="http://www.doxygen.org/index.html">doxygen</a> 1.5.3 </small></address> </div></body> </html>