Diffstat (limited to 'htdocs/quickref/metasyntax.chtml') (more/less context) (ignore whitespace changes)
-rw-r--r-- | htdocs/quickref/metasyntax.chtml | 344 |
1 files changed, 344 insertions, 0 deletions
diff --git a/htdocs/quickref/metasyntax.chtml b/htdocs/quickref/metasyntax.chtml new file mode 100644 index 0000000..a63f596 --- a/dev/null +++ b/htdocs/quickref/metasyntax.chtml @@ -0,0 +1,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"><% ... %></a></li> + <li><a href="#qr__code"><%code></a></li> + <li><a href="#qr__codemethod"><%codemethod ... ></a></li> + <li><a href="#qr__constructor"><%constructor></a></li> + <li><a href="#qr__decl"><%decl></a></li> + <li><a href="#qr___decl">%%decl</a></li> + <li><a href="#qr___derive">%%derive</a></li> + <li><a href="#qr__destructor"><%destructor></a></li> + <li><a href="#qr__impl"><%impl></a></li> + <li><a href="#qr___impl">%%impl</a></li> + <li><a href="#qr__method"><%method ... ></a></li> + <li><a href="#qr__output"><%output></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"> + <body><br/> + <em><a href="#qr__line" title="% description">%</a> for(int t=0;t<10;t++) {<br/></em> + Here is the way we count.<br/><br/> + Just saying out loud: <a href="#qr__inline" title="<% ... %> description"><%</a> t <a href="#qr__inline" title="<% ... %> description">%></a><br/><br/> + <em><a href="#qr__line" title="% description">%</a> }<br/></em> + </body> + </blockquote> + </dd> + +% /* <% %> */ + <dt> + <a id="qr__inline" name="qr__inline" title="output expression"> + <code><% <kbd>expression</kbd> %></code> + </a> + </dt> + <dd> + <p> + << <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<10;t++) {<br/> + Here is the way we count.<br/><br/> + <em> Just saying out loud: <a href="#qr__inline" title="<% ... %> description"><%</a> t <a href="#qr__inline" title="<% ... %> description">%></a><br/><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> + <%code> <kbd>...</kbd> </%code> + </code> + </a> + </dt> + <dd> + Escape from the output mode to code mode. Opposite to <code><a href="#qr__output" title="<%output> description"><%output></a></code>. Roughly the same as <code><a href="#qr__output" title="<%output> description"></%output></a> <kbd>...</kbd> <a href="#qr__output" title="<%output> description"><%output></a></code> (note the reverse order), but more self-explanatory and applies to more cases. + </p> + <blockquote class="qr_sample"> + <body><br/> + <em> <a href="#qr__code" title="<%code> descrption"><%code></a><br/></em> + for(int t=0;t<10;t++) {<br/> + <a href="#qr__output" title="<%output> descrption"><%output></a><br/> + Here is the way we count.<br/><br/> + Just saying out loud: <a href="#qr__inline" title="<% ... %> description"><%</a> t <a href="#qr__inline" title="<% ... %> description">%></a><br/><br/> + <a href="#qr__output" title="<%output> descrption"></%output></a><br/> + <em> <a href="#qr__code" title="<%code> descrption"></%code></a><br/></em> + </body> + </blockquote> + </dd> + +% /* %codemethod */ + <dt> + <a id="qr__codemethod" name="qr__codemethod" title="member function definition"> + <code> + <%codemethod <kbd>return_type_t</kbd> <kbd>member_name</kbd>(<kbd>args,...</kbd>) %><br/> + <kbd>code</kbd><br/> + </%codemethod> + </code> + </a> + </dt> + <dd> + <p> + Define the member function. Essentially equivalent to <code><a href="#qr__method" title="<%method ... %> description" class="internal"><%method</a> <kbd>...</kbd> <a href="#qr__method" title="<%method ... %> description" class="internal">%></a><a href="#qr__code" title="<%code> description" class="internal"><%code></a> <kbd>...</kbd> <a href="#qr__code" title="<%code> description" class="internal"></%code></a><a href="#qr__method" title="<%method ... %> description" class="internal"></%method></a></code>. + </p> + <blockquote class="qr_sample"> + <em><a href="#qr__codemethod" title="<%codemethod ... %> description"><%codemethod</a> std::string ua() <a href="#qr__codemethod" title="<%codemethod ... %> description">%></a><br/> + return __CGI->get_meta("USER_AGENT");<br/> + <a href="#qr__codemethod" title="<%codemethod ... %> description"></%codemethod></a><br/></em> + The user agent is: <a href="#qr__inline" title="<% ... %> description"><%</a> ua() <a href="#qr__inline" title="<% ... %> description">%></a><br/> + </blockquote> + </dd> + +% /* %constructor */ + <dt> + <a id="qr__constructor" name="qr__constructor" title="constructor code"> + <code> + <%constructor><br/> + <kbd>code</kbd><br/> + </%constructor> + </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="<%constructor> description"><%constructor></a><br/> + is_msie = (__CGI->get_meta("USER_AGENT").find("MSIE")!=string::npos);<br/> + <a href="#qr__constructor" title="<%constructor> description"></%constructor></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> + <%decl><br/> + <kbd>lines of code</kbd><br/> + </%decl> + </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 <string><br/></em> + <a href="#qr___var" title="%%var description">%%var</a> std::string str = "default"<br/> + <em><a href="#qr__decl" title="<%decl> description"><%decl></a><br/> + typedef int integer_t;<br/> + <a href="#qr__decl" title="<%decl> description"></%decl></a><br/></em> + <a href="#qr__method" title="<%method ... %> description"><%method</a> void do_nothing(integer_t input) <a href="#qr__method" title="<%method ... %> description">%></a><br/> + nothing is done<br/> + <a href="#qr__method" title="<%method ... %> description"></%method></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> + <%destructor><br/> + <kbd>code</kbd><br/> + </%destructor> + </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="<%constructor> description"><%constructor></a><br/> + tmp = new type_t(type_t::option_1);<br/> + <a href="#qr__constructor" title="<%constructor> description"></%constructor></a><br/> + <em><a href="#qr__destructor" title="<%destructor> description"><%destructor></a><br/> + delete tmp;<br/> + <a href="#qr__destructor" title="<%destructor> description"></%destructor></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> + <%impl><br/> + <kbd>lines of code</kbd><br/> + </%impl> + </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 <string.h><br/></em> + <a href="#qr__method" title="<%method ... %gt; description"><%method</a> void output_if_contains(const char *haystack,const char *needle) <a href="#qr__method" title="<%method ... %gt; description">%></a><br/> + <a href="#qr__line" title="% description">%</a> if(strstr(haystack,needle)) {<br/> + <a href="#qr__inline" title="<% ... %> description"><%</a> haystack <a href="#qr__inline" title="<% ... %> description">%></a><br/> + <a href="#qr__line" title="% description">%</a> }<br/> + <a href="#qr__method" title="<%method ... %> description"></%method></a><br/> + <em><a href="#qr__impl" title="<%impl> description"><%impl></a><br/> + #include <konforka/exception.h> + static const char *tokens[] = {<br/> + "token 1", "token 2", "token 3"<br/> + };<br/> + <a href="#qr__impl" title="<%impl> description"></%impl></a><br/></em> + <a href="#qr__method" title="<%method ... %gt; description"><%method</a> void output_token(int toknum) <a href="#qr__method" title="<%method ... %gt; description">%></a><br/> + <a href="#qr__code" title="<%code> description"><%code></a><br/> + if(toknum<0 || toknum>=(sizeof(tokens)/sizeof(*tokens)))<br/> + throw konforka::exception(CODEPOINT,"out of bounds");<br/> + <a href="#qr__code" title="<%code> description"></%code></a><br/> + <a href="#qr__inline" title="<% ... %> description"><%</a> tokens[toknum] <a href="#qr__inline" title="<% ... %> description">%></a><br/> + <a href="#qr__method" title="<%method ... %> description"></%method></a><br/> + </blockquote> + </dd> + +% /* %method */ + <dt> + <a id="qr__method" name="qr__method" title="member function definition"> + <code> + <%method <kbd>return_type_t</kbd> <kbd>member_name</kbd>(<kbd>args,...</kbd>) %><br/> + <kbd>code</kbd><br/> + </%method> + </code> + </a> + </dt> + <dd> + <p> + Define the member function. Essentially equivalent to <code><a href="#qr__codemethod" title="<%codemethod ... %> description" class="internal"><%codemethod</a> <kbd>...</kbd> <a href="#qr__codemethod" title="<%codemethod ... %> description" class="internal">%></a><a href="#qr__output" title="<%output> description" class="internal"><%output></a> <kbd>...</kbd> <a href="#qr__output" title="<%output> description" class="internal"></%output></a><a href="#qr__codemethod" title="<%codemethod ... %> description" class="internal"></%codemethod></a></code>. + </p> + <blockquote class="qr_sample"> + <em><a href="#qr__method" title="<%method ... %> description"><%method</a> void emphasized(const char *t) <a href="#qr__method" title="<%method ... %> description">%></a><br/> + <em><a href="#qr__inline" title="<% ... %> description"><%</a> t <a href="#qr__inline" title="<% ... %> description">%></a></em><br/> + <a href="#qr__codemethod" title="<%codemethod ... %> description"></%method></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> + <%output> <kbd>...</kbd> </%output> + </code> + </a> + </dt> + <dd> + <p> + Escape from the code mode to output mode. Opposite to <code><a href="#qr__code" title="<%code> description"><%code></a></code>. Roughly the same as <code><a href="#qr__code" title="<%code> description"></%code></a> <kbd>...</kbd> <a href="#qr__code" title="<%code> description"><%code></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="<%codemethod ... %> description"><%codemethod</a> void count() <a href="#qr__codemethod" title="<%codemethod ... > description">%></a><br/> + for(int t=0;t<10;t++) {<br/> + <em> <a href="#qr__output" title="<%output> descrption"><%output></a><br/> + Here is the way we count.<br/><br/> + Just saying out loud: <a href="#qr__inline" title="<% ... %> description"><%</a> t <a href="#qr__inline" title="<% ... %> description">%></a><br/><br/> + <a href="#qr__output" title="<%output> descrption"></%output></a><br/></em> + <a href="#qr__codemethod" title="</%codemethod ... %> description"></%codemethod></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> |