forked from loafle/openapi-generator-original
* Added cpp-restbed "out-of-the-box" functionality * handling class dependencies * added method override to clean interfaces of ambiguity * added default values for shared pointers * fixed _name and name parameters generating the same getters and setters * updated enum handling * updated Petstore samples * updated templates for automated object generation * fix whitespace * removed model initialisation * added model brace initialisation
142 lines
2.5 KiB
C++
142 lines
2.5 KiB
C++
/**
|
|
* OpenAPI Petstore
|
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
|
*
|
|
* The version of the OpenAPI document: 1.0.0
|
|
*
|
|
*
|
|
* NOTE: This class is auto generated by OpenAPI-Generator unset.
|
|
* https://openapi-generator.tech
|
|
* Do not edit the class manually.
|
|
*/
|
|
|
|
|
|
|
|
#include "Order.h"
|
|
|
|
#include <string>
|
|
#include <sstream>
|
|
#include <algorithm>
|
|
#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 org {
|
|
namespace openapitools {
|
|
namespace server {
|
|
namespace model {
|
|
|
|
Order::Order()
|
|
{
|
|
m_Id = 0L;
|
|
m_PetId = 0L;
|
|
m_Quantity = 0;
|
|
m_ShipDate = "";
|
|
m_Status = "";
|
|
m_StatusEnum = { "placed", "approved", "delivered" };
|
|
m_Complete = false;
|
|
}
|
|
|
|
Order::~Order()
|
|
{
|
|
}
|
|
|
|
std::string Order::toJsonString(bool prettyJson)
|
|
{
|
|
std::stringstream ss;
|
|
write_json(ss, this->toPropertyTree(), prettyJson);
|
|
return ss.str();
|
|
}
|
|
|
|
void Order::fromJsonString(std::string const& jsonString)
|
|
{
|
|
std::stringstream ss(jsonString);
|
|
ptree pt;
|
|
read_json(ss,pt);
|
|
this->fromPropertyTree(pt);
|
|
}
|
|
|
|
ptree Order::toPropertyTree()
|
|
{
|
|
ptree pt;
|
|
ptree tmp_node;
|
|
pt.put("id", m_Id);
|
|
pt.put("petId", m_PetId);
|
|
pt.put("quantity", m_Quantity);
|
|
pt.put("shipDate", m_ShipDate);
|
|
pt.put("status", m_Status);
|
|
pt.put("complete", m_Complete);
|
|
return pt;
|
|
}
|
|
|
|
void Order::fromPropertyTree(ptree const &pt)
|
|
{
|
|
ptree tmp_node;
|
|
m_Id = pt.get("id", 0L);
|
|
m_PetId = pt.get("petId", 0L);
|
|
m_Quantity = pt.get("quantity", 0);
|
|
m_ShipDate = pt.get("shipDate", "");
|
|
setStatus(pt.get("status", ""));
|
|
m_Complete = pt.get("complete", false);
|
|
}
|
|
|
|
int64_t Order::getId() const
|
|
{
|
|
return m_Id;
|
|
}
|
|
void Order::setId(int64_t value)
|
|
{
|
|
m_Id = value;
|
|
}
|
|
int64_t Order::getPetId() const
|
|
{
|
|
return m_PetId;
|
|
}
|
|
void Order::setPetId(int64_t value)
|
|
{
|
|
m_PetId = value;
|
|
}
|
|
int32_t Order::getQuantity() const
|
|
{
|
|
return m_Quantity;
|
|
}
|
|
void Order::setQuantity(int32_t value)
|
|
{
|
|
m_Quantity = value;
|
|
}
|
|
std::string Order::getShipDate() const
|
|
{
|
|
return m_ShipDate;
|
|
}
|
|
void Order::setShipDate(std::string value)
|
|
{
|
|
m_ShipDate = value;
|
|
}
|
|
std::string Order::getStatus() const
|
|
{
|
|
return m_Status;
|
|
}
|
|
void Order::setStatus(std::string value)
|
|
{
|
|
if (std::find(m_StatusEnum.begin(), m_StatusEnum.end(), value) != m_StatusEnum.end()) {
|
|
m_Status = value;
|
|
}
|
|
}
|
|
bool Order::isComplete() const
|
|
{
|
|
return m_Complete;
|
|
}
|
|
void Order::setComplete(bool value)
|
|
{
|
|
m_Complete = value;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|