Menu

[r902]: / framework / branches / refactoring / base_view.cpp  Maximize  Restore  History

Download this file

76 lines (58 with data), 1.2 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#define CPPCMS_SOURCE
#include "base_view.h"
#include "util.h"
#include "cppcms_error.h"
#include <vector>
#include <boost/format.hpp>
namespace cppcms {
struct base_view::data {
std::ostream *out;
};
base_view::base_view(std::ostream &out) :
d(new data)
{
d->out=&out;
}
std::ostream &base_view::out()
{
return *d->out;
}
base_view::~base_view()
{
}
void base_view::render()
{
}
namespace details {
struct views_storage::data {};
views_storage &views_storage::instance() {
static views_storage this_instance;
return this_instance;
};
void views_storage::add_view(std::string t,std::string v,view_factory_type f)
{
storage[t][v]=f;
}
void views_storage::remove_views(std::string t)
{
storage.erase(t);
}
std::auto_ptr<base_view> views_storage::fetch_view(std::string t,std::string v,std::ostream &s,base_content *c)
{
templates_type::iterator p=storage.find(t);
if(p==storage.end())
throw cppcms_error("Can't find skin "+t);
template_views_type::iterator p2=p->second.find(v);
if(p2==p->second.end())
throw cppcms_error("Can't find template "+v);
view_factory_type &f=p2->second;
return f(s,c);
}
views_storage::views_storage()
{
}
views_storage::~views_storage()
{
}
} // details
}// cppcms
MongoDB Logo MongoDB