CPPSP  0.2
C++ Server Pages
 All Classes Functions Variables
cppsp::Page Class Reference

#include <page.H>

Inheritance diagram for cppsp::Page:
RGC::Object

Public Types

typedef Delegate< void()> Callback
 

Public Member Functions

 Page (Request &req, Response &resp, CP::StringPool *sp)
 
void cancelRender ()
 
void __writeStringTable (int i, int len)
 
String mapPath (String path)
 
String mapPath (String path, RGC::Allocator &a)
 
String mapRelativePath (String path)
 
String mapRelativePath (String path, RGC::Allocator &a)
 
void loadNestedPage (String path, Delegate< void(Page *, exception *ex)> cb)
 
void loadNestedPage (String path, Delegate< void(Page *, exception *ex)> cb, RGC::Allocator &a)
 
void loadNestedPageFromFile (String path, Delegate< void(Page *, exception *ex)> cb)
 
void loadNestedPageFromFile (String path, Delegate< void(Page *, exception *ex)> cb, RGC::Allocator &a)
 
virtual void handleRequest (Callback cb=nullptr)
 
virtual void processRequest ()
 
virtual void init ()
 
virtual void doInit ()
 
virtual void initCB ()
 
virtual void cancelLoad (exception *ex=NULL)
 
virtual void load ()
 
virtual void render (CP::StreamWriter &out)
 
virtual void flush ()
 
virtual void flushCB ()
 
virtual void finalize ()
 
virtual void finalizeCB ()
 
void _readPOSTCB (Request &r)
 
void _flushCB (Response &r)
 
void _pageCB (Page *p, exception *ex)
 
- Public Member Functions inherited from RGC::Object
 Object (const Object &other)
 
void retain (int n=1)
 
void destruct ()
 
bool release (int n=1)
 

Public Attributes

RGC::Ref< Requestrequest
 
RGC::Ref< Responseresponse
 
Delegate< void(Page
*, exception *ex)> 
pageCB
 
CP::Pollpoll
 
Serverserver
 
Callback cb
 
String filePath
 
CP::StringPoolsp
 
bool doRender
 
bool doReadPost
 
const uint8_t * __stringTable
 
- Public Attributes inherited from RGC::Object
Allocatorallocator
 
atomic_t refCount
 

Detailed Description

Base class for all cppsp pages.

Definition at line 264 of file page.H.

Member Function Documentation

void cppsp::Page::__writeStringTable ( int  i,
int  len 
)

internal method do not use.

Definition at line 57 of file page.C.

virtual void cppsp::Page::finalize ( )
inlinevirtual

Called after flush() is done. See init() for a description of the request life-cycle.

Definition at line 387 of file page.H.

void cppsp::Page::finalizeCB ( )
virtual

Called by finalize() after it is done doing its work. This will call the web server's callback and cause it to clean-up and re-cycle the Request and Response objects, and destroy the Page object. See init() for a description of the request life-cycle.

Definition at line 152 of file page.C.

void cppsp::Page::flush ( )
virtual

Called after rendering. See init() for a description of the request life-cycle.

Definition at line 102 of file page.C.

virtual void cppsp::Page::flushCB ( )
inlinevirtual

Called by flush() after it is done writing. See init() for a description of the request life-cycle.

Definition at line 381 of file page.H.

void cppsp::Page::handleRequest ( Callback  cb = nullptr)
virtual

Called by the web server immediately after instantiating the current page. The page calls "cb" when it is done processing, to signal the web server that it can clean up the StringPool and all request-related data. The object pointed to by fields "request" and "response" may be recycled.

Definition at line 60 of file page.C.

virtual void cppsp::Page::init ( )
inlinevirtual

Each page goes through these stages (in order): init, [readPost], load, render, flush, finalize, [web server callback], ~Page

To be overridden by base class; called before load() is called, and must call initCB() or cancelLoad() after it's done

Definition at line 362 of file page.H.

virtual void cppsp::Page::load ( )
inlinevirtual

To be overridden by derived class; called before headers are written. See init() for a description of the request life-cycle.

Definition at line 371 of file page.H.

void cppsp::Page::loadNestedPage ( String  path,
Delegate< void(Page *, exception *ex)>  cb 
)

Load and instantiate dynamic page from "path". path is relative to the current page.

Definition at line 121 of file page.C.

void cppsp::Page::loadNestedPage ( String  path,
Delegate< void(Page *, exception *ex)>  cb,
RGC::Allocator a 
)

Load and instantiate dynamic page from "path". path is relative to the current page. Returned Page object is allocated from "a".

Definition at line 124 of file page.C.

void cppsp::Page::loadNestedPageFromFile ( String  path,
Delegate< void(Page *, exception *ex)>  cb 
)

Load and instantiate dynamic page from "path". path is absolute.

Definition at line 130 of file page.C.

void cppsp::Page::loadNestedPageFromFile ( String  path,
Delegate< void(Page *, exception *ex)>  cb,
RGC::Allocator a 
)

Load and instantiate dynamic page from "path". path is absolute. Returned Page object is allocated from "a".

Definition at line 133 of file page.C.

String cppsp::Page::mapPath ( String  path)

Given a path relative to the current page, returns the absolute path. The returned string is allocated from the request-wide StringPool and is invalid after the page finishes executing.

Definition at line 106 of file page.C.

String cppsp::Page::mapPath ( String  path,
RGC::Allocator a 
)

Given a path relative to the current page, returns the absolute path. The returned string is allocated from "a".

Definition at line 109 of file page.C.

String cppsp::Page::mapRelativePath ( String  path)

Given a path relative to the current page, returns the path relative to the server root. The returned string is allocated from the request-wide StringPool and is invalid after the page finishes executing.

Definition at line 112 of file page.C.

String cppsp::Page::mapRelativePath ( String  path,
RGC::Allocator a 
)

Given a path relative to the current page, returns the path relative to the server root. The returned string is allocated from "a".

Definition at line 115 of file page.C.

Member Data Documentation

const uint8_t* cppsp::Page::__stringTable

internal field do not use. Pointer to mmap()ed address of the string table file.

Definition at line 312 of file page.H.

Callback cppsp::Page::cb

internal field do not use.

Definition at line 292 of file page.H.

String cppsp::Page::filePath

Absolute path of the current cppsp page.

Definition at line 296 of file page.H.

Delegate<void(Page*, exception* ex)> cppsp::Page::pageCB

internal field do not use.

Definition at line 280 of file page.H.

CP::Poll* cppsp::Page::poll

Poll instance for the current thread. Can be used for asynchronous I/O, timers, etc.

Definition at line 284 of file page.H.

RGC::Ref<Request> cppsp::Page::request

Object representing the HTTP request.

Definition at line 272 of file page.H.

RGC::Ref<Response> cppsp::Page::response

Object representing the HTTP response.

Definition at line 276 of file page.H.

Server* cppsp::Page::server

The current Server instance. Usually there is one Server instance for every thread.

Definition at line 288 of file page.H.

CP::StringPool* cppsp::Page::sp

The per-request StringPool instance. You can allocate memory from this if it only need to persist for the duration of this http request. The StringPool is cleared after the page has finished executing.

Definition at line 300 of file page.H.


The documentation for this class was generated from the following files: