Menu

[r614]: / framework / trunk / base_view.cpp  Maximize  Restore  History

Download this file

49 lines (39 with data), 954 Bytes

 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
#include "base_view.h"
#include "worker_thread.h"
#include "util.h"
namespace cppcms {
string base_view::escape(string const &s)
{
return cppcms::escape(s);
}
string base_view::urlencode(string const &s)
{
return cppcms::urlencode(s);
}
namespace details {
views_storage &views_storage::instance() {
static views_storage this_instance;
return this_instance;
};
void views_storage::add_view(string t,string v,view_factory_t f)
{
view_factory_t &func=storage[t][v];
if(!func.empty())
throw cppcms_error("Duplicate template " + t+"::"+v);
func=f;
}
void views_storage::remove_views(string t)
{
storage.erase(t);
}
base_view *views_storage::fetch_view(string t,string v,base_view::settings s,base_content *c)
{
templates_t::iterator p=storage.find(t);
if(p==storage.end()) return NULL;
template_views_t::iterator p2=p->second.find(v);
if(p2==p->second.end()) return NULL;
view_factory_t &f=p2->second;
return f(s,c);
}
};
}// CPPCMS
MongoDB Logo MongoDB