HCE project C++ developers source code library
1.1.1
HCE project developer library
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
JsonMessageCover.hpp
Go to the documentation of this file.
1
14
#ifndef JSON_MESSAGE_COVER_HPP
15
#define JSON_MESSAGE_COVER_HPP
16
17
#include "
JsonSerializable.hpp
"
18
#include "
MessageType.hpp
"
19
20
namespace
HCE
21
{
22
//-----------------------------------------------------------------------------
23
namespace
jsonMessageCoverConst
24
{
25
const
std::string
messageType
=
"type"
;
26
const
std::string
messageBody
=
"data"
;
27
const
std::string
messageTTL
=
"ttl"
;
28
const
unsigned
int
defaultTTLValue
= 1;
29
}
30
//-----------------------------------------------------------------------------
31
class
JsonMessageCover
:
public
IJsonSerializable
32
{
33
public
:
34
enum
ErrorCode
35
{
36
NO_ERROR
=0,
37
ERROR_SERIALIZE
=1,
38
ERROR_UNSERIALIZE
=2
39
};
40
public
:
41
explicit
JsonMessageCover
(
const
std::string& json=
""
);
42
43
JsonMessageCover
(
types::MessageType
messageType_,
44
const
std::string& messageBody_,
45
unsigned
int
ttl_=
HCE::jsonMessageCoverConst::defaultTTLValue
);
46
47
JsonMessageCover
(
unsigned
int
messageType_,
48
const
std::string& messageBody_,
49
unsigned
int
ttl_=
HCE::jsonMessageCoverConst::defaultTTLValue
);
50
51
virtual
~JsonMessageCover
(
void
) {};
52
53
bool
serialize
(std::string& json);
54
bool
unserialize
(
const
std::string& json);
55
56
void
setType
(
unsigned
int
messageType_) {messageType=
static_cast<
types::MessageType
>
(messageType_);}
57
void
setType
(
types::MessageType
messageType_) {messageType=messageType_;}
58
types::MessageType
getType
(
void
)
const
{
return
messageType;}
59
60
void
setData
(
const
std::string& messageBody_) {messageBody=messageBody_;}
61
std::string
getData
(
void
) {
return
messageBody;}
62
63
void
setTTL
(
unsigned
int
ttl) {messageTTL=ttl;}
64
unsigned
int
getTTL
(
void
)
const
{
return
messageTTL;}
65
private
:
66
types::MessageType
messageType;
67
std::string messageBody;
68
unsigned
int
messageTTL;
69
70
private
:
71
friend
std::istream&
operator>>
(std::istream& is,
HCE::JsonMessageCover
& jsonHandler);
72
friend
std::ostream&
operator<<
(std::ostream& os,
const
HCE::JsonMessageCover
& jsonHandler);
73
typedef
HCE::IJsonSerializable
inherited;
74
};
75
//-----------------------------------------------------------------------------
76
//-----------------------------------------------------------------------------
77
}
// end namespace HCE
78
79
#endif // JSON_MESSAGE_COVER_HPP
sources
serializable
src
JsonMessageCover.hpp
Generated on Mon Jan 13 2014 13:08:38 for HCE project C++ developers source code library by
1.8.1.2