From 8e7ab6661815e333ee9377c2655a03aee89372c2 Mon Sep 17 00:00:00 2001 From: Michael Krelin Date: Fri, 01 Apr 2005 22:23:54 +0000 Subject: added a quick reference section --- (limited to 'htdocs/quickref/metasyntax.chtml') 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"); + +<%codemethod string title() %> + return "meta syntax quick reference"; + +<%method void content() %> +

site-C-ing meta syntax quick reference

+ +

Table of Contents

+ + + +
+ +% /* % */ +
+ + % line of code + +
+
+

+ Break out into the code mode for just one line. +

+
+  <body>
+ % for(int t=0;t<10;t++) {
+    Here is the way we count.<br/>
+    Just saying out loud: <% t %><br/>
+ % }
+  </body> +
+
+ +% /* <% %> */ +
+ + <% expression %> + +
+
+

+ << expression into output stream (think c++). +

+
+ % for(int t=0;t<10;t++) {
+    Here is the way we count.<br/>
+    Just saying out loud: <% t %><br/>
+ % } +
+
+ +% /* %code */ +
+ + + <%code> ... </%code> + + +
+
+ Escape from the output mode to code mode. Opposite to <%output>. Roughly the same as </%output> ... <%output> (note the reverse order), but more self-explanatory and applies to more cases. +

+
+ <body>
+  <%code>
+   for(int t=0;t<10;t++) {
+    <%output>
+     Here is the way we count.<br/>
+     Just saying out loud: <% t %><br/>
+    </%output>
+  </%code>
+ </body> +
+
+ +% /* %codemethod */ +
+ + + <%codemethod return_type_t member_name(args,...) %>
+  code
+ </%codemethod> +
+
+
+
+

+ Define the member function. Essentially equivalent to <%method ... %><%code> ... </%code></%method>. +

+
+ <%codemethod std::string ua() %>
+  return __CGI->get_meta("USER_AGENT");
+ </%codemethod>
+ The user agent is: <% ua() %>
+
+
+ +% /* %constructor */ +
+ + + <%constructor>
+  code
+ </%constructor> +
+
+
+
+

+ Provide the code for constructor. +

+
+ %%var bool is_msie;
+ <%constructor>
+  is_msie = (__CGI->get_meta("USER_AGENT").find("MSIE")!=string::npos);
+ </%constructor>
+
+
+ +% /* %decl / %%decl */ +
+ + %%decl line of code + +
+
+ + + <%decl>
+  lines of code
+ </%decl> +
+
+
+
+

+ Put the line(s) of code into the resulting .h file before the + class declaration. +

+
+ %%decl #include <string>
+ %%var std::string str = "default"
+ <%decl>
+  typedef int integer_t;
+ </%decl>
+ <%method void do_nothing(integer_t input) %>
+  nothing is done
+ </%method> +
+
+ +% /* %%derive */ +
+ + %%derive name = "base-component"; + +
+
+

+ Inherit what is there to be inherited from the base component specified. +

+
+ %%derive pagelayout = "/ancestry/page_layout.chtml";
+ % pagelayout::member_function(); +
+
+ +% /* %destructor */ +
+ + + <%destructor>
+  code
+ </%destructor> +
+
+
+
+

+ Provide the code for destructor. +

+
+ %%var type_t *tmp = 0;
+ <%constructor>
+  tmp = new type_t(type_t::option_1);
+ </%constructor>
+ <%destructor>
+  delete tmp;
+ </%destructor>
+
+
+ +% /* %impl / %%impl */ +
+ + %%impl line of code + +
+
+ + + <%impl>
+  lines of code
+ </%impl> +
+
+
+
+

+ Put the line(s) of code into the resulting .cc implementation file + before any members definitions. +

+
+ %%impl #include <string.h>
+ <%method void output_if_contains(const char *haystack,const char *needle) %>
+ % if(strstr(haystack,needle)) {
+    <% haystack %>
+ % }
+ </%method>
+ <%impl>
+  #include <konforka/exception.h> +  static const char *tokens[] = {
+   "token 1", "token 2", "token 3"
+  };
+ </%impl>
+ <%method void output_token(int toknum) %>
+  <%code>
+   if(toknum<0 || toknum>=(sizeof(tokens)/sizeof(*tokens)))
+    throw konforka::exception(CODEPOINT,"out of bounds");
+  </%code>
+  <% tokens[toknum] %>
+ </%method>
+
+
+ +% /* %method */ +
+ + + <%method return_type_t member_name(args,...) %>
+  code
+ </%method> +
+
+
+
+

+ Define the member function. Essentially equivalent to <%codemethod ... %><%output> ... </%output></%codemethod>. +

+
+ <%method void emphasized(const char *t) %>
+  <em><% t %></em>
+ </%method>
+ % emphasized("emphasized text"); +
+
+ +% /* %output */ +
+ + + <%output> ... </%output> + + +
+
+

+ Escape from the code mode to output mode. Opposite to <%code>. Roughly the same as </%code> ... <%code> (note the reverse order), but more self-explanatory and applies to more cases. +

+
+ <%codemethod void count() %>
+  for(int t=0;t<10;t++) {
+   <%output>
+    Here is the way we count.<br/>
+    Just saying out loud: <% t %><br/>
+   </%output>
+ </%codemethod>
+ % count(); +
+
+ +% /* %%pragma */ +
+ + + %%pragma pragma_name
+ %%pragma pragma_name=pragma_value +
+
+
+
+

provide pseudo instructions to the preprocessor. At this time only pragma + named main is defined, which instructs preprocessor to discard + the 'main' member that would be generated for the component and call the + main member of the named base class.

+
+ %%derive pagelayout = "/ancestry/page_layout.chtml";
+ %%pragma main=pagelayout +
+
+ +% /* %%var */ +
+ + %%var type_t varname;
+ %%var type_t varname = initalizer;
+
+
+
+

+ Define the member variable with optional default value (suitable for + putting into the : varname(initializer) + part of the c++ constructor. +

+
+ %%var std::string strval = "default value";
+ %%var int usecount = 0;
+ %%var int whatnot;
+
+
+ +
+ -- cgit v0.9.0.2