-
Notifications
You must be signed in to change notification settings - Fork 1
/
post.h
49 lines (39 loc) · 1.1 KB
/
post.h
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
#ifndef POST_H_
#define POST_H_
#include <Wt/Dbo/Dbo>
#include <Wt/Dbo/Session>
#include <Wt/Dbo/backend/Sqlite3>
#include <Wt/Dbo/SqlConnection>
#include <Wt/WText>
#include <Wt/WContainerWidget>
#include <Wt/WBreak>
#include <string>
using namespace std;
using namespace Wt;
namespace dbo = Wt::Dbo;
class Post;
class Category;
typedef dbo::collection< dbo::ptr<Post> > PostCollection;
typedef dbo::collection< dbo::ptr<Category> > CategoryCollection;
class Post {
public: string postName, postContent, permalink;
dbo::collection <dbo::ptr<Category> > categories;
template<class Action>
void persist(Action& a) {
dbo::field(a, postName, "postname");
dbo::field(a, permalink, "permalink");
dbo::field(a, postContent, "postcontent");
dbo::hasMany(a, categories, dbo::ManyToMany, "post_cat");
}
};
class Category {
public: string categoryname, checkedcat;
dbo::collection <dbo::ptr<Post> > posts;
template<class Action>
void persist(Action& a) {
dbo::field(a, categoryname, "categoryname");
dbo::field(a, checkedcat, "checkedcat");
dbo::hasMany(a, posts, dbo::ManyToMany, "post_cat");
}
};
#endif