hce-node application
1.4.3
HCE Hierarchical Cluster Engine node application
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
DRCEOutputJsonMessage.cpp
Go to the documentation of this file.
1
#include "
DRCEOutputJsonMessage.hpp
"
2
3
namespace
HCE
4
{
5
namespace
drce
6
{
7
//-----------------------------------------------------------------------------
8
DRCEOutputJsonMessage::DRCEOutputJsonMessage
(
const
std::string& json)
9
:
inherited
(), resultData()
10
{
11
if
(!json.empty())
12
unserialize
(json);
13
}
14
//-----------------------------------------------------------------------------
15
void
DRCEOutputJsonMessage::clear
(
void
)
16
{
17
resetError
();
18
resultData.
clear
();
19
}
20
//-----------------------------------------------------------------------------
21
void
DRCEOutputJsonMessage::setResultData
(
const
DRCEResultData
& rhs)
22
{
23
resultData = rhs;
24
}
25
//-----------------------------------------------------------------------------
26
void
DRCEOutputJsonMessage::setResultData
(
DRCEResultData
&& rhs)
27
{
28
resultData = std::forward<DRCEResultData>(rhs);
29
}
30
//-----------------------------------------------------------------------------
31
bool
DRCEOutputJsonMessage::serialize
(std::string& json)
32
{
33
resetError
();
34
DRCEResultDataSerializator
resultDataSerializator(resultData);
35
if
(!resultDataSerializator.
serialize
(json))
36
{
37
_isError
= resultDataSerializator.
isError
();
38
errorMsg
= resultDataSerializator.
getErrorMsg
();
39
errorCode
= resultDataSerializator.
getErrorCode
();
40
}
41
return
!
_isError
;
42
}
43
//-----------------------------------------------------------------------------
44
bool
DRCEOutputJsonMessage::unserialize
(
const
std::string& json)
45
{
46
clear
();
47
DRCEResultDataSerializator
resultDataSerializator(resultData);
48
if
(!resultDataSerializator.
unserialize
(json))
49
{
50
_isError
= resultDataSerializator.
isError
();
51
errorMsg
= resultDataSerializator.
getErrorMsg
();
52
errorCode
= resultDataSerializator.
getErrorCode
();
53
}
54
return
!
_isError
;
55
}
56
//-----------------------------------------------------------------------------
57
std::istream&
operator>>
(std::istream& is,
DRCEOutputJsonMessage
& outputJsonMessage)
58
{
59
std::string json;
60
is.seekg(0, std::ios::end);
61
json.resize(is.tellg());
62
is.seekg(0, std::ios::beg);
63
is.read(const_cast<char*>(json.c_str()), json.size());
64
outputJsonMessage.
unserialize
(json);
65
return
is;
66
}
67
//-----------------------------------------------------------------------------
68
std::ostream&
operator<<
(std::ostream& os,
const
DRCEOutputJsonMessage
& outputJsonMessage)
69
{
70
std::string json;
71
const_cast<
DRCEOutputJsonMessage
&
>
(outputJsonMessage).serialize(json);
72
return
os << json;
73
}
74
//-----------------------------------------------------------------------------
75
//-----------------------------------------------------------------------------
76
}
// namespace drce
77
}
// namespace HCE
sources
utils
DRCE
src
DRCEOutputJsonMessage.cpp
Generated on Tue Jun 30 2015 19:42:11 for hce-node application by
1.8.1.2