Wt examples
4.11.3
hangman
User.h
Go to the documentation of this file.
1
// This may look like C code, but it's really -*- C++ -*-
2
/*
3
* Copyright (C) 2011 Emweb bv, Herent, Belgium
4
*
5
* See the LICENSE file for terms of use.
6
*/
7
8
#ifndef USER_H_
9
#define USER_H_
10
11
#include <Wt/WDateTime.h>
12
#include <Wt/Dbo/Types.h>
13
#include <Wt/Dbo/WtSqlTraits.h>
14
#include <Wt/Auth/Dbo/AuthInfo.h>
15
16
#include <string>
17
18
namespace
dbo
=
Wt::Dbo
;
19
20
class
User
;
21
using
AuthInfo
=
Wt::Auth::Dbo::AuthInfo<User>
;
22
using
Users
=
dbo::collection<dbo::ptr<User>
>;
23
24
class
User
25
{
26
public
:
27
std::string
name
;
/* a copy of auth info's user name */
28
int
gamesPlayed
= 0;
29
long
long
score
= 0;
30
Wt::WDateTime
lastGame
;
31
dbo::weak_ptr<AuthInfo>
authInfo
;
32
33
template
<
class
Action>
34
void
persist
(Action& a)
35
{
36
dbo::field
(a,
gamesPlayed
,
"gamesPlayed"
);
37
dbo::field
(a,
score
,
"score"
);
38
dbo::field
(a,
lastGame
,
"lastGame"
);
39
dbo::hasOne
(a,
authInfo
,
"user"
);
40
}
41
};
42
43
DBO_EXTERN_TEMPLATES(
User
)
44
45
#endif
// USER_H_
User
Definition:
User.h:25
User::name
std::string name
Definition:
User.h:27
User::authInfo
dbo::weak_ptr< AuthInfo > authInfo
Definition:
User.h:31
User::score
long long score
Definition:
User.h:29
User::persist
void persist(Action &a)
Definition:
User.h:34
User::lastGame
Wt::WDateTime lastGame
Definition:
User.h:30
User::gamesPlayed
int gamesPlayed
Definition:
User.h:28
Wt::Auth::Dbo::AuthInfo
Wt::Dbo::collection
Wt::Dbo::weak_ptr
Wt::WDateTime
Wt::Dbo::hasOne
void hasOne(Action &action, weak_ptr< C > &value, const std::string &name=std::string())
Wt::Dbo::field
void field(Action &action, V &value, const std::string &name, int size=-1)
Wt::Dbo
Generated on Wed Feb 19 2025 for
the C++ Web Toolkit (Wt)
by
1.9.1