summaryrefslogtreecommitdiffabout
path: root/htdocs/quickref/metasyntax.chtml
blob: a63f596ef70b4a56555480e16ff9611955b609c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
% html(); return; /* vim:set ft=sitecing: */
%%derive layout = "/ancestry/layout.chtml";
<%constructor>
 PN_PREV("/quickref/","quick reference","quick reference");
 PN_NEXT("/sources","sources","source browser");
</%constructor>
<%codemethod string title() %>
 return "meta syntax quick reference";
</%codemethod>
<%method void content() %>
 <h1>site-C-ing meta syntax quick reference</h1>

 <h2>Table of Contents</h2>

 <ul class="quickref toc">
  <li><a href="#qr__line">% ...</a></li>
  <li><a href="#qr__inline">&lt;% ... %&gt;</a></li>
  <li><a href="#qr__code">&lt;%code&gt;</a></li>
  <li><a href="#qr__codemethod">&lt;%codemethod ... &gt;</a></li>
  <li><a href="#qr__constructor">&lt;%constructor&gt;</a></li>
  <li><a href="#qr__decl">&lt;%decl&gt;</a></li>
  <li><a href="#qr___decl">%%decl</a></li>
  <li><a href="#qr___derive">%%derive</a></li>
  <li><a href="#qr__destructor">&lt;%destructor&gt;</a></li>
  <li><a href="#qr__impl">&lt;%impl&gt;</a></li>
  <li><a href="#qr___impl">%%impl</a></li>
  <li><a href="#qr__method">&lt;%method ... &gt;</a></li>
  <li><a href="#qr__output">&lt;%output&gt;</a></li>
  <li><a href="#qr___pragma">%%pragma</a></li>
  <li><a href="#qr___var">%%var</a></li>
 </ul>

 <dl class="metasyntax quickref">

% /* % */
  <dt>
   <a id="qr__line" name="qr__line" title="line of code">
    <code>% <kbd>line of code</kbd></code>
   </a>
  </dt>
  <dd>
   <p>
    Break out into the code mode for just one line.
   </p>
   <blockquote class="qr_sample">
    &nbsp;&lt;body&gt;<br/>
    <em><a href="#qr__line" title="% description">%</a> for(int t=0;t&lt;10;t++) {<br/></em>
    &nbsp;&nbsp;&nbsp;Here is the way we count.&lt;br/&gt;<br/>
    &nbsp;&nbsp;&nbsp;Just saying out loud: <a href="#qr__inline" title="&lt;% ... %&gt; description">&lt;%</a> t <a href="#qr__inline" title="&lt;% ... %&gt; description">%&gt;</a>&lt;br/&gt;<br/>
    <em><a href="#qr__line" title="% description">%</a> }<br/></em>
    &nbsp;&lt;/body&gt;
   </blockquote>
  </dd>

% /* <% %> */
  <dt>
   <a id="qr__inline" name="qr__inline" title="output expression">
    <code>&lt;% <kbd>expression</kbd> %&gt;</code>
   </a>
  </dt>
  <dd>
   <p>
    &lt;&lt; <kbd>expression</kbd> into output stream (think c++).
   </p>
   <blockquote class="qr_sample">
    <a href="#qr__line" title="% description">%</a> for(int t=0;t&lt;10;t++) {<br/>
    &nbsp;&nbsp;&nbsp;Here is the way we count.&lt;br/&gt;<br/>
    <em>&nbsp;&nbsp;&nbsp;Just saying out loud: <a href="#qr__inline" title="&lt;% ... %&gt; description">&lt;%</a> t <a href="#qr__inline" title="&lt;% ... %&gt; description">%&gt;</a>&lt;br/&gt;<br/></em>
    <a href="#qr__line" title="% description">%</a> }
   </blockquote>
  </dd>

% /* %code */
  <dt>
   <a id="qr__code" name="qr__code" title="switching to code mode">
    <code>
     &lt;%code&gt; <kbd>...</kbd> &lt;/%code&gt;
    </code>
   </a>
  </dt>
  <dd>
    Escape from the output mode to code mode. Opposite to <code><a href="#qr__output" title="&lt;%output&gt; description">&lt;%output&gt;</a></code>. Roughly the same as <code><a href="#qr__output" title="&lt;%output&gt; description">&lt;/%output&gt;</a> <kbd>...</kbd> <a href="#qr__output" title="&lt;%output&gt; description">&lt;%output&gt;</a></code> (note the reverse order), but more self-explanatory and applies to more cases.
   </p>
   <blockquote class="qr_sample">
    &lt;body&gt;<br/>
    <em>&nbsp;<a href="#qr__code" title="&lt;%code&gt; descrption">&lt;%code&gt;</a><br/></em>
    &nbsp;&nbsp;for(int t=0;t&lt;10;t++) {<br/>
    &nbsp;&nbsp;&nbsp;<a href="#qr__output" title="&lt;%output&gt; descrption">&lt;%output&gt;</a><br/>
    &nbsp;&nbsp;&nbsp;&nbsp;Here is the way we count.&lt;br/&gt;<br/>
    &nbsp;&nbsp;&nbsp;&nbsp;Just saying out loud: <a href="#qr__inline" title="&lt;% ... %&gt; description">&lt;%</a> t <a href="#qr__inline" title="&lt;% ... %&gt; description">%&gt;</a>&lt;br/&gt;<br/>
    &nbsp;&nbsp;&nbsp;<a href="#qr__output" title="&lt;%output&gt; descrption">&lt;/%output&gt;</a><br/>
    <em>&nbsp;<a href="#qr__code" title="&lt;%code&gt; descrption">&lt;/%code&gt;</a><br/></em>
    &lt;/body&gt;
   </blockquote>
  </dd>

% /* %codemethod */
  <dt>
   <a id="qr__codemethod" name="qr__codemethod" title="member function definition">
    <code>
     &lt;%codemethod <kbd>return_type_t</kbd> <kbd>member_name</kbd>(<kbd>args,...</kbd>) %&gt;<br/>
     &nbsp;<kbd>code</kbd><br/>
     &lt;/%codemethod&gt;
    </code>
   </a>
  </dt>
  <dd>
   <p>
    Define the member function. Essentially equivalent to <code><a href="#qr__method" title="&lt;%method ... %&gt; description" class="internal">&lt;%method</a> <kbd>...</kbd> <a href="#qr__method" title="&lt;%method ... %&gt; description" class="internal">%&gt;</a><a href="#qr__code" title="&lt;%code&gt; description" class="internal">&lt;%code&gt;</a> <kbd>...</kbd> <a href="#qr__code" title="&lt;%code&gt; description" class="internal">&lt;/%code&gt;</a><a href="#qr__method" title="&lt;%method ... %&gt; description" class="internal">&lt;/%method&gt;</a></code>.
   </p>
   <blockquote class="qr_sample">
    <em><a href="#qr__codemethod" title="&lt;%codemethod ... %&gt; description">&lt;%codemethod</a> std::string ua() <a href="#qr__codemethod" title="&lt;%codemethod ... %&gt; description">%&gt;</a><br/>
    &nbsp;return __CGI-&gt;get_meta("USER_AGENT");<br/>
    <a href="#qr__codemethod" title="&lt;%codemethod ... %&gt; description">&lt;/%codemethod&gt;</a><br/></em>
    The user agent is: <a href="#qr__inline" title="&lt;% ... %&gt; description">&lt;%</a> ua() <a href="#qr__inline" title="&lt;% ... %&gt; description">%&gt;</a><br/>
   </blockquote>
  </dd>

% /* %constructor */
  <dt>
   <a id="qr__constructor" name="qr__constructor" title="constructor code">
    <code>
     &lt;%constructor&gt;<br/>
     &nbsp;<kbd>code</kbd><br/>
     &lt;/%constructor&gt;
    </code>
   </a>
  </dt>
  <dd>
   <p>
    Provide the code for constructor.
   </p>
   <blockquote class="qr_sample">
    <a href="#qr___var" title="%%var description">%%var</a> bool is_msie;<br/>
    <em><a href="#qr__constructor" title="&lt;%constructor&gt; description">&lt;%constructor&gt;</a><br/>
    &nbsp;is_msie = (__CGI-&gt;get_meta("USER_AGENT").find("MSIE")!=string::npos);<br/>
    <a href="#qr__constructor" title="&lt;%constructor&gt; description">&lt;/%constructor&gt;</a><br/></em>
   </blockquote>
  </dd>

% /* %decl / %%decl */
  <dt>
   <a id="qr___decl" name="qr___decl" title="verbatim declaration">
    <code>%%decl <kbd>line of code</kbd></code>
   </a>
  </dt>
  <dt>
   <a id="qr__decl" name="qr__decl" title="verbatim declaration">
    <code>
     &lt;%decl&gt;<br/>
     &nbsp;<kbd>lines of code</kbd><br/>
     &lt;/%decl&gt;
    </code>
   </a>
  </dt>
  <dd>
   <p>
    Put the line(s) of code into the resulting <em>.h</em> file before the
    class declaration.
   </p>
   <blockquote class="qr_sample">
    <em><a href="#qr___decl" title="%%decl description">%%decl</a> #include &lt;string&gt;<br/></em>
    <a href="#qr___var" title="%%var description">%%var</a> std::string str = "default"<br/>
    <em><a href="#qr__decl" title="&lt;%decl&gt; description">&lt;%decl&gt;</a><br/>
    &nbsp;typedef int integer_t;<br/>
    <a href="#qr__decl" title="&lt;%decl&gt; description">&lt;/%decl&gt;</a><br/></em>
    <a href="#qr__method" title="&lt;%method ... %&gt; description">&lt;%method</a> void do_nothing(integer_t input) <a href="#qr__method" title="&lt;%method ... %&gt; description">%&gt;</a><br/>
    &nbsp;nothing is done<br/>
    <a href="#qr__method" title="&lt;%method ... %&gt; description">&lt;/%method&gt;</a>
   </blockquote>
  </dd>

% /* %%derive */
  <dt>
   <a id="qr___derive" name="qr___derive" title="base class(es) specification">
    <code>%%derive <kbd>name</kbd> = "<kbd>base-component</kbd>";</code>
   </a>
  </dt>
  <dd>
   <p>
    Inherit what is there to be inherited from the base component specified.
   </p>
   <blockquote class="qr_sample">
    <em><a href="#qr___derive" title="%%derive description">%%derive</a> pagelayout = "/ancestry/page_layout.chtml";<br/></em>
    <a href="#qr__line" title="% description">%</a> pagelayout::member_function();
   </blockquote>
  </dd>

% /* %destructor */
  <dt>
   <a id="qr__destructor" name="qr__destructor" title="destructor code">
    <code>
     &lt;%destructor&gt;<br/>
     &nbsp;<kbd>code</kbd><br/>
     &lt;/%destructor&gt;
    </code>
   </a>
  </dt>
  <dd>
   <p>
    Provide the code for destructor.
   </p>
   <blockquote class="qr_sample">
    <a href="#qr___var" title="%%var description">%%var</a> type_t *tmp = 0;<br/>
    <a href="#qr__constructor" title="&lt;%constructor&gt; description">&lt;%constructor&gt;</a><br/>
    &nbsp;tmp = new type_t(type_t::option_1);<br/>
    <a href="#qr__constructor" title="&lt;%constructor&gt; description">&lt;/%constructor&gt;</a><br/>
    <em><a href="#qr__destructor" title="&lt;%destructor&gt; description">&lt;%destructor&gt;</a><br/>
    &nbsp;delete tmp;<br/>
    <a href="#qr__destructor" title="&lt;%destructor&gt; description">&lt;/%destructor&gt;</a><br/></em>
   </blockquote>
  </dd>

% /* %impl / %%impl */
  <dt>
   <a id="qr___impl" name="qr__impl" title="verbatim definition">
    <code>%%impl <kbd>line of code</kbd></code>
   </a>
  </dt>
  <dt>
   <a id="qr__impl" name="qr__impl" title="verbatim definition">
    <code>
     &lt;%impl&gt;<br/>
     &nbsp;<kbd>lines of code</kbd><br/>
     &lt;/%impl&gt;
    </code>
   </a>
  </dt>
  <dd>
   <p>
    Put the line(s) of code into the resulting <em>.cc</em> implementation file
    before any members definitions.
   </p>
   <blockquote class="qr_sample">
    <em><a href"#qr___impl" title="%%impl description">%%impl</a> #include &lt;string.h&gt;<br/></em>
    <a href="#qr__method" title="&lt;%method ... %gt; description">&lt;%method</a> void output_if_contains(const char *haystack,const char *needle) <a href="#qr__method" title="&lt;%method ... %gt; description">%&gt;</a><br/>
    <a href="#qr__line" title="% description">%</a> if(strstr(haystack,needle)) {<br/>
    &nbsp;&nbsp;&nbsp;<a href="#qr__inline" title="&lt;% ... %&gt; description">&lt;%</a> haystack <a href="#qr__inline" title="&lt;% ... %&gt; description">%&gt;</a><br/>
    <a href="#qr__line" title="% description">%</a> }<br/>
    <a href="#qr__method" title="&lt;%method ... %&gt; description">&lt;/%method&gt;</a><br/>
    <em><a href="#qr__impl" title="&lt;%impl&gt; description">&lt;%impl&gt;</a><br/>
    &nbsp;#include &lt;konforka/exception.h&gt;
    &nbsp;static const char *tokens[] = {<br/>
    &nbsp;&nbsp;"token 1", "token 2", "token 3"<br/>
    &nbsp;};<br/>
    <a href="#qr__impl" title="&lt;%impl&gt; description">&lt;/%impl&gt;</a><br/></em>
    <a href="#qr__method" title="&lt;%method ... %gt; description">&lt;%method</a> void output_token(int toknum) <a href="#qr__method" title="&lt;%method ... %gt; description">%&gt;</a><br/>
    &nbsp;<a href="#qr__code" title="&lt;%code&gt; description">&lt;%code&gt;</a><br/>
    &nbsp;&nbsp;if(toknum&lt;0 || toknum&gt;=(sizeof(tokens)/sizeof(*tokens)))<br/>
    &nbsp;&nbsp;&nbsp;throw konforka::exception(CODEPOINT,"out of bounds");<br/>
    &nbsp;<a href="#qr__code" title="&lt;%code&gt; description">&lt;/%code&gt;</a><br/>
    &nbsp;<a href="#qr__inline" title="&lt;% ... %&gt; description">&lt;%</a> tokens[toknum] <a href="#qr__inline" title="&lt;% ... %&gt; description">%&gt;</a><br/>
    <a href="#qr__method" title="&lt;%method ... %&gt; description">&lt;/%method&gt;</a><br/>
   </blockquote>
  </dd>

% /* %method */
  <dt>
   <a id="qr__method" name="qr__method" title="member function definition">
    <code>
     &lt;%method <kbd>return_type_t</kbd> <kbd>member_name</kbd>(<kbd>args,...</kbd>) %&gt;<br/>
     &nbsp;<kbd>code</kbd><br/>
     &lt;/%method&gt;
    </code>
   </a>
  </dt>
  <dd>
   <p>
    Define the member function. Essentially equivalent to <code><a href="#qr__codemethod" title="&lt;%codemethod ... %&gt; description" class="internal">&lt;%codemethod</a> <kbd>...</kbd> <a href="#qr__codemethod" title="&lt;%codemethod ... %&gt; description" class="internal">%&gt;</a><a href="#qr__output" title="&lt;%output&gt; description" class="internal">&lt;%output&gt;</a> <kbd>...</kbd> <a href="#qr__output" title="&lt;%output&gt; description" class="internal">&lt;/%output&gt;</a><a href="#qr__codemethod" title="&lt;%codemethod ... %&gt; description" class="internal">&lt;/%codemethod&gt;</a></code>.
   </p>
   <blockquote class="qr_sample">
    <em><a href="#qr__method" title="&lt;%method ... %&gt; description">&lt;%method</a> void emphasized(const char *t) <a href="#qr__method" title="&lt;%method ... %&gt; description">%&gt;</a><br/>
    &nbsp;&lt;em&gt;<a href="#qr__inline" title="&lt;% ... %&gt; description">&lt;%</a> t <a href="#qr__inline" title="&lt;% ... %&gt; description">%&gt;</a>&lt;/em&gt;<br/>
    <a href="#qr__codemethod" title="&lt;%codemethod ... %&gt; description">&lt;/%method&gt;</a><br/></em>
    <a href="#qr__line" title="% description">%</a> emphasized("emphasized text");
   </blockquote>
  </dd>

% /* %output */
  <dt>
   <a id="qr__output" name="qr__output" title="switching to output mode">
    <code>
     &lt;%output&gt; <kbd>...</kbd> &lt;/%output&gt;
    </code>
   </a>
  </dt>
  <dd>
   <p>
    Escape from the code mode to output mode. Opposite to <code><a href="#qr__code" title="&lt;%code&gt; description">&lt;%code&gt;</a></code>. Roughly the same as <code><a href="#qr__code" title="&lt;%code&gt; description">&lt;/%code&gt;</a> <kbd>...</kbd> <a href="#qr__code" title="&lt;%code&gt; description">&lt;%code&gt;</a></code> (note the reverse order), but more self-explanatory and applies to more cases.
   </p>
   <blockquote class="qr_sample">
    <a href="#qr__codemethod" title="&lt;%codemethod ... %&gt; description">&lt;%codemethod</a> void count() <a href="#qr__codemethod" title="&lt;%codemethod ... &gt; description">%&gt;</a><br/>
    &nbsp;for(int t=0;t&lt;10;t++) {<br/>
    <em>&nbsp;&nbsp;<a href="#qr__output" title="&lt;%output&gt; descrption">&lt;%output&gt;</a><br/>
    &nbsp;&nbsp;&nbsp;Here is the way we count.&lt;br/&gt;<br/>
    &nbsp;&nbsp;&nbsp;Just saying out loud: <a href="#qr__inline" title="&lt;% ... %&gt; description">&lt;%</a> t <a href="#qr__inline" title="&lt;% ... %&gt; description">%&gt;</a>&lt;br/&gt;<br/>
    &nbsp;&nbsp;<a href="#qr__output" title="&lt;%output&gt; descrption">&lt;/%output&gt;</a><br/></em>
    <a href="#qr__codemethod" title="&lt;/%codemethod ... %&gt; description">&lt;/%codemethod&gt;</a><br/>
    <a href="#qr__line" title="% description">%</a> count();
   </blockquote>
  </dd>

% /* %%pragma */
  <dt>
   <a id="qr___pragma" name="qr___pragma" title="pragma">
    <code>
     %%pragma <kbd>pragma_name</kbd><br/>
     %%pragma <kbd>pragma_name</kbd>=<kbd>pragma_value</kbd>
    </code>
   </a>
  </dt>
  <dd>
   <p>provide pseudo instructions to the preprocessor. At this time only pragma
   named <code>main</code> is defined, which instructs preprocessor to discard
   the 'main' member that would be generated for the component and call the
   <code>main</code> member of the named base class.</p>
   <blockquote class="qr_sample">
    <a href="#qr___derive" title="%%derive description">%%derive</a> pagelayout = "/ancestry/page_layout.chtml";<br/>
    <em><a href="#qr___pragma" title="%%pragma description">%%pragma</a> main=pagelayout</em>
   </blockquote>
  </dd>

% /* %%var */
  <dt>
   <a id="qr___var" name="qr___var" title="member variable declaration">
    <code>%%var <kbd>type_t</kbd> <kbd>varname</kbd>;<br/>
    <code>%%var <kbd>type_t</kbd> <kbd>varname</kbd> = <kbd>initalizer</kbd>;<br/>
   </a>
  </dt>
  <dd>
   <p>
    Define the member variable with optional default value (suitable for
    putting into the <code>: <kbd>varname</kbd>(<kbd>initializer</kbd>)</code>
    part of the c++ constructor.
   </p>
   <blockquote class="qr_sample">
    <em><a href="#qr___var" title="%%var description">%%var</a> std::string strval = "default value";<br/>
    <a href="#qr___var" title="%%var description">%%var</a> int usecount = 0;<br/>
    <a href="#qr___var" title="%%var description">%%var</a> int whatnot;</em>
   </blockquote>
  </dd>

 </dl>
</%method>