View Class Reference

#include <View.h>

Collaboration diagram for View:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 View ()
 ~View ()
void show ()

Public Attributes

std::string htmlTemplate


Constructor & Destructor Documentation

View::View (  ) 

00023           {
00024    /* Get Registry instance */
00025    reg = Registry::getInstance();
00026 
00027    apr = static_cast<Request *> (reg->get("apr"));
00028 }

Here is the call graph for this function:

View::~View (  ) 

00030            {
00031 
00032 }


Member Function Documentation

void View::show (  ) 

00034                {
00035    std::string content = content_type;
00036    content += ";charset=";
00037    content += charset;
00038    content += "\n\n";
00039    apr->setHeader("Content-type:", content);
00040    apr->sendHeaders();
00041 
00042    std::ifstream htmlStream;
00043 
00044    std::string path = templatePath + htmlTemplate;
00045    htmlStream.open(path.c_str());
00046 
00047    if (!htmlStream) {
00048       // TODO Error page !!?
00049       std::cerr << "Can not find template!\n";
00050       exit(-1);
00051    }
00052    int length;
00053    char * buffer;
00054 
00055    htmlStream.seekg (0, std::ios::end);
00056    length = htmlStream.tellg();
00057    htmlStream.seekg (0, std::ios::beg);
00058 
00059    buffer = new char [length];
00060    htmlStream.read (buffer,length);
00061    htmlStream.close();
00062 
00063    std::cout.write(buffer, length);
00064    delete [] buffer;
00065 }

Here is the call graph for this function:


Member Data Documentation

std::string View::htmlTemplate


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

Generated on Wed Dec 23 14:15:05 2009 for CPPFrame by  doxygen 1.5.8