Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site













SourceForge.net Logo

Renderer

 

class Renderer

This class represents shared variable space. It is separated from Http class to be available in cases when association with current HTTP request is not desirable (e.g. subtemplate rendering). Renderer is used as base class of Http.

(Note: the term shared variable space reflects the fact, that for single HTTP request all related values are stored into this single space: values set by handler, <form> or Ajax variables, session variables and cookies).

 

Public Method List

 

Renderer& operator()(const char *id, const Value& v)

Renderer& operator()(const char *id, const char *v)

Renderer& operator()(const char *id, const String& v)

Adds variable id id with value v to shared variable space. Returns *this.

 


 

Renderer& operator()(const ValueMap& map)

Adds all key/value pairs of map as variables id / value to shared variable space. Returns *this.

 


 

Renderer& operator()(const char *id, const HandlerId& handler)

Renderer& operator()(const char *id, void (*handler)(Http&))

Adds variable id to shared variable space; the value of variable will be actual URL to handler (with no URL parameters). Returns *this.

 


 

Renderer& operator()(const char *id, const HandlerId& handler, const Value& arg1)

Renderer& operator()(const char *id, void (*handler)(Http&), const Value& arg1)

Adds variable id to shared variable space; the value of variable will be actual URL to handler, placing arg1 to appropriate place (defined by handler URL pattern) as URL parameter. Returns *this.

 


 

Renderer& operator()(const char *id, const HandlerId& handler, const Value& arg1, const Value& arg2)

Renderer& operator()(const char *id, void (*handler)(Http&), const Value& arg1, const Value& arg2)

Adds variable id to shared variable space; the value of variable will be actual URL to handler, placing arg1 and arg2 to appropriate place (defined by handler URL pattern) as URL parameter. Returns *this.

 


 

Renderer& operator()(const Sql& sql)

Method expects that Fetch was performed on sql and adds columns of the fetched row to shared variable space, Each column will be stored as a single variable with id equal to uppercased name of the column. Returns *this.

 


 

Renderer& operator()(Fields rec)

Method stores fields of rec as shared variable values, each variable with id defined by field name and value by field value. Note that Fields is usually created as mapping object of S_* database records. Returns *this.

 


 

Renderer& operator()(const SqlSelect& row_sel)

Methods executes row_sel with SQLR (read session), fetches single row and adds columns of the fetched row to shared variable space, Each column will be stored as a single variable with id equal to uppercased name of the column. If no column is fetched, BadRequestExc exception is raised, which eventually (if not handled sooner) results in 400/Bad request response from the web server. Returns *this.

 


 

Renderer& operator()(const char *id, const SqlSelect& sel)

Methods executes sel with SQLR (read session), fetches all rows and creates an ValueArray of ValueMaps (with column-name/column-value pairs) and stores the result into id shared variable. Returns *this.

 


 

Renderer& SetLanguage(int lang)

Sets the language to be used while rendering witz template. Basically, it affects the choice of the template file, language specific templates have priority.E.g. if language is set to LNG_('C','S','C','Z') and there exists file index.cs-cz.witz, it has priority over index.witz. The default value is LNG_ENGLISH (en-us). Returns *this.

 


 

SqlUpdate Update(SqlId table)

This method creates an update SQL statement for table based on current shared variables. It obtains a list of columns for the table and adds to SqlUpdate all columns found in as shared variables; for each column it first tries to find it case-sensitive, then lower-cased, then upper-cased. Columns not found as shared variable are not added.

 


 

SqlInsert Insert(SqlId table)

This method creates an insert SQL statement for table based on current shared variables. It obtains a list of columns for the table and adds to SqlUpdate all columns found in as shared variables; for each column it first tries to find it case-sensitive, then lower-cased, then upper-cased. Columns not found as shared variable are not added.

 


 

Value operator[](const char *idconst

Returns the value of shared variable id.

 


 

String RenderString(const String& template_name)

Renders template_name using current set of variables.

 


 

Value Render(const String& template_name)

Same as Raw(RenderString(template_name)). The purpose is that Strings represented by RawHtmlText (a result of Raw) are not escaped when insterted into witz templates.

 


 

Renderer& Render(const char *id, const String& template_name)

Same as operator()(id, Render(template_name)), in other words sets the variable to the result of template rendering. Returns *this.


 

const VectorMap<String, Value>& Variables() const

Returns a reference to all shared variables.

 

Last edit by cxl on 10/24/2012. Do you want to contribute?. T++