mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-04 14:40:53 +00:00
Change the Model template (#5222)
This commit is contained in:
parent
54c2956461
commit
2d6311cbdc
@ -24,6 +24,7 @@ import io.swagger.v3.oas.models.media.Schema;
|
|||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.openapitools.codegen.CodegenConfig;
|
import org.openapitools.codegen.CodegenConfig;
|
||||||
|
import org.openapitools.codegen.CodegenModel;
|
||||||
import org.openapitools.codegen.CodegenProperty;
|
import org.openapitools.codegen.CodegenProperty;
|
||||||
import org.openapitools.codegen.DefaultCodegen;
|
import org.openapitools.codegen.DefaultCodegen;
|
||||||
import org.openapitools.codegen.templating.mustache.IndentedLambda;
|
import org.openapitools.codegen.templating.mustache.IndentedLambda;
|
||||||
@ -34,6 +35,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
abstract public class AbstractCppCodegen extends DefaultCodegen implements CodegenConfig {
|
abstract public class AbstractCppCodegen extends DefaultCodegen implements CodegenConfig {
|
||||||
@ -327,7 +329,17 @@ abstract public class AbstractCppCodegen extends DefaultCodegen implements Codeg
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||||
|
List<Object> models = (List<Object>) objs.get("models");
|
||||||
|
for (Object _mo : models) {
|
||||||
|
Map<String, Object> mo = (Map<String, Object>) _mo;
|
||||||
|
CodegenModel cm = (CodegenModel) mo.get("model");
|
||||||
|
// cannot handle inheritance from maps and arrays in C++
|
||||||
|
if((cm.isArrayModel || cm.isMapModel ) && (cm.parentModel == null)) {
|
||||||
|
cm.parent = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
return postProcessModelsEnum(objs);
|
return postProcessModelsEnum(objs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
|
|||||||
typeMapping.put("map", "std::map");
|
typeMapping.put("map", "std::map");
|
||||||
typeMapping.put("file", "HttpContent");
|
typeMapping.put("file", "HttpContent");
|
||||||
typeMapping.put("object", "Object");
|
typeMapping.put("object", "Object");
|
||||||
typeMapping.put("binary", "utility::string_t");
|
typeMapping.put("binary", "HttpContent");
|
||||||
typeMapping.put("number", "double");
|
typeMapping.put("number", "double");
|
||||||
typeMapping.put("UUID", "utility::string_t");
|
typeMapping.put("UUID", "utility::string_t");
|
||||||
typeMapping.put("URI", "utility::string_t");
|
typeMapping.put("URI", "utility::string_t");
|
||||||
@ -348,6 +348,8 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
|
|||||||
} else if (ModelUtils.isMapSchema(p)) {
|
} else if (ModelUtils.isMapSchema(p)) {
|
||||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||||
return getSchemaType(p) + "<utility::string_t, " + getTypeDeclaration(inner) + ">";
|
return getSchemaType(p) + "<utility::string_t, " + getTypeDeclaration(inner) + ">";
|
||||||
|
} else if (ModelUtils.isFileSchema(p) || ModelUtils.isBinarySchema(p)) {
|
||||||
|
return "std::shared_ptr<" + openAPIType + ">";
|
||||||
} else if (ModelUtils.isStringSchema(p)
|
} else if (ModelUtils.isStringSchema(p)
|
||||||
|| ModelUtils.isDateSchema(p) || ModelUtils.isDateTimeSchema(p)
|
|| ModelUtils.isDateSchema(p) || ModelUtils.isDateTimeSchema(p)
|
||||||
|| ModelUtils.isFileSchema(p) || ModelUtils.isUUIDSchema(p)
|
|| ModelUtils.isFileSchema(p) || ModelUtils.isUUIDSchema(p)
|
||||||
@ -403,9 +405,10 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
|
|||||||
|
|
||||||
boolean isPrimitiveType = parameter.isPrimitiveType == Boolean.TRUE;
|
boolean isPrimitiveType = parameter.isPrimitiveType == Boolean.TRUE;
|
||||||
boolean isListContainer = parameter.isListContainer == Boolean.TRUE;
|
boolean isListContainer = parameter.isListContainer == Boolean.TRUE;
|
||||||
|
boolean isMapContainer = parameter.isMapContainer == Boolean.TRUE;
|
||||||
boolean isString = parameter.isString == Boolean.TRUE;
|
boolean isString = parameter.isString == Boolean.TRUE;
|
||||||
|
|
||||||
if (!isPrimitiveType && !isListContainer && !isString && !parameter.dataType.startsWith("std::shared_ptr")) {
|
if (!isPrimitiveType && !isListContainer && !isMapContainer && !isString && !parameter.dataType.startsWith("std::shared_ptr")) {
|
||||||
parameter.dataType = "std::shared_ptr<" + parameter.dataType + ">";
|
parameter.dataType = "std::shared_ptr<" + parameter.dataType + ">";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ public:
|
|||||||
{{#operation}}
|
{{#operation}}
|
||||||
virtual pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> {{operationId}}(
|
virtual pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> {{operationId}}(
|
||||||
{{#allParams}}
|
{{#allParams}}
|
||||||
{{^required}}boost::optional<{{/required}}{{#isFile}}std::shared_ptr<{{/isFile}}{{{dataType}}}{{#isFile}}>{{/isFile}}{{^required}}>{{/required}} {{paramName}}{{#hasMore}},{{/hasMore}}
|
{{^required}}boost::optional<{{/required}}{{{dataType}}}{{^required}}>{{/required}} {{paramName}}{{#hasMore}},{{/hasMore}}
|
||||||
{{/allParams}}
|
{{/allParams}}
|
||||||
) const = 0;
|
) const = 0;
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
@ -67,7 +67,7 @@ public:
|
|||||||
{{/allParams}}
|
{{/allParams}}
|
||||||
pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> {{operationId}}(
|
pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> {{operationId}}(
|
||||||
{{#allParams}}
|
{{#allParams}}
|
||||||
{{^required}}boost::optional<{{/required}}{{#isFile}}std::shared_ptr<{{/isFile}}{{{dataType}}}{{#isFile}}>{{/isFile}}{{^required}}>{{/required}} {{paramName}}{{#hasMore}},{{/hasMore}}
|
{{^required}}boost::optional<{{/required}}{{{dataType}}}{{^required}}>{{/required}} {{paramName}}{{#hasMore}},{{/hasMore}}
|
||||||
{{/allParams}}
|
{{/allParams}}
|
||||||
) const{{#gmockApis}} override{{/gmockApis}};
|
) const{{#gmockApis}} override{{/gmockApis}};
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
|
@ -26,7 +26,7 @@ using namespace {{modelNamespace}};
|
|||||||
}
|
}
|
||||||
|
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> {{classname}}::{{operationId}}({{#allParams}}{{^required}}boost::optional<{{/required}}{{#isFile}}std::shared_ptr<{{/isFile}}{{{dataType}}}{{#isFile}}>{{/isFile}}{{^required}}>{{/required}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) const
|
pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> {{classname}}::{{operationId}}({{#allParams}}{{^required}}boost::optional<{{/required}}{{{dataType}}}{{^required}}>{{/required}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) const
|
||||||
{
|
{
|
||||||
{{#allParams}}{{#required}}{{^isPrimitiveType}}{{^isContainer}}
|
{{#allParams}}{{#required}}{{^isPrimitiveType}}{{^isContainer}}
|
||||||
// verify the required parameter '{{paramName}}' is set
|
// verify the required parameter '{{paramName}}' is set
|
||||||
@ -160,13 +160,13 @@ pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/r
|
|||||||
web::json::value localVarJson;
|
web::json::value localVarJson;
|
||||||
|
|
||||||
{{#isPrimitiveType}}
|
{{#isPrimitiveType}}
|
||||||
localVarJson = ModelBase::toJson({{paramName}});
|
localVarJson = ModelBase::toJson({{paramName}}{{^required}}.get(){{/required}});
|
||||||
{{/isPrimitiveType}}
|
{{/isPrimitiveType}}
|
||||||
{{^isPrimitiveType}}
|
{{^isPrimitiveType}}
|
||||||
{{#isListContainer}}
|
{{#isListContainer}}
|
||||||
{
|
{
|
||||||
std::vector<web::json::value> localVarJsonArray;
|
std::vector<web::json::value> localVarJsonArray;
|
||||||
for( auto& localVarItem : {{paramName}} )
|
for( auto& localVarItem : {{paramName}}{{^required}}.get(){{/required}} )
|
||||||
{
|
{
|
||||||
{{#items.isPrimitiveType}}localVarJsonArray.push_back(ModelBase::toJson(localVarItem));
|
{{#items.isPrimitiveType}}localVarJsonArray.push_back(ModelBase::toJson(localVarItem));
|
||||||
{{/items.isPrimitiveType}}{{^items.isPrimitiveType}}{{#items.isString}}localVarJsonArray.push_back(ModelBase::toJson(localVarItem));
|
{{/items.isPrimitiveType}}{{^items.isPrimitiveType}}{{#items.isString}}localVarJsonArray.push_back(ModelBase::toJson(localVarItem));
|
||||||
@ -193,30 +193,32 @@ pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/r
|
|||||||
{{#bodyParam}}
|
{{#bodyParam}}
|
||||||
std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData);
|
std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData);
|
||||||
{{#isPrimitiveType}}
|
{{#isPrimitiveType}}
|
||||||
localVarMultipart->add(ModelBase::toHttpContent(utility::conversions::to_string_t("{{paramName}}"), {{paramName}}));
|
localVarMultipart->add(ModelBase::toHttpContent(utility::conversions::to_string_t("{{paramName}}"), {{paramName}}{{^required}}.get(){{/required}}));
|
||||||
{{/isPrimitiveType}}
|
{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isListContainer}}
|
||||||
{{^isPrimitiveType}}
|
|
||||||
{{#isListContainer}}
|
|
||||||
{
|
{
|
||||||
std::vector<web::json::value> localVarJsonArray;
|
std::vector<web::json::value> localVarJsonArray;
|
||||||
for( auto& localVarItem : {{paramName}} )
|
for( auto& localVarItem : {{paramName}}{{^required}}.get(){{/required}} )
|
||||||
{
|
{
|
||||||
{{#items.isPrimitiveType}}localVarJsonArray.push_back(ModelBase::toJson(localVarItem));
|
localVarJsonArray.push_back(ModelBase::toJson(localVarItem));
|
||||||
{{/items.isPrimitiveType}}{{^items.isPrimitiveType}}{{#items.isString}}localVarJsonArray.push_back(ModelBase::toJson(localVarItem));
|
|
||||||
{{/items.isString}}{{^items.isString}}{{#items.isDateTime}}localVarJsonArray.push_back(ModelBase::toJson(localVarItem));
|
|
||||||
{{/items.isDateTime}}{{^items.isDateTime}}localVarJsonArray.push_back( localVarItem.get() ? localVarItem->toJson() : web::json::value::null() );
|
|
||||||
{{/items.isDateTime}}{{/items.isString}}{{/items.isPrimitiveType}}
|
|
||||||
}
|
}
|
||||||
localVarMultipart->add(ModelBase::toHttpContent(utility::conversions::to_string_t("{{paramName}}"), web::json::value::array(localVarJsonArray), utility::conversions::to_string_t("application/json")));
|
localVarMultipart->add(ModelBase::toHttpContent(utility::conversions::to_string_t("{{paramName}}"), localVarJsonArray, utility::conversions::to_string_t("application/json")));
|
||||||
}{{/isListContainer}}
|
}{{/isListContainer}}{{#isMapContainer}}
|
||||||
{{^isListContainer}}{{#isString}}localVarMultipart->add(ModelBase::toHttpContent(utility::conversions::to_string_t("{{paramName}}"), {{paramName}}));
|
{
|
||||||
|
std::map<utility::string_t, web::json::value> localVarJsonMap;
|
||||||
|
for( auto& localVarItem : {{paramName}}{{^required}}.get(){{/required}} )
|
||||||
|
{
|
||||||
|
web::json::value jval;
|
||||||
|
localVarJsonMap.insert( std::pair<utility::string_t, web::json::value>(localVarItem.first, ModelBase::toJson(localVarItem.second) ));
|
||||||
|
}
|
||||||
|
localVarMultipart->add(ModelBase::toHttpContent(utility::conversions::to_string_t("{{paramName}}"), localVarJsonMap, utility::conversions::to_string_t("application/json")));
|
||||||
|
}{{/isMapContainer}}
|
||||||
|
{{^isListContainer}}{{^isMapContainer}}{{#isString}}localVarMultipart->add(ModelBase::toHttpContent(utility::conversions::to_string_t("{{paramName}}"), {{paramName}}));
|
||||||
{{/isString}}{{^isString}}if({{^required}}{{paramName}} && (*{{paramName}}){{/required}}{{#required}}{{paramName}}{{/required}}.get())
|
{{/isString}}{{^isString}}if({{^required}}{{paramName}} && (*{{paramName}}){{/required}}{{#required}}{{paramName}}{{/required}}.get())
|
||||||
{
|
{
|
||||||
{{^required}}(*{{/required}}{{paramName}}{{^required}}){{/required}}->toMultipart(localVarMultipart, utility::conversions::to_string_t("{{paramName}}"));
|
{{^required}}(*{{/required}}{{paramName}}{{^required}}){{/required}}->toMultipart(localVarMultipart, utility::conversions::to_string_t("{{paramName}}"));
|
||||||
}
|
}
|
||||||
{{/isString}}
|
{{/isString}}
|
||||||
{{/isListContainer}}
|
{{/isMapContainer}}{{/isListContainer}}{{/isPrimitiveType}}
|
||||||
{{/isPrimitiveType}}
|
|
||||||
|
|
||||||
localVarHttpBody = localVarMultipart;
|
localVarHttpBody = localVarMultipart;
|
||||||
localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary();
|
localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary();
|
||||||
@ -318,29 +320,20 @@ pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/r
|
|||||||
if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json"))
|
if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json"))
|
||||||
{
|
{
|
||||||
web::json::value localVarJson = web::json::value::parse(localVarResponse);
|
web::json::value localVarJson = web::json::value::parse(localVarResponse);
|
||||||
|
{{#isListContainer}}
|
||||||
{{#isListContainer}}for( auto& localVarItem : localVarJson.as_array() )
|
for( auto& localVarItem : localVarJson.as_array() )
|
||||||
{
|
{
|
||||||
{{#vendorExtensions.x-codegen-response.items.isPrimitiveType}}localVarResult.push_back(ModelBase::{{vendorExtensions.x-codegen-response.items.datatype}}FromJson(localVarItem));
|
{{{vendorExtensions.x-codegen-response.items.datatype}}} localVarItemObj;
|
||||||
{{/vendorExtensions.x-codegen-response.items.isPrimitiveType}}{{^vendorExtensions.x-codegen-response.items.isPrimitiveType}}{{#vendorExtensions.x-codegen-response.items.isString}}localVarResult.push_back(ModelBase::stringFromJson(localVarItem));
|
ModelBase::fromJson(localVarItem, localVarItemObj);
|
||||||
{{/vendorExtensions.x-codegen-response.items.isString}}{{^vendorExtensions.x-codegen-response.items.isString}}{{{vendorExtensions.x-codegen-response.items.datatype}}} localVarItemObj({{{vendorExtensions.x-codegen-response.items.defaultValue}}});
|
|
||||||
localVarItemObj->fromJson(localVarItem);
|
|
||||||
localVarResult.push_back(localVarItemObj);
|
localVarResult.push_back(localVarItemObj);
|
||||||
{{/vendorExtensions.x-codegen-response.items.isString}}{{/vendorExtensions.x-codegen-response.items.isPrimitiveType}}
|
}{{/isListContainer}}{{#isMapContainer}}
|
||||||
}
|
for( auto& localVarItem : localVarJson.as_object() )
|
||||||
{{/isListContainer}}{{^isListContainer}}{{#isMapContainer}}for( auto& localVarItem : localVarJson.as_object() )
|
|
||||||
{
|
{
|
||||||
{{#vendorExtensions.x-codegen-response.items.isPrimitiveType}}localVarResult[localVarItem.first] = ModelBase::{{vendorExtensions.x-codegen-response.items.datatype}}FromJson(localVarItem.second);
|
{{{vendorExtensions.x-codegen-response.items.datatype}}} localVarItemObj;
|
||||||
{{/vendorExtensions.x-codegen-response.items.isPrimitiveType}}{{^vendorExtensions.x-codegen-response.items.isPrimitiveType}}{{#vendorExtensions.x-codegen-response.items.isString}}localVarResult[localVarItem.first] = ModelBase::stringFromJson(localVarItem.second);
|
ModelBase::fromJson(localVarItem.second, localVarItemObj);
|
||||||
{{/vendorExtensions.x-codegen-response.items.isString}}{{^vendorExtensions.x-codegen-response.items.isString}}{{{vendorExtensions.x-codegen-response.items.datatype}}} localVarItemObj({{{vendorExtensions.x-codegen-response.items.defaultValue}}});
|
|
||||||
localVarItemObj->fromJson(localVarItem.second);
|
|
||||||
localVarResult[localVarItem.first] = localVarItemObj;
|
localVarResult[localVarItem.first] = localVarItemObj;
|
||||||
{{/vendorExtensions.x-codegen-response.items.isString}}{{/vendorExtensions.x-codegen-response.items.isPrimitiveType}}
|
}{{/isMapContainer}}{{^isListContainer}}{{^isMapContainer}}
|
||||||
}
|
ModelBase::fromJson(localVarJson, localVarResult);{{/isMapContainer}}{{/isListContainer}}
|
||||||
{{/isMapContainer}}{{^isMapContainer}}{{#vendorExtensions.x-codegen-response.isPrimitiveType}}{{#vendorExtensions.x-codegen-response.items.datatype}}localVarResult = ModelBase::{{vendorExtensions.x-codegen-response.items.datatype}}FromJson(localVarJson);
|
|
||||||
{{/vendorExtensions.x-codegen-response.items.datatype}}{{^vendorExtensions.x-codegen-response.items.datatype}}localVarResult = ModelBase::{{vendorExtensions.x-codegen-response.datatype}}FromJson(localVarJson);
|
|
||||||
{{/vendorExtensions.x-codegen-response.items.datatype}}{{/vendorExtensions.x-codegen-response.isPrimitiveType}}{{^vendorExtensions.x-codegen-response.isPrimitiveType}}{{#vendorExtensions.x-codegen-response.isString}}localVarResult = ModelBase::stringFromJson(localVarJson);
|
|
||||||
{{/vendorExtensions.x-codegen-response.isString}}{{^vendorExtensions.x-codegen-response.isString}}localVarResult->fromJson(localVarJson);{{/vendorExtensions.x-codegen-response.isString}}{{/vendorExtensions.x-codegen-response.isPrimitiveType}}{{/isMapContainer}}{{/isListContainer}}
|
|
||||||
}{{#vendorExtensions.x-codegen-response.isString}}
|
}{{#vendorExtensions.x-codegen-response.isString}}
|
||||||
else if(localVarResponseHttpContentType == utility::conversions::to_string_t("text/plain"))
|
else if(localVarResponseHttpContentType == utility::conversions::to_string_t("text/plain"))
|
||||||
{
|
{
|
||||||
|
@ -24,19 +24,19 @@ public:
|
|||||||
HttpContent();
|
HttpContent();
|
||||||
virtual ~HttpContent();
|
virtual ~HttpContent();
|
||||||
|
|
||||||
virtual utility::string_t getContentDisposition();
|
virtual utility::string_t getContentDisposition() const;
|
||||||
virtual void setContentDisposition( const utility::string_t& value );
|
virtual void setContentDisposition( const utility::string_t& value );
|
||||||
|
|
||||||
virtual utility::string_t getName();
|
virtual utility::string_t getName() const;
|
||||||
virtual void setName( const utility::string_t& value );
|
virtual void setName( const utility::string_t& value );
|
||||||
|
|
||||||
virtual utility::string_t getFileName();
|
virtual utility::string_t getFileName() const;
|
||||||
virtual void setFileName( const utility::string_t& value );
|
virtual void setFileName( const utility::string_t& value );
|
||||||
|
|
||||||
virtual utility::string_t getContentType();
|
virtual utility::string_t getContentType() const;
|
||||||
virtual void setContentType( const utility::string_t& value );
|
virtual void setContentType( const utility::string_t& value );
|
||||||
|
|
||||||
virtual std::shared_ptr<std::istream> getData();
|
virtual std::shared_ptr<std::istream> getData() const;
|
||||||
virtual void setData( std::shared_ptr<std::istream> value );
|
virtual void setData( std::shared_ptr<std::istream> value );
|
||||||
|
|
||||||
virtual void writeTo( std::ostream& stream );
|
virtual void writeTo( std::ostream& stream );
|
||||||
|
@ -13,7 +13,7 @@ HttpContent::~HttpContent()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
utility::string_t HttpContent::getContentDisposition()
|
utility::string_t HttpContent::getContentDisposition() const
|
||||||
{
|
{
|
||||||
return m_ContentDisposition;
|
return m_ContentDisposition;
|
||||||
}
|
}
|
||||||
@ -23,7 +23,7 @@ void HttpContent::setContentDisposition( const utility::string_t & value )
|
|||||||
m_ContentDisposition = value;
|
m_ContentDisposition = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
utility::string_t HttpContent::getName()
|
utility::string_t HttpContent::getName() const
|
||||||
{
|
{
|
||||||
return m_Name;
|
return m_Name;
|
||||||
}
|
}
|
||||||
@ -33,7 +33,7 @@ void HttpContent::setName( const utility::string_t & value )
|
|||||||
m_Name = value;
|
m_Name = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
utility::string_t HttpContent::getFileName()
|
utility::string_t HttpContent::getFileName() const
|
||||||
{
|
{
|
||||||
return m_FileName;
|
return m_FileName;
|
||||||
}
|
}
|
||||||
@ -43,7 +43,7 @@ void HttpContent::setFileName( const utility::string_t & value )
|
|||||||
m_FileName = value;
|
m_FileName = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
utility::string_t HttpContent::getContentType()
|
utility::string_t HttpContent::getContentType() const
|
||||||
{
|
{
|
||||||
return m_ContentType;
|
return m_ContentType;
|
||||||
}
|
}
|
||||||
@ -53,7 +53,7 @@ void HttpContent::setContentType( const utility::string_t & value )
|
|||||||
m_ContentType = value;
|
m_ContentType = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<std::istream> HttpContent::getData()
|
std::shared_ptr<std::istream> HttpContent::getData() const
|
||||||
{
|
{
|
||||||
return m_Data;
|
return m_Data;
|
||||||
}
|
}
|
||||||
|
@ -34,10 +34,10 @@ public:
|
|||||||
void validate() override;
|
void validate() override;
|
||||||
|
|
||||||
web::json::value toJson() const override;
|
web::json::value toJson() const override;
|
||||||
void fromJson(const web::json::value& json) override;
|
bool fromJson(const web::json::value& json) override;
|
||||||
|
|
||||||
void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
|
void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
|
||||||
void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override;
|
bool fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override;
|
||||||
|
|
||||||
enum class e{{classname}}
|
enum class e{{classname}}
|
||||||
{
|
{
|
||||||
@ -78,10 +78,10 @@ public:
|
|||||||
void validate() override;
|
void validate() override;
|
||||||
|
|
||||||
web::json::value toJson() const override;
|
web::json::value toJson() const override;
|
||||||
void fromJson(const web::json::value& json) override;
|
bool fromJson(const web::json::value& json) override;
|
||||||
|
|
||||||
void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
|
void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
|
||||||
void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override;
|
bool fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override;
|
||||||
|
|
||||||
/////////////////////////////////////////////
|
/////////////////////////////////////////////
|
||||||
/// {{classname}} members
|
/// {{classname}} members
|
||||||
@ -93,9 +93,8 @@ public:
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
{{#isContainer}}{{{dataType}}}& {{getter}}();
|
{{#isContainer}}{{{dataType}}}& {{getter}}();
|
||||||
{{/isContainer}}{{^isContainer}}{{{dataType}}} {{getter}}() const;
|
{{/isContainer}}{{^isContainer}}{{{dataType}}} {{getter}}() const;
|
||||||
{{/isContainer}}{{^required}}bool {{nameInCamelCase}}IsSet() const;
|
{{/isContainer}}bool {{nameInCamelCase}}IsSet() const;
|
||||||
void unset{{name}}();
|
void unset{{name}}();
|
||||||
{{/required}}
|
|
||||||
|
|
||||||
{{#isPrimitiveType}}
|
{{#isPrimitiveType}}
|
||||||
void {{setter}}({{{dataType}}} value);
|
void {{setter}}({{{dataType}}} value);
|
||||||
@ -111,8 +110,7 @@ protected:
|
|||||||
{{#vars}}
|
{{#vars}}
|
||||||
{{^isInherited}}
|
{{^isInherited}}
|
||||||
{{{dataType}}} m_{{name}};
|
{{{dataType}}} m_{{name}};
|
||||||
{{^required}}bool m_{{name}}IsSet;
|
bool m_{{name}}IsSet;
|
||||||
{{/required}}
|
|
||||||
{{/isInherited}}
|
{{/isInherited}}
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
};
|
};
|
||||||
|
@ -33,12 +33,13 @@ web::json::value {{classname}}::toJson() const
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void {{classname}}::fromJson(const web::json::value& val)
|
bool {{classname}}::fromJson(const web::json::value& val)
|
||||||
{
|
{
|
||||||
auto s = val.as_string();
|
auto s = val.as_string();
|
||||||
|
|
||||||
{{#allowableValues}}{{#enumVars}}
|
{{#allowableValues}}{{#enumVars}}
|
||||||
if (s == utility::conversions::to_string_t({{{value}}})) m_value = e{{classname}}::{{classname}}_{{name}};{{/enumVars}}{{/allowableValues}}
|
if (s == utility::conversions::to_string_t({{{value}}})) m_value = e{{classname}}::{{classname}}_{{name}};{{/enumVars}}{{/allowableValues}}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void {{classname}}::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const
|
void {{classname}}::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const
|
||||||
@ -57,17 +58,17 @@ void {{classname}}::toMultipart(std::shared_ptr<MultipartFormData> multipart, co
|
|||||||
multipart->add(ModelBase::toHttpContent(namePrefix, s));
|
multipart->add(ModelBase::toHttpContent(namePrefix, s));
|
||||||
}
|
}
|
||||||
|
|
||||||
void {{classname}}::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
|
bool {{classname}}::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
|
||||||
{
|
{
|
||||||
|
bool ok = true;
|
||||||
utility::string_t namePrefix = prefix;
|
utility::string_t namePrefix = prefix;
|
||||||
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t("."))
|
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t("."))
|
||||||
{
|
{
|
||||||
namePrefix += utility::conversions::to_string_t(".");
|
namePrefix += utility::conversions::to_string_t(".");
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
utility::string_t s;
|
utility::string_t s;
|
||||||
s = ModelBase::stringFromHttpContent(multipart->getContent(namePrefix));
|
ok = ModelBase::fromHttpContent(multipart->getContent(namePrefix), s);
|
||||||
e{{classname}} v;
|
e{{classname}} v;
|
||||||
|
|
||||||
{{#allowableValues}}{{#enumVars}}
|
{{#allowableValues}}{{#enumVars}}
|
||||||
@ -75,6 +76,7 @@ void {{classname}}::fromMultiPart(std::shared_ptr<MultipartFormData> multipart,
|
|||||||
|
|
||||||
setValue(v);
|
setValue(v);
|
||||||
}
|
}
|
||||||
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
{{classname}}::e{{classname}} {{classname}}::getValue() const
|
{{classname}}::e{{classname}} {{classname}}::getValue() const
|
||||||
@ -108,9 +110,7 @@ void {{classname}}::setValue({{classname}}::e{{classname}} const value)
|
|||||||
{{/isDateTime}}
|
{{/isDateTime}}
|
||||||
{{/isPrimitiveType}}
|
{{/isPrimitiveType}}
|
||||||
{{/isContainer}}
|
{{/isContainer}}
|
||||||
{{^required}}
|
|
||||||
m_{{name}}IsSet = false;
|
m_{{name}}IsSet = false;
|
||||||
{{/required}}
|
|
||||||
{{/isInherited}}
|
{{/isInherited}}
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
}
|
}
|
||||||
@ -127,263 +127,37 @@ void {{classname}}::validate()
|
|||||||
web::json::value {{classname}}::toJson() const
|
web::json::value {{classname}}::toJson() const
|
||||||
{
|
{
|
||||||
{{#parent}}
|
{{#parent}}
|
||||||
web::json::value val = this->{{{parent}}}::toJson();
|
web::json::value val = this->{{{parent}}}::toJson();{{/parent}}
|
||||||
{{/parent}}
|
|
||||||
{{^parent}}
|
{{^parent}}
|
||||||
web::json::value val = web::json::value::object();
|
web::json::value val = web::json::value::object();
|
||||||
{{/parent}}
|
{{/parent}}
|
||||||
|
{{#vars}}{{^isInherited}}
|
||||||
{{#vars}}
|
|
||||||
{{^isInherited}}
|
|
||||||
{{#isPrimitiveType}}
|
|
||||||
{{^isListContainer}}
|
|
||||||
{{^isMapContainer}}
|
|
||||||
{{^required}}
|
|
||||||
if(m_{{name}}IsSet)
|
if(m_{{name}}IsSet)
|
||||||
{
|
{
|
||||||
val[utility::conversions::to_string_t("{{baseName}}")] = ModelBase::toJson(m_{{name}});
|
val[utility::conversions::to_string_t("{{baseName}}")] = ModelBase::toJson(m_{{name}});
|
||||||
}
|
}{{/isInherited}}{{/vars}}
|
||||||
{{/required}}
|
|
||||||
{{#required}}
|
|
||||||
val[utility::conversions::to_string_t("{{baseName}}")] = ModelBase::toJson(m_{{name}});
|
|
||||||
{{/required}}
|
|
||||||
{{/isMapContainer}}
|
|
||||||
{{/isListContainer}}
|
|
||||||
{{/isPrimitiveType}}
|
|
||||||
{{#isListContainer}}
|
|
||||||
{
|
|
||||||
std::vector<web::json::value> jsonArray;
|
|
||||||
for( auto& item : m_{{name}} )
|
|
||||||
{
|
|
||||||
jsonArray.push_back(ModelBase::toJson(item));
|
|
||||||
}
|
|
||||||
{{#required}}
|
|
||||||
val[utility::conversions::to_string_t("{{baseName}}")] = web::json::value::array(jsonArray);
|
|
||||||
{{/required}}
|
|
||||||
{{^required}}
|
|
||||||
if(jsonArray.size() > 0)
|
|
||||||
{
|
|
||||||
val[utility::conversions::to_string_t("{{baseName}}")] = web::json::value::array(jsonArray);
|
|
||||||
}
|
|
||||||
{{/required}}
|
|
||||||
}
|
|
||||||
{{/isListContainer}}
|
|
||||||
{{#isMapContainer}}
|
|
||||||
{
|
|
||||||
std::vector<web::json::value> jsonArray;
|
|
||||||
for( auto& item : m_{{name}} )
|
|
||||||
{
|
|
||||||
web::json::value tmp = web::json::value::object();
|
|
||||||
tmp[utility::conversions::to_string_t("key")] = ModelBase::toJson(item.first);
|
|
||||||
tmp[utility::conversions::to_string_t("value")] = ModelBase::toJson(item.second);
|
|
||||||
jsonArray.push_back(tmp);
|
|
||||||
}
|
|
||||||
{{#required}}
|
|
||||||
val[utility::conversions::to_string_t("{{baseName}}")] = web::json::value::array(jsonArray);
|
|
||||||
{{/required}}
|
|
||||||
{{^required}}
|
|
||||||
if(jsonArray.size() > 0)
|
|
||||||
{
|
|
||||||
val[utility::conversions::to_string_t("{{baseName}}")] = web::json::value::array(jsonArray);
|
|
||||||
}
|
|
||||||
{{/required}}
|
|
||||||
}
|
|
||||||
{{/isMapContainer}}
|
|
||||||
{{^isListContainer}}
|
|
||||||
{{^isMapContainer}}
|
|
||||||
{{^isPrimitiveType}}
|
|
||||||
{{^required}}
|
|
||||||
if(m_{{name}}IsSet)
|
|
||||||
{
|
|
||||||
val[utility::conversions::to_string_t("{{baseName}}")] = ModelBase::toJson(m_{{name}});
|
|
||||||
}
|
|
||||||
{{/required}}
|
|
||||||
{{#required}}
|
|
||||||
val[utility::conversions::to_string_t("{{baseName}}")] = ModelBase::toJson(m_{{name}});
|
|
||||||
{{/required}}
|
|
||||||
{{/isPrimitiveType}}
|
|
||||||
{{/isMapContainer}}
|
|
||||||
{{/isListContainer}}
|
|
||||||
{{/isInherited}}
|
|
||||||
{{/vars}}
|
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void {{classname}}::fromJson(const web::json::value& val)
|
bool {{classname}}::fromJson(const web::json::value& val)
|
||||||
{
|
{
|
||||||
|
bool ok = true;
|
||||||
{{#parent}}
|
{{#parent}}
|
||||||
this->{{{parent}}}::fromJson(val);
|
ok &= this->{{{parent}}}::fromJson(val);
|
||||||
|
|
||||||
{{/parent}}
|
{{/parent}}
|
||||||
{{#vars}}
|
{{#vars}}{{^isInherited}}
|
||||||
{{^isInherited}}
|
|
||||||
{{#isPrimitiveType}}
|
|
||||||
{{^isListContainer}}
|
|
||||||
{{^isMapContainer}}
|
|
||||||
{{^required}}
|
|
||||||
if(val.has_field(utility::conversions::to_string_t("{{baseName}}")))
|
if(val.has_field(utility::conversions::to_string_t("{{baseName}}")))
|
||||||
{
|
{
|
||||||
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("{{baseName}}"));
|
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("{{baseName}}"));
|
||||||
if(!fieldValue.is_null())
|
if(!fieldValue.is_null())
|
||||||
{
|
{
|
||||||
{{setter}}(ModelBase::{{baseType}}FromJson(fieldValue));
|
{{{dataType}}} refVal_{{baseName}};
|
||||||
|
ok &= ModelBase::fromJson(fieldValue, refVal_{{baseName}});
|
||||||
|
{{setter}}(refVal_{{baseName}});
|
||||||
}
|
}
|
||||||
}
|
}{{/isInherited}}{{/vars}}
|
||||||
{{/required}}
|
return ok;
|
||||||
{{#required}}
|
|
||||||
{{setter}}(ModelBase::{{baseType}}FromJson(val.at(utility::conversions::to_string_t("{{baseName}}"))));
|
|
||||||
{{/required}}
|
|
||||||
{{/isMapContainer}}
|
|
||||||
{{/isListContainer}}
|
|
||||||
{{/isPrimitiveType}}
|
|
||||||
{{#isListContainer}}
|
|
||||||
{
|
|
||||||
m_{{name}}.clear();
|
|
||||||
std::vector<web::json::value> jsonArray;
|
|
||||||
{{^required}}
|
|
||||||
if(val.has_field(utility::conversions::to_string_t("{{baseName}}")))
|
|
||||||
{
|
|
||||||
{{/required}}
|
|
||||||
for( auto& item : val.at(utility::conversions::to_string_t("{{baseName}}")).as_array() )
|
|
||||||
{
|
|
||||||
{{#items.isPrimitiveType}}
|
|
||||||
m_{{name}}.push_back(ModelBase::{{items.baseType}}FromJson(item));
|
|
||||||
{{/items.isPrimitiveType}}
|
|
||||||
{{^items.isPrimitiveType}}
|
|
||||||
{{#items.isString}}
|
|
||||||
m_{{name}}.push_back(ModelBase::stringFromJson(item));
|
|
||||||
{{/items.isString}}
|
|
||||||
{{^items.isString}}
|
|
||||||
{{#items.isDateTime}}
|
|
||||||
m_{{name}}.push_back(ModelBase::dateFromJson(item));
|
|
||||||
{{/items.isDateTime}}
|
|
||||||
{{^items.isDateTime}}
|
|
||||||
if(item.is_null())
|
|
||||||
{
|
|
||||||
m_{{name}}.push_back( {{{items.datatype}}}(nullptr) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
auto newItem = std::make_shared<{{{items.datatype}}}::element_type>();
|
|
||||||
newItem->fromJson(item);
|
|
||||||
m_{{name}}.push_back( newItem );
|
|
||||||
}
|
|
||||||
{{/items.isDateTime}}
|
|
||||||
{{/items.isString}}
|
|
||||||
{{/items.isPrimitiveType}}
|
|
||||||
}
|
|
||||||
{{^required}}
|
|
||||||
}
|
|
||||||
{{/required}}
|
|
||||||
}
|
|
||||||
{{/isListContainer}}
|
|
||||||
{{#isMapContainer}}
|
|
||||||
{
|
|
||||||
m_{{name}}.clear();
|
|
||||||
std::vector<web::json::value> jsonArray;
|
|
||||||
{{^required}}
|
|
||||||
if(val.has_field(utility::conversions::to_string_t("{{baseName}}")))
|
|
||||||
{
|
|
||||||
{{/required}}
|
|
||||||
for( const auto& item : val.at(utility::conversions::to_string_t("{{baseName}}")).as_array() )
|
|
||||||
{
|
|
||||||
if(item.has_field(utility::conversions::to_string_t("key")))
|
|
||||||
{
|
|
||||||
utility::string_t key = ModelBase::stringFromJson(item.at(utility::conversions::to_string_t("key")));
|
|
||||||
{{#items.isPrimitiveType}}
|
|
||||||
m_{{name}}.insert(std::pair<utility::string_t,{{{items.datatype}}}>( key, ModelBase::{{items.baseType}}FromJson(item.at(utility::conversions::to_string_t("value")))));
|
|
||||||
{{/items.isPrimitiveType}}
|
|
||||||
{{^items.isPrimitiveType}}
|
|
||||||
{{#items.isString}}
|
|
||||||
m_{{name}}.insert(std::pair<utility::string_t,{{{items.datatype}}}>( key, ModelBase::stringFromJson(item.at(utility::conversions::to_string_t("value")))));
|
|
||||||
{{/items.isString}}
|
|
||||||
{{^items.isString}}
|
|
||||||
{{#items.isDateTime}}
|
|
||||||
m_{{name}}.insert(std::pair<utility::string_t,{{{items.datatype}}}>( key, ModelBase::dateFromJson(item.at(utility::conversions::to_string_t("value")))));
|
|
||||||
{{/items.isDateTime}}
|
|
||||||
{{^items.isDateTime}}
|
|
||||||
if(item.is_null())
|
|
||||||
{
|
|
||||||
m_{{name}}.insert(std::pair<utility::string_t,{{{items.datatype}}}>( key, {{{items.datatype}}}(nullptr) ));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
auto newItem = std::make_shared<{{{items.datatype}}}::element_type>();
|
|
||||||
newItem->fromJson(item.at(utility::conversions::to_string_t("value")));
|
|
||||||
m_{{name}}.insert(std::pair<utility::string_t,{{{items.datatype}}}>( key, newItem ));
|
|
||||||
}
|
|
||||||
{{/items.isDateTime}}
|
|
||||||
{{/items.isString}}
|
|
||||||
{{/items.isPrimitiveType}}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
{{^required}}
|
|
||||||
}
|
|
||||||
{{/required}}
|
|
||||||
}
|
|
||||||
{{/isMapContainer}}
|
|
||||||
{{^isListContainer}}
|
|
||||||
{{^isMapContainer}}
|
|
||||||
{{^isPrimitiveType}}
|
|
||||||
{{^required}}
|
|
||||||
if(val.has_field(utility::conversions::to_string_t("{{baseName}}")))
|
|
||||||
{
|
|
||||||
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("{{baseName}}"));
|
|
||||||
if(!fieldValue.is_null())
|
|
||||||
{
|
|
||||||
{{#isString}}
|
|
||||||
{{setter}}(ModelBase::stringFromJson(fieldValue));
|
|
||||||
{{/isString}}
|
|
||||||
{{#isByteArray}}
|
|
||||||
{{setter}}(ModelBase::stringFromJson(fieldValue));
|
|
||||||
{{/isByteArray}}
|
|
||||||
{{^isString}}
|
|
||||||
{{#isDateTime}}
|
|
||||||
{{setter}}(ModelBase::dateFromJson(fieldValue));
|
|
||||||
{{/isDateTime}}
|
|
||||||
{{^isDateTime}}
|
|
||||||
{{^isByteArray}}
|
|
||||||
auto newItem = std::make_shared<{{{datatype}}}::element_type>();
|
|
||||||
newItem->fromJson(fieldValue);
|
|
||||||
{{setter}}( newItem );
|
|
||||||
{{/isByteArray}}
|
|
||||||
{{/isDateTime}}
|
|
||||||
{{/isString}}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
{{/required}}
|
|
||||||
{{#required}}
|
|
||||||
{{#isString}}
|
|
||||||
{{setter}}(ModelBase::stringFromJson(val.at(utility::conversions::to_string_t("{{baseName}}"))));
|
|
||||||
{{/isString}}
|
|
||||||
{{#isByteArray}}
|
|
||||||
{{setter}}(ModelBase::stringFromJson(val[utility::conversions::to_string_t("{{baseName}}")]));
|
|
||||||
{{/isByteArray}}
|
|
||||||
{{^isString}}
|
|
||||||
{{^isByteArray}}
|
|
||||||
{{#isDateTime}}
|
|
||||||
{{setter}}
|
|
||||||
(ModelBase::dateFromJson(val.at(utility::conversions::to_string_t("{{baseName}}"))));
|
|
||||||
{{/isDateTime}}
|
|
||||||
{{^isDateTime}}
|
|
||||||
{{#vendorExtensions.x-codegen-file}}
|
|
||||||
{{setter}}(ModelBase::fileFromJson(val.at(utility::conversions::to_string_t("{{baseName}}"))));
|
|
||||||
{{/vendorExtensions.x-codegen-file}}
|
|
||||||
{{^vendorExtensions.x-codegen-file}}
|
|
||||||
auto new{{name}} = std::make_shared<{{{dataType}}}::element_type>();
|
|
||||||
new{{name}}->fromJson(val.at(utility::conversions::to_string_t("{{baseName}}")));
|
|
||||||
{{setter}}( new{{name}} );
|
|
||||||
{{/vendorExtensions.x-codegen-file}}
|
|
||||||
{{/isDateTime}}
|
|
||||||
{{/isByteArray}}
|
|
||||||
{{/isString}}
|
|
||||||
{{/required}}
|
|
||||||
{{/isPrimitiveType}}
|
|
||||||
{{/isMapContainer}}
|
|
||||||
{{/isListContainer}}
|
|
||||||
{{/isInherited}}
|
|
||||||
{{/vars}}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void {{classname}}::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const
|
void {{classname}}::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const
|
||||||
@ -393,115 +167,17 @@ void {{classname}}::toMultipart(std::shared_ptr<MultipartFormData> multipart, co
|
|||||||
{
|
{
|
||||||
namePrefix += utility::conversions::to_string_t(".");
|
namePrefix += utility::conversions::to_string_t(".");
|
||||||
}
|
}
|
||||||
|
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
{{#isPrimitiveType}}
|
|
||||||
{{^isMapContainer}}
|
|
||||||
{{^isListContainer}}
|
|
||||||
{{^required}}
|
|
||||||
if(m_{{name}}IsSet)
|
if(m_{{name}}IsSet)
|
||||||
{
|
{
|
||||||
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("{{baseName}}"), m_{{name}}));
|
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("{{baseName}}"), m_{{name}}));
|
||||||
}
|
}
|
||||||
{{/required}}
|
|
||||||
{{#required}}
|
|
||||||
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("{{baseName}}"), m_{{name}}));
|
|
||||||
{{/required}}
|
|
||||||
{{/isListContainer}}
|
|
||||||
{{/isMapContainer}}
|
|
||||||
{{/isPrimitiveType}}
|
|
||||||
{{#isListContainer}}
|
|
||||||
{
|
|
||||||
std::vector<web::json::value> jsonArray;
|
|
||||||
for( auto& item : m_{{name}} )
|
|
||||||
{
|
|
||||||
jsonArray.push_back(ModelBase::toJson(item));
|
|
||||||
}
|
|
||||||
{{#required}}multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("{{baseName}}"), web::json::value::array(jsonArray), utility::conversions::to_string_t("application/json")));
|
|
||||||
{{/required}}{{^required}}
|
|
||||||
if(jsonArray.size() > 0)
|
|
||||||
{
|
|
||||||
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("{{baseName}}"), web::json::value::array(jsonArray), utility::conversions::to_string_t("application/json")));
|
|
||||||
}
|
|
||||||
{{/required}}
|
|
||||||
}
|
|
||||||
{{/isListContainer}}
|
|
||||||
{{#isMapContainer}}
|
|
||||||
{
|
|
||||||
std::vector<web::json::value> jsonArray;
|
|
||||||
for( auto& item : m_{{name}} )
|
|
||||||
{
|
|
||||||
web::json::value tmp = web::json::value::object();
|
|
||||||
tmp[utility::conversions::to_string_t("key")] = ModelBase::toJson(item.first);
|
|
||||||
tmp[utility::conversions::to_string_t("value")] = ModelBase::toJson(item.second);
|
|
||||||
jsonArray.push_back(tmp);
|
|
||||||
}
|
|
||||||
{{#required}}multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("{{baseName}}"), web::json::value::array(jsonArray), utility::conversions::to_string_t("application/json")));
|
|
||||||
{{/required}}{{^required}}
|
|
||||||
if(jsonArray.size() > 0)
|
|
||||||
{
|
|
||||||
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("{{baseName}}"), web::json::value::array(jsonArray), utility::conversions::to_string_t("application/json")));
|
|
||||||
}
|
|
||||||
{{/required}}
|
|
||||||
}
|
|
||||||
{{/isMapContainer}}
|
|
||||||
{{^isListContainer}}
|
|
||||||
{{^isMapContainer}}
|
|
||||||
{{^isPrimitiveType}}
|
|
||||||
{{^required}}
|
|
||||||
if(m_{{name}}IsSet)
|
|
||||||
{
|
|
||||||
{{#isString}}
|
|
||||||
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("{{baseName}}"), m_{{name}}));
|
|
||||||
{{/isString}}
|
|
||||||
{{#isByteArray}}
|
|
||||||
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("{{baseName}}"), m_{{name}}));
|
|
||||||
{{/isByteArray}}
|
|
||||||
{{^isString}}
|
|
||||||
{{#isDateTime}}
|
|
||||||
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("{{baseName}}"), m_{{name}}));
|
|
||||||
{{/isDateTime}}
|
|
||||||
{{^isDateTime}}
|
|
||||||
{{^isByteArray}}if (m_{{name}}.get())
|
|
||||||
{
|
|
||||||
m_{{name}}->toMultipart(multipart, utility::conversions::to_string_t("{{baseName}}."));
|
|
||||||
}
|
|
||||||
{{/isByteArray}}
|
|
||||||
{{/isDateTime}}
|
|
||||||
{{/isString}}
|
|
||||||
}
|
|
||||||
{{/required}}
|
|
||||||
{{#required}}
|
|
||||||
{{#isString}}
|
|
||||||
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("{{baseName}}"), m_{{name}}));
|
|
||||||
{{/isString}}
|
|
||||||
{{#isByteArray}}
|
|
||||||
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("{{baseName}}"), m_{{name}}));
|
|
||||||
{{/isByteArray}}
|
|
||||||
{{^isString}}
|
|
||||||
{{#isDateTime}}
|
|
||||||
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("{{baseName}}"), m_{{name}}));
|
|
||||||
{{/isDateTime}}
|
|
||||||
{{^isDateTime}}
|
|
||||||
{{^isByteArray}}
|
|
||||||
{{#vendorExtensions.x-codegen-file}}
|
|
||||||
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("{{baseName}}"), m_{{name}}));
|
|
||||||
{{/vendorExtensions.x-codegen-file}}
|
|
||||||
{{^vendorExtensions.x-codegen-file}}
|
|
||||||
m_{{name}}->toMultipart(multipart, utility::conversions::to_string_t("{{baseName}}."));
|
|
||||||
{{/vendorExtensions.x-codegen-file}}
|
|
||||||
{{/isByteArray}}
|
|
||||||
{{/isDateTime}}
|
|
||||||
{{/isString}}
|
|
||||||
{{/required}}
|
|
||||||
{{/isPrimitiveType}}
|
|
||||||
{{/isMapContainer}}
|
|
||||||
{{/isListContainer}}
|
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
}
|
}
|
||||||
|
|
||||||
void {{classname}}::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
|
bool {{classname}}::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
|
||||||
{
|
{
|
||||||
|
bool ok = true;
|
||||||
utility::string_t namePrefix = prefix;
|
utility::string_t namePrefix = prefix;
|
||||||
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t("."))
|
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t("."))
|
||||||
{
|
{
|
||||||
@ -509,168 +185,14 @@ void {{classname}}::fromMultiPart(std::shared_ptr<MultipartFormData> multipart,
|
|||||||
}
|
}
|
||||||
|
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
{{#isPrimitiveType}}
|
|
||||||
{{^isListContainer}}
|
|
||||||
{{^isMapContainer}}
|
|
||||||
{{^required}}
|
|
||||||
if(multipart->hasContent(utility::conversions::to_string_t("{{baseName}}")))
|
if(multipart->hasContent(utility::conversions::to_string_t("{{baseName}}")))
|
||||||
{
|
{
|
||||||
{{setter}}(ModelBase::{{baseType}}FromHttpContent(multipart->getContent(utility::conversions::to_string_t("{{baseName}}"))));
|
{{{dataType}}} refVal_{{baseName}};
|
||||||
|
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t("{{baseName}}")), refVal_{{baseName}} );
|
||||||
|
{{setter}}(refVal_{{baseName}});
|
||||||
}
|
}
|
||||||
{{/required}}
|
|
||||||
{{#required}}
|
|
||||||
{{setter}}(ModelBase::{{baseType}}FromHttpContent(multipart->getContent(utility::conversions::to_string_t("{{baseName}}"))));
|
|
||||||
{{/required}}
|
|
||||||
{{/isMapContainer}}
|
|
||||||
{{/isListContainer}}
|
|
||||||
{{/isPrimitiveType}}
|
|
||||||
{{#isListContainer}}
|
|
||||||
{
|
|
||||||
m_{{name}}.clear();
|
|
||||||
{{^required}}
|
|
||||||
if(multipart->hasContent(utility::conversions::to_string_t("{{baseName}}")))
|
|
||||||
{
|
|
||||||
{{/required}}
|
|
||||||
|
|
||||||
web::json::value jsonArray = web::json::value::parse(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("{{baseName}}"))));
|
|
||||||
for( auto& item : jsonArray.as_array() )
|
|
||||||
{
|
|
||||||
{{#isPrimitiveType}}
|
|
||||||
m_{{name}}.push_back(ModelBase::{{items.baseType}}FromJson(item));
|
|
||||||
{{/isPrimitiveType}}
|
|
||||||
{{^isPrimitiveType}}
|
|
||||||
{{#items.isString}}
|
|
||||||
m_{{name}}.push_back(ModelBase::stringFromJson(item));
|
|
||||||
{{/items.isString}}
|
|
||||||
{{^items.isString}}
|
|
||||||
{{#items.isDateTime}}
|
|
||||||
m_{{name}}.push_back(ModelBase::dateFromJson(item));
|
|
||||||
{{/items.isDateTime}}
|
|
||||||
{{^items.isDateTime}}
|
|
||||||
if(item.is_null())
|
|
||||||
{
|
|
||||||
m_{{name}}.push_back( {{{items.datatype}}}(nullptr) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
auto newItem = std::make_shared<{{{items.datatype}}}::element_type>();
|
|
||||||
newItem->fromJson(item);
|
|
||||||
m_{{name}}.push_back( newItem );
|
|
||||||
}
|
|
||||||
{{/items.isDateTime}}
|
|
||||||
{{/items.isString}}
|
|
||||||
{{/isPrimitiveType}}
|
|
||||||
}
|
|
||||||
{{^required}}
|
|
||||||
}
|
|
||||||
{{/required}}
|
|
||||||
}
|
|
||||||
{{/isListContainer}}
|
|
||||||
{{#isMapContainer}}
|
|
||||||
{
|
|
||||||
m_{{name}}.clear();
|
|
||||||
{{^required}}
|
|
||||||
if(multipart->hasContent(utility::conversions::to_string_t("{{baseName}}")))
|
|
||||||
{
|
|
||||||
{{/required}}
|
|
||||||
|
|
||||||
web::json::value jsonArray = web::json::value::parse(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("{{baseName}}"))));
|
|
||||||
for( auto& item : jsonArray.as_array() )
|
|
||||||
{
|
|
||||||
utility::string_t key;
|
|
||||||
if(item.has_field(utility::conversions::to_string_t("key")))
|
|
||||||
{
|
|
||||||
key = ModelBase::stringFromJson(item[utility::conversions::to_string_t("key")]);
|
|
||||||
}
|
|
||||||
{{#items.isPrimitiveType}}
|
|
||||||
m_{{name}}.insert(std::pair<utility::string_t,{{{items.datatype}}}>( key, ModelBase::{{items.baseType}}FromJson(item[utility::conversions::to_string_t("value")])));
|
|
||||||
{{/items.isPrimitiveType}}
|
|
||||||
{{^items.isPrimitiveType}}
|
|
||||||
{{#items.isString}}
|
|
||||||
m_{{name}}.insert(std::pair<utility::string_t,{{{items.datatype}}}>( key, ModelBase::stringFromJson(item[utility::conversions::to_string_t("value")])));
|
|
||||||
{{/items.isString}}
|
|
||||||
{{^items.isString}}
|
|
||||||
{{#items.isDateTime}}
|
|
||||||
m_{{name}}.insert(std::pair<utility::string_t,{{{items.datatype}}}>( key, ModelBase::dateFromJson(item[utility::conversions::to_string_t("value")])));
|
|
||||||
{{/items.isDateTime}}
|
|
||||||
{{^items.isDateTime}}
|
|
||||||
if(item.is_null())
|
|
||||||
{
|
|
||||||
m_{{name}}.insert(std::pair<utility::string_t,{{{items.datatype}}}>( key, {{{items.datatype}}}(nullptr) ));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
auto newItem = std::make_shared<{{{items.datatype}}}::element_type>();
|
|
||||||
newItem->fromJson(item[utility::conversions::to_string_t("value")]);
|
|
||||||
m_{{name}}.insert(std::pair<utility::string_t,{{{items.datatype}}}>( key, newItem ));
|
|
||||||
}
|
|
||||||
{{/items.isDateTime}}
|
|
||||||
{{/items.isString}}
|
|
||||||
{{/items.isPrimitiveType}}
|
|
||||||
}
|
|
||||||
{{^required}}
|
|
||||||
}
|
|
||||||
{{/required}}
|
|
||||||
}
|
|
||||||
{{/isMapContainer}}
|
|
||||||
{{^isListContainer}}
|
|
||||||
{{^isMapContainer}}
|
|
||||||
{{^isPrimitiveType}}
|
|
||||||
{{^required}}
|
|
||||||
if(multipart->hasContent(utility::conversions::to_string_t("{{baseName}}")))
|
|
||||||
{
|
|
||||||
{{#isString}}
|
|
||||||
{{setter}}(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("{{baseName}}"))));
|
|
||||||
{{/isString}}
|
|
||||||
{{#isByteArray}}
|
|
||||||
{{setter}}(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("{{baseName}}"))));
|
|
||||||
{{/isByteArray}}
|
|
||||||
{{^isString}}
|
|
||||||
{{^isByteArray}}
|
|
||||||
{{#isDateTime}}
|
|
||||||
{{setter}}(ModelBase::dateFromHttpContent(multipart->getContent(utility::conversions::to_string_t("{{baseName}}"))));
|
|
||||||
{{/isDateTime}}
|
|
||||||
{{^isDateTime}}
|
|
||||||
if(multipart->hasContent(utility::conversions::to_string_t("{{baseName}}")))
|
|
||||||
{
|
|
||||||
auto newItem = std::make_shared<{{{datatype}}}::element_type>();
|
|
||||||
newItem->fromMultiPart(multipart, utility::conversions::to_string_t("{{baseName}}."));
|
|
||||||
{{setter}}( newItem );
|
|
||||||
}
|
|
||||||
{{/isDateTime}}
|
|
||||||
{{/isByteArray}}
|
|
||||||
{{/isString}}
|
|
||||||
}
|
|
||||||
{{/required}}
|
|
||||||
{{#required}}
|
|
||||||
{{#isString}}
|
|
||||||
{{setter}}(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("{{baseName}}"))));
|
|
||||||
{{/isString}}
|
|
||||||
{{#isByteArray}}
|
|
||||||
{{setter}}(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("{{baseName}}"))));
|
|
||||||
{{/isByteArray}}
|
|
||||||
{{^isString}}
|
|
||||||
{{^isByteArray}}
|
|
||||||
{{#isDateTime}}
|
|
||||||
{{setter}}(ModelBase::dateFromHttpContent(multipart->getContent(utility::conversions::to_string_t("{{baseName}}"))));
|
|
||||||
{{/isDateTime}}
|
|
||||||
{{^isDateTime}}
|
|
||||||
{{#vendorExtensions.x-codegen-file}}
|
|
||||||
{{setter}}(multipart->getContent(utility::conversions::to_string_t("{{baseName}}")));
|
|
||||||
{{/vendorExtensions.x-codegen-file}}
|
|
||||||
{{^vendorExtensions.x-codegen-file}}
|
|
||||||
auto new{{name}} = std::make_shared<{{{dataType}}}::element_type>();
|
|
||||||
new{{name}}->fromMultiPart(multipart, utility::conversions::to_string_t("{{baseName}}."));
|
|
||||||
{{setter}}( new{{name}} );
|
|
||||||
{{/vendorExtensions.x-codegen-file}}
|
|
||||||
{{/isDateTime}}
|
|
||||||
{{/isByteArray}}
|
|
||||||
{{/isString}}
|
|
||||||
{{/required}}
|
|
||||||
{{/isPrimitiveType}}
|
|
||||||
{{/isMapContainer}}
|
|
||||||
{{/isListContainer}}
|
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
@ -696,10 +218,9 @@ void {{classname}}::{{setter}}(const {{{dataType}}}& value)
|
|||||||
{{/isPrimitiveType}}
|
{{/isPrimitiveType}}
|
||||||
{
|
{
|
||||||
m_{{name}} = value;
|
m_{{name}} = value;
|
||||||
{{^required}}m_{{name}}IsSet = true;{{/required}}
|
m_{{name}}IsSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
{{^required}}
|
|
||||||
bool {{classname}}::{{nameInCamelCase}}IsSet() const
|
bool {{classname}}::{{nameInCamelCase}}IsSet() const
|
||||||
{
|
{
|
||||||
return m_{{name}}IsSet;
|
return m_{{name}}IsSet;
|
||||||
@ -709,8 +230,6 @@ void {{classname}}::unset{{name}}()
|
|||||||
{
|
{
|
||||||
m_{{name}}IsSet = false;
|
m_{{name}}IsSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
{{/required}}
|
|
||||||
{{/isInherited}}
|
{{/isInherited}}
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
{{/isEnum}}
|
{{/isEnum}}
|
||||||
|
@ -9,14 +9,15 @@
|
|||||||
#define {{modelHeaderGuardPrefix}}_ModelBase_H_
|
#define {{modelHeaderGuardPrefix}}_ModelBase_H_
|
||||||
|
|
||||||
{{{defaultInclude}}}
|
{{{defaultInclude}}}
|
||||||
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "HttpContent.h"
|
#include "HttpContent.h"
|
||||||
#include "MultipartFormData.h"
|
#include "MultipartFormData.h"
|
||||||
|
|
||||||
#include <cpprest/details/basic_types.h>
|
#include <cpprest/details/basic_types.h>
|
||||||
#include <cpprest/json.h>
|
#include <cpprest/json.h>
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
{{#modelNamespaceDeclarations}}
|
{{#modelNamespaceDeclarations}}
|
||||||
namespace {{this}} {
|
namespace {{this}} {
|
||||||
{{/modelNamespaceDeclarations}}
|
{{/modelNamespaceDeclarations}}
|
||||||
@ -30,68 +31,252 @@ public:
|
|||||||
virtual void validate() = 0;
|
virtual void validate() = 0;
|
||||||
|
|
||||||
virtual web::json::value toJson() const = 0;
|
virtual web::json::value toJson() const = 0;
|
||||||
virtual void fromJson(const web::json::value& json) = 0;
|
virtual bool fromJson( const web::json::value& json ) = 0;
|
||||||
|
|
||||||
virtual void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const = 0;
|
virtual void toMultipart( std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix ) const = 0;
|
||||||
virtual void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) = 0;
|
virtual bool fromMultiPart( std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix ) = 0;
|
||||||
|
|
||||||
static web::json::value toJson( const utility::string_t& value );
|
virtual bool isSet() const;
|
||||||
static web::json::value toJson( const utility::datetime& value );
|
|
||||||
static web::json::value toJson( std::shared_ptr<HttpContent> value );
|
|
||||||
static web::json::value toJson( std::shared_ptr<ModelBase> value );
|
|
||||||
static web::json::value toJson( int32_t value );
|
|
||||||
static web::json::value toJson( int64_t value );
|
|
||||||
static web::json::value toJson( double value );
|
|
||||||
static web::json::value toJson( bool value );
|
|
||||||
template<class T>
|
|
||||||
static web::json::value toJson(const std::vector<T>& value);
|
|
||||||
|
|
||||||
static int64_t int64_tFromJson(const web::json::value& val);
|
static utility::string_t toString( const bool val );
|
||||||
static int32_t int32_tFromJson(const web::json::value& val);
|
static utility::string_t toString( const float val );
|
||||||
static float floatFromJson(const web::json::value& val);
|
static utility::string_t toString( const double val );
|
||||||
static utility::string_t stringFromJson(const web::json::value& val);
|
static utility::string_t toString( const int32_t val );
|
||||||
static utility::datetime dateFromJson(const web::json::value& val);
|
static utility::string_t toString( const int64_t val );
|
||||||
static double doubleFromJson(const web::json::value& val);
|
static utility::string_t toString( const utility::string_t &val );
|
||||||
static bool boolFromJson(const web::json::value& val);
|
static utility::string_t toString( const utility::datetime &val );
|
||||||
static std::shared_ptr<HttpContent> fileFromJson(const web::json::value& val);
|
static utility::string_t toString( const web::json::value &val );
|
||||||
|
static utility::string_t toString( const std::shared_ptr<HttpContent>& val );
|
||||||
|
template <typename T>
|
||||||
|
static utility::string_t toString( const std::shared_ptr<T>& val );
|
||||||
|
template <typename T>
|
||||||
|
static utility::string_t toString( const std::vector<T> & val );
|
||||||
|
|
||||||
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const utility::string_t& value, const utility::string_t& contentType = utility::conversions::to_string_t(""));
|
static web::json::value toJson( bool val );
|
||||||
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const utility::datetime& value, const utility::string_t& contentType = utility::conversions::to_string_t(""));
|
static web::json::value toJson( float val );
|
||||||
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, std::shared_ptr<HttpContent> value );
|
static web::json::value toJson( double val );
|
||||||
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const web::json::value& value, const utility::string_t& contentType = utility::conversions::to_string_t("application/json") );
|
static web::json::value toJson( int32_t val );
|
||||||
|
static web::json::value toJson( int64_t val );
|
||||||
|
static web::json::value toJson( const utility::string_t& val );
|
||||||
|
static web::json::value toJson( const utility::datetime& val );
|
||||||
|
static web::json::value toJson( const web::json::value& val );
|
||||||
|
static web::json::value toJson( const std::shared_ptr<HttpContent>& val );
|
||||||
|
template<typename T>
|
||||||
|
static web::json::value toJson( const std::shared_ptr<T>& val );
|
||||||
|
template<typename T>
|
||||||
|
static web::json::value toJson( const std::vector<T>& val );
|
||||||
|
template<typename T>
|
||||||
|
static web::json::value toJson( const std::map<utility::string_t, T>& val );
|
||||||
|
|
||||||
|
static bool fromString( const utility::string_t& val, bool & );
|
||||||
|
static bool fromString( const utility::string_t& val, float & );
|
||||||
|
static bool fromString( const utility::string_t& val, double & );
|
||||||
|
static bool fromString( const utility::string_t& val, int32_t & );
|
||||||
|
static bool fromString( const utility::string_t& val, int64_t & );
|
||||||
|
static bool fromString( const utility::string_t& val, utility::string_t & );
|
||||||
|
static bool fromString( const utility::string_t& val, utility::datetime & );
|
||||||
|
static bool fromString( const utility::string_t& val, web::json::value & );
|
||||||
|
static bool fromString( const utility::string_t& val, std::shared_ptr<HttpContent> & );
|
||||||
|
template<typename T>
|
||||||
|
static bool fromString( const utility::string_t& val, std::shared_ptr<T>& );
|
||||||
|
template<typename T>
|
||||||
|
static bool fromString( const utility::string_t& val, std::vector<T> & );
|
||||||
|
template<typename T>
|
||||||
|
static bool fromString( const utility::string_t& val, std::map<utility::string_t, T> & );
|
||||||
|
|
||||||
|
static bool fromJson( const web::json::value& val, bool & );
|
||||||
|
static bool fromJson( const web::json::value& val, float & );
|
||||||
|
static bool fromJson( const web::json::value& val, double & );
|
||||||
|
static bool fromJson( const web::json::value& val, int32_t & );
|
||||||
|
static bool fromJson( const web::json::value& val, int64_t & );
|
||||||
|
static bool fromJson( const web::json::value& val, utility::string_t & );
|
||||||
|
static bool fromJson( const web::json::value& val, utility::datetime & );
|
||||||
|
static bool fromJson( const web::json::value& val, web::json::value & );
|
||||||
|
static bool fromJson( const web::json::value& val, std::shared_ptr<HttpContent> & );
|
||||||
|
template<typename T>
|
||||||
|
static bool fromJson( const web::json::value& val, std::shared_ptr<T>& );
|
||||||
|
template<typename T>
|
||||||
|
static bool fromJson( const web::json::value& val, std::vector<T> & );
|
||||||
|
template<typename T>
|
||||||
|
static bool fromJson( const web::json::value& val, std::map<utility::string_t, T> & );
|
||||||
|
|
||||||
|
|
||||||
|
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, bool value, const utility::string_t& contentType = utility::conversions::to_string_t("") );
|
||||||
|
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, float value, const utility::string_t& contentType = utility::conversions::to_string_t("") );
|
||||||
|
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, double value, const utility::string_t& contentType = utility::conversions::to_string_t("") );
|
||||||
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, int32_t value, const utility::string_t& contentType = utility::conversions::to_string_t("") );
|
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, int32_t value, const utility::string_t& contentType = utility::conversions::to_string_t("") );
|
||||||
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, int64_t value, const utility::string_t& contentType = utility::conversions::to_string_t("") );
|
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, int64_t value, const utility::string_t& contentType = utility::conversions::to_string_t("") );
|
||||||
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, double value, const utility::string_t& contentType = utility::conversions::to_string_t("") );
|
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const utility::string_t& value, const utility::string_t& contentType = utility::conversions::to_string_t(""));
|
||||||
template <class T>
|
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const utility::datetime& value, const utility::string_t& contentType = utility::conversions::to_string_t(""));
|
||||||
|
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const web::json::value& value, const utility::string_t& contentType = utility::conversions::to_string_t("application/json") );
|
||||||
|
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const std::shared_ptr<HttpContent>& );
|
||||||
|
template <typename T>
|
||||||
|
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const std::shared_ptr<T>& , const utility::string_t& contentType = utility::conversions::to_string_t("application/json") );
|
||||||
|
template <typename T>
|
||||||
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const std::vector<T>& value, const utility::string_t& contentType = utility::conversions::to_string_t("") );
|
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const std::vector<T>& value, const utility::string_t& contentType = utility::conversions::to_string_t("") );
|
||||||
|
template <typename T>
|
||||||
|
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const std::map<utility::string_t, T>& value, const utility::string_t& contentType = utility::conversions::to_string_t("") );
|
||||||
|
|
||||||
static int64_t int64_tFromHttpContent(std::shared_ptr<HttpContent> val);
|
static bool fromHttpContent( std::shared_ptr<HttpContent> val, bool & );
|
||||||
static int32_t int32_tFromHttpContent(std::shared_ptr<HttpContent> val);
|
static bool fromHttpContent( std::shared_ptr<HttpContent> val, float & );
|
||||||
static float floatFromHttpContent(std::shared_ptr<HttpContent> val);
|
static bool fromHttpContent( std::shared_ptr<HttpContent> val, double & );
|
||||||
static utility::string_t stringFromHttpContent(std::shared_ptr<HttpContent> val);
|
static bool fromHttpContent( std::shared_ptr<HttpContent> val, int64_t & );
|
||||||
static utility::datetime dateFromHttpContent(std::shared_ptr<HttpContent> val);
|
static bool fromHttpContent( std::shared_ptr<HttpContent> val, int32_t & );
|
||||||
static bool boolFromHttpContent(std::shared_ptr<HttpContent> val);
|
static bool fromHttpContent( std::shared_ptr<HttpContent> val, utility::string_t & );
|
||||||
static double doubleFromHttpContent(std::shared_ptr<HttpContent> val);
|
static bool fromHttpContent( std::shared_ptr<HttpContent> val, utility::datetime & );
|
||||||
static web::json::value valueFromHttpContent(std::shared_ptr<HttpContent> val);
|
static bool fromHttpContent( std::shared_ptr<HttpContent> val, web::json::value & );
|
||||||
|
static bool fromHttpContent( std::shared_ptr<HttpContent> val, std::shared_ptr<HttpContent>& );
|
||||||
|
template <typename T>
|
||||||
|
static bool fromHttpContent( std::shared_ptr<HttpContent> val, std::shared_ptr<T>& );
|
||||||
|
template <typename T>
|
||||||
|
static bool fromHttpContent( std::shared_ptr<HttpContent> val, std::vector<T> & );
|
||||||
|
template <typename T>
|
||||||
|
static bool fromHttpContent( std::shared_ptr<HttpContent> val, std::map<utility::string_t, T> & );
|
||||||
|
|
||||||
static utility::string_t toBase64( utility::string_t value );
|
static utility::string_t toBase64( utility::string_t value );
|
||||||
static utility::string_t toBase64( std::shared_ptr<std::istream> value );
|
static utility::string_t toBase64( std::shared_ptr<std::istream> value );
|
||||||
static std::shared_ptr<std::istream> fromBase64( const utility::string_t& encoded );
|
static std::shared_ptr<std::istream> fromBase64( const utility::string_t& encoded );
|
||||||
|
protected:
|
||||||
|
bool m_IsSet;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
template <typename T>
|
||||||
web::json::value ModelBase::toJson(const std::vector<T>& value) {
|
utility::string_t ModelBase::toString( const std::shared_ptr<T>& val )
|
||||||
std::vector<web::json::value> ret;
|
{
|
||||||
for (auto& x : value) {
|
utility::stringstream_t ss;
|
||||||
ret.push_back(toJson(x));
|
if( val != nullptr )
|
||||||
|
{
|
||||||
|
val->toJson().serialize(ss);
|
||||||
|
}
|
||||||
|
return utility::string_t(ss.str());
|
||||||
|
}
|
||||||
|
template<typename T>
|
||||||
|
utility::string_t ModelBase::toString( const std::vector<T> & val )
|
||||||
|
{
|
||||||
|
utility::string_t strArray;
|
||||||
|
for ( const auto &item : val )
|
||||||
|
{
|
||||||
|
strArray.append( toString(item) + "," );
|
||||||
|
}
|
||||||
|
if (val.count() > 0)
|
||||||
|
{
|
||||||
|
strArray.pop_back();
|
||||||
|
}
|
||||||
|
return strArray;
|
||||||
|
}
|
||||||
|
template<typename T>
|
||||||
|
web::json::value ModelBase::toJson( const std::shared_ptr<T>& val )
|
||||||
|
{
|
||||||
|
web::json::value retVal;
|
||||||
|
if(val != nullptr)
|
||||||
|
{
|
||||||
|
retVal = val->toJson();
|
||||||
|
}
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
template<typename T>
|
||||||
|
web::json::value ModelBase::toJson( const std::vector<T>& value )
|
||||||
|
{
|
||||||
|
std::vector<web::json::value> ret;
|
||||||
|
for ( const auto& x : value )
|
||||||
|
{
|
||||||
|
ret.push_back( toJson(x) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return web::json::value::array(ret);
|
return web::json::value::array(ret);
|
||||||
}
|
}
|
||||||
|
template<typename T>
|
||||||
template <class T>
|
web::json::value ModelBase::toJson( const std::map<utility::string_t, T>& val )
|
||||||
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, const std::vector<T>& value, const utility::string_t& contentType ) {
|
{
|
||||||
|
web::json::value obj;
|
||||||
|
for ( const auto &itemkey : val )
|
||||||
|
{
|
||||||
|
obj[itemkey.first] = toJson( itemkey.second );
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
template<typename T>
|
||||||
|
bool ModelBase::fromString( const utility::string_t& val, std::shared_ptr<T>& outVal )
|
||||||
|
{
|
||||||
|
bool ok = false;
|
||||||
|
if(outVal == nullptr)
|
||||||
|
{
|
||||||
|
outVal = std::shared_ptr<T>(new T());
|
||||||
|
}
|
||||||
|
if( outVal != nullptr )
|
||||||
|
{
|
||||||
|
ok = outVal->fromJson(web::json::value::parse(val));
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
template<typename T>
|
||||||
|
bool ModelBase::fromJson( const web::json::value& val, std::shared_ptr<T> &outVal )
|
||||||
|
{
|
||||||
|
bool ok = false;
|
||||||
|
if(outVal == nullptr)
|
||||||
|
{
|
||||||
|
outVal = std::shared_ptr<T>(new T());
|
||||||
|
}
|
||||||
|
if( outVal != nullptr )
|
||||||
|
{
|
||||||
|
ok = outVal->fromJson(val);
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
template<typename T>
|
||||||
|
bool ModelBase::fromJson( const web::json::value& val, std::vector<T> &outVal )
|
||||||
|
{
|
||||||
|
bool ok = true;
|
||||||
|
if (val.is_array())
|
||||||
|
{
|
||||||
|
for (const auto jitem : val.as_array())
|
||||||
|
{
|
||||||
|
T item;
|
||||||
|
ok &= fromJson(jitem, item);
|
||||||
|
outVal.push_back(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ok = false;
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
template<typename T>
|
||||||
|
bool ModelBase::fromJson( const web::json::value& jval, std::map<utility::string_t, T> &outVal )
|
||||||
|
{
|
||||||
|
bool ok = true;
|
||||||
|
if ( jval.is_object() )
|
||||||
|
{
|
||||||
|
auto obj = jval.as_object();
|
||||||
|
for( auto objItr = obj.begin() ; objItr != obj.end() ; objItr++ )
|
||||||
|
{
|
||||||
|
T itemVal;
|
||||||
|
ok &= fromJson(objItr->second, itemVal);
|
||||||
|
outVal.insert(std::pair<utility::string_t, T>(objItr->first, itemVal));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ok = false;
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
std::shared_ptr<HttpContent> ModelBase::toHttpContent(const utility::string_t& name, const std::shared_ptr<T>& value , const utility::string_t& contentType )
|
||||||
|
{
|
||||||
|
std::shared_ptr<HttpContent> content( new HttpContent );
|
||||||
|
if (value != nullptr )
|
||||||
|
{
|
||||||
|
content->setName( name );
|
||||||
|
content->setContentDisposition( utility::conversions::to_string_t("form-data") );
|
||||||
|
content->setContentType( contentType );
|
||||||
|
content->setData( std::shared_ptr<std::istream>( new std::stringstream( utility::conversions::to_utf8string( value->toJson().serialize() ) ) ) );
|
||||||
|
}
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, const std::vector<T>& value, const utility::string_t& contentType )
|
||||||
|
{
|
||||||
web::json::value json_array = ModelBase::toJson(value);
|
web::json::value json_array = ModelBase::toJson(value);
|
||||||
std::shared_ptr<HttpContent> content( new HttpContent );
|
std::shared_ptr<HttpContent> content( new HttpContent );
|
||||||
content->setName( name );
|
content->setName( name );
|
||||||
@ -100,7 +285,39 @@ std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t&
|
|||||||
content->setData( std::shared_ptr<std::istream>( new std::stringstream( utility::conversions::to_utf8string(json_array.serialize()) ) ) );
|
content->setData( std::shared_ptr<std::istream>( new std::stringstream( utility::conversions::to_utf8string(json_array.serialize()) ) ) );
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
template <typename T>
|
||||||
|
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, const std::map<utility::string_t, T>& value, const utility::string_t& contentType )
|
||||||
|
{
|
||||||
|
web::json::value jobj = ModelBase::toJson(value);
|
||||||
|
std::shared_ptr<HttpContent> content( new HttpContent );
|
||||||
|
content->setName( name );
|
||||||
|
content->setContentDisposition( utility::conversions::to_string_t("form-data") );
|
||||||
|
content->setContentType( contentType );
|
||||||
|
content->setData( std::shared_ptr<std::istream>( new std::stringstream( utility::conversions::to_utf8string(jobj.serialize()) ) ) );
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
bool ModelBase::fromHttpContent( std::shared_ptr<HttpContent> val, std::shared_ptr<T>& outVal )
|
||||||
|
{
|
||||||
|
utility::string_t str;
|
||||||
|
if(val == nullptr) return false;
|
||||||
|
if( outVal == nullptr )
|
||||||
|
{
|
||||||
|
outVal = std::shared_ptr<T>(new T());
|
||||||
|
}
|
||||||
|
ModelBase::fromHttpContent(val, str);
|
||||||
|
return fromString(str, outVal);
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
bool ModelBase::fromHttpContent( std::shared_ptr<HttpContent> val, std::vector<T> & )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
bool ModelBase::fromHttpContent( std::shared_ptr<HttpContent> val, std::map<utility::string_t, T> & )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
{{#modelNamespaceDeclarations}}
|
{{#modelNamespaceDeclarations}}
|
||||||
}
|
}
|
||||||
{{/modelNamespaceDeclarations}}
|
{{/modelNamespaceDeclarations}}
|
||||||
|
@ -5,20 +5,80 @@
|
|||||||
namespace {{this}} {
|
namespace {{this}} {
|
||||||
{{/modelNamespaceDeclarations}}
|
{{/modelNamespaceDeclarations}}
|
||||||
|
|
||||||
ModelBase::ModelBase()
|
ModelBase::ModelBase(): m_IsSet(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
ModelBase::~ModelBase()
|
ModelBase::~ModelBase()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
bool ModelBase::isSet() const
|
||||||
web::json::value ModelBase::toJson( const utility::string_t& value )
|
|
||||||
{
|
{
|
||||||
return web::json::value::string(value);
|
return m_IsSet;
|
||||||
}
|
}
|
||||||
web::json::value ModelBase::toJson( const utility::datetime& value )
|
utility::string_t ModelBase::toString( const bool val )
|
||||||
{
|
{
|
||||||
return web::json::value::string(value.to_string(utility::datetime::ISO_8601));
|
utility::stringstream_t ss;
|
||||||
|
ss << val;
|
||||||
|
return utility::string_t(ss.str());
|
||||||
|
}
|
||||||
|
utility::string_t ModelBase::toString( const float val )
|
||||||
|
{
|
||||||
|
utility::stringstream_t ss;
|
||||||
|
ss << val;
|
||||||
|
return utility::string_t(ss.str());
|
||||||
|
}
|
||||||
|
utility::string_t ModelBase::toString( const double val )
|
||||||
|
{
|
||||||
|
utility::stringstream_t ss;
|
||||||
|
ss << val;
|
||||||
|
return utility::string_t(ss.str());
|
||||||
|
}
|
||||||
|
utility::string_t ModelBase::toString( const int32_t val )
|
||||||
|
{
|
||||||
|
utility::stringstream_t ss;
|
||||||
|
ss << val;
|
||||||
|
return utility::string_t(ss.str());
|
||||||
|
}
|
||||||
|
utility::string_t ModelBase::toString( const int64_t val )
|
||||||
|
{
|
||||||
|
utility::stringstream_t ss;
|
||||||
|
ss << val;
|
||||||
|
return utility::string_t(ss.str());
|
||||||
|
}
|
||||||
|
utility::string_t ModelBase::toString (const utility::string_t &val )
|
||||||
|
{
|
||||||
|
utility::stringstream_t ss;
|
||||||
|
ss << val;
|
||||||
|
return utility::string_t(ss.str());
|
||||||
|
}
|
||||||
|
utility::string_t ModelBase::toString( const utility::datetime &val )
|
||||||
|
{
|
||||||
|
return val.to_string(utility::datetime::ISO_8601);
|
||||||
|
}
|
||||||
|
utility::string_t ModelBase::toString( const web::json::value &val )
|
||||||
|
{
|
||||||
|
return val.serialize();
|
||||||
|
}
|
||||||
|
utility::string_t ModelBase::toString( const std::shared_ptr<HttpContent>& val )
|
||||||
|
{
|
||||||
|
utility::stringstream_t ss;
|
||||||
|
if( val != nullptr )
|
||||||
|
{
|
||||||
|
ss << val->getData();
|
||||||
|
}
|
||||||
|
return utility::string_t(ss.str());
|
||||||
|
}
|
||||||
|
web::json::value ModelBase::toJson(bool value)
|
||||||
|
{
|
||||||
|
return web::json::value::boolean(value);
|
||||||
|
}
|
||||||
|
web::json::value ModelBase::toJson( float value )
|
||||||
|
{
|
||||||
|
return web::json::value::number(value);
|
||||||
|
}
|
||||||
|
web::json::value ModelBase::toJson( double value )
|
||||||
|
{
|
||||||
|
return web::json::value::number(value);
|
||||||
}
|
}
|
||||||
web::json::value ModelBase::toJson( int32_t value )
|
web::json::value ModelBase::toJson( int32_t value )
|
||||||
{
|
{
|
||||||
@ -28,88 +88,259 @@ web::json::value ModelBase::toJson( int64_t value )
|
|||||||
{
|
{
|
||||||
return web::json::value::number(value);
|
return web::json::value::number(value);
|
||||||
}
|
}
|
||||||
web::json::value ModelBase::toJson( double value )
|
web::json::value ModelBase::toJson( const utility::string_t& value )
|
||||||
{
|
{
|
||||||
return web::json::value::number(value);
|
return web::json::value::string(value);
|
||||||
}
|
}
|
||||||
web::json::value ModelBase::toJson(bool value) {
|
web::json::value ModelBase::toJson( const utility::datetime& value )
|
||||||
return web::json::value::boolean(value);
|
{
|
||||||
}
|
return web::json::value::string(value.to_string(utility::datetime::ISO_8601));
|
||||||
|
}
|
||||||
web::json::value ModelBase::toJson( std::shared_ptr<HttpContent> content )
|
web::json::value ModelBase::toJson( const web::json::value& value )
|
||||||
{
|
{
|
||||||
web::json::value value;
|
|
||||||
value[utility::conversions::to_string_t("ContentDisposition")] = ModelBase::toJson(content->getContentDisposition());
|
|
||||||
value[utility::conversions::to_string_t("ContentType")] = ModelBase::toJson(content->getContentType());
|
|
||||||
value[utility::conversions::to_string_t("FileName")] = ModelBase::toJson(content->getFileName());
|
|
||||||
value[utility::conversions::to_string_t("InputStream")] = web::json::value::string( ModelBase::toBase64(content->getData()) );
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
web::json::value ModelBase::toJson( const std::shared_ptr<HttpContent>& content )
|
||||||
std::shared_ptr<HttpContent> ModelBase::fileFromJson(const web::json::value& val)
|
|
||||||
{
|
{
|
||||||
std::shared_ptr<HttpContent> content(new HttpContent);
|
web::json::value value;
|
||||||
|
if(content != nullptr)
|
||||||
if(val.has_field(utility::conversions::to_string_t("ContentDisposition")))
|
|
||||||
{
|
{
|
||||||
content->setContentDisposition( ModelBase::stringFromJson(val.at(utility::conversions::to_string_t("ContentDisposition"))) );
|
value[utility::conversions::to_string_t("ContentDisposition")] = ModelBase::toJson(content->getContentDisposition());
|
||||||
|
value[utility::conversions::to_string_t("ContentType")] = ModelBase::toJson(content->getContentType());
|
||||||
|
value[utility::conversions::to_string_t("FileName")] = ModelBase::toJson(content->getFileName());
|
||||||
|
value[utility::conversions::to_string_t("InputStream")] = web::json::value::string( ModelBase::toBase64(content->getData()) );
|
||||||
}
|
}
|
||||||
if(val.has_field(utility::conversions::to_string_t("ContentType")))
|
return value;
|
||||||
{
|
|
||||||
content->setContentType( ModelBase::stringFromJson(val.at(utility::conversions::to_string_t("ContentType"))) );
|
|
||||||
}
|
|
||||||
if(val.has_field(utility::conversions::to_string_t("FileName")))
|
|
||||||
{
|
|
||||||
content->setFileName( ModelBase::stringFromJson(val.at(utility::conversions::to_string_t("FileName"))) );
|
|
||||||
}
|
|
||||||
if(val.has_field(utility::conversions::to_string_t("InputStream")))
|
|
||||||
{
|
|
||||||
content->setData( ModelBase::fromBase64( ModelBase::stringFromJson(val.at(utility::conversions::to_string_t("InputStream")))) );
|
|
||||||
}
|
|
||||||
|
|
||||||
return content;
|
|
||||||
}
|
}
|
||||||
|
bool ModelBase::fromString( const utility::string_t& val, bool &outVal )
|
||||||
web::json::value ModelBase::toJson( std::shared_ptr<ModelBase> content )
|
|
||||||
{
|
{
|
||||||
return content.get() ? content->toJson() : web::json::value::null();
|
utility::stringstream_t ss(val);
|
||||||
|
bool success = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ss >> outVal;
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
bool ModelBase::fromString( const utility::string_t& val, float &outVal )
|
||||||
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, const utility::string_t& value, const utility::string_t& contentType)
|
|
||||||
{
|
{
|
||||||
std::shared_ptr<HttpContent> content(new HttpContent);
|
utility::stringstream_t ss(val);
|
||||||
content->setName( name );
|
bool success = true;
|
||||||
content->setContentDisposition( utility::conversions::to_string_t("form-data") );
|
try
|
||||||
content->setContentType( contentType );
|
{
|
||||||
content->setData( std::shared_ptr<std::istream>( new std::stringstream( utility::conversions::to_utf8string(value) ) ) );
|
ss >> outVal;
|
||||||
return content;
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, const utility::datetime& value, const utility::string_t& contentType )
|
bool ModelBase::fromString( const utility::string_t& val, double &outVal )
|
||||||
|
{
|
||||||
|
utility::stringstream_t ss(val);
|
||||||
|
bool success = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ss >> outVal;
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
bool ModelBase::fromString( const utility::string_t& val, int32_t &outVal )
|
||||||
|
{
|
||||||
|
utility::stringstream_t ss(val);
|
||||||
|
bool success = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ss >> outVal;
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
bool ModelBase::fromString( const utility::string_t& val, int64_t &outVal )
|
||||||
|
{
|
||||||
|
utility::stringstream_t ss(val);
|
||||||
|
bool success = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ss >> outVal;
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
bool ModelBase::fromString( const utility::string_t& val, utility::string_t &outVal )
|
||||||
|
{
|
||||||
|
utility::stringstream_t ss(val);
|
||||||
|
bool success = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ss >> outVal;
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
bool ModelBase::fromString( const utility::string_t& val, utility::datetime &outVal )
|
||||||
|
{
|
||||||
|
bool success = true;
|
||||||
|
auto dt = utility::datetime::from_string(val, utility::datetime::ISO_8601);
|
||||||
|
if( dt.is_initialized() )
|
||||||
|
{
|
||||||
|
outVal = dt;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
bool ModelBase::fromString( const utility::string_t& val, web::json::value &outVal )
|
||||||
|
{
|
||||||
|
outVal = web::json::value::parse(val);
|
||||||
|
return !outVal.is_null();
|
||||||
|
}
|
||||||
|
bool ModelBase::fromString( const utility::string_t& val, std::shared_ptr<HttpContent>& outVal )
|
||||||
|
{
|
||||||
|
bool ok = true;
|
||||||
|
if(outVal == nullptr)
|
||||||
|
{
|
||||||
|
outVal = std::shared_ptr<HttpContent>(new HttpContent());
|
||||||
|
}
|
||||||
|
std::shared_ptr<utility::stringstream_t> ssptr = std::make_shared<utility::stringstream_t>(val);
|
||||||
|
if(outVal != nullptr)
|
||||||
|
{
|
||||||
|
outVal->setData(ssptr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ok = false;
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
bool ModelBase::fromJson( const web::json::value& val, bool & outVal )
|
||||||
|
{
|
||||||
|
outVal = !val.is_boolean() ? false : val.as_bool();
|
||||||
|
return val.is_boolean();
|
||||||
|
}
|
||||||
|
bool ModelBase::fromJson( const web::json::value& val, float & outVal )
|
||||||
|
{
|
||||||
|
outVal = !val.is_double() ? std::numeric_limits<float>::quiet_NaN(): static_cast<float>(val.as_double());
|
||||||
|
return val.is_double();
|
||||||
|
}
|
||||||
|
bool ModelBase::fromJson( const web::json::value& val, double & outVal )
|
||||||
|
{
|
||||||
|
outVal = !val.is_double() ? std::numeric_limits<double>::quiet_NaN(): val.as_double();
|
||||||
|
return val.is_double() ;
|
||||||
|
}
|
||||||
|
bool ModelBase::fromJson( const web::json::value& val, int32_t & outVal )
|
||||||
|
{
|
||||||
|
outVal = !val.is_integer() ? std::numeric_limits<int32_t>::quiet_NaN() : val.as_integer();
|
||||||
|
return val.is_integer();
|
||||||
|
}
|
||||||
|
bool ModelBase::fromJson( const web::json::value& val, int64_t & outVal )
|
||||||
|
{
|
||||||
|
outVal = !val.is_null() ? std::numeric_limits<int64_t>::quiet_NaN() : val.as_number().to_int64();
|
||||||
|
return val.is_number();
|
||||||
|
}
|
||||||
|
bool ModelBase::fromJson( const web::json::value& val, utility::string_t & outVal )
|
||||||
|
{
|
||||||
|
outVal = val.is_string() ? val.as_string() : utility::conversions::to_string_t("");
|
||||||
|
return val.is_string();
|
||||||
|
}
|
||||||
|
bool ModelBase::fromJson( const web::json::value& val, utility::datetime & outVal )
|
||||||
|
{
|
||||||
|
outVal = val.is_null() ? utility::datetime::from_string(utility::conversions::to_string_t("NULL"), utility::datetime::ISO_8601) : utility::datetime::from_string(val.as_string(), utility::datetime::ISO_8601);
|
||||||
|
return outVal.is_initialized();
|
||||||
|
}
|
||||||
|
bool ModelBase::fromJson( const web::json::value& val, web::json::value & outVal )
|
||||||
|
{
|
||||||
|
outVal = val;
|
||||||
|
return !val.is_null();
|
||||||
|
}
|
||||||
|
bool ModelBase::fromJson( const web::json::value& val, std::shared_ptr<HttpContent>& content )
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
if( content != nullptr)
|
||||||
|
{
|
||||||
|
result = true;
|
||||||
|
if(content == nullptr)
|
||||||
|
{
|
||||||
|
content = std::shared_ptr<HttpContent>(new HttpContent());
|
||||||
|
}
|
||||||
|
if(val.has_field(utility::conversions::to_string_t("ContentDisposition")))
|
||||||
|
{
|
||||||
|
utility::string_t value;
|
||||||
|
result = result && ModelBase::fromJson(val.at(utility::conversions::to_string_t("ContentDisposition")), value);
|
||||||
|
content->setContentDisposition( value );
|
||||||
|
}
|
||||||
|
if(val.has_field(utility::conversions::to_string_t("ContentType")))
|
||||||
|
{
|
||||||
|
utility::string_t value;
|
||||||
|
result = result && ModelBase::fromJson(val.at(utility::conversions::to_string_t("ContentType")), value);
|
||||||
|
content->setContentType( value );
|
||||||
|
}
|
||||||
|
if(val.has_field(utility::conversions::to_string_t("FileName")))
|
||||||
|
{
|
||||||
|
utility::string_t value;
|
||||||
|
result = result && ModelBase::fromJson(val.at(utility::conversions::to_string_t("FileName")), value);
|
||||||
|
content->setFileName( value );
|
||||||
|
}
|
||||||
|
if(val.has_field(utility::conversions::to_string_t("InputStream")))
|
||||||
|
{
|
||||||
|
utility::string_t value;
|
||||||
|
result = result && ModelBase::fromJson(val.at(utility::conversions::to_string_t("InputStream")), value);
|
||||||
|
content->setData( ModelBase::fromBase64( value ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, bool value, const utility::string_t& contentType )
|
||||||
{
|
{
|
||||||
std::shared_ptr<HttpContent> content( new HttpContent );
|
std::shared_ptr<HttpContent> content( new HttpContent );
|
||||||
content->setName( name );
|
content->setName( name );
|
||||||
content->setContentDisposition( utility::conversions::to_string_t("form-data") );
|
content->setContentDisposition( utility::conversions::to_string_t("form-data") );
|
||||||
content->setContentType( contentType );
|
content->setContentType( contentType );
|
||||||
content->setData( std::shared_ptr<std::istream>( new std::stringstream( utility::conversions::to_utf8string(value.to_string(utility::datetime::ISO_8601) ) ) ) );
|
std::stringstream* valueAsStringStream = new std::stringstream();
|
||||||
|
(*valueAsStringStream) << value;
|
||||||
|
content->setData( std::shared_ptr<std::istream>( valueAsStringStream ) );
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, std::shared_ptr<HttpContent> value )
|
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, float value, const utility::string_t& contentType )
|
||||||
{
|
|
||||||
std::shared_ptr<HttpContent> content( new HttpContent );
|
|
||||||
content->setName( name );
|
|
||||||
content->setContentDisposition( value->getContentDisposition() );
|
|
||||||
content->setContentType( value->getContentType() );
|
|
||||||
content->setData( value->getData() );
|
|
||||||
content->setFileName( value->getFileName() );
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, const web::json::value& value, const utility::string_t& contentType )
|
|
||||||
{
|
{
|
||||||
std::shared_ptr<HttpContent> content( new HttpContent );
|
std::shared_ptr<HttpContent> content( new HttpContent );
|
||||||
content->setName( name );
|
content->setName( name );
|
||||||
content->setContentDisposition( utility::conversions::to_string_t("form-data") );
|
content->setContentDisposition( utility::conversions::to_string_t("form-data") );
|
||||||
content->setContentType( contentType );
|
content->setContentType( contentType );
|
||||||
content->setData( std::shared_ptr<std::istream>( new std::stringstream( utility::conversions::to_utf8string(value.serialize()) ) ) );
|
std::stringstream* valueAsStringStream = new std::stringstream();
|
||||||
|
(*valueAsStringStream) << value;
|
||||||
|
content->setData( std::shared_ptr<std::istream>( valueAsStringStream ) );
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, double value, const utility::string_t& contentType )
|
||||||
|
{
|
||||||
|
std::shared_ptr<HttpContent> content( new HttpContent );
|
||||||
|
content->setName( name );
|
||||||
|
content->setContentDisposition( utility::conversions::to_string_t("form-data") );
|
||||||
|
content->setContentType( contentType );
|
||||||
|
std::stringstream* valueAsStringStream = new std::stringstream();
|
||||||
|
(*valueAsStringStream) << value;
|
||||||
|
content->setData( std::shared_ptr<std::istream>( valueAsStringStream ) );
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, int32_t value, const utility::string_t& contentType )
|
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, int32_t value, const utility::string_t& contentType )
|
||||||
@ -134,18 +365,118 @@ std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t&
|
|||||||
content->setData( std::shared_ptr<std::istream>( valueAsStringStream) ) ;
|
content->setData( std::shared_ptr<std::istream>( valueAsStringStream) ) ;
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, double value, const utility::string_t& contentType )
|
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, const utility::string_t& value, const utility::string_t& contentType)
|
||||||
|
{
|
||||||
|
std::shared_ptr<HttpContent> content(new HttpContent);
|
||||||
|
content->setName( name );
|
||||||
|
content->setContentDisposition( utility::conversions::to_string_t("form-data") );
|
||||||
|
content->setContentType( contentType );
|
||||||
|
content->setData( std::shared_ptr<std::istream>( new std::stringstream( utility::conversions::to_utf8string(value) ) ) );
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, const utility::datetime& value, const utility::string_t& contentType )
|
||||||
{
|
{
|
||||||
std::shared_ptr<HttpContent> content( new HttpContent );
|
std::shared_ptr<HttpContent> content( new HttpContent );
|
||||||
content->setName( name );
|
content->setName( name );
|
||||||
content->setContentDisposition( utility::conversions::to_string_t("form-data") );
|
content->setContentDisposition( utility::conversions::to_string_t("form-data") );
|
||||||
content->setContentType( contentType );
|
content->setContentType( contentType );
|
||||||
std::stringstream* valueAsStringStream = new std::stringstream();
|
content->setData( std::shared_ptr<std::istream>( new std::stringstream( utility::conversions::to_utf8string(value.to_string(utility::datetime::ISO_8601) ) ) ) );
|
||||||
(*valueAsStringStream) << value;
|
|
||||||
content->setData( std::shared_ptr<std::istream>( valueAsStringStream ) );
|
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, const web::json::value& value, const utility::string_t& contentType )
|
||||||
|
{
|
||||||
|
std::shared_ptr<HttpContent> content( new HttpContent );
|
||||||
|
content->setName( name );
|
||||||
|
content->setContentDisposition( utility::conversions::to_string_t("form-data") );
|
||||||
|
content->setContentType( contentType );
|
||||||
|
content->setData( std::shared_ptr<std::istream>( new std::stringstream( utility::conversions::to_utf8string(value.serialize()) ) ) );
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, const std::shared_ptr<HttpContent>& value )
|
||||||
|
{
|
||||||
|
std::shared_ptr<HttpContent> content( new HttpContent );
|
||||||
|
if( value != nullptr )
|
||||||
|
{
|
||||||
|
content->setName( name );
|
||||||
|
content->setContentDisposition( value->getContentDisposition() );
|
||||||
|
content->setContentType( value->getContentType() );
|
||||||
|
content->setData( value->getData() );
|
||||||
|
content->setFileName( value->getFileName() );
|
||||||
|
}
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
bool ModelBase::fromHttpContent(std::shared_ptr<HttpContent> val, bool & outVal )
|
||||||
|
{
|
||||||
|
utility::string_t str;
|
||||||
|
if( val == nullptr ) return false;
|
||||||
|
ModelBase::fromHttpContent(val, str);
|
||||||
|
return fromString(str, outVal);
|
||||||
|
}
|
||||||
|
bool ModelBase::fromHttpContent(std::shared_ptr<HttpContent> val, float & outVal )
|
||||||
|
{
|
||||||
|
utility::string_t str;
|
||||||
|
if( val == nullptr ) return false;
|
||||||
|
ModelBase::fromHttpContent(val, str);
|
||||||
|
return fromString(str, outVal);
|
||||||
|
}
|
||||||
|
bool ModelBase::fromHttpContent(std::shared_ptr<HttpContent> val, double & outVal )
|
||||||
|
{
|
||||||
|
utility::string_t str;
|
||||||
|
if( val == nullptr ) return false;
|
||||||
|
ModelBase::fromHttpContent(val, str);
|
||||||
|
return fromString(str, outVal);
|
||||||
|
}
|
||||||
|
bool ModelBase::fromHttpContent(std::shared_ptr<HttpContent> val, int32_t & outVal )
|
||||||
|
{
|
||||||
|
utility::string_t str;
|
||||||
|
if( val == nullptr ) return false;
|
||||||
|
ModelBase::fromHttpContent(val, str);
|
||||||
|
return fromString(str, outVal);
|
||||||
|
}
|
||||||
|
bool ModelBase::fromHttpContent(std::shared_ptr<HttpContent> val, int64_t & outVal )
|
||||||
|
{
|
||||||
|
utility::string_t str;
|
||||||
|
if( val == nullptr ) return false;
|
||||||
|
ModelBase::fromHttpContent(val, str);
|
||||||
|
return fromString(str, outVal);
|
||||||
|
}
|
||||||
|
bool ModelBase::fromHttpContent(std::shared_ptr<HttpContent> val, utility::string_t & outVal )
|
||||||
|
{
|
||||||
|
if( val == nullptr ) return false;
|
||||||
|
std::shared_ptr<std::istream> data = val->getData();
|
||||||
|
data->seekg( 0, data->beg );
|
||||||
|
|
||||||
|
std::string str((std::istreambuf_iterator<char>(*data.get())),
|
||||||
|
std::istreambuf_iterator<char>());
|
||||||
|
outVal = utility::conversions::to_string_t(str);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool ModelBase::fromHttpContent(std::shared_ptr<HttpContent> val, utility::datetime & outVal )
|
||||||
|
{
|
||||||
|
utility::string_t str;
|
||||||
|
if( val == nullptr ) return false;
|
||||||
|
ModelBase::fromHttpContent(val, str);
|
||||||
|
outVal = utility::datetime::from_string(str, utility::datetime::ISO_8601);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool ModelBase::fromHttpContent(std::shared_ptr<HttpContent> val, web::json::value & outVal )
|
||||||
|
{
|
||||||
|
utility::string_t str;
|
||||||
|
if( val == nullptr ) return false;
|
||||||
|
ModelBase::fromHttpContent(val, str);
|
||||||
|
return fromString(str, outVal);
|
||||||
|
}
|
||||||
|
bool ModelBase::fromHttpContent(std::shared_ptr<HttpContent> val, std::shared_ptr<HttpContent>& outVal )
|
||||||
|
{
|
||||||
|
utility::string_t str;
|
||||||
|
if( val == nullptr ) return false;
|
||||||
|
if( outVal == nullptr )
|
||||||
|
{
|
||||||
|
outVal = std::shared_ptr<HttpContent>(new HttpContent());
|
||||||
|
}
|
||||||
|
ModelBase::fromHttpContent(val, str);
|
||||||
|
return fromString(str, outVal);
|
||||||
|
}
|
||||||
// base64 encoding/decoding based on : https://en.wikibooks.org/wiki/Algorithm_Implementation/Miscellaneous/Base64#C.2B.2B
|
// base64 encoding/decoding based on : https://en.wikibooks.org/wiki/Algorithm_Implementation/Miscellaneous/Base64#C.2B.2B
|
||||||
const static char Base64Chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
const static char Base64Chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||||
const static char Base64PadChar = '=';
|
const static char Base64PadChar = '=';
|
||||||
@ -195,8 +526,6 @@ utility::string_t ModelBase::toBase64( std::shared_ptr<std::istream> value )
|
|||||||
}
|
}
|
||||||
return base64;
|
return base64;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::shared_ptr<std::istream> ModelBase::fromBase64( const utility::string_t& encoded )
|
std::shared_ptr<std::istream> ModelBase::fromBase64( const utility::string_t& encoded )
|
||||||
{
|
{
|
||||||
std::shared_ptr<std::stringstream> result(new std::stringstream);
|
std::shared_ptr<std::stringstream> result(new std::stringstream);
|
||||||
@ -263,107 +592,6 @@ std::shared_ptr<std::istream> ModelBase::fromBase64( const utility::string_t& en
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t ModelBase::int64_tFromJson(const web::json::value& val)
|
|
||||||
{
|
|
||||||
return val.is_null() ? std::numeric_limits<int64_t>::quiet_NaN() : val.as_number().to_int64();
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t ModelBase::int32_tFromJson(const web::json::value& val)
|
|
||||||
{
|
|
||||||
return val.is_null() ? std::numeric_limits<int32_t>::quiet_NaN() : val.as_integer();
|
|
||||||
}
|
|
||||||
|
|
||||||
float ModelBase::floatFromJson(const web::json::value& val)
|
|
||||||
{
|
|
||||||
return val.is_null() ? std::numeric_limits<float>::quiet_NaN() : static_cast<float>(val.as_double());
|
|
||||||
}
|
|
||||||
|
|
||||||
utility::string_t ModelBase::stringFromJson(const web::json::value& val)
|
|
||||||
{
|
|
||||||
return val.is_string() ? val.as_string() : utility::conversions::to_string_t("");
|
|
||||||
}
|
|
||||||
|
|
||||||
utility::datetime ModelBase::dateFromJson(const web::json::value& val)
|
|
||||||
{
|
|
||||||
return val.is_null() ? utility::datetime::from_string(utility::conversions::to_string_t("NULL"), utility::datetime::ISO_8601) : utility::datetime::from_string(val.as_string(), utility::datetime::ISO_8601);
|
|
||||||
}
|
|
||||||
bool ModelBase::boolFromJson(const web::json::value& val)
|
|
||||||
{
|
|
||||||
return val.is_null() ? false : val.as_bool();
|
|
||||||
}
|
|
||||||
double ModelBase::doubleFromJson(const web::json::value& val)
|
|
||||||
{
|
|
||||||
return val.is_null() ? std::numeric_limits<double>::quiet_NaN(): val.as_double();
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t ModelBase::int64_tFromHttpContent(std::shared_ptr<HttpContent> val)
|
|
||||||
{
|
|
||||||
utility::string_t str = ModelBase::stringFromHttpContent(val);
|
|
||||||
|
|
||||||
utility::stringstream_t ss(str);
|
|
||||||
int64_t result = 0;
|
|
||||||
ss >> result;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
int32_t ModelBase::int32_tFromHttpContent(std::shared_ptr<HttpContent> val)
|
|
||||||
{
|
|
||||||
utility::string_t str = ModelBase::stringFromHttpContent(val);
|
|
||||||
|
|
||||||
utility::stringstream_t ss(str);
|
|
||||||
int32_t result = 0;
|
|
||||||
ss >> result;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
float ModelBase::floatFromHttpContent(std::shared_ptr<HttpContent> val)
|
|
||||||
{
|
|
||||||
utility::string_t str = ModelBase::stringFromHttpContent(val);
|
|
||||||
|
|
||||||
utility::stringstream_t ss(str);
|
|
||||||
float result = 0;
|
|
||||||
ss >> result;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
utility::string_t ModelBase::stringFromHttpContent(std::shared_ptr<HttpContent> val)
|
|
||||||
{
|
|
||||||
std::shared_ptr<std::istream> data = val->getData();
|
|
||||||
data->seekg( 0, data->beg );
|
|
||||||
|
|
||||||
std::string str((std::istreambuf_iterator<char>(*data.get())),
|
|
||||||
std::istreambuf_iterator<char>());
|
|
||||||
|
|
||||||
return utility::conversions::to_string_t(str);
|
|
||||||
}
|
|
||||||
utility::datetime ModelBase::dateFromHttpContent(std::shared_ptr<HttpContent> val)
|
|
||||||
{
|
|
||||||
utility::string_t str = ModelBase::stringFromHttpContent(val);
|
|
||||||
return utility::datetime::from_string(str, utility::datetime::ISO_8601);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ModelBase::boolFromHttpContent(std::shared_ptr<HttpContent> val)
|
|
||||||
{
|
|
||||||
utility::string_t str = ModelBase::stringFromHttpContent(val);
|
|
||||||
|
|
||||||
utility::stringstream_t ss(str);
|
|
||||||
bool result = false;
|
|
||||||
ss >> result;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
double ModelBase::doubleFromHttpContent(std::shared_ptr<HttpContent> val)
|
|
||||||
{
|
|
||||||
utility::string_t str = ModelBase::stringFromHttpContent(val);
|
|
||||||
|
|
||||||
utility::stringstream_t ss(str);
|
|
||||||
double result = 0.0;
|
|
||||||
ss >> result;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
web::json::value ModelBase::valueFromHttpContent(std::shared_ptr<HttpContent> val)
|
|
||||||
{
|
|
||||||
utility::string_t str = ModelBase::stringFromHttpContent(val);
|
|
||||||
return web::json::value::parse(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
{{#modelNamespaceDeclarations}}
|
{{#modelNamespaceDeclarations}}
|
||||||
}
|
}
|
||||||
{{/modelNamespaceDeclarations}}
|
{{/modelNamespaceDeclarations}}
|
||||||
|
@ -29,10 +29,10 @@ public:
|
|||||||
void validate() override;
|
void validate() override;
|
||||||
|
|
||||||
web::json::value toJson() const override;
|
web::json::value toJson() const override;
|
||||||
void fromJson(const web::json::value& json) override;
|
bool fromJson(const web::json::value& json) override;
|
||||||
|
|
||||||
void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
|
void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
|
||||||
void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override;
|
bool fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override;
|
||||||
|
|
||||||
/////////////////////////////////////////////
|
/////////////////////////////////////////////
|
||||||
/// Object manipulation
|
/// Object manipulation
|
||||||
|
@ -16,7 +16,7 @@ Object::~Object()
|
|||||||
|
|
||||||
void Object::validate()
|
void Object::validate()
|
||||||
{
|
{
|
||||||
// TODO: implement validation
|
|
||||||
}
|
}
|
||||||
|
|
||||||
web::json::value Object::toJson() const
|
web::json::value Object::toJson() const
|
||||||
@ -24,12 +24,14 @@ web::json::value Object::toJson() const
|
|||||||
return m_object;
|
return m_object;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Object::fromJson(const web::json::value& val)
|
bool Object::fromJson(const web::json::value& val)
|
||||||
{
|
{
|
||||||
if (val.is_object())
|
if (val.is_object())
|
||||||
{
|
{
|
||||||
m_object = val;
|
m_object = val;
|
||||||
|
m_IsSet = true;
|
||||||
}
|
}
|
||||||
|
return isSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Object::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const
|
void Object::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const
|
||||||
@ -42,7 +44,7 @@ void Object::toMultipart(std::shared_ptr<MultipartFormData> multipart, const uti
|
|||||||
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("object"), m_object));
|
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("object"), m_object));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Object::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
|
bool Object::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
|
||||||
{
|
{
|
||||||
utility::string_t namePrefix = prefix;
|
utility::string_t namePrefix = prefix;
|
||||||
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t("."))
|
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t("."))
|
||||||
@ -50,7 +52,11 @@ void Object::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const u
|
|||||||
namePrefix += utility::conversions::to_string_t(".");
|
namePrefix += utility::conversions::to_string_t(".");
|
||||||
}
|
}
|
||||||
|
|
||||||
m_object = ModelBase::valueFromHttpContent(multipart->getContent(namePrefix + utility::conversions::to_string_t("object")));
|
if( ModelBase::fromHttpContent(multipart->getContent(namePrefix + utility::conversions::to_string_t("object")), m_object ) )
|
||||||
|
{
|
||||||
|
m_IsSet = true;
|
||||||
|
}
|
||||||
|
return isSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
web::json::value Object::getValue(const utility::string_t& key) const
|
web::json::value Object::getValue(const utility::string_t& key) const
|
||||||
@ -61,7 +67,11 @@ web::json::value Object::getValue(const utility::string_t& key) const
|
|||||||
|
|
||||||
void Object::setValue(const utility::string_t& key, const web::json::value& value)
|
void Object::setValue(const utility::string_t& key, const web::json::value& value)
|
||||||
{
|
{
|
||||||
m_object[key] = value;
|
if( !value.is_null() )
|
||||||
|
{
|
||||||
|
m_object[key] = value;
|
||||||
|
m_IsSet = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{{#modelNamespaceDeclarations}}
|
{{#modelNamespaceDeclarations}}
|
||||||
|
@ -24,7 +24,7 @@ HttpContent::~HttpContent()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
utility::string_t HttpContent::getContentDisposition()
|
utility::string_t HttpContent::getContentDisposition() const
|
||||||
{
|
{
|
||||||
return m_ContentDisposition;
|
return m_ContentDisposition;
|
||||||
}
|
}
|
||||||
@ -34,7 +34,7 @@ void HttpContent::setContentDisposition( const utility::string_t & value )
|
|||||||
m_ContentDisposition = value;
|
m_ContentDisposition = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
utility::string_t HttpContent::getName()
|
utility::string_t HttpContent::getName() const
|
||||||
{
|
{
|
||||||
return m_Name;
|
return m_Name;
|
||||||
}
|
}
|
||||||
@ -44,7 +44,7 @@ void HttpContent::setName( const utility::string_t & value )
|
|||||||
m_Name = value;
|
m_Name = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
utility::string_t HttpContent::getFileName()
|
utility::string_t HttpContent::getFileName() const
|
||||||
{
|
{
|
||||||
return m_FileName;
|
return m_FileName;
|
||||||
}
|
}
|
||||||
@ -54,7 +54,7 @@ void HttpContent::setFileName( const utility::string_t & value )
|
|||||||
m_FileName = value;
|
m_FileName = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
utility::string_t HttpContent::getContentType()
|
utility::string_t HttpContent::getContentType() const
|
||||||
{
|
{
|
||||||
return m_ContentType;
|
return m_ContentType;
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ void HttpContent::setContentType( const utility::string_t & value )
|
|||||||
m_ContentType = value;
|
m_ContentType = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<std::istream> HttpContent::getData()
|
std::shared_ptr<std::istream> HttpContent::getData() const
|
||||||
{
|
{
|
||||||
return m_Data;
|
return m_Data;
|
||||||
}
|
}
|
||||||
|
@ -35,19 +35,19 @@ public:
|
|||||||
HttpContent();
|
HttpContent();
|
||||||
virtual ~HttpContent();
|
virtual ~HttpContent();
|
||||||
|
|
||||||
virtual utility::string_t getContentDisposition();
|
virtual utility::string_t getContentDisposition() const;
|
||||||
virtual void setContentDisposition( const utility::string_t& value );
|
virtual void setContentDisposition( const utility::string_t& value );
|
||||||
|
|
||||||
virtual utility::string_t getName();
|
virtual utility::string_t getName() const;
|
||||||
virtual void setName( const utility::string_t& value );
|
virtual void setName( const utility::string_t& value );
|
||||||
|
|
||||||
virtual utility::string_t getFileName();
|
virtual utility::string_t getFileName() const;
|
||||||
virtual void setFileName( const utility::string_t& value );
|
virtual void setFileName( const utility::string_t& value );
|
||||||
|
|
||||||
virtual utility::string_t getContentType();
|
virtual utility::string_t getContentType() const;
|
||||||
virtual void setContentType( const utility::string_t& value );
|
virtual void setContentType( const utility::string_t& value );
|
||||||
|
|
||||||
virtual std::shared_ptr<std::istream> getData();
|
virtual std::shared_ptr<std::istream> getData() const;
|
||||||
virtual void setData( std::shared_ptr<std::istream> value );
|
virtual void setData( std::shared_ptr<std::istream> value );
|
||||||
|
|
||||||
virtual void writeTo( std::ostream& stream );
|
virtual void writeTo( std::ostream& stream );
|
||||||
|
@ -16,20 +16,80 @@ namespace openapitools {
|
|||||||
namespace client {
|
namespace client {
|
||||||
namespace model {
|
namespace model {
|
||||||
|
|
||||||
ModelBase::ModelBase()
|
ModelBase::ModelBase(): m_IsSet(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
ModelBase::~ModelBase()
|
ModelBase::~ModelBase()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
bool ModelBase::isSet() const
|
||||||
web::json::value ModelBase::toJson( const utility::string_t& value )
|
|
||||||
{
|
{
|
||||||
return web::json::value::string(value);
|
return m_IsSet;
|
||||||
}
|
}
|
||||||
web::json::value ModelBase::toJson( const utility::datetime& value )
|
utility::string_t ModelBase::toString( const bool val )
|
||||||
{
|
{
|
||||||
return web::json::value::string(value.to_string(utility::datetime::ISO_8601));
|
utility::stringstream_t ss;
|
||||||
|
ss << val;
|
||||||
|
return utility::string_t(ss.str());
|
||||||
|
}
|
||||||
|
utility::string_t ModelBase::toString( const float val )
|
||||||
|
{
|
||||||
|
utility::stringstream_t ss;
|
||||||
|
ss << val;
|
||||||
|
return utility::string_t(ss.str());
|
||||||
|
}
|
||||||
|
utility::string_t ModelBase::toString( const double val )
|
||||||
|
{
|
||||||
|
utility::stringstream_t ss;
|
||||||
|
ss << val;
|
||||||
|
return utility::string_t(ss.str());
|
||||||
|
}
|
||||||
|
utility::string_t ModelBase::toString( const int32_t val )
|
||||||
|
{
|
||||||
|
utility::stringstream_t ss;
|
||||||
|
ss << val;
|
||||||
|
return utility::string_t(ss.str());
|
||||||
|
}
|
||||||
|
utility::string_t ModelBase::toString( const int64_t val )
|
||||||
|
{
|
||||||
|
utility::stringstream_t ss;
|
||||||
|
ss << val;
|
||||||
|
return utility::string_t(ss.str());
|
||||||
|
}
|
||||||
|
utility::string_t ModelBase::toString (const utility::string_t &val )
|
||||||
|
{
|
||||||
|
utility::stringstream_t ss;
|
||||||
|
ss << val;
|
||||||
|
return utility::string_t(ss.str());
|
||||||
|
}
|
||||||
|
utility::string_t ModelBase::toString( const utility::datetime &val )
|
||||||
|
{
|
||||||
|
return val.to_string(utility::datetime::ISO_8601);
|
||||||
|
}
|
||||||
|
utility::string_t ModelBase::toString( const web::json::value &val )
|
||||||
|
{
|
||||||
|
return val.serialize();
|
||||||
|
}
|
||||||
|
utility::string_t ModelBase::toString( const std::shared_ptr<HttpContent>& val )
|
||||||
|
{
|
||||||
|
utility::stringstream_t ss;
|
||||||
|
if( val != nullptr )
|
||||||
|
{
|
||||||
|
ss << val->getData();
|
||||||
|
}
|
||||||
|
return utility::string_t(ss.str());
|
||||||
|
}
|
||||||
|
web::json::value ModelBase::toJson(bool value)
|
||||||
|
{
|
||||||
|
return web::json::value::boolean(value);
|
||||||
|
}
|
||||||
|
web::json::value ModelBase::toJson( float value )
|
||||||
|
{
|
||||||
|
return web::json::value::number(value);
|
||||||
|
}
|
||||||
|
web::json::value ModelBase::toJson( double value )
|
||||||
|
{
|
||||||
|
return web::json::value::number(value);
|
||||||
}
|
}
|
||||||
web::json::value ModelBase::toJson( int32_t value )
|
web::json::value ModelBase::toJson( int32_t value )
|
||||||
{
|
{
|
||||||
@ -39,88 +99,259 @@ web::json::value ModelBase::toJson( int64_t value )
|
|||||||
{
|
{
|
||||||
return web::json::value::number(value);
|
return web::json::value::number(value);
|
||||||
}
|
}
|
||||||
web::json::value ModelBase::toJson( double value )
|
web::json::value ModelBase::toJson( const utility::string_t& value )
|
||||||
{
|
{
|
||||||
return web::json::value::number(value);
|
return web::json::value::string(value);
|
||||||
}
|
}
|
||||||
web::json::value ModelBase::toJson(bool value) {
|
web::json::value ModelBase::toJson( const utility::datetime& value )
|
||||||
return web::json::value::boolean(value);
|
{
|
||||||
}
|
return web::json::value::string(value.to_string(utility::datetime::ISO_8601));
|
||||||
|
}
|
||||||
web::json::value ModelBase::toJson( std::shared_ptr<HttpContent> content )
|
web::json::value ModelBase::toJson( const web::json::value& value )
|
||||||
{
|
{
|
||||||
web::json::value value;
|
|
||||||
value[utility::conversions::to_string_t("ContentDisposition")] = ModelBase::toJson(content->getContentDisposition());
|
|
||||||
value[utility::conversions::to_string_t("ContentType")] = ModelBase::toJson(content->getContentType());
|
|
||||||
value[utility::conversions::to_string_t("FileName")] = ModelBase::toJson(content->getFileName());
|
|
||||||
value[utility::conversions::to_string_t("InputStream")] = web::json::value::string( ModelBase::toBase64(content->getData()) );
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
web::json::value ModelBase::toJson( const std::shared_ptr<HttpContent>& content )
|
||||||
std::shared_ptr<HttpContent> ModelBase::fileFromJson(const web::json::value& val)
|
|
||||||
{
|
{
|
||||||
std::shared_ptr<HttpContent> content(new HttpContent);
|
web::json::value value;
|
||||||
|
if(content != nullptr)
|
||||||
if(val.has_field(utility::conversions::to_string_t("ContentDisposition")))
|
|
||||||
{
|
{
|
||||||
content->setContentDisposition( ModelBase::stringFromJson(val.at(utility::conversions::to_string_t("ContentDisposition"))) );
|
value[utility::conversions::to_string_t("ContentDisposition")] = ModelBase::toJson(content->getContentDisposition());
|
||||||
|
value[utility::conversions::to_string_t("ContentType")] = ModelBase::toJson(content->getContentType());
|
||||||
|
value[utility::conversions::to_string_t("FileName")] = ModelBase::toJson(content->getFileName());
|
||||||
|
value[utility::conversions::to_string_t("InputStream")] = web::json::value::string( ModelBase::toBase64(content->getData()) );
|
||||||
}
|
}
|
||||||
if(val.has_field(utility::conversions::to_string_t("ContentType")))
|
return value;
|
||||||
{
|
|
||||||
content->setContentType( ModelBase::stringFromJson(val.at(utility::conversions::to_string_t("ContentType"))) );
|
|
||||||
}
|
|
||||||
if(val.has_field(utility::conversions::to_string_t("FileName")))
|
|
||||||
{
|
|
||||||
content->setFileName( ModelBase::stringFromJson(val.at(utility::conversions::to_string_t("FileName"))) );
|
|
||||||
}
|
|
||||||
if(val.has_field(utility::conversions::to_string_t("InputStream")))
|
|
||||||
{
|
|
||||||
content->setData( ModelBase::fromBase64( ModelBase::stringFromJson(val.at(utility::conversions::to_string_t("InputStream")))) );
|
|
||||||
}
|
|
||||||
|
|
||||||
return content;
|
|
||||||
}
|
}
|
||||||
|
bool ModelBase::fromString( const utility::string_t& val, bool &outVal )
|
||||||
web::json::value ModelBase::toJson( std::shared_ptr<ModelBase> content )
|
|
||||||
{
|
{
|
||||||
return content.get() ? content->toJson() : web::json::value::null();
|
utility::stringstream_t ss(val);
|
||||||
|
bool success = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ss >> outVal;
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
bool ModelBase::fromString( const utility::string_t& val, float &outVal )
|
||||||
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, const utility::string_t& value, const utility::string_t& contentType)
|
|
||||||
{
|
{
|
||||||
std::shared_ptr<HttpContent> content(new HttpContent);
|
utility::stringstream_t ss(val);
|
||||||
content->setName( name );
|
bool success = true;
|
||||||
content->setContentDisposition( utility::conversions::to_string_t("form-data") );
|
try
|
||||||
content->setContentType( contentType );
|
{
|
||||||
content->setData( std::shared_ptr<std::istream>( new std::stringstream( utility::conversions::to_utf8string(value) ) ) );
|
ss >> outVal;
|
||||||
return content;
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, const utility::datetime& value, const utility::string_t& contentType )
|
bool ModelBase::fromString( const utility::string_t& val, double &outVal )
|
||||||
|
{
|
||||||
|
utility::stringstream_t ss(val);
|
||||||
|
bool success = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ss >> outVal;
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
bool ModelBase::fromString( const utility::string_t& val, int32_t &outVal )
|
||||||
|
{
|
||||||
|
utility::stringstream_t ss(val);
|
||||||
|
bool success = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ss >> outVal;
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
bool ModelBase::fromString( const utility::string_t& val, int64_t &outVal )
|
||||||
|
{
|
||||||
|
utility::stringstream_t ss(val);
|
||||||
|
bool success = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ss >> outVal;
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
bool ModelBase::fromString( const utility::string_t& val, utility::string_t &outVal )
|
||||||
|
{
|
||||||
|
utility::stringstream_t ss(val);
|
||||||
|
bool success = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ss >> outVal;
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
bool ModelBase::fromString( const utility::string_t& val, utility::datetime &outVal )
|
||||||
|
{
|
||||||
|
bool success = true;
|
||||||
|
auto dt = utility::datetime::from_string(val, utility::datetime::ISO_8601);
|
||||||
|
if( dt.is_initialized() )
|
||||||
|
{
|
||||||
|
outVal = dt;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
bool ModelBase::fromString( const utility::string_t& val, web::json::value &outVal )
|
||||||
|
{
|
||||||
|
outVal = web::json::value::parse(val);
|
||||||
|
return !outVal.is_null();
|
||||||
|
}
|
||||||
|
bool ModelBase::fromString( const utility::string_t& val, std::shared_ptr<HttpContent>& outVal )
|
||||||
|
{
|
||||||
|
bool ok = true;
|
||||||
|
if(outVal == nullptr)
|
||||||
|
{
|
||||||
|
outVal = std::shared_ptr<HttpContent>(new HttpContent());
|
||||||
|
}
|
||||||
|
std::shared_ptr<utility::stringstream_t> ssptr = std::make_shared<utility::stringstream_t>(val);
|
||||||
|
if(outVal != nullptr)
|
||||||
|
{
|
||||||
|
outVal->setData(ssptr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ok = false;
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
bool ModelBase::fromJson( const web::json::value& val, bool & outVal )
|
||||||
|
{
|
||||||
|
outVal = !val.is_boolean() ? false : val.as_bool();
|
||||||
|
return val.is_boolean();
|
||||||
|
}
|
||||||
|
bool ModelBase::fromJson( const web::json::value& val, float & outVal )
|
||||||
|
{
|
||||||
|
outVal = !val.is_double() ? std::numeric_limits<float>::quiet_NaN(): static_cast<float>(val.as_double());
|
||||||
|
return val.is_double();
|
||||||
|
}
|
||||||
|
bool ModelBase::fromJson( const web::json::value& val, double & outVal )
|
||||||
|
{
|
||||||
|
outVal = !val.is_double() ? std::numeric_limits<double>::quiet_NaN(): val.as_double();
|
||||||
|
return val.is_double() ;
|
||||||
|
}
|
||||||
|
bool ModelBase::fromJson( const web::json::value& val, int32_t & outVal )
|
||||||
|
{
|
||||||
|
outVal = !val.is_integer() ? std::numeric_limits<int32_t>::quiet_NaN() : val.as_integer();
|
||||||
|
return val.is_integer();
|
||||||
|
}
|
||||||
|
bool ModelBase::fromJson( const web::json::value& val, int64_t & outVal )
|
||||||
|
{
|
||||||
|
outVal = !val.is_null() ? std::numeric_limits<int64_t>::quiet_NaN() : val.as_number().to_int64();
|
||||||
|
return val.is_number();
|
||||||
|
}
|
||||||
|
bool ModelBase::fromJson( const web::json::value& val, utility::string_t & outVal )
|
||||||
|
{
|
||||||
|
outVal = val.is_string() ? val.as_string() : utility::conversions::to_string_t("");
|
||||||
|
return val.is_string();
|
||||||
|
}
|
||||||
|
bool ModelBase::fromJson( const web::json::value& val, utility::datetime & outVal )
|
||||||
|
{
|
||||||
|
outVal = val.is_null() ? utility::datetime::from_string(utility::conversions::to_string_t("NULL"), utility::datetime::ISO_8601) : utility::datetime::from_string(val.as_string(), utility::datetime::ISO_8601);
|
||||||
|
return outVal.is_initialized();
|
||||||
|
}
|
||||||
|
bool ModelBase::fromJson( const web::json::value& val, web::json::value & outVal )
|
||||||
|
{
|
||||||
|
outVal = val;
|
||||||
|
return !val.is_null();
|
||||||
|
}
|
||||||
|
bool ModelBase::fromJson( const web::json::value& val, std::shared_ptr<HttpContent>& content )
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
if( content != nullptr)
|
||||||
|
{
|
||||||
|
result = true;
|
||||||
|
if(content == nullptr)
|
||||||
|
{
|
||||||
|
content = std::shared_ptr<HttpContent>(new HttpContent());
|
||||||
|
}
|
||||||
|
if(val.has_field(utility::conversions::to_string_t("ContentDisposition")))
|
||||||
|
{
|
||||||
|
utility::string_t value;
|
||||||
|
result = result && ModelBase::fromJson(val.at(utility::conversions::to_string_t("ContentDisposition")), value);
|
||||||
|
content->setContentDisposition( value );
|
||||||
|
}
|
||||||
|
if(val.has_field(utility::conversions::to_string_t("ContentType")))
|
||||||
|
{
|
||||||
|
utility::string_t value;
|
||||||
|
result = result && ModelBase::fromJson(val.at(utility::conversions::to_string_t("ContentType")), value);
|
||||||
|
content->setContentType( value );
|
||||||
|
}
|
||||||
|
if(val.has_field(utility::conversions::to_string_t("FileName")))
|
||||||
|
{
|
||||||
|
utility::string_t value;
|
||||||
|
result = result && ModelBase::fromJson(val.at(utility::conversions::to_string_t("FileName")), value);
|
||||||
|
content->setFileName( value );
|
||||||
|
}
|
||||||
|
if(val.has_field(utility::conversions::to_string_t("InputStream")))
|
||||||
|
{
|
||||||
|
utility::string_t value;
|
||||||
|
result = result && ModelBase::fromJson(val.at(utility::conversions::to_string_t("InputStream")), value);
|
||||||
|
content->setData( ModelBase::fromBase64( value ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, bool value, const utility::string_t& contentType )
|
||||||
{
|
{
|
||||||
std::shared_ptr<HttpContent> content( new HttpContent );
|
std::shared_ptr<HttpContent> content( new HttpContent );
|
||||||
content->setName( name );
|
content->setName( name );
|
||||||
content->setContentDisposition( utility::conversions::to_string_t("form-data") );
|
content->setContentDisposition( utility::conversions::to_string_t("form-data") );
|
||||||
content->setContentType( contentType );
|
content->setContentType( contentType );
|
||||||
content->setData( std::shared_ptr<std::istream>( new std::stringstream( utility::conversions::to_utf8string(value.to_string(utility::datetime::ISO_8601) ) ) ) );
|
std::stringstream* valueAsStringStream = new std::stringstream();
|
||||||
|
(*valueAsStringStream) << value;
|
||||||
|
content->setData( std::shared_ptr<std::istream>( valueAsStringStream ) );
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, std::shared_ptr<HttpContent> value )
|
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, float value, const utility::string_t& contentType )
|
||||||
{
|
|
||||||
std::shared_ptr<HttpContent> content( new HttpContent );
|
|
||||||
content->setName( name );
|
|
||||||
content->setContentDisposition( value->getContentDisposition() );
|
|
||||||
content->setContentType( value->getContentType() );
|
|
||||||
content->setData( value->getData() );
|
|
||||||
content->setFileName( value->getFileName() );
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, const web::json::value& value, const utility::string_t& contentType )
|
|
||||||
{
|
{
|
||||||
std::shared_ptr<HttpContent> content( new HttpContent );
|
std::shared_ptr<HttpContent> content( new HttpContent );
|
||||||
content->setName( name );
|
content->setName( name );
|
||||||
content->setContentDisposition( utility::conversions::to_string_t("form-data") );
|
content->setContentDisposition( utility::conversions::to_string_t("form-data") );
|
||||||
content->setContentType( contentType );
|
content->setContentType( contentType );
|
||||||
content->setData( std::shared_ptr<std::istream>( new std::stringstream( utility::conversions::to_utf8string(value.serialize()) ) ) );
|
std::stringstream* valueAsStringStream = new std::stringstream();
|
||||||
|
(*valueAsStringStream) << value;
|
||||||
|
content->setData( std::shared_ptr<std::istream>( valueAsStringStream ) );
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, double value, const utility::string_t& contentType )
|
||||||
|
{
|
||||||
|
std::shared_ptr<HttpContent> content( new HttpContent );
|
||||||
|
content->setName( name );
|
||||||
|
content->setContentDisposition( utility::conversions::to_string_t("form-data") );
|
||||||
|
content->setContentType( contentType );
|
||||||
|
std::stringstream* valueAsStringStream = new std::stringstream();
|
||||||
|
(*valueAsStringStream) << value;
|
||||||
|
content->setData( std::shared_ptr<std::istream>( valueAsStringStream ) );
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, int32_t value, const utility::string_t& contentType )
|
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, int32_t value, const utility::string_t& contentType )
|
||||||
@ -145,18 +376,118 @@ std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t&
|
|||||||
content->setData( std::shared_ptr<std::istream>( valueAsStringStream) ) ;
|
content->setData( std::shared_ptr<std::istream>( valueAsStringStream) ) ;
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, double value, const utility::string_t& contentType )
|
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, const utility::string_t& value, const utility::string_t& contentType)
|
||||||
|
{
|
||||||
|
std::shared_ptr<HttpContent> content(new HttpContent);
|
||||||
|
content->setName( name );
|
||||||
|
content->setContentDisposition( utility::conversions::to_string_t("form-data") );
|
||||||
|
content->setContentType( contentType );
|
||||||
|
content->setData( std::shared_ptr<std::istream>( new std::stringstream( utility::conversions::to_utf8string(value) ) ) );
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, const utility::datetime& value, const utility::string_t& contentType )
|
||||||
{
|
{
|
||||||
std::shared_ptr<HttpContent> content( new HttpContent );
|
std::shared_ptr<HttpContent> content( new HttpContent );
|
||||||
content->setName( name );
|
content->setName( name );
|
||||||
content->setContentDisposition( utility::conversions::to_string_t("form-data") );
|
content->setContentDisposition( utility::conversions::to_string_t("form-data") );
|
||||||
content->setContentType( contentType );
|
content->setContentType( contentType );
|
||||||
std::stringstream* valueAsStringStream = new std::stringstream();
|
content->setData( std::shared_ptr<std::istream>( new std::stringstream( utility::conversions::to_utf8string(value.to_string(utility::datetime::ISO_8601) ) ) ) );
|
||||||
(*valueAsStringStream) << value;
|
|
||||||
content->setData( std::shared_ptr<std::istream>( valueAsStringStream ) );
|
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, const web::json::value& value, const utility::string_t& contentType )
|
||||||
|
{
|
||||||
|
std::shared_ptr<HttpContent> content( new HttpContent );
|
||||||
|
content->setName( name );
|
||||||
|
content->setContentDisposition( utility::conversions::to_string_t("form-data") );
|
||||||
|
content->setContentType( contentType );
|
||||||
|
content->setData( std::shared_ptr<std::istream>( new std::stringstream( utility::conversions::to_utf8string(value.serialize()) ) ) );
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, const std::shared_ptr<HttpContent>& value )
|
||||||
|
{
|
||||||
|
std::shared_ptr<HttpContent> content( new HttpContent );
|
||||||
|
if( value != nullptr )
|
||||||
|
{
|
||||||
|
content->setName( name );
|
||||||
|
content->setContentDisposition( value->getContentDisposition() );
|
||||||
|
content->setContentType( value->getContentType() );
|
||||||
|
content->setData( value->getData() );
|
||||||
|
content->setFileName( value->getFileName() );
|
||||||
|
}
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
bool ModelBase::fromHttpContent(std::shared_ptr<HttpContent> val, bool & outVal )
|
||||||
|
{
|
||||||
|
utility::string_t str;
|
||||||
|
if( val == nullptr ) return false;
|
||||||
|
ModelBase::fromHttpContent(val, str);
|
||||||
|
return fromString(str, outVal);
|
||||||
|
}
|
||||||
|
bool ModelBase::fromHttpContent(std::shared_ptr<HttpContent> val, float & outVal )
|
||||||
|
{
|
||||||
|
utility::string_t str;
|
||||||
|
if( val == nullptr ) return false;
|
||||||
|
ModelBase::fromHttpContent(val, str);
|
||||||
|
return fromString(str, outVal);
|
||||||
|
}
|
||||||
|
bool ModelBase::fromHttpContent(std::shared_ptr<HttpContent> val, double & outVal )
|
||||||
|
{
|
||||||
|
utility::string_t str;
|
||||||
|
if( val == nullptr ) return false;
|
||||||
|
ModelBase::fromHttpContent(val, str);
|
||||||
|
return fromString(str, outVal);
|
||||||
|
}
|
||||||
|
bool ModelBase::fromHttpContent(std::shared_ptr<HttpContent> val, int32_t & outVal )
|
||||||
|
{
|
||||||
|
utility::string_t str;
|
||||||
|
if( val == nullptr ) return false;
|
||||||
|
ModelBase::fromHttpContent(val, str);
|
||||||
|
return fromString(str, outVal);
|
||||||
|
}
|
||||||
|
bool ModelBase::fromHttpContent(std::shared_ptr<HttpContent> val, int64_t & outVal )
|
||||||
|
{
|
||||||
|
utility::string_t str;
|
||||||
|
if( val == nullptr ) return false;
|
||||||
|
ModelBase::fromHttpContent(val, str);
|
||||||
|
return fromString(str, outVal);
|
||||||
|
}
|
||||||
|
bool ModelBase::fromHttpContent(std::shared_ptr<HttpContent> val, utility::string_t & outVal )
|
||||||
|
{
|
||||||
|
if( val == nullptr ) return false;
|
||||||
|
std::shared_ptr<std::istream> data = val->getData();
|
||||||
|
data->seekg( 0, data->beg );
|
||||||
|
|
||||||
|
std::string str((std::istreambuf_iterator<char>(*data.get())),
|
||||||
|
std::istreambuf_iterator<char>());
|
||||||
|
outVal = utility::conversions::to_string_t(str);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool ModelBase::fromHttpContent(std::shared_ptr<HttpContent> val, utility::datetime & outVal )
|
||||||
|
{
|
||||||
|
utility::string_t str;
|
||||||
|
if( val == nullptr ) return false;
|
||||||
|
ModelBase::fromHttpContent(val, str);
|
||||||
|
outVal = utility::datetime::from_string(str, utility::datetime::ISO_8601);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool ModelBase::fromHttpContent(std::shared_ptr<HttpContent> val, web::json::value & outVal )
|
||||||
|
{
|
||||||
|
utility::string_t str;
|
||||||
|
if( val == nullptr ) return false;
|
||||||
|
ModelBase::fromHttpContent(val, str);
|
||||||
|
return fromString(str, outVal);
|
||||||
|
}
|
||||||
|
bool ModelBase::fromHttpContent(std::shared_ptr<HttpContent> val, std::shared_ptr<HttpContent>& outVal )
|
||||||
|
{
|
||||||
|
utility::string_t str;
|
||||||
|
if( val == nullptr ) return false;
|
||||||
|
if( outVal == nullptr )
|
||||||
|
{
|
||||||
|
outVal = std::shared_ptr<HttpContent>(new HttpContent());
|
||||||
|
}
|
||||||
|
ModelBase::fromHttpContent(val, str);
|
||||||
|
return fromString(str, outVal);
|
||||||
|
}
|
||||||
// base64 encoding/decoding based on : https://en.wikibooks.org/wiki/Algorithm_Implementation/Miscellaneous/Base64#C.2B.2B
|
// base64 encoding/decoding based on : https://en.wikibooks.org/wiki/Algorithm_Implementation/Miscellaneous/Base64#C.2B.2B
|
||||||
const static char Base64Chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
const static char Base64Chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||||
const static char Base64PadChar = '=';
|
const static char Base64PadChar = '=';
|
||||||
@ -206,8 +537,6 @@ utility::string_t ModelBase::toBase64( std::shared_ptr<std::istream> value )
|
|||||||
}
|
}
|
||||||
return base64;
|
return base64;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::shared_ptr<std::istream> ModelBase::fromBase64( const utility::string_t& encoded )
|
std::shared_ptr<std::istream> ModelBase::fromBase64( const utility::string_t& encoded )
|
||||||
{
|
{
|
||||||
std::shared_ptr<std::stringstream> result(new std::stringstream);
|
std::shared_ptr<std::stringstream> result(new std::stringstream);
|
||||||
@ -274,107 +603,6 @@ std::shared_ptr<std::istream> ModelBase::fromBase64( const utility::string_t& en
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t ModelBase::int64_tFromJson(const web::json::value& val)
|
|
||||||
{
|
|
||||||
return val.is_null() ? std::numeric_limits<int64_t>::quiet_NaN() : val.as_number().to_int64();
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t ModelBase::int32_tFromJson(const web::json::value& val)
|
|
||||||
{
|
|
||||||
return val.is_null() ? std::numeric_limits<int32_t>::quiet_NaN() : val.as_integer();
|
|
||||||
}
|
|
||||||
|
|
||||||
float ModelBase::floatFromJson(const web::json::value& val)
|
|
||||||
{
|
|
||||||
return val.is_null() ? std::numeric_limits<float>::quiet_NaN() : static_cast<float>(val.as_double());
|
|
||||||
}
|
|
||||||
|
|
||||||
utility::string_t ModelBase::stringFromJson(const web::json::value& val)
|
|
||||||
{
|
|
||||||
return val.is_string() ? val.as_string() : utility::conversions::to_string_t("");
|
|
||||||
}
|
|
||||||
|
|
||||||
utility::datetime ModelBase::dateFromJson(const web::json::value& val)
|
|
||||||
{
|
|
||||||
return val.is_null() ? utility::datetime::from_string(utility::conversions::to_string_t("NULL"), utility::datetime::ISO_8601) : utility::datetime::from_string(val.as_string(), utility::datetime::ISO_8601);
|
|
||||||
}
|
|
||||||
bool ModelBase::boolFromJson(const web::json::value& val)
|
|
||||||
{
|
|
||||||
return val.is_null() ? false : val.as_bool();
|
|
||||||
}
|
|
||||||
double ModelBase::doubleFromJson(const web::json::value& val)
|
|
||||||
{
|
|
||||||
return val.is_null() ? std::numeric_limits<double>::quiet_NaN(): val.as_double();
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t ModelBase::int64_tFromHttpContent(std::shared_ptr<HttpContent> val)
|
|
||||||
{
|
|
||||||
utility::string_t str = ModelBase::stringFromHttpContent(val);
|
|
||||||
|
|
||||||
utility::stringstream_t ss(str);
|
|
||||||
int64_t result = 0;
|
|
||||||
ss >> result;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
int32_t ModelBase::int32_tFromHttpContent(std::shared_ptr<HttpContent> val)
|
|
||||||
{
|
|
||||||
utility::string_t str = ModelBase::stringFromHttpContent(val);
|
|
||||||
|
|
||||||
utility::stringstream_t ss(str);
|
|
||||||
int32_t result = 0;
|
|
||||||
ss >> result;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
float ModelBase::floatFromHttpContent(std::shared_ptr<HttpContent> val)
|
|
||||||
{
|
|
||||||
utility::string_t str = ModelBase::stringFromHttpContent(val);
|
|
||||||
|
|
||||||
utility::stringstream_t ss(str);
|
|
||||||
float result = 0;
|
|
||||||
ss >> result;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
utility::string_t ModelBase::stringFromHttpContent(std::shared_ptr<HttpContent> val)
|
|
||||||
{
|
|
||||||
std::shared_ptr<std::istream> data = val->getData();
|
|
||||||
data->seekg( 0, data->beg );
|
|
||||||
|
|
||||||
std::string str((std::istreambuf_iterator<char>(*data.get())),
|
|
||||||
std::istreambuf_iterator<char>());
|
|
||||||
|
|
||||||
return utility::conversions::to_string_t(str);
|
|
||||||
}
|
|
||||||
utility::datetime ModelBase::dateFromHttpContent(std::shared_ptr<HttpContent> val)
|
|
||||||
{
|
|
||||||
utility::string_t str = ModelBase::stringFromHttpContent(val);
|
|
||||||
return utility::datetime::from_string(str, utility::datetime::ISO_8601);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ModelBase::boolFromHttpContent(std::shared_ptr<HttpContent> val)
|
|
||||||
{
|
|
||||||
utility::string_t str = ModelBase::stringFromHttpContent(val);
|
|
||||||
|
|
||||||
utility::stringstream_t ss(str);
|
|
||||||
bool result = false;
|
|
||||||
ss >> result;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
double ModelBase::doubleFromHttpContent(std::shared_ptr<HttpContent> val)
|
|
||||||
{
|
|
||||||
utility::string_t str = ModelBase::stringFromHttpContent(val);
|
|
||||||
|
|
||||||
utility::stringstream_t ss(str);
|
|
||||||
double result = 0.0;
|
|
||||||
ss >> result;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
web::json::value ModelBase::valueFromHttpContent(std::shared_ptr<HttpContent> val)
|
|
||||||
{
|
|
||||||
utility::string_t str = ModelBase::stringFromHttpContent(val);
|
|
||||||
return web::json::value::parse(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,14 +19,15 @@
|
|||||||
#define ORG_OPENAPITOOLS_CLIENT_MODEL_ModelBase_H_
|
#define ORG_OPENAPITOOLS_CLIENT_MODEL_ModelBase_H_
|
||||||
|
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "HttpContent.h"
|
#include "HttpContent.h"
|
||||||
#include "MultipartFormData.h"
|
#include "MultipartFormData.h"
|
||||||
|
|
||||||
#include <cpprest/details/basic_types.h>
|
#include <cpprest/details/basic_types.h>
|
||||||
#include <cpprest/json.h>
|
#include <cpprest/json.h>
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace org {
|
namespace org {
|
||||||
namespace openapitools {
|
namespace openapitools {
|
||||||
namespace client {
|
namespace client {
|
||||||
@ -41,68 +42,252 @@ public:
|
|||||||
virtual void validate() = 0;
|
virtual void validate() = 0;
|
||||||
|
|
||||||
virtual web::json::value toJson() const = 0;
|
virtual web::json::value toJson() const = 0;
|
||||||
virtual void fromJson(const web::json::value& json) = 0;
|
virtual bool fromJson( const web::json::value& json ) = 0;
|
||||||
|
|
||||||
virtual void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const = 0;
|
virtual void toMultipart( std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix ) const = 0;
|
||||||
virtual void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) = 0;
|
virtual bool fromMultiPart( std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix ) = 0;
|
||||||
|
|
||||||
static web::json::value toJson( const utility::string_t& value );
|
virtual bool isSet() const;
|
||||||
static web::json::value toJson( const utility::datetime& value );
|
|
||||||
static web::json::value toJson( std::shared_ptr<HttpContent> value );
|
|
||||||
static web::json::value toJson( std::shared_ptr<ModelBase> value );
|
|
||||||
static web::json::value toJson( int32_t value );
|
|
||||||
static web::json::value toJson( int64_t value );
|
|
||||||
static web::json::value toJson( double value );
|
|
||||||
static web::json::value toJson( bool value );
|
|
||||||
template<class T>
|
|
||||||
static web::json::value toJson(const std::vector<T>& value);
|
|
||||||
|
|
||||||
static int64_t int64_tFromJson(const web::json::value& val);
|
static utility::string_t toString( const bool val );
|
||||||
static int32_t int32_tFromJson(const web::json::value& val);
|
static utility::string_t toString( const float val );
|
||||||
static float floatFromJson(const web::json::value& val);
|
static utility::string_t toString( const double val );
|
||||||
static utility::string_t stringFromJson(const web::json::value& val);
|
static utility::string_t toString( const int32_t val );
|
||||||
static utility::datetime dateFromJson(const web::json::value& val);
|
static utility::string_t toString( const int64_t val );
|
||||||
static double doubleFromJson(const web::json::value& val);
|
static utility::string_t toString( const utility::string_t &val );
|
||||||
static bool boolFromJson(const web::json::value& val);
|
static utility::string_t toString( const utility::datetime &val );
|
||||||
static std::shared_ptr<HttpContent> fileFromJson(const web::json::value& val);
|
static utility::string_t toString( const web::json::value &val );
|
||||||
|
static utility::string_t toString( const std::shared_ptr<HttpContent>& val );
|
||||||
|
template <typename T>
|
||||||
|
static utility::string_t toString( const std::shared_ptr<T>& val );
|
||||||
|
template <typename T>
|
||||||
|
static utility::string_t toString( const std::vector<T> & val );
|
||||||
|
|
||||||
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const utility::string_t& value, const utility::string_t& contentType = utility::conversions::to_string_t(""));
|
static web::json::value toJson( bool val );
|
||||||
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const utility::datetime& value, const utility::string_t& contentType = utility::conversions::to_string_t(""));
|
static web::json::value toJson( float val );
|
||||||
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, std::shared_ptr<HttpContent> value );
|
static web::json::value toJson( double val );
|
||||||
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const web::json::value& value, const utility::string_t& contentType = utility::conversions::to_string_t("application/json") );
|
static web::json::value toJson( int32_t val );
|
||||||
|
static web::json::value toJson( int64_t val );
|
||||||
|
static web::json::value toJson( const utility::string_t& val );
|
||||||
|
static web::json::value toJson( const utility::datetime& val );
|
||||||
|
static web::json::value toJson( const web::json::value& val );
|
||||||
|
static web::json::value toJson( const std::shared_ptr<HttpContent>& val );
|
||||||
|
template<typename T>
|
||||||
|
static web::json::value toJson( const std::shared_ptr<T>& val );
|
||||||
|
template<typename T>
|
||||||
|
static web::json::value toJson( const std::vector<T>& val );
|
||||||
|
template<typename T>
|
||||||
|
static web::json::value toJson( const std::map<utility::string_t, T>& val );
|
||||||
|
|
||||||
|
static bool fromString( const utility::string_t& val, bool & );
|
||||||
|
static bool fromString( const utility::string_t& val, float & );
|
||||||
|
static bool fromString( const utility::string_t& val, double & );
|
||||||
|
static bool fromString( const utility::string_t& val, int32_t & );
|
||||||
|
static bool fromString( const utility::string_t& val, int64_t & );
|
||||||
|
static bool fromString( const utility::string_t& val, utility::string_t & );
|
||||||
|
static bool fromString( const utility::string_t& val, utility::datetime & );
|
||||||
|
static bool fromString( const utility::string_t& val, web::json::value & );
|
||||||
|
static bool fromString( const utility::string_t& val, std::shared_ptr<HttpContent> & );
|
||||||
|
template<typename T>
|
||||||
|
static bool fromString( const utility::string_t& val, std::shared_ptr<T>& );
|
||||||
|
template<typename T>
|
||||||
|
static bool fromString( const utility::string_t& val, std::vector<T> & );
|
||||||
|
template<typename T>
|
||||||
|
static bool fromString( const utility::string_t& val, std::map<utility::string_t, T> & );
|
||||||
|
|
||||||
|
static bool fromJson( const web::json::value& val, bool & );
|
||||||
|
static bool fromJson( const web::json::value& val, float & );
|
||||||
|
static bool fromJson( const web::json::value& val, double & );
|
||||||
|
static bool fromJson( const web::json::value& val, int32_t & );
|
||||||
|
static bool fromJson( const web::json::value& val, int64_t & );
|
||||||
|
static bool fromJson( const web::json::value& val, utility::string_t & );
|
||||||
|
static bool fromJson( const web::json::value& val, utility::datetime & );
|
||||||
|
static bool fromJson( const web::json::value& val, web::json::value & );
|
||||||
|
static bool fromJson( const web::json::value& val, std::shared_ptr<HttpContent> & );
|
||||||
|
template<typename T>
|
||||||
|
static bool fromJson( const web::json::value& val, std::shared_ptr<T>& );
|
||||||
|
template<typename T>
|
||||||
|
static bool fromJson( const web::json::value& val, std::vector<T> & );
|
||||||
|
template<typename T>
|
||||||
|
static bool fromJson( const web::json::value& val, std::map<utility::string_t, T> & );
|
||||||
|
|
||||||
|
|
||||||
|
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, bool value, const utility::string_t& contentType = utility::conversions::to_string_t("") );
|
||||||
|
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, float value, const utility::string_t& contentType = utility::conversions::to_string_t("") );
|
||||||
|
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, double value, const utility::string_t& contentType = utility::conversions::to_string_t("") );
|
||||||
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, int32_t value, const utility::string_t& contentType = utility::conversions::to_string_t("") );
|
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, int32_t value, const utility::string_t& contentType = utility::conversions::to_string_t("") );
|
||||||
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, int64_t value, const utility::string_t& contentType = utility::conversions::to_string_t("") );
|
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, int64_t value, const utility::string_t& contentType = utility::conversions::to_string_t("") );
|
||||||
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, double value, const utility::string_t& contentType = utility::conversions::to_string_t("") );
|
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const utility::string_t& value, const utility::string_t& contentType = utility::conversions::to_string_t(""));
|
||||||
template <class T>
|
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const utility::datetime& value, const utility::string_t& contentType = utility::conversions::to_string_t(""));
|
||||||
|
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const web::json::value& value, const utility::string_t& contentType = utility::conversions::to_string_t("application/json") );
|
||||||
|
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const std::shared_ptr<HttpContent>& );
|
||||||
|
template <typename T>
|
||||||
|
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const std::shared_ptr<T>& , const utility::string_t& contentType = utility::conversions::to_string_t("application/json") );
|
||||||
|
template <typename T>
|
||||||
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const std::vector<T>& value, const utility::string_t& contentType = utility::conversions::to_string_t("") );
|
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const std::vector<T>& value, const utility::string_t& contentType = utility::conversions::to_string_t("") );
|
||||||
|
template <typename T>
|
||||||
|
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const std::map<utility::string_t, T>& value, const utility::string_t& contentType = utility::conversions::to_string_t("") );
|
||||||
|
|
||||||
static int64_t int64_tFromHttpContent(std::shared_ptr<HttpContent> val);
|
static bool fromHttpContent( std::shared_ptr<HttpContent> val, bool & );
|
||||||
static int32_t int32_tFromHttpContent(std::shared_ptr<HttpContent> val);
|
static bool fromHttpContent( std::shared_ptr<HttpContent> val, float & );
|
||||||
static float floatFromHttpContent(std::shared_ptr<HttpContent> val);
|
static bool fromHttpContent( std::shared_ptr<HttpContent> val, double & );
|
||||||
static utility::string_t stringFromHttpContent(std::shared_ptr<HttpContent> val);
|
static bool fromHttpContent( std::shared_ptr<HttpContent> val, int64_t & );
|
||||||
static utility::datetime dateFromHttpContent(std::shared_ptr<HttpContent> val);
|
static bool fromHttpContent( std::shared_ptr<HttpContent> val, int32_t & );
|
||||||
static bool boolFromHttpContent(std::shared_ptr<HttpContent> val);
|
static bool fromHttpContent( std::shared_ptr<HttpContent> val, utility::string_t & );
|
||||||
static double doubleFromHttpContent(std::shared_ptr<HttpContent> val);
|
static bool fromHttpContent( std::shared_ptr<HttpContent> val, utility::datetime & );
|
||||||
static web::json::value valueFromHttpContent(std::shared_ptr<HttpContent> val);
|
static bool fromHttpContent( std::shared_ptr<HttpContent> val, web::json::value & );
|
||||||
|
static bool fromHttpContent( std::shared_ptr<HttpContent> val, std::shared_ptr<HttpContent>& );
|
||||||
|
template <typename T>
|
||||||
|
static bool fromHttpContent( std::shared_ptr<HttpContent> val, std::shared_ptr<T>& );
|
||||||
|
template <typename T>
|
||||||
|
static bool fromHttpContent( std::shared_ptr<HttpContent> val, std::vector<T> & );
|
||||||
|
template <typename T>
|
||||||
|
static bool fromHttpContent( std::shared_ptr<HttpContent> val, std::map<utility::string_t, T> & );
|
||||||
|
|
||||||
static utility::string_t toBase64( utility::string_t value );
|
static utility::string_t toBase64( utility::string_t value );
|
||||||
static utility::string_t toBase64( std::shared_ptr<std::istream> value );
|
static utility::string_t toBase64( std::shared_ptr<std::istream> value );
|
||||||
static std::shared_ptr<std::istream> fromBase64( const utility::string_t& encoded );
|
static std::shared_ptr<std::istream> fromBase64( const utility::string_t& encoded );
|
||||||
|
protected:
|
||||||
|
bool m_IsSet;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
template <typename T>
|
||||||
web::json::value ModelBase::toJson(const std::vector<T>& value) {
|
utility::string_t ModelBase::toString( const std::shared_ptr<T>& val )
|
||||||
std::vector<web::json::value> ret;
|
{
|
||||||
for (auto& x : value) {
|
utility::stringstream_t ss;
|
||||||
ret.push_back(toJson(x));
|
if( val != nullptr )
|
||||||
|
{
|
||||||
|
val->toJson().serialize(ss);
|
||||||
|
}
|
||||||
|
return utility::string_t(ss.str());
|
||||||
|
}
|
||||||
|
template<typename T>
|
||||||
|
utility::string_t ModelBase::toString( const std::vector<T> & val )
|
||||||
|
{
|
||||||
|
utility::string_t strArray;
|
||||||
|
for ( const auto &item : val )
|
||||||
|
{
|
||||||
|
strArray.append( toString(item) + "," );
|
||||||
|
}
|
||||||
|
if (val.count() > 0)
|
||||||
|
{
|
||||||
|
strArray.pop_back();
|
||||||
|
}
|
||||||
|
return strArray;
|
||||||
|
}
|
||||||
|
template<typename T>
|
||||||
|
web::json::value ModelBase::toJson( const std::shared_ptr<T>& val )
|
||||||
|
{
|
||||||
|
web::json::value retVal;
|
||||||
|
if(val != nullptr)
|
||||||
|
{
|
||||||
|
retVal = val->toJson();
|
||||||
|
}
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
template<typename T>
|
||||||
|
web::json::value ModelBase::toJson( const std::vector<T>& value )
|
||||||
|
{
|
||||||
|
std::vector<web::json::value> ret;
|
||||||
|
for ( const auto& x : value )
|
||||||
|
{
|
||||||
|
ret.push_back( toJson(x) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return web::json::value::array(ret);
|
return web::json::value::array(ret);
|
||||||
}
|
}
|
||||||
|
template<typename T>
|
||||||
template <class T>
|
web::json::value ModelBase::toJson( const std::map<utility::string_t, T>& val )
|
||||||
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, const std::vector<T>& value, const utility::string_t& contentType ) {
|
{
|
||||||
|
web::json::value obj;
|
||||||
|
for ( const auto &itemkey : val )
|
||||||
|
{
|
||||||
|
obj[itemkey.first] = toJson( itemkey.second );
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
template<typename T>
|
||||||
|
bool ModelBase::fromString( const utility::string_t& val, std::shared_ptr<T>& outVal )
|
||||||
|
{
|
||||||
|
bool ok = false;
|
||||||
|
if(outVal == nullptr)
|
||||||
|
{
|
||||||
|
outVal = std::shared_ptr<T>(new T());
|
||||||
|
}
|
||||||
|
if( outVal != nullptr )
|
||||||
|
{
|
||||||
|
ok = outVal->fromJson(web::json::value::parse(val));
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
template<typename T>
|
||||||
|
bool ModelBase::fromJson( const web::json::value& val, std::shared_ptr<T> &outVal )
|
||||||
|
{
|
||||||
|
bool ok = false;
|
||||||
|
if(outVal == nullptr)
|
||||||
|
{
|
||||||
|
outVal = std::shared_ptr<T>(new T());
|
||||||
|
}
|
||||||
|
if( outVal != nullptr )
|
||||||
|
{
|
||||||
|
ok = outVal->fromJson(val);
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
template<typename T>
|
||||||
|
bool ModelBase::fromJson( const web::json::value& val, std::vector<T> &outVal )
|
||||||
|
{
|
||||||
|
bool ok = true;
|
||||||
|
if (val.is_array())
|
||||||
|
{
|
||||||
|
for (const auto jitem : val.as_array())
|
||||||
|
{
|
||||||
|
T item;
|
||||||
|
ok &= fromJson(jitem, item);
|
||||||
|
outVal.push_back(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ok = false;
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
template<typename T>
|
||||||
|
bool ModelBase::fromJson( const web::json::value& jval, std::map<utility::string_t, T> &outVal )
|
||||||
|
{
|
||||||
|
bool ok = true;
|
||||||
|
if ( jval.is_object() )
|
||||||
|
{
|
||||||
|
auto obj = jval.as_object();
|
||||||
|
for( auto objItr = obj.begin() ; objItr != obj.end() ; objItr++ )
|
||||||
|
{
|
||||||
|
T itemVal;
|
||||||
|
ok &= fromJson(objItr->second, itemVal);
|
||||||
|
outVal.insert(std::pair<utility::string_t, T>(objItr->first, itemVal));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ok = false;
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
std::shared_ptr<HttpContent> ModelBase::toHttpContent(const utility::string_t& name, const std::shared_ptr<T>& value , const utility::string_t& contentType )
|
||||||
|
{
|
||||||
|
std::shared_ptr<HttpContent> content( new HttpContent );
|
||||||
|
if (value != nullptr )
|
||||||
|
{
|
||||||
|
content->setName( name );
|
||||||
|
content->setContentDisposition( utility::conversions::to_string_t("form-data") );
|
||||||
|
content->setContentType( contentType );
|
||||||
|
content->setData( std::shared_ptr<std::istream>( new std::stringstream( utility::conversions::to_utf8string( value->toJson().serialize() ) ) ) );
|
||||||
|
}
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, const std::vector<T>& value, const utility::string_t& contentType )
|
||||||
|
{
|
||||||
web::json::value json_array = ModelBase::toJson(value);
|
web::json::value json_array = ModelBase::toJson(value);
|
||||||
std::shared_ptr<HttpContent> content( new HttpContent );
|
std::shared_ptr<HttpContent> content( new HttpContent );
|
||||||
content->setName( name );
|
content->setName( name );
|
||||||
@ -111,7 +296,39 @@ std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t&
|
|||||||
content->setData( std::shared_ptr<std::istream>( new std::stringstream( utility::conversions::to_utf8string(json_array.serialize()) ) ) );
|
content->setData( std::shared_ptr<std::istream>( new std::stringstream( utility::conversions::to_utf8string(json_array.serialize()) ) ) );
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
template <typename T>
|
||||||
|
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, const std::map<utility::string_t, T>& value, const utility::string_t& contentType )
|
||||||
|
{
|
||||||
|
web::json::value jobj = ModelBase::toJson(value);
|
||||||
|
std::shared_ptr<HttpContent> content( new HttpContent );
|
||||||
|
content->setName( name );
|
||||||
|
content->setContentDisposition( utility::conversions::to_string_t("form-data") );
|
||||||
|
content->setContentType( contentType );
|
||||||
|
content->setData( std::shared_ptr<std::istream>( new std::stringstream( utility::conversions::to_utf8string(jobj.serialize()) ) ) );
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
bool ModelBase::fromHttpContent( std::shared_ptr<HttpContent> val, std::shared_ptr<T>& outVal )
|
||||||
|
{
|
||||||
|
utility::string_t str;
|
||||||
|
if(val == nullptr) return false;
|
||||||
|
if( outVal == nullptr )
|
||||||
|
{
|
||||||
|
outVal = std::shared_ptr<T>(new T());
|
||||||
|
}
|
||||||
|
ModelBase::fromHttpContent(val, str);
|
||||||
|
return fromString(str, outVal);
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
bool ModelBase::fromHttpContent( std::shared_ptr<HttpContent> val, std::vector<T> & )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
bool ModelBase::fromHttpContent( std::shared_ptr<HttpContent> val, std::map<utility::string_t, T> & )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ Object::~Object()
|
|||||||
|
|
||||||
void Object::validate()
|
void Object::validate()
|
||||||
{
|
{
|
||||||
// TODO: implement validation
|
|
||||||
}
|
}
|
||||||
|
|
||||||
web::json::value Object::toJson() const
|
web::json::value Object::toJson() const
|
||||||
@ -35,12 +35,14 @@ web::json::value Object::toJson() const
|
|||||||
return m_object;
|
return m_object;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Object::fromJson(const web::json::value& val)
|
bool Object::fromJson(const web::json::value& val)
|
||||||
{
|
{
|
||||||
if (val.is_object())
|
if (val.is_object())
|
||||||
{
|
{
|
||||||
m_object = val;
|
m_object = val;
|
||||||
|
m_IsSet = true;
|
||||||
}
|
}
|
||||||
|
return isSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Object::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const
|
void Object::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const
|
||||||
@ -53,7 +55,7 @@ void Object::toMultipart(std::shared_ptr<MultipartFormData> multipart, const uti
|
|||||||
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("object"), m_object));
|
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("object"), m_object));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Object::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
|
bool Object::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
|
||||||
{
|
{
|
||||||
utility::string_t namePrefix = prefix;
|
utility::string_t namePrefix = prefix;
|
||||||
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t("."))
|
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t("."))
|
||||||
@ -61,7 +63,11 @@ void Object::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const u
|
|||||||
namePrefix += utility::conversions::to_string_t(".");
|
namePrefix += utility::conversions::to_string_t(".");
|
||||||
}
|
}
|
||||||
|
|
||||||
m_object = ModelBase::valueFromHttpContent(multipart->getContent(namePrefix + utility::conversions::to_string_t("object")));
|
if( ModelBase::fromHttpContent(multipart->getContent(namePrefix + utility::conversions::to_string_t("object")), m_object ) )
|
||||||
|
{
|
||||||
|
m_IsSet = true;
|
||||||
|
}
|
||||||
|
return isSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
web::json::value Object::getValue(const utility::string_t& key) const
|
web::json::value Object::getValue(const utility::string_t& key) const
|
||||||
@ -72,7 +78,11 @@ web::json::value Object::getValue(const utility::string_t& key) const
|
|||||||
|
|
||||||
void Object::setValue(const utility::string_t& key, const web::json::value& value)
|
void Object::setValue(const utility::string_t& key, const web::json::value& value)
|
||||||
{
|
{
|
||||||
m_object[key] = value;
|
if( !value.is_null() )
|
||||||
|
{
|
||||||
|
m_object[key] = value;
|
||||||
|
m_IsSet = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -40,10 +40,10 @@ public:
|
|||||||
void validate() override;
|
void validate() override;
|
||||||
|
|
||||||
web::json::value toJson() const override;
|
web::json::value toJson() const override;
|
||||||
void fromJson(const web::json::value& json) override;
|
bool fromJson(const web::json::value& json) override;
|
||||||
|
|
||||||
void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
|
void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
|
||||||
void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override;
|
bool fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override;
|
||||||
|
|
||||||
/////////////////////////////////////////////
|
/////////////////////////////////////////////
|
||||||
/// Object manipulation
|
/// Object manipulation
|
||||||
|
@ -109,6 +109,7 @@ pplx::task<void> PetApi::addPet(std::shared_ptr<Pet> body) const
|
|||||||
body->toMultipart(localVarMultipart, utility::conversions::to_string_t("body"));
|
body->toMultipart(localVarMultipart, utility::conversions::to_string_t("body"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
localVarHttpBody = localVarMultipart;
|
localVarHttpBody = localVarMultipart;
|
||||||
localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary();
|
localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary();
|
||||||
}
|
}
|
||||||
@ -373,15 +374,12 @@ pplx::task<std::vector<std::shared_ptr<Pet>>> PetApi::findPetsByStatus(std::vect
|
|||||||
if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json"))
|
if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json"))
|
||||||
{
|
{
|
||||||
web::json::value localVarJson = web::json::value::parse(localVarResponse);
|
web::json::value localVarJson = web::json::value::parse(localVarResponse);
|
||||||
|
|
||||||
for( auto& localVarItem : localVarJson.as_array() )
|
for( auto& localVarItem : localVarJson.as_array() )
|
||||||
{
|
{
|
||||||
std::shared_ptr<Pet> localVarItemObj(new Pet());
|
std::shared_ptr<Pet> localVarItemObj;
|
||||||
localVarItemObj->fromJson(localVarItem);
|
ModelBase::fromJson(localVarItem, localVarItemObj);
|
||||||
localVarResult.push_back(localVarItemObj);
|
localVarResult.push_back(localVarItemObj);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data"))
|
// else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data"))
|
||||||
// {
|
// {
|
||||||
@ -504,15 +502,12 @@ pplx::task<std::vector<std::shared_ptr<Pet>>> PetApi::findPetsByTags(std::vector
|
|||||||
if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json"))
|
if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json"))
|
||||||
{
|
{
|
||||||
web::json::value localVarJson = web::json::value::parse(localVarResponse);
|
web::json::value localVarJson = web::json::value::parse(localVarResponse);
|
||||||
|
|
||||||
for( auto& localVarItem : localVarJson.as_array() )
|
for( auto& localVarItem : localVarJson.as_array() )
|
||||||
{
|
{
|
||||||
std::shared_ptr<Pet> localVarItemObj(new Pet());
|
std::shared_ptr<Pet> localVarItemObj;
|
||||||
localVarItemObj->fromJson(localVarItem);
|
ModelBase::fromJson(localVarItem, localVarItemObj);
|
||||||
localVarResult.push_back(localVarItemObj);
|
localVarResult.push_back(localVarItemObj);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data"))
|
// else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data"))
|
||||||
// {
|
// {
|
||||||
@ -640,7 +635,7 @@ pplx::task<std::shared_ptr<Pet>> PetApi::getPetById(int64_t petId) const
|
|||||||
{
|
{
|
||||||
web::json::value localVarJson = web::json::value::parse(localVarResponse);
|
web::json::value localVarJson = web::json::value::parse(localVarResponse);
|
||||||
|
|
||||||
localVarResult->fromJson(localVarJson);
|
ModelBase::fromJson(localVarJson, localVarResult);
|
||||||
}
|
}
|
||||||
// else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data"))
|
// else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data"))
|
||||||
// {
|
// {
|
||||||
@ -729,6 +724,7 @@ pplx::task<void> PetApi::updatePet(std::shared_ptr<Pet> body) const
|
|||||||
body->toMultipart(localVarMultipart, utility::conversions::to_string_t("body"));
|
body->toMultipart(localVarMultipart, utility::conversions::to_string_t("body"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
localVarHttpBody = localVarMultipart;
|
localVarHttpBody = localVarMultipart;
|
||||||
localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary();
|
localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary();
|
||||||
}
|
}
|
||||||
@ -1005,7 +1001,7 @@ pplx::task<std::shared_ptr<ApiResponse>> PetApi::uploadFile(int64_t petId, boost
|
|||||||
{
|
{
|
||||||
web::json::value localVarJson = web::json::value::parse(localVarResponse);
|
web::json::value localVarJson = web::json::value::parse(localVarResponse);
|
||||||
|
|
||||||
localVarResult->fromJson(localVarJson);
|
ModelBase::fromJson(localVarJson, localVarResult);
|
||||||
}
|
}
|
||||||
// else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data"))
|
// else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data"))
|
||||||
// {
|
// {
|
||||||
|
@ -248,10 +248,10 @@ pplx::task<std::map<utility::string_t, int32_t>> StoreApi::getInventory() const
|
|||||||
|
|
||||||
for( auto& localVarItem : localVarJson.as_object() )
|
for( auto& localVarItem : localVarJson.as_object() )
|
||||||
{
|
{
|
||||||
localVarResult[localVarItem.first] = ModelBase::int32_tFromJson(localVarItem.second);
|
int32_t localVarItemObj;
|
||||||
|
ModelBase::fromJson(localVarItem.second, localVarItemObj);
|
||||||
|
localVarResult[localVarItem.first] = localVarItemObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data"))
|
// else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data"))
|
||||||
// {
|
// {
|
||||||
@ -371,7 +371,7 @@ pplx::task<std::shared_ptr<Order>> StoreApi::getOrderById(int64_t orderId) const
|
|||||||
{
|
{
|
||||||
web::json::value localVarJson = web::json::value::parse(localVarResponse);
|
web::json::value localVarJson = web::json::value::parse(localVarResponse);
|
||||||
|
|
||||||
localVarResult->fromJson(localVarJson);
|
ModelBase::fromJson(localVarJson, localVarResult);
|
||||||
}
|
}
|
||||||
// else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data"))
|
// else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data"))
|
||||||
// {
|
// {
|
||||||
@ -460,6 +460,7 @@ pplx::task<std::shared_ptr<Order>> StoreApi::placeOrder(std::shared_ptr<Order> b
|
|||||||
body->toMultipart(localVarMultipart, utility::conversions::to_string_t("body"));
|
body->toMultipart(localVarMultipart, utility::conversions::to_string_t("body"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
localVarHttpBody = localVarMultipart;
|
localVarHttpBody = localVarMultipart;
|
||||||
localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary();
|
localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary();
|
||||||
}
|
}
|
||||||
@ -511,7 +512,7 @@ pplx::task<std::shared_ptr<Order>> StoreApi::placeOrder(std::shared_ptr<Order> b
|
|||||||
{
|
{
|
||||||
web::json::value localVarJson = web::json::value::parse(localVarResponse);
|
web::json::value localVarJson = web::json::value::parse(localVarResponse);
|
||||||
|
|
||||||
localVarResult->fromJson(localVarJson);
|
ModelBase::fromJson(localVarJson, localVarResult);
|
||||||
}
|
}
|
||||||
// else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data"))
|
// else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data"))
|
||||||
// {
|
// {
|
||||||
|
@ -107,6 +107,7 @@ pplx::task<void> UserApi::createUser(std::shared_ptr<User> body) const
|
|||||||
body->toMultipart(localVarMultipart, utility::conversions::to_string_t("body"));
|
body->toMultipart(localVarMultipart, utility::conversions::to_string_t("body"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
localVarHttpBody = localVarMultipart;
|
localVarHttpBody = localVarMultipart;
|
||||||
localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary();
|
localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary();
|
||||||
}
|
}
|
||||||
@ -222,16 +223,17 @@ pplx::task<void> UserApi::createUsersWithArrayInput(std::vector<std::shared_ptr<
|
|||||||
{
|
{
|
||||||
localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
||||||
std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData);
|
std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData);
|
||||||
|
|
||||||
{
|
{
|
||||||
std::vector<web::json::value> localVarJsonArray;
|
std::vector<web::json::value> localVarJsonArray;
|
||||||
for( auto& localVarItem : body )
|
for( auto& localVarItem : body )
|
||||||
{
|
{
|
||||||
localVarJsonArray.push_back( localVarItem.get() ? localVarItem->toJson() : web::json::value::null() );
|
localVarJsonArray.push_back(ModelBase::toJson(localVarItem));
|
||||||
|
|
||||||
}
|
}
|
||||||
localVarMultipart->add(ModelBase::toHttpContent(utility::conversions::to_string_t("body"), web::json::value::array(localVarJsonArray), utility::conversions::to_string_t("application/json")));
|
localVarMultipart->add(ModelBase::toHttpContent(utility::conversions::to_string_t("body"), localVarJsonArray, utility::conversions::to_string_t("application/json")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
localVarHttpBody = localVarMultipart;
|
localVarHttpBody = localVarMultipart;
|
||||||
localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary();
|
localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary();
|
||||||
}
|
}
|
||||||
@ -347,16 +349,17 @@ pplx::task<void> UserApi::createUsersWithListInput(std::vector<std::shared_ptr<U
|
|||||||
{
|
{
|
||||||
localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
||||||
std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData);
|
std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData);
|
||||||
|
|
||||||
{
|
{
|
||||||
std::vector<web::json::value> localVarJsonArray;
|
std::vector<web::json::value> localVarJsonArray;
|
||||||
for( auto& localVarItem : body )
|
for( auto& localVarItem : body )
|
||||||
{
|
{
|
||||||
localVarJsonArray.push_back( localVarItem.get() ? localVarItem->toJson() : web::json::value::null() );
|
localVarJsonArray.push_back(ModelBase::toJson(localVarItem));
|
||||||
|
|
||||||
}
|
}
|
||||||
localVarMultipart->add(ModelBase::toHttpContent(utility::conversions::to_string_t("body"), web::json::value::array(localVarJsonArray), utility::conversions::to_string_t("application/json")));
|
localVarMultipart->add(ModelBase::toHttpContent(utility::conversions::to_string_t("body"), localVarJsonArray, utility::conversions::to_string_t("application/json")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
localVarHttpBody = localVarMultipart;
|
localVarHttpBody = localVarMultipart;
|
||||||
localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary();
|
localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary();
|
||||||
}
|
}
|
||||||
@ -610,7 +613,7 @@ pplx::task<std::shared_ptr<User>> UserApi::getUserByName(utility::string_t usern
|
|||||||
{
|
{
|
||||||
web::json::value localVarJson = web::json::value::parse(localVarResponse);
|
web::json::value localVarJson = web::json::value::parse(localVarResponse);
|
||||||
|
|
||||||
localVarResult->fromJson(localVarJson);
|
ModelBase::fromJson(localVarJson, localVarResult);
|
||||||
}
|
}
|
||||||
// else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data"))
|
// else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data"))
|
||||||
// {
|
// {
|
||||||
@ -740,8 +743,7 @@ pplx::task<utility::string_t> UserApi::loginUser(utility::string_t username, uti
|
|||||||
{
|
{
|
||||||
web::json::value localVarJson = web::json::value::parse(localVarResponse);
|
web::json::value localVarJson = web::json::value::parse(localVarResponse);
|
||||||
|
|
||||||
localVarResult = ModelBase::stringFromJson(localVarJson);
|
ModelBase::fromJson(localVarJson, localVarResult);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(localVarResponseHttpContentType == utility::conversions::to_string_t("text/plain"))
|
else if(localVarResponseHttpContentType == utility::conversions::to_string_t("text/plain"))
|
||||||
{
|
{
|
||||||
@ -932,6 +934,7 @@ pplx::task<void> UserApi::updateUser(utility::string_t username, std::shared_ptr
|
|||||||
body->toMultipart(localVarMultipart, utility::conversions::to_string_t("body"));
|
body->toMultipart(localVarMultipart, utility::conversions::to_string_t("body"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
localVarHttpBody = localVarMultipart;
|
localVarHttpBody = localVarMultipart;
|
||||||
localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary();
|
localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary();
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ void ApiResponse::validate()
|
|||||||
|
|
||||||
web::json::value ApiResponse::toJson() const
|
web::json::value ApiResponse::toJson() const
|
||||||
{
|
{
|
||||||
|
|
||||||
web::json::value val = web::json::value::object();
|
web::json::value val = web::json::value::object();
|
||||||
|
|
||||||
if(m_CodeIsSet)
|
if(m_CodeIsSet)
|
||||||
@ -60,14 +61,18 @@ web::json::value ApiResponse::toJson() const
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApiResponse::fromJson(const web::json::value& val)
|
bool ApiResponse::fromJson(const web::json::value& val)
|
||||||
{
|
{
|
||||||
|
bool ok = true;
|
||||||
|
|
||||||
if(val.has_field(utility::conversions::to_string_t("code")))
|
if(val.has_field(utility::conversions::to_string_t("code")))
|
||||||
{
|
{
|
||||||
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("code"));
|
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("code"));
|
||||||
if(!fieldValue.is_null())
|
if(!fieldValue.is_null())
|
||||||
{
|
{
|
||||||
setCode(ModelBase::int32_tFromJson(fieldValue));
|
int32_t refVal_code;
|
||||||
|
ok &= ModelBase::fromJson(fieldValue, refVal_code);
|
||||||
|
setCode(refVal_code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(val.has_field(utility::conversions::to_string_t("type")))
|
if(val.has_field(utility::conversions::to_string_t("type")))
|
||||||
@ -75,7 +80,9 @@ void ApiResponse::fromJson(const web::json::value& val)
|
|||||||
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("type"));
|
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("type"));
|
||||||
if(!fieldValue.is_null())
|
if(!fieldValue.is_null())
|
||||||
{
|
{
|
||||||
setType(ModelBase::stringFromJson(fieldValue));
|
utility::string_t refVal_type;
|
||||||
|
ok &= ModelBase::fromJson(fieldValue, refVal_type);
|
||||||
|
setType(refVal_type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(val.has_field(utility::conversions::to_string_t("message")))
|
if(val.has_field(utility::conversions::to_string_t("message")))
|
||||||
@ -83,9 +90,12 @@ void ApiResponse::fromJson(const web::json::value& val)
|
|||||||
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("message"));
|
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("message"));
|
||||||
if(!fieldValue.is_null())
|
if(!fieldValue.is_null())
|
||||||
{
|
{
|
||||||
setMessage(ModelBase::stringFromJson(fieldValue));
|
utility::string_t refVal_message;
|
||||||
|
ok &= ModelBase::fromJson(fieldValue, refVal_message);
|
||||||
|
setMessage(refVal_message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApiResponse::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const
|
void ApiResponse::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const
|
||||||
@ -95,7 +105,6 @@ void ApiResponse::toMultipart(std::shared_ptr<MultipartFormData> multipart, cons
|
|||||||
{
|
{
|
||||||
namePrefix += utility::conversions::to_string_t(".");
|
namePrefix += utility::conversions::to_string_t(".");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_CodeIsSet)
|
if(m_CodeIsSet)
|
||||||
{
|
{
|
||||||
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("code"), m_Code));
|
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("code"), m_Code));
|
||||||
@ -110,8 +119,9 @@ void ApiResponse::toMultipart(std::shared_ptr<MultipartFormData> multipart, cons
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApiResponse::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
|
bool ApiResponse::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
|
||||||
{
|
{
|
||||||
|
bool ok = true;
|
||||||
utility::string_t namePrefix = prefix;
|
utility::string_t namePrefix = prefix;
|
||||||
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t("."))
|
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t("."))
|
||||||
{
|
{
|
||||||
@ -120,16 +130,23 @@ void ApiResponse::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, co
|
|||||||
|
|
||||||
if(multipart->hasContent(utility::conversions::to_string_t("code")))
|
if(multipart->hasContent(utility::conversions::to_string_t("code")))
|
||||||
{
|
{
|
||||||
setCode(ModelBase::int32_tFromHttpContent(multipart->getContent(utility::conversions::to_string_t("code"))));
|
int32_t refVal_code;
|
||||||
|
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t("code")), refVal_code );
|
||||||
|
setCode(refVal_code);
|
||||||
}
|
}
|
||||||
if(multipart->hasContent(utility::conversions::to_string_t("type")))
|
if(multipart->hasContent(utility::conversions::to_string_t("type")))
|
||||||
{
|
{
|
||||||
setType(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("type"))));
|
utility::string_t refVal_type;
|
||||||
|
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t("type")), refVal_type );
|
||||||
|
setType(refVal_type);
|
||||||
}
|
}
|
||||||
if(multipart->hasContent(utility::conversions::to_string_t("message")))
|
if(multipart->hasContent(utility::conversions::to_string_t("message")))
|
||||||
{
|
{
|
||||||
setMessage(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("message"))));
|
utility::string_t refVal_message;
|
||||||
|
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t("message")), refVal_message );
|
||||||
|
setMessage(refVal_message);
|
||||||
}
|
}
|
||||||
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ApiResponse::getCode() const
|
int32_t ApiResponse::getCode() const
|
||||||
@ -152,7 +169,6 @@ void ApiResponse::unsetCode()
|
|||||||
{
|
{
|
||||||
m_CodeIsSet = false;
|
m_CodeIsSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
utility::string_t ApiResponse::getType() const
|
utility::string_t ApiResponse::getType() const
|
||||||
{
|
{
|
||||||
return m_Type;
|
return m_Type;
|
||||||
@ -173,7 +189,6 @@ void ApiResponse::unsetType()
|
|||||||
{
|
{
|
||||||
m_TypeIsSet = false;
|
m_TypeIsSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
utility::string_t ApiResponse::getMessage() const
|
utility::string_t ApiResponse::getMessage() const
|
||||||
{
|
{
|
||||||
return m_Message;
|
return m_Message;
|
||||||
@ -194,7 +209,6 @@ void ApiResponse::unsetMessage()
|
|||||||
{
|
{
|
||||||
m_MessageIsSet = false;
|
m_MessageIsSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,10 +45,10 @@ public:
|
|||||||
void validate() override;
|
void validate() override;
|
||||||
|
|
||||||
web::json::value toJson() const override;
|
web::json::value toJson() const override;
|
||||||
void fromJson(const web::json::value& json) override;
|
bool fromJson(const web::json::value& json) override;
|
||||||
|
|
||||||
void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
|
void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
|
||||||
void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override;
|
bool fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override;
|
||||||
|
|
||||||
/////////////////////////////////////////////
|
/////////////////////////////////////////////
|
||||||
/// ApiResponse members
|
/// ApiResponse members
|
||||||
|
@ -40,6 +40,7 @@ void Category::validate()
|
|||||||
|
|
||||||
web::json::value Category::toJson() const
|
web::json::value Category::toJson() const
|
||||||
{
|
{
|
||||||
|
|
||||||
web::json::value val = web::json::value::object();
|
web::json::value val = web::json::value::object();
|
||||||
|
|
||||||
if(m_IdIsSet)
|
if(m_IdIsSet)
|
||||||
@ -54,14 +55,18 @@ web::json::value Category::toJson() const
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Category::fromJson(const web::json::value& val)
|
bool Category::fromJson(const web::json::value& val)
|
||||||
{
|
{
|
||||||
|
bool ok = true;
|
||||||
|
|
||||||
if(val.has_field(utility::conversions::to_string_t("id")))
|
if(val.has_field(utility::conversions::to_string_t("id")))
|
||||||
{
|
{
|
||||||
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("id"));
|
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("id"));
|
||||||
if(!fieldValue.is_null())
|
if(!fieldValue.is_null())
|
||||||
{
|
{
|
||||||
setId(ModelBase::int64_tFromJson(fieldValue));
|
int64_t refVal_id;
|
||||||
|
ok &= ModelBase::fromJson(fieldValue, refVal_id);
|
||||||
|
setId(refVal_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(val.has_field(utility::conversions::to_string_t("name")))
|
if(val.has_field(utility::conversions::to_string_t("name")))
|
||||||
@ -69,9 +74,12 @@ void Category::fromJson(const web::json::value& val)
|
|||||||
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("name"));
|
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("name"));
|
||||||
if(!fieldValue.is_null())
|
if(!fieldValue.is_null())
|
||||||
{
|
{
|
||||||
setName(ModelBase::stringFromJson(fieldValue));
|
utility::string_t refVal_name;
|
||||||
|
ok &= ModelBase::fromJson(fieldValue, refVal_name);
|
||||||
|
setName(refVal_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Category::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const
|
void Category::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const
|
||||||
@ -81,7 +89,6 @@ void Category::toMultipart(std::shared_ptr<MultipartFormData> multipart, const u
|
|||||||
{
|
{
|
||||||
namePrefix += utility::conversions::to_string_t(".");
|
namePrefix += utility::conversions::to_string_t(".");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_IdIsSet)
|
if(m_IdIsSet)
|
||||||
{
|
{
|
||||||
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("id"), m_Id));
|
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("id"), m_Id));
|
||||||
@ -92,8 +99,9 @@ void Category::toMultipart(std::shared_ptr<MultipartFormData> multipart, const u
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Category::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
|
bool Category::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
|
||||||
{
|
{
|
||||||
|
bool ok = true;
|
||||||
utility::string_t namePrefix = prefix;
|
utility::string_t namePrefix = prefix;
|
||||||
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t("."))
|
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t("."))
|
||||||
{
|
{
|
||||||
@ -102,12 +110,17 @@ void Category::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const
|
|||||||
|
|
||||||
if(multipart->hasContent(utility::conversions::to_string_t("id")))
|
if(multipart->hasContent(utility::conversions::to_string_t("id")))
|
||||||
{
|
{
|
||||||
setId(ModelBase::int64_tFromHttpContent(multipart->getContent(utility::conversions::to_string_t("id"))));
|
int64_t refVal_id;
|
||||||
|
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t("id")), refVal_id );
|
||||||
|
setId(refVal_id);
|
||||||
}
|
}
|
||||||
if(multipart->hasContent(utility::conversions::to_string_t("name")))
|
if(multipart->hasContent(utility::conversions::to_string_t("name")))
|
||||||
{
|
{
|
||||||
setName(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("name"))));
|
utility::string_t refVal_name;
|
||||||
|
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t("name")), refVal_name );
|
||||||
|
setName(refVal_name);
|
||||||
}
|
}
|
||||||
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t Category::getId() const
|
int64_t Category::getId() const
|
||||||
@ -130,7 +143,6 @@ void Category::unsetId()
|
|||||||
{
|
{
|
||||||
m_IdIsSet = false;
|
m_IdIsSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
utility::string_t Category::getName() const
|
utility::string_t Category::getName() const
|
||||||
{
|
{
|
||||||
return m_Name;
|
return m_Name;
|
||||||
@ -151,7 +163,6 @@ void Category::unsetName()
|
|||||||
{
|
{
|
||||||
m_NameIsSet = false;
|
m_NameIsSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,10 +45,10 @@ public:
|
|||||||
void validate() override;
|
void validate() override;
|
||||||
|
|
||||||
web::json::value toJson() const override;
|
web::json::value toJson() const override;
|
||||||
void fromJson(const web::json::value& json) override;
|
bool fromJson(const web::json::value& json) override;
|
||||||
|
|
||||||
void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
|
void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
|
||||||
void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override;
|
bool fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override;
|
||||||
|
|
||||||
/////////////////////////////////////////////
|
/////////////////////////////////////////////
|
||||||
/// Category members
|
/// Category members
|
||||||
|
@ -48,6 +48,7 @@ void Order::validate()
|
|||||||
|
|
||||||
web::json::value Order::toJson() const
|
web::json::value Order::toJson() const
|
||||||
{
|
{
|
||||||
|
|
||||||
web::json::value val = web::json::value::object();
|
web::json::value val = web::json::value::object();
|
||||||
|
|
||||||
if(m_IdIsSet)
|
if(m_IdIsSet)
|
||||||
@ -78,14 +79,18 @@ web::json::value Order::toJson() const
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Order::fromJson(const web::json::value& val)
|
bool Order::fromJson(const web::json::value& val)
|
||||||
{
|
{
|
||||||
|
bool ok = true;
|
||||||
|
|
||||||
if(val.has_field(utility::conversions::to_string_t("id")))
|
if(val.has_field(utility::conversions::to_string_t("id")))
|
||||||
{
|
{
|
||||||
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("id"));
|
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("id"));
|
||||||
if(!fieldValue.is_null())
|
if(!fieldValue.is_null())
|
||||||
{
|
{
|
||||||
setId(ModelBase::int64_tFromJson(fieldValue));
|
int64_t refVal_id;
|
||||||
|
ok &= ModelBase::fromJson(fieldValue, refVal_id);
|
||||||
|
setId(refVal_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(val.has_field(utility::conversions::to_string_t("petId")))
|
if(val.has_field(utility::conversions::to_string_t("petId")))
|
||||||
@ -93,7 +98,9 @@ void Order::fromJson(const web::json::value& val)
|
|||||||
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("petId"));
|
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("petId"));
|
||||||
if(!fieldValue.is_null())
|
if(!fieldValue.is_null())
|
||||||
{
|
{
|
||||||
setPetId(ModelBase::int64_tFromJson(fieldValue));
|
int64_t refVal_petId;
|
||||||
|
ok &= ModelBase::fromJson(fieldValue, refVal_petId);
|
||||||
|
setPetId(refVal_petId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(val.has_field(utility::conversions::to_string_t("quantity")))
|
if(val.has_field(utility::conversions::to_string_t("quantity")))
|
||||||
@ -101,7 +108,9 @@ void Order::fromJson(const web::json::value& val)
|
|||||||
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("quantity"));
|
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("quantity"));
|
||||||
if(!fieldValue.is_null())
|
if(!fieldValue.is_null())
|
||||||
{
|
{
|
||||||
setQuantity(ModelBase::int32_tFromJson(fieldValue));
|
int32_t refVal_quantity;
|
||||||
|
ok &= ModelBase::fromJson(fieldValue, refVal_quantity);
|
||||||
|
setQuantity(refVal_quantity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(val.has_field(utility::conversions::to_string_t("shipDate")))
|
if(val.has_field(utility::conversions::to_string_t("shipDate")))
|
||||||
@ -109,7 +118,9 @@ void Order::fromJson(const web::json::value& val)
|
|||||||
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("shipDate"));
|
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("shipDate"));
|
||||||
if(!fieldValue.is_null())
|
if(!fieldValue.is_null())
|
||||||
{
|
{
|
||||||
setShipDate(ModelBase::dateFromJson(fieldValue));
|
utility::datetime refVal_shipDate;
|
||||||
|
ok &= ModelBase::fromJson(fieldValue, refVal_shipDate);
|
||||||
|
setShipDate(refVal_shipDate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(val.has_field(utility::conversions::to_string_t("status")))
|
if(val.has_field(utility::conversions::to_string_t("status")))
|
||||||
@ -117,7 +128,9 @@ void Order::fromJson(const web::json::value& val)
|
|||||||
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("status"));
|
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("status"));
|
||||||
if(!fieldValue.is_null())
|
if(!fieldValue.is_null())
|
||||||
{
|
{
|
||||||
setStatus(ModelBase::stringFromJson(fieldValue));
|
utility::string_t refVal_status;
|
||||||
|
ok &= ModelBase::fromJson(fieldValue, refVal_status);
|
||||||
|
setStatus(refVal_status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(val.has_field(utility::conversions::to_string_t("complete")))
|
if(val.has_field(utility::conversions::to_string_t("complete")))
|
||||||
@ -125,9 +138,12 @@ void Order::fromJson(const web::json::value& val)
|
|||||||
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("complete"));
|
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("complete"));
|
||||||
if(!fieldValue.is_null())
|
if(!fieldValue.is_null())
|
||||||
{
|
{
|
||||||
setComplete(ModelBase::boolFromJson(fieldValue));
|
bool refVal_complete;
|
||||||
|
ok &= ModelBase::fromJson(fieldValue, refVal_complete);
|
||||||
|
setComplete(refVal_complete);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Order::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const
|
void Order::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const
|
||||||
@ -137,7 +153,6 @@ void Order::toMultipart(std::shared_ptr<MultipartFormData> multipart, const util
|
|||||||
{
|
{
|
||||||
namePrefix += utility::conversions::to_string_t(".");
|
namePrefix += utility::conversions::to_string_t(".");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_IdIsSet)
|
if(m_IdIsSet)
|
||||||
{
|
{
|
||||||
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("id"), m_Id));
|
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("id"), m_Id));
|
||||||
@ -164,8 +179,9 @@ void Order::toMultipart(std::shared_ptr<MultipartFormData> multipart, const util
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Order::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
|
bool Order::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
|
||||||
{
|
{
|
||||||
|
bool ok = true;
|
||||||
utility::string_t namePrefix = prefix;
|
utility::string_t namePrefix = prefix;
|
||||||
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t("."))
|
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t("."))
|
||||||
{
|
{
|
||||||
@ -174,28 +190,41 @@ void Order::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const ut
|
|||||||
|
|
||||||
if(multipart->hasContent(utility::conversions::to_string_t("id")))
|
if(multipart->hasContent(utility::conversions::to_string_t("id")))
|
||||||
{
|
{
|
||||||
setId(ModelBase::int64_tFromHttpContent(multipart->getContent(utility::conversions::to_string_t("id"))));
|
int64_t refVal_id;
|
||||||
|
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t("id")), refVal_id );
|
||||||
|
setId(refVal_id);
|
||||||
}
|
}
|
||||||
if(multipart->hasContent(utility::conversions::to_string_t("petId")))
|
if(multipart->hasContent(utility::conversions::to_string_t("petId")))
|
||||||
{
|
{
|
||||||
setPetId(ModelBase::int64_tFromHttpContent(multipart->getContent(utility::conversions::to_string_t("petId"))));
|
int64_t refVal_petId;
|
||||||
|
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t("petId")), refVal_petId );
|
||||||
|
setPetId(refVal_petId);
|
||||||
}
|
}
|
||||||
if(multipart->hasContent(utility::conversions::to_string_t("quantity")))
|
if(multipart->hasContent(utility::conversions::to_string_t("quantity")))
|
||||||
{
|
{
|
||||||
setQuantity(ModelBase::int32_tFromHttpContent(multipart->getContent(utility::conversions::to_string_t("quantity"))));
|
int32_t refVal_quantity;
|
||||||
|
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t("quantity")), refVal_quantity );
|
||||||
|
setQuantity(refVal_quantity);
|
||||||
}
|
}
|
||||||
if(multipart->hasContent(utility::conversions::to_string_t("shipDate")))
|
if(multipart->hasContent(utility::conversions::to_string_t("shipDate")))
|
||||||
{
|
{
|
||||||
setShipDate(ModelBase::dateFromHttpContent(multipart->getContent(utility::conversions::to_string_t("shipDate"))));
|
utility::datetime refVal_shipDate;
|
||||||
|
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t("shipDate")), refVal_shipDate );
|
||||||
|
setShipDate(refVal_shipDate);
|
||||||
}
|
}
|
||||||
if(multipart->hasContent(utility::conversions::to_string_t("status")))
|
if(multipart->hasContent(utility::conversions::to_string_t("status")))
|
||||||
{
|
{
|
||||||
setStatus(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("status"))));
|
utility::string_t refVal_status;
|
||||||
|
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t("status")), refVal_status );
|
||||||
|
setStatus(refVal_status);
|
||||||
}
|
}
|
||||||
if(multipart->hasContent(utility::conversions::to_string_t("complete")))
|
if(multipart->hasContent(utility::conversions::to_string_t("complete")))
|
||||||
{
|
{
|
||||||
setComplete(ModelBase::boolFromHttpContent(multipart->getContent(utility::conversions::to_string_t("complete"))));
|
bool refVal_complete;
|
||||||
|
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t("complete")), refVal_complete );
|
||||||
|
setComplete(refVal_complete);
|
||||||
}
|
}
|
||||||
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t Order::getId() const
|
int64_t Order::getId() const
|
||||||
@ -218,7 +247,6 @@ void Order::unsetId()
|
|||||||
{
|
{
|
||||||
m_IdIsSet = false;
|
m_IdIsSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t Order::getPetId() const
|
int64_t Order::getPetId() const
|
||||||
{
|
{
|
||||||
return m_PetId;
|
return m_PetId;
|
||||||
@ -239,7 +267,6 @@ void Order::unsetPetId()
|
|||||||
{
|
{
|
||||||
m_PetIdIsSet = false;
|
m_PetIdIsSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t Order::getQuantity() const
|
int32_t Order::getQuantity() const
|
||||||
{
|
{
|
||||||
return m_Quantity;
|
return m_Quantity;
|
||||||
@ -260,7 +287,6 @@ void Order::unsetQuantity()
|
|||||||
{
|
{
|
||||||
m_QuantityIsSet = false;
|
m_QuantityIsSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
utility::datetime Order::getShipDate() const
|
utility::datetime Order::getShipDate() const
|
||||||
{
|
{
|
||||||
return m_ShipDate;
|
return m_ShipDate;
|
||||||
@ -281,7 +307,6 @@ void Order::unsetShipDate()
|
|||||||
{
|
{
|
||||||
m_ShipDateIsSet = false;
|
m_ShipDateIsSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
utility::string_t Order::getStatus() const
|
utility::string_t Order::getStatus() const
|
||||||
{
|
{
|
||||||
return m_Status;
|
return m_Status;
|
||||||
@ -302,7 +327,6 @@ void Order::unsetStatus()
|
|||||||
{
|
{
|
||||||
m_StatusIsSet = false;
|
m_StatusIsSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Order::isComplete() const
|
bool Order::isComplete() const
|
||||||
{
|
{
|
||||||
return m_Complete;
|
return m_Complete;
|
||||||
@ -323,7 +347,6 @@ void Order::unsetComplete()
|
|||||||
{
|
{
|
||||||
m_CompleteIsSet = false;
|
m_CompleteIsSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,10 +45,10 @@ public:
|
|||||||
void validate() override;
|
void validate() override;
|
||||||
|
|
||||||
web::json::value toJson() const override;
|
web::json::value toJson() const override;
|
||||||
void fromJson(const web::json::value& json) override;
|
bool fromJson(const web::json::value& json) override;
|
||||||
|
|
||||||
void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
|
void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
|
||||||
void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override;
|
bool fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override;
|
||||||
|
|
||||||
/////////////////////////////////////////////
|
/////////////////////////////////////////////
|
||||||
/// Order members
|
/// Order members
|
||||||
|
@ -27,6 +27,8 @@ Pet::Pet()
|
|||||||
m_IdIsSet = false;
|
m_IdIsSet = false;
|
||||||
m_CategoryIsSet = false;
|
m_CategoryIsSet = false;
|
||||||
m_Name = utility::conversions::to_string_t("");
|
m_Name = utility::conversions::to_string_t("");
|
||||||
|
m_NameIsSet = false;
|
||||||
|
m_PhotoUrlsIsSet = false;
|
||||||
m_TagsIsSet = false;
|
m_TagsIsSet = false;
|
||||||
m_Status = utility::conversions::to_string_t("");
|
m_Status = utility::conversions::to_string_t("");
|
||||||
m_StatusIsSet = false;
|
m_StatusIsSet = false;
|
||||||
@ -43,6 +45,7 @@ void Pet::validate()
|
|||||||
|
|
||||||
web::json::value Pet::toJson() const
|
web::json::value Pet::toJson() const
|
||||||
{
|
{
|
||||||
|
|
||||||
web::json::value val = web::json::value::object();
|
web::json::value val = web::json::value::object();
|
||||||
|
|
||||||
if(m_IdIsSet)
|
if(m_IdIsSet)
|
||||||
@ -53,25 +56,17 @@ web::json::value Pet::toJson() const
|
|||||||
{
|
{
|
||||||
val[utility::conversions::to_string_t("category")] = ModelBase::toJson(m_Category);
|
val[utility::conversions::to_string_t("category")] = ModelBase::toJson(m_Category);
|
||||||
}
|
}
|
||||||
val[utility::conversions::to_string_t("name")] = ModelBase::toJson(m_Name);
|
if(m_NameIsSet)
|
||||||
{
|
{
|
||||||
std::vector<web::json::value> jsonArray;
|
val[utility::conversions::to_string_t("name")] = ModelBase::toJson(m_Name);
|
||||||
for( auto& item : m_PhotoUrls )
|
|
||||||
{
|
|
||||||
jsonArray.push_back(ModelBase::toJson(item));
|
|
||||||
}
|
|
||||||
val[utility::conversions::to_string_t("photoUrls")] = web::json::value::array(jsonArray);
|
|
||||||
}
|
}
|
||||||
|
if(m_PhotoUrlsIsSet)
|
||||||
{
|
{
|
||||||
std::vector<web::json::value> jsonArray;
|
val[utility::conversions::to_string_t("photoUrls")] = ModelBase::toJson(m_PhotoUrls);
|
||||||
for( auto& item : m_Tags )
|
}
|
||||||
{
|
if(m_TagsIsSet)
|
||||||
jsonArray.push_back(ModelBase::toJson(item));
|
{
|
||||||
}
|
val[utility::conversions::to_string_t("tags")] = ModelBase::toJson(m_Tags);
|
||||||
if(jsonArray.size() > 0)
|
|
||||||
{
|
|
||||||
val[utility::conversions::to_string_t("tags")] = web::json::value::array(jsonArray);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(m_StatusIsSet)
|
if(m_StatusIsSet)
|
||||||
{
|
{
|
||||||
@ -81,14 +76,18 @@ web::json::value Pet::toJson() const
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Pet::fromJson(const web::json::value& val)
|
bool Pet::fromJson(const web::json::value& val)
|
||||||
{
|
{
|
||||||
|
bool ok = true;
|
||||||
|
|
||||||
if(val.has_field(utility::conversions::to_string_t("id")))
|
if(val.has_field(utility::conversions::to_string_t("id")))
|
||||||
{
|
{
|
||||||
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("id"));
|
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("id"));
|
||||||
if(!fieldValue.is_null())
|
if(!fieldValue.is_null())
|
||||||
{
|
{
|
||||||
setId(ModelBase::int64_tFromJson(fieldValue));
|
int64_t refVal_id;
|
||||||
|
ok &= ModelBase::fromJson(fieldValue, refVal_id);
|
||||||
|
setId(refVal_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(val.has_field(utility::conversions::to_string_t("category")))
|
if(val.has_field(utility::conversions::to_string_t("category")))
|
||||||
@ -96,38 +95,39 @@ void Pet::fromJson(const web::json::value& val)
|
|||||||
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("category"));
|
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("category"));
|
||||||
if(!fieldValue.is_null())
|
if(!fieldValue.is_null())
|
||||||
{
|
{
|
||||||
auto newItem = std::make_shared<std::shared_ptr<Category>::element_type>();
|
std::shared_ptr<Category> refVal_category;
|
||||||
newItem->fromJson(fieldValue);
|
ok &= ModelBase::fromJson(fieldValue, refVal_category);
|
||||||
setCategory( newItem );
|
setCategory(refVal_category);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setName(ModelBase::stringFromJson(val.at(utility::conversions::to_string_t("name"))));
|
if(val.has_field(utility::conversions::to_string_t("name")))
|
||||||
{
|
{
|
||||||
m_PhotoUrls.clear();
|
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("name"));
|
||||||
std::vector<web::json::value> jsonArray;
|
if(!fieldValue.is_null())
|
||||||
for( auto& item : val.at(utility::conversions::to_string_t("photoUrls")).as_array() )
|
|
||||||
{
|
{
|
||||||
m_PhotoUrls.push_back(ModelBase::stringFromJson(item));
|
utility::string_t refVal_name;
|
||||||
|
ok &= ModelBase::fromJson(fieldValue, refVal_name);
|
||||||
|
setName(refVal_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(val.has_field(utility::conversions::to_string_t("photoUrls")))
|
||||||
{
|
{
|
||||||
m_Tags.clear();
|
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("photoUrls"));
|
||||||
std::vector<web::json::value> jsonArray;
|
if(!fieldValue.is_null())
|
||||||
if(val.has_field(utility::conversions::to_string_t("tags")))
|
|
||||||
{
|
{
|
||||||
for( auto& item : val.at(utility::conversions::to_string_t("tags")).as_array() )
|
std::vector<utility::string_t> refVal_photoUrls;
|
||||||
{
|
ok &= ModelBase::fromJson(fieldValue, refVal_photoUrls);
|
||||||
if(item.is_null())
|
setPhotoUrls(refVal_photoUrls);
|
||||||
{
|
|
||||||
m_Tags.push_back( std::shared_ptr<Tag>(nullptr) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
auto newItem = std::make_shared<std::shared_ptr<Tag>::element_type>();
|
|
||||||
newItem->fromJson(item);
|
|
||||||
m_Tags.push_back( newItem );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if(val.has_field(utility::conversions::to_string_t("tags")))
|
||||||
|
{
|
||||||
|
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("tags"));
|
||||||
|
if(!fieldValue.is_null())
|
||||||
|
{
|
||||||
|
std::vector<std::shared_ptr<Tag>> refVal_tags;
|
||||||
|
ok &= ModelBase::fromJson(fieldValue, refVal_tags);
|
||||||
|
setTags(refVal_tags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(val.has_field(utility::conversions::to_string_t("status")))
|
if(val.has_field(utility::conversions::to_string_t("status")))
|
||||||
@ -135,9 +135,12 @@ void Pet::fromJson(const web::json::value& val)
|
|||||||
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("status"));
|
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("status"));
|
||||||
if(!fieldValue.is_null())
|
if(!fieldValue.is_null())
|
||||||
{
|
{
|
||||||
setStatus(ModelBase::stringFromJson(fieldValue));
|
utility::string_t refVal_status;
|
||||||
|
ok &= ModelBase::fromJson(fieldValue, refVal_status);
|
||||||
|
setStatus(refVal_status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Pet::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const
|
void Pet::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const
|
||||||
@ -147,38 +150,25 @@ void Pet::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utilit
|
|||||||
{
|
{
|
||||||
namePrefix += utility::conversions::to_string_t(".");
|
namePrefix += utility::conversions::to_string_t(".");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_IdIsSet)
|
if(m_IdIsSet)
|
||||||
{
|
{
|
||||||
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("id"), m_Id));
|
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("id"), m_Id));
|
||||||
}
|
}
|
||||||
if(m_CategoryIsSet)
|
if(m_CategoryIsSet)
|
||||||
{
|
{
|
||||||
if (m_Category.get())
|
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("category"), m_Category));
|
||||||
{
|
|
||||||
m_Category->toMultipart(multipart, utility::conversions::to_string_t("category."));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("name"), m_Name));
|
if(m_NameIsSet)
|
||||||
{
|
{
|
||||||
std::vector<web::json::value> jsonArray;
|
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("name"), m_Name));
|
||||||
for( auto& item : m_PhotoUrls )
|
}
|
||||||
{
|
if(m_PhotoUrlsIsSet)
|
||||||
jsonArray.push_back(ModelBase::toJson(item));
|
|
||||||
}
|
|
||||||
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("photoUrls"), web::json::value::array(jsonArray), utility::conversions::to_string_t("application/json")));
|
|
||||||
}
|
|
||||||
{
|
{
|
||||||
std::vector<web::json::value> jsonArray;
|
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("photoUrls"), m_PhotoUrls));
|
||||||
for( auto& item : m_Tags )
|
}
|
||||||
{
|
if(m_TagsIsSet)
|
||||||
jsonArray.push_back(ModelBase::toJson(item));
|
{
|
||||||
}
|
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("tags"), m_Tags));
|
||||||
|
|
||||||
if(jsonArray.size() > 0)
|
|
||||||
{
|
|
||||||
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("tags"), web::json::value::array(jsonArray), utility::conversions::to_string_t("application/json")));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(m_StatusIsSet)
|
if(m_StatusIsSet)
|
||||||
{
|
{
|
||||||
@ -186,8 +176,9 @@ void Pet::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utilit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Pet::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
|
bool Pet::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
|
||||||
{
|
{
|
||||||
|
bool ok = true;
|
||||||
utility::string_t namePrefix = prefix;
|
utility::string_t namePrefix = prefix;
|
||||||
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t("."))
|
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t("."))
|
||||||
{
|
{
|
||||||
@ -196,52 +187,41 @@ void Pet::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const util
|
|||||||
|
|
||||||
if(multipart->hasContent(utility::conversions::to_string_t("id")))
|
if(multipart->hasContent(utility::conversions::to_string_t("id")))
|
||||||
{
|
{
|
||||||
setId(ModelBase::int64_tFromHttpContent(multipart->getContent(utility::conversions::to_string_t("id"))));
|
int64_t refVal_id;
|
||||||
|
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t("id")), refVal_id );
|
||||||
|
setId(refVal_id);
|
||||||
}
|
}
|
||||||
if(multipart->hasContent(utility::conversions::to_string_t("category")))
|
if(multipart->hasContent(utility::conversions::to_string_t("category")))
|
||||||
{
|
{
|
||||||
if(multipart->hasContent(utility::conversions::to_string_t("category")))
|
std::shared_ptr<Category> refVal_category;
|
||||||
{
|
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t("category")), refVal_category );
|
||||||
auto newItem = std::make_shared<std::shared_ptr<Category>::element_type>();
|
setCategory(refVal_category);
|
||||||
newItem->fromMultiPart(multipart, utility::conversions::to_string_t("category."));
|
|
||||||
setCategory( newItem );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
setName(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("name"))));
|
if(multipart->hasContent(utility::conversions::to_string_t("name")))
|
||||||
{
|
{
|
||||||
m_PhotoUrls.clear();
|
utility::string_t refVal_name;
|
||||||
|
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t("name")), refVal_name );
|
||||||
web::json::value jsonArray = web::json::value::parse(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("photoUrls"))));
|
setName(refVal_name);
|
||||||
for( auto& item : jsonArray.as_array() )
|
|
||||||
{
|
|
||||||
m_PhotoUrls.push_back(ModelBase::stringFromJson(item));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if(multipart->hasContent(utility::conversions::to_string_t("photoUrls")))
|
||||||
{
|
{
|
||||||
m_Tags.clear();
|
std::vector<utility::string_t> refVal_photoUrls;
|
||||||
if(multipart->hasContent(utility::conversions::to_string_t("tags")))
|
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t("photoUrls")), refVal_photoUrls );
|
||||||
{
|
setPhotoUrls(refVal_photoUrls);
|
||||||
|
}
|
||||||
web::json::value jsonArray = web::json::value::parse(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("tags"))));
|
if(multipart->hasContent(utility::conversions::to_string_t("tags")))
|
||||||
for( auto& item : jsonArray.as_array() )
|
{
|
||||||
{
|
std::vector<std::shared_ptr<Tag>> refVal_tags;
|
||||||
if(item.is_null())
|
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t("tags")), refVal_tags );
|
||||||
{
|
setTags(refVal_tags);
|
||||||
m_Tags.push_back( std::shared_ptr<Tag>(nullptr) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
auto newItem = std::make_shared<std::shared_ptr<Tag>::element_type>();
|
|
||||||
newItem->fromJson(item);
|
|
||||||
m_Tags.push_back( newItem );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(multipart->hasContent(utility::conversions::to_string_t("status")))
|
if(multipart->hasContent(utility::conversions::to_string_t("status")))
|
||||||
{
|
{
|
||||||
setStatus(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("status"))));
|
utility::string_t refVal_status;
|
||||||
|
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t("status")), refVal_status );
|
||||||
|
setStatus(refVal_status);
|
||||||
}
|
}
|
||||||
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t Pet::getId() const
|
int64_t Pet::getId() const
|
||||||
@ -264,7 +244,6 @@ void Pet::unsetId()
|
|||||||
{
|
{
|
||||||
m_IdIsSet = false;
|
m_IdIsSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Category> Pet::getCategory() const
|
std::shared_ptr<Category> Pet::getCategory() const
|
||||||
{
|
{
|
||||||
return m_Category;
|
return m_Category;
|
||||||
@ -285,7 +264,6 @@ void Pet::unsetCategory()
|
|||||||
{
|
{
|
||||||
m_CategoryIsSet = false;
|
m_CategoryIsSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
utility::string_t Pet::getName() const
|
utility::string_t Pet::getName() const
|
||||||
{
|
{
|
||||||
return m_Name;
|
return m_Name;
|
||||||
@ -294,9 +272,18 @@ utility::string_t Pet::getName() const
|
|||||||
void Pet::setName(const utility::string_t& value)
|
void Pet::setName(const utility::string_t& value)
|
||||||
{
|
{
|
||||||
m_Name = value;
|
m_Name = value;
|
||||||
|
m_NameIsSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Pet::nameIsSet() const
|
||||||
|
{
|
||||||
|
return m_NameIsSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Pet::unsetName()
|
||||||
|
{
|
||||||
|
m_NameIsSet = false;
|
||||||
|
}
|
||||||
std::vector<utility::string_t>& Pet::getPhotoUrls()
|
std::vector<utility::string_t>& Pet::getPhotoUrls()
|
||||||
{
|
{
|
||||||
return m_PhotoUrls;
|
return m_PhotoUrls;
|
||||||
@ -305,9 +292,18 @@ std::vector<utility::string_t>& Pet::getPhotoUrls()
|
|||||||
void Pet::setPhotoUrls(const std::vector<utility::string_t>& value)
|
void Pet::setPhotoUrls(const std::vector<utility::string_t>& value)
|
||||||
{
|
{
|
||||||
m_PhotoUrls = value;
|
m_PhotoUrls = value;
|
||||||
|
m_PhotoUrlsIsSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Pet::photoUrlsIsSet() const
|
||||||
|
{
|
||||||
|
return m_PhotoUrlsIsSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Pet::unsetPhotoUrls()
|
||||||
|
{
|
||||||
|
m_PhotoUrlsIsSet = false;
|
||||||
|
}
|
||||||
std::vector<std::shared_ptr<Tag>>& Pet::getTags()
|
std::vector<std::shared_ptr<Tag>>& Pet::getTags()
|
||||||
{
|
{
|
||||||
return m_Tags;
|
return m_Tags;
|
||||||
@ -328,7 +324,6 @@ void Pet::unsetTags()
|
|||||||
{
|
{
|
||||||
m_TagsIsSet = false;
|
m_TagsIsSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
utility::string_t Pet::getStatus() const
|
utility::string_t Pet::getStatus() const
|
||||||
{
|
{
|
||||||
return m_Status;
|
return m_Status;
|
||||||
@ -349,7 +344,6 @@ void Pet::unsetStatus()
|
|||||||
{
|
{
|
||||||
m_StatusIsSet = false;
|
m_StatusIsSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,10 +48,10 @@ public:
|
|||||||
void validate() override;
|
void validate() override;
|
||||||
|
|
||||||
web::json::value toJson() const override;
|
web::json::value toJson() const override;
|
||||||
void fromJson(const web::json::value& json) override;
|
bool fromJson(const web::json::value& json) override;
|
||||||
|
|
||||||
void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
|
void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
|
||||||
void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override;
|
bool fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override;
|
||||||
|
|
||||||
/////////////////////////////////////////////
|
/////////////////////////////////////////////
|
||||||
/// Pet members
|
/// Pet members
|
||||||
@ -78,6 +78,8 @@ public:
|
|||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
utility::string_t getName() const;
|
utility::string_t getName() const;
|
||||||
|
bool nameIsSet() const;
|
||||||
|
void unsetName();
|
||||||
|
|
||||||
void setName(const utility::string_t& value);
|
void setName(const utility::string_t& value);
|
||||||
|
|
||||||
@ -85,6 +87,8 @@ public:
|
|||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
std::vector<utility::string_t>& getPhotoUrls();
|
std::vector<utility::string_t>& getPhotoUrls();
|
||||||
|
bool photoUrlsIsSet() const;
|
||||||
|
void unsetPhotoUrls();
|
||||||
|
|
||||||
void setPhotoUrls(const std::vector<utility::string_t>& value);
|
void setPhotoUrls(const std::vector<utility::string_t>& value);
|
||||||
|
|
||||||
@ -113,8 +117,10 @@ protected:
|
|||||||
std::shared_ptr<Category> m_Category;
|
std::shared_ptr<Category> m_Category;
|
||||||
bool m_CategoryIsSet;
|
bool m_CategoryIsSet;
|
||||||
utility::string_t m_Name;
|
utility::string_t m_Name;
|
||||||
std::vector<utility::string_t> m_PhotoUrls;
|
bool m_NameIsSet;
|
||||||
std::vector<std::shared_ptr<Tag>> m_Tags;
|
std::vector<utility::string_t> m_PhotoUrls;
|
||||||
|
bool m_PhotoUrlsIsSet;
|
||||||
|
std::vector<std::shared_ptr<Tag>> m_Tags;
|
||||||
bool m_TagsIsSet;
|
bool m_TagsIsSet;
|
||||||
utility::string_t m_Status;
|
utility::string_t m_Status;
|
||||||
bool m_StatusIsSet;
|
bool m_StatusIsSet;
|
||||||
|
@ -40,6 +40,7 @@ void Tag::validate()
|
|||||||
|
|
||||||
web::json::value Tag::toJson() const
|
web::json::value Tag::toJson() const
|
||||||
{
|
{
|
||||||
|
|
||||||
web::json::value val = web::json::value::object();
|
web::json::value val = web::json::value::object();
|
||||||
|
|
||||||
if(m_IdIsSet)
|
if(m_IdIsSet)
|
||||||
@ -54,14 +55,18 @@ web::json::value Tag::toJson() const
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tag::fromJson(const web::json::value& val)
|
bool Tag::fromJson(const web::json::value& val)
|
||||||
{
|
{
|
||||||
|
bool ok = true;
|
||||||
|
|
||||||
if(val.has_field(utility::conversions::to_string_t("id")))
|
if(val.has_field(utility::conversions::to_string_t("id")))
|
||||||
{
|
{
|
||||||
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("id"));
|
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("id"));
|
||||||
if(!fieldValue.is_null())
|
if(!fieldValue.is_null())
|
||||||
{
|
{
|
||||||
setId(ModelBase::int64_tFromJson(fieldValue));
|
int64_t refVal_id;
|
||||||
|
ok &= ModelBase::fromJson(fieldValue, refVal_id);
|
||||||
|
setId(refVal_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(val.has_field(utility::conversions::to_string_t("name")))
|
if(val.has_field(utility::conversions::to_string_t("name")))
|
||||||
@ -69,9 +74,12 @@ void Tag::fromJson(const web::json::value& val)
|
|||||||
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("name"));
|
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("name"));
|
||||||
if(!fieldValue.is_null())
|
if(!fieldValue.is_null())
|
||||||
{
|
{
|
||||||
setName(ModelBase::stringFromJson(fieldValue));
|
utility::string_t refVal_name;
|
||||||
|
ok &= ModelBase::fromJson(fieldValue, refVal_name);
|
||||||
|
setName(refVal_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tag::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const
|
void Tag::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const
|
||||||
@ -81,7 +89,6 @@ void Tag::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utilit
|
|||||||
{
|
{
|
||||||
namePrefix += utility::conversions::to_string_t(".");
|
namePrefix += utility::conversions::to_string_t(".");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_IdIsSet)
|
if(m_IdIsSet)
|
||||||
{
|
{
|
||||||
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("id"), m_Id));
|
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("id"), m_Id));
|
||||||
@ -92,8 +99,9 @@ void Tag::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utilit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tag::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
|
bool Tag::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
|
||||||
{
|
{
|
||||||
|
bool ok = true;
|
||||||
utility::string_t namePrefix = prefix;
|
utility::string_t namePrefix = prefix;
|
||||||
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t("."))
|
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t("."))
|
||||||
{
|
{
|
||||||
@ -102,12 +110,17 @@ void Tag::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const util
|
|||||||
|
|
||||||
if(multipart->hasContent(utility::conversions::to_string_t("id")))
|
if(multipart->hasContent(utility::conversions::to_string_t("id")))
|
||||||
{
|
{
|
||||||
setId(ModelBase::int64_tFromHttpContent(multipart->getContent(utility::conversions::to_string_t("id"))));
|
int64_t refVal_id;
|
||||||
|
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t("id")), refVal_id );
|
||||||
|
setId(refVal_id);
|
||||||
}
|
}
|
||||||
if(multipart->hasContent(utility::conversions::to_string_t("name")))
|
if(multipart->hasContent(utility::conversions::to_string_t("name")))
|
||||||
{
|
{
|
||||||
setName(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("name"))));
|
utility::string_t refVal_name;
|
||||||
|
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t("name")), refVal_name );
|
||||||
|
setName(refVal_name);
|
||||||
}
|
}
|
||||||
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t Tag::getId() const
|
int64_t Tag::getId() const
|
||||||
@ -130,7 +143,6 @@ void Tag::unsetId()
|
|||||||
{
|
{
|
||||||
m_IdIsSet = false;
|
m_IdIsSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
utility::string_t Tag::getName() const
|
utility::string_t Tag::getName() const
|
||||||
{
|
{
|
||||||
return m_Name;
|
return m_Name;
|
||||||
@ -151,7 +163,6 @@ void Tag::unsetName()
|
|||||||
{
|
{
|
||||||
m_NameIsSet = false;
|
m_NameIsSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,10 +45,10 @@ public:
|
|||||||
void validate() override;
|
void validate() override;
|
||||||
|
|
||||||
web::json::value toJson() const override;
|
web::json::value toJson() const override;
|
||||||
void fromJson(const web::json::value& json) override;
|
bool fromJson(const web::json::value& json) override;
|
||||||
|
|
||||||
void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
|
void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
|
||||||
void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override;
|
bool fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override;
|
||||||
|
|
||||||
/////////////////////////////////////////////
|
/////////////////////////////////////////////
|
||||||
/// Tag members
|
/// Tag members
|
||||||
|
@ -52,6 +52,7 @@ void User::validate()
|
|||||||
|
|
||||||
web::json::value User::toJson() const
|
web::json::value User::toJson() const
|
||||||
{
|
{
|
||||||
|
|
||||||
web::json::value val = web::json::value::object();
|
web::json::value val = web::json::value::object();
|
||||||
|
|
||||||
if(m_IdIsSet)
|
if(m_IdIsSet)
|
||||||
@ -90,14 +91,18 @@ web::json::value User::toJson() const
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void User::fromJson(const web::json::value& val)
|
bool User::fromJson(const web::json::value& val)
|
||||||
{
|
{
|
||||||
|
bool ok = true;
|
||||||
|
|
||||||
if(val.has_field(utility::conversions::to_string_t("id")))
|
if(val.has_field(utility::conversions::to_string_t("id")))
|
||||||
{
|
{
|
||||||
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("id"));
|
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("id"));
|
||||||
if(!fieldValue.is_null())
|
if(!fieldValue.is_null())
|
||||||
{
|
{
|
||||||
setId(ModelBase::int64_tFromJson(fieldValue));
|
int64_t refVal_id;
|
||||||
|
ok &= ModelBase::fromJson(fieldValue, refVal_id);
|
||||||
|
setId(refVal_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(val.has_field(utility::conversions::to_string_t("username")))
|
if(val.has_field(utility::conversions::to_string_t("username")))
|
||||||
@ -105,7 +110,9 @@ void User::fromJson(const web::json::value& val)
|
|||||||
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("username"));
|
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("username"));
|
||||||
if(!fieldValue.is_null())
|
if(!fieldValue.is_null())
|
||||||
{
|
{
|
||||||
setUsername(ModelBase::stringFromJson(fieldValue));
|
utility::string_t refVal_username;
|
||||||
|
ok &= ModelBase::fromJson(fieldValue, refVal_username);
|
||||||
|
setUsername(refVal_username);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(val.has_field(utility::conversions::to_string_t("firstName")))
|
if(val.has_field(utility::conversions::to_string_t("firstName")))
|
||||||
@ -113,7 +120,9 @@ void User::fromJson(const web::json::value& val)
|
|||||||
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("firstName"));
|
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("firstName"));
|
||||||
if(!fieldValue.is_null())
|
if(!fieldValue.is_null())
|
||||||
{
|
{
|
||||||
setFirstName(ModelBase::stringFromJson(fieldValue));
|
utility::string_t refVal_firstName;
|
||||||
|
ok &= ModelBase::fromJson(fieldValue, refVal_firstName);
|
||||||
|
setFirstName(refVal_firstName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(val.has_field(utility::conversions::to_string_t("lastName")))
|
if(val.has_field(utility::conversions::to_string_t("lastName")))
|
||||||
@ -121,7 +130,9 @@ void User::fromJson(const web::json::value& val)
|
|||||||
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("lastName"));
|
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("lastName"));
|
||||||
if(!fieldValue.is_null())
|
if(!fieldValue.is_null())
|
||||||
{
|
{
|
||||||
setLastName(ModelBase::stringFromJson(fieldValue));
|
utility::string_t refVal_lastName;
|
||||||
|
ok &= ModelBase::fromJson(fieldValue, refVal_lastName);
|
||||||
|
setLastName(refVal_lastName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(val.has_field(utility::conversions::to_string_t("email")))
|
if(val.has_field(utility::conversions::to_string_t("email")))
|
||||||
@ -129,7 +140,9 @@ void User::fromJson(const web::json::value& val)
|
|||||||
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("email"));
|
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("email"));
|
||||||
if(!fieldValue.is_null())
|
if(!fieldValue.is_null())
|
||||||
{
|
{
|
||||||
setEmail(ModelBase::stringFromJson(fieldValue));
|
utility::string_t refVal_email;
|
||||||
|
ok &= ModelBase::fromJson(fieldValue, refVal_email);
|
||||||
|
setEmail(refVal_email);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(val.has_field(utility::conversions::to_string_t("password")))
|
if(val.has_field(utility::conversions::to_string_t("password")))
|
||||||
@ -137,7 +150,9 @@ void User::fromJson(const web::json::value& val)
|
|||||||
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("password"));
|
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("password"));
|
||||||
if(!fieldValue.is_null())
|
if(!fieldValue.is_null())
|
||||||
{
|
{
|
||||||
setPassword(ModelBase::stringFromJson(fieldValue));
|
utility::string_t refVal_password;
|
||||||
|
ok &= ModelBase::fromJson(fieldValue, refVal_password);
|
||||||
|
setPassword(refVal_password);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(val.has_field(utility::conversions::to_string_t("phone")))
|
if(val.has_field(utility::conversions::to_string_t("phone")))
|
||||||
@ -145,7 +160,9 @@ void User::fromJson(const web::json::value& val)
|
|||||||
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("phone"));
|
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("phone"));
|
||||||
if(!fieldValue.is_null())
|
if(!fieldValue.is_null())
|
||||||
{
|
{
|
||||||
setPhone(ModelBase::stringFromJson(fieldValue));
|
utility::string_t refVal_phone;
|
||||||
|
ok &= ModelBase::fromJson(fieldValue, refVal_phone);
|
||||||
|
setPhone(refVal_phone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(val.has_field(utility::conversions::to_string_t("userStatus")))
|
if(val.has_field(utility::conversions::to_string_t("userStatus")))
|
||||||
@ -153,9 +170,12 @@ void User::fromJson(const web::json::value& val)
|
|||||||
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("userStatus"));
|
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("userStatus"));
|
||||||
if(!fieldValue.is_null())
|
if(!fieldValue.is_null())
|
||||||
{
|
{
|
||||||
setUserStatus(ModelBase::int32_tFromJson(fieldValue));
|
int32_t refVal_userStatus;
|
||||||
|
ok &= ModelBase::fromJson(fieldValue, refVal_userStatus);
|
||||||
|
setUserStatus(refVal_userStatus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
void User::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const
|
void User::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const
|
||||||
@ -165,7 +185,6 @@ void User::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utili
|
|||||||
{
|
{
|
||||||
namePrefix += utility::conversions::to_string_t(".");
|
namePrefix += utility::conversions::to_string_t(".");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_IdIsSet)
|
if(m_IdIsSet)
|
||||||
{
|
{
|
||||||
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("id"), m_Id));
|
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("id"), m_Id));
|
||||||
@ -200,8 +219,9 @@ void User::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utili
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void User::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
|
bool User::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
|
||||||
{
|
{
|
||||||
|
bool ok = true;
|
||||||
utility::string_t namePrefix = prefix;
|
utility::string_t namePrefix = prefix;
|
||||||
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t("."))
|
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t("."))
|
||||||
{
|
{
|
||||||
@ -210,36 +230,53 @@ void User::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const uti
|
|||||||
|
|
||||||
if(multipart->hasContent(utility::conversions::to_string_t("id")))
|
if(multipart->hasContent(utility::conversions::to_string_t("id")))
|
||||||
{
|
{
|
||||||
setId(ModelBase::int64_tFromHttpContent(multipart->getContent(utility::conversions::to_string_t("id"))));
|
int64_t refVal_id;
|
||||||
|
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t("id")), refVal_id );
|
||||||
|
setId(refVal_id);
|
||||||
}
|
}
|
||||||
if(multipart->hasContent(utility::conversions::to_string_t("username")))
|
if(multipart->hasContent(utility::conversions::to_string_t("username")))
|
||||||
{
|
{
|
||||||
setUsername(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("username"))));
|
utility::string_t refVal_username;
|
||||||
|
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t("username")), refVal_username );
|
||||||
|
setUsername(refVal_username);
|
||||||
}
|
}
|
||||||
if(multipart->hasContent(utility::conversions::to_string_t("firstName")))
|
if(multipart->hasContent(utility::conversions::to_string_t("firstName")))
|
||||||
{
|
{
|
||||||
setFirstName(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("firstName"))));
|
utility::string_t refVal_firstName;
|
||||||
|
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t("firstName")), refVal_firstName );
|
||||||
|
setFirstName(refVal_firstName);
|
||||||
}
|
}
|
||||||
if(multipart->hasContent(utility::conversions::to_string_t("lastName")))
|
if(multipart->hasContent(utility::conversions::to_string_t("lastName")))
|
||||||
{
|
{
|
||||||
setLastName(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("lastName"))));
|
utility::string_t refVal_lastName;
|
||||||
|
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t("lastName")), refVal_lastName );
|
||||||
|
setLastName(refVal_lastName);
|
||||||
}
|
}
|
||||||
if(multipart->hasContent(utility::conversions::to_string_t("email")))
|
if(multipart->hasContent(utility::conversions::to_string_t("email")))
|
||||||
{
|
{
|
||||||
setEmail(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("email"))));
|
utility::string_t refVal_email;
|
||||||
|
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t("email")), refVal_email );
|
||||||
|
setEmail(refVal_email);
|
||||||
}
|
}
|
||||||
if(multipart->hasContent(utility::conversions::to_string_t("password")))
|
if(multipart->hasContent(utility::conversions::to_string_t("password")))
|
||||||
{
|
{
|
||||||
setPassword(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("password"))));
|
utility::string_t refVal_password;
|
||||||
|
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t("password")), refVal_password );
|
||||||
|
setPassword(refVal_password);
|
||||||
}
|
}
|
||||||
if(multipart->hasContent(utility::conversions::to_string_t("phone")))
|
if(multipart->hasContent(utility::conversions::to_string_t("phone")))
|
||||||
{
|
{
|
||||||
setPhone(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("phone"))));
|
utility::string_t refVal_phone;
|
||||||
|
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t("phone")), refVal_phone );
|
||||||
|
setPhone(refVal_phone);
|
||||||
}
|
}
|
||||||
if(multipart->hasContent(utility::conversions::to_string_t("userStatus")))
|
if(multipart->hasContent(utility::conversions::to_string_t("userStatus")))
|
||||||
{
|
{
|
||||||
setUserStatus(ModelBase::int32_tFromHttpContent(multipart->getContent(utility::conversions::to_string_t("userStatus"))));
|
int32_t refVal_userStatus;
|
||||||
|
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t("userStatus")), refVal_userStatus );
|
||||||
|
setUserStatus(refVal_userStatus);
|
||||||
}
|
}
|
||||||
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t User::getId() const
|
int64_t User::getId() const
|
||||||
@ -262,7 +299,6 @@ void User::unsetId()
|
|||||||
{
|
{
|
||||||
m_IdIsSet = false;
|
m_IdIsSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
utility::string_t User::getUsername() const
|
utility::string_t User::getUsername() const
|
||||||
{
|
{
|
||||||
return m_Username;
|
return m_Username;
|
||||||
@ -283,7 +319,6 @@ void User::unsetUsername()
|
|||||||
{
|
{
|
||||||
m_UsernameIsSet = false;
|
m_UsernameIsSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
utility::string_t User::getFirstName() const
|
utility::string_t User::getFirstName() const
|
||||||
{
|
{
|
||||||
return m_FirstName;
|
return m_FirstName;
|
||||||
@ -304,7 +339,6 @@ void User::unsetFirstName()
|
|||||||
{
|
{
|
||||||
m_FirstNameIsSet = false;
|
m_FirstNameIsSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
utility::string_t User::getLastName() const
|
utility::string_t User::getLastName() const
|
||||||
{
|
{
|
||||||
return m_LastName;
|
return m_LastName;
|
||||||
@ -325,7 +359,6 @@ void User::unsetLastName()
|
|||||||
{
|
{
|
||||||
m_LastNameIsSet = false;
|
m_LastNameIsSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
utility::string_t User::getEmail() const
|
utility::string_t User::getEmail() const
|
||||||
{
|
{
|
||||||
return m_Email;
|
return m_Email;
|
||||||
@ -346,7 +379,6 @@ void User::unsetEmail()
|
|||||||
{
|
{
|
||||||
m_EmailIsSet = false;
|
m_EmailIsSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
utility::string_t User::getPassword() const
|
utility::string_t User::getPassword() const
|
||||||
{
|
{
|
||||||
return m_Password;
|
return m_Password;
|
||||||
@ -367,7 +399,6 @@ void User::unsetPassword()
|
|||||||
{
|
{
|
||||||
m_PasswordIsSet = false;
|
m_PasswordIsSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
utility::string_t User::getPhone() const
|
utility::string_t User::getPhone() const
|
||||||
{
|
{
|
||||||
return m_Phone;
|
return m_Phone;
|
||||||
@ -388,7 +419,6 @@ void User::unsetPhone()
|
|||||||
{
|
{
|
||||||
m_PhoneIsSet = false;
|
m_PhoneIsSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t User::getUserStatus() const
|
int32_t User::getUserStatus() const
|
||||||
{
|
{
|
||||||
return m_UserStatus;
|
return m_UserStatus;
|
||||||
@ -409,7 +439,6 @@ void User::unsetUserStatus()
|
|||||||
{
|
{
|
||||||
m_UserStatusIsSet = false;
|
m_UserStatusIsSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,10 +45,10 @@ public:
|
|||||||
void validate() override;
|
void validate() override;
|
||||||
|
|
||||||
web::json::value toJson() const override;
|
web::json::value toJson() const override;
|
||||||
void fromJson(const web::json::value& json) override;
|
bool fromJson(const web::json::value& json) override;
|
||||||
|
|
||||||
void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
|
void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
|
||||||
void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override;
|
bool fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override;
|
||||||
|
|
||||||
/////////////////////////////////////////////
|
/////////////////////////////////////////////
|
||||||
/// User members
|
/// User members
|
||||||
|
Loading…
x
Reference in New Issue
Block a user