blob: c11d64403f08708dda2acd3ba56fda61b9ae9c36 (
plain)
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
|
#ifndef PAGE_HPP
#define PAGE_HPP
#include "master.hpp"
#include "page_content.hpp"
#include <cppcms/json.h>
namespace apps {
class page : public master {
public:
page( aCms &cms );
private:
void display( std::string slug );
void api_pages( );
void api_page( std::string slug );
void ini( content::page &c );
};
} // namespace apps
struct Page {
std::string slug;
std::string title;
std::string content;
};
namespace cppcms {
namespace json {
template<>
struct traits<Page> {
static Page get( value const &v )
{
Page p;
if( v.type( ) != is_object) {
throw bad_value_cast( );
}
p.slug = v.get<std::string>( "slug" );
p.title = v.get<std::string>( "title" );
p.content = v.get<std::string>( "content" );
return p;
}
static void set( value &v, Page const &p )
{
v.set( "slug", p.slug );
v.set( "title", p.title );
v.set( "content", p.content );
}
};
} } // namespace cppcms::json
#endif
|