forked from swagger-api/swagger-codegen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ApiResponse.cpp
93 lines (79 loc) · 1.81 KB
/
ApiResponse.cpp
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/**
* Swagger Petstore
* This is a sample server Petstore server. You can find out more about Swagger at [http:https://swagger.io](http:https://swagger.io) or on [irc.freenode.net, #swagger](http:https://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
*
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator 2.2.3-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
#include "ApiResponse.h"
#include <string>
#include <sstream>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
using boost::property_tree::ptree;
using boost::property_tree::read_json;
using boost::property_tree::write_json;
namespace io {
namespace swagger {
namespace server {
namespace model {
ApiResponse::ApiResponse()
{
m_Code = 0;
m_Type = "";
m_Message = "";
}
ApiResponse::~ApiResponse()
{
}
std::string ApiResponse::toJsonString()
{
std::stringstream ss;
ptree pt;
pt.put("Code", m_Code);
pt.put("Type", m_Type);
pt.put("Message", m_Message);
write_json(ss, pt, false);
return ss.str();
}
void ApiResponse::fromJsonString(std::string const& jsonString)
{
std::stringstream ss(jsonString);
ptree pt;
read_json(ss,pt);
m_Code = pt.get("Code", 0);
m_Type = pt.get("Type", "");
m_Message = pt.get("Message", "");
}
int32_t ApiResponse::getCode() const
{
return m_Code;
}
void ApiResponse::setCode(int32_t value)
{
m_Code = value;
}
std::string ApiResponse::getType() const
{
return m_Type;
}
void ApiResponse::setType(std::string value)
{
m_Type = value;
}
std::string ApiResponse::getMessage() const
{
return m_Message;
}
void ApiResponse::setMessage(std::string value)
{
m_Message = value;
}
}
}
}
}