CPPSP  1.0
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)
 
AsyncValue< Page * > loadNestedPage (String path)
 
AsyncValue< Page * > loadNestedPage (String path, RGC::Allocator &a)
 
AsyncValue< Page * > loadNestedPageFromFile (String path)
 
AsyncValue< Page * > loadNestedPageFromFile (String path, RGC::Allocator &a)
 
String loadNestedStaticPage (String path)
 
String loadNestedStaticPageFromFile (String path)
 
void staticInclude (String path)
 
void staticIncludeFromFile (String path)
 
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)
 
- 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
 
RGC::Ref< cppsp::loadedPagelp
 
CP::Pollpoll
 
Serverserver
 
Callback cb
 
String filePath
 
CP::StringPoolsp
 
bool doRender
 
bool doReadPost
 
const uint8_t * __stringTable
 
- Public Attributes inherited from RGC::Object
Allocatorallocator
 
int refCount
 

Detailed Description

Base class for all cppsp pages.

Definition at line 598 of file page.H.

Member Function Documentation

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

internal method do not use.

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

Called by flushCB. See init() for a description of the request life-cycle.

Definition at line 730 of file page.H.

virtual 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.

virtual void cppsp::Page::flush ( )
virtual

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

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 724 of file page.H.

virtual 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.

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 705 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 714 of file page.H.

AsyncValue<Page*> cppsp::Page::loadNestedPage ( String  path)

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

AsyncValue<Page*> cppsp::Page::loadNestedPage ( String  path,
RGC::Allocator a 
)

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

AsyncValue<Page*> cppsp::Page::loadNestedPageFromFile ( String  path)

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

AsyncValue<Page*> cppsp::Page::loadNestedPageFromFile ( String  path,
RGC::Allocator a 
)

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

String cppsp::Page::loadNestedStaticPage ( String  path)

Load static page from "path". path is relative to the current page.

String cppsp::Page::loadNestedStaticPageFromFile ( String  path)

Load static page from "path". path is absolute.

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.

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".

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.

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".

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 644 of file page.H.

Callback cppsp::Page::cb

internal field do not use. web server callback.

Definition at line 624 of file page.H.

String cppsp::Page::filePath

Absolute path of the current cppsp page.

Definition at line 628 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 615 of file page.H.

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

Object representing the HTTP request.

Definition at line 606 of file page.H.

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

Object representing the HTTP response.

Definition at line 610 of file page.H.

Server* cppsp::Page::server

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

Definition at line 619 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 632 of file page.H.


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