Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ if(NOT CMAKE_BUILD_TYPE)
endif()

find_package(cpprestsdk REQUIRED)
target_compile_definitions(cpprestsdk::cpprest INTERFACE _TURN_OFF_PLATFORM_STRING)
find_package(Boost REQUIRED)

include(GNUInstallDirs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ using EnumUnderlyingType = {{#isNumeric}}int64_t{{/isNumeric}}{{^isNumeric}}util
{{/isNumeric}}
{{^isNumeric}}
{{#enumVars}}
if (val == utility::conversions::to_string_t(U("{{{value}}}")))
if (val == utility::conversions::to_string_t(_XPLATSTR("{{{value}}}")))
return {{classname}}::e{{classname}}::{{classname}}_{{name}};
{{/enumVars}}
{{/isNumeric}}
Expand All @@ -97,7 +97,7 @@ EnumUnderlyingType fromEnum({{classname}}::e{{classname}} e)
{
{{#enumVars}}
case {{classname}}::e{{classname}}::{{classname}}_{{name}}:
return {{#isNumeric}}{{value}}{{/isNumeric}}{{^isNumeric}}U("{{value}}"){{/isNumeric}};
return {{#isNumeric}}{{value}}{{/isNumeric}}{{^isNumeric}}_XPLATSTR("{{value}}"){{/isNumeric}};
{{#-last}}
default:
break;
Expand Down Expand Up @@ -137,9 +137,9 @@ bool {{classname}}::fromJson(const web::json::value& val)
void {{classname}}::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const
{
utility::string_t namePrefix = prefix;
if (!namePrefix.empty() && namePrefix.back() != U('.'))
if (!namePrefix.empty() && namePrefix.back() != _XPLATSTR('.'))
{
namePrefix.push_back(U('.'));
namePrefix.push_back(_XPLATSTR('.'));
}

auto e = fromEnum(m_value);
Expand All @@ -150,9 +150,9 @@ bool {{classname}}::fromMultiPart(std::shared_ptr<MultipartFormData> multipart,
{
bool ok = true;
utility::string_t namePrefix = prefix;
if (!namePrefix.empty() && namePrefix.back() != U('.'))
if (!namePrefix.empty() && namePrefix.back() != _XPLATSTR('.'))
{
namePrefix.push_back(U('.'));
namePrefix.push_back(_XPLATSTR('.'));
}
{
EnumUnderlyingType e;
Expand Down Expand Up @@ -231,13 +231,13 @@ web::json::value {{classname}}::toJson() const
{{#isEnum}}{{#isContainer}}{{#isArray}}
{{{dataType}}} refVal = from{{{enumName}}}(m_{{name}});
{{/isArray}}{{#isMap}}
val[utility::conversions::to_string_t(U("{{baseName}}"))] = ModelBase::toJson(m_{{name}});
val[utility::conversions::to_string_t(_XPLATSTR("{{baseName}}"))] = ModelBase::toJson(m_{{name}});
{{/isMap}}{{/isContainer}}{{^isContainer}}
utility::string_t refVal = from{{{datatypeWithEnum}}}(m_{{name}});
{{/isContainer}}{{^isMap}}val[utility::conversions::to_string_t(U("{{baseName}}"))] = ModelBase::toJson(refVal);
{{/isContainer}}{{^isMap}}val[utility::conversions::to_string_t(_XPLATSTR("{{baseName}}"))] = ModelBase::toJson(refVal);
{{/isMap}}{{/isEnum}}
{{^isEnum}}
val[utility::conversions::to_string_t(U("{{baseName}}"))] = ModelBase::toJson(m_{{name}});
val[utility::conversions::to_string_t(_XPLATSTR("{{baseName}}"))] = ModelBase::toJson(m_{{name}});
{{/isEnum}}
}
{{/isInherited}}
Expand All @@ -254,9 +254,9 @@ bool {{classname}}::fromJson(const web::json::value& val)
{{/parent}}
{{#vars}}
{{^isInherited}}
if(val.has_field(utility::conversions::to_string_t(U("{{baseName}}"))))
if(val.has_field(utility::conversions::to_string_t(_XPLATSTR("{{baseName}}"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("{{baseName}}")));
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(_XPLATSTR("{{baseName}}")));
if(!fieldValue.is_null())
{
{{{dataType}}} refVal_{{setter}};
Expand All @@ -281,26 +281,26 @@ bool {{classname}}::fromJson(const web::json::value& val)
void {{classname}}::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const
{
utility::string_t namePrefix = prefix;
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U(".")))
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(_XPLATSTR(".")))
{
namePrefix += utility::conversions::to_string_t(U("."));
namePrefix += utility::conversions::to_string_t(_XPLATSTR("."));
}
{{#vars}}
if(m_{{name}}IsSet)
{
{{^isEnum}}
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("{{baseName}}")), m_{{name}}));
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(_XPLATSTR("{{baseName}}")), m_{{name}}));
{{/isEnum}}
{{#isEnum}}
{{#isContainer}}
{{#isArray}}
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("{{baseName}}")), from{{{enumName}}}(m_{{name}})));
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(_XPLATSTR("{{baseName}}")), from{{{enumName}}}(m_{{name}})));
{{/isArray}}{{#isMap}}
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("{{baseName}}")), m_{{name}}));
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(_XPLATSTR("{{baseName}}")), m_{{name}}));
{{/isMap}}
{{/isContainer}}
{{^isContainer}}
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("{{baseName}}")), from{{{datatypeWithEnum}}}(m_{{name}})));
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(_XPLATSTR("{{baseName}}")), from{{{datatypeWithEnum}}}(m_{{name}})));
{{/isContainer}}
{{/isEnum}}
}
Expand All @@ -311,16 +311,16 @@ bool {{classname}}::fromMultiPart(std::shared_ptr<MultipartFormData> multipart,
{
bool ok = true;
utility::string_t namePrefix = prefix;
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U(".")))
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(_XPLATSTR(".")))
{
namePrefix += utility::conversions::to_string_t(U("."));
namePrefix += utility::conversions::to_string_t(_XPLATSTR("."));
}

{{#vars}}
if(multipart->hasContent(utility::conversions::to_string_t(U("{{baseName}}"))))
if(multipart->hasContent(utility::conversions::to_string_t(_XPLATSTR("{{baseName}}"))))
{
{{{dataType}}} refVal_{{setter}};
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("{{baseName}}"))), refVal_{{setter}} );
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(_XPLATSTR("{{baseName}}"))), refVal_{{setter}} );
{{^isEnum}}
{{setter}}(refVal_{{setter}});
{{/isEnum}}
Expand Down
1 change: 1 addition & 0 deletions samples/client/petstore/cpp-restsdk/client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ if(NOT CMAKE_BUILD_TYPE)
endif()

find_package(cpprestsdk REQUIRED)
target_compile_definitions(cpprestsdk::cpprest INTERFACE _TURN_OFF_PLATFORM_STRING)
find_package(Boost REQUIRED)

include(GNUInstallDirs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ web::json::value ApiResponse::toJson() const
if(m_CodeIsSet)
{

val[utility::conversions::to_string_t(U("code"))] = ModelBase::toJson(m_Code);
val[utility::conversions::to_string_t(_XPLATSTR("code"))] = ModelBase::toJson(m_Code);
}
if(m_TypeIsSet)
{

val[utility::conversions::to_string_t(U("type"))] = ModelBase::toJson(m_Type);
val[utility::conversions::to_string_t(_XPLATSTR("type"))] = ModelBase::toJson(m_Type);
}
if(m_MessageIsSet)
{

val[utility::conversions::to_string_t(U("message"))] = ModelBase::toJson(m_Message);
val[utility::conversions::to_string_t(_XPLATSTR("message"))] = ModelBase::toJson(m_Message);
}

return val;
Expand All @@ -62,9 +62,9 @@ web::json::value ApiResponse::toJson() const
bool ApiResponse::fromJson(const web::json::value& val)
{
bool ok = true;
if(val.has_field(utility::conversions::to_string_t(U("code"))))
if(val.has_field(utility::conversions::to_string_t(_XPLATSTR("code"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("code")));
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(_XPLATSTR("code")));
if(!fieldValue.is_null())
{
int32_t refVal_setCode;
Expand All @@ -73,9 +73,9 @@ bool ApiResponse::fromJson(const web::json::value& val)

}
}
if(val.has_field(utility::conversions::to_string_t(U("type"))))
if(val.has_field(utility::conversions::to_string_t(_XPLATSTR("type"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("type")));
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(_XPLATSTR("type")));
if(!fieldValue.is_null())
{
utility::string_t refVal_setType;
Expand All @@ -84,9 +84,9 @@ bool ApiResponse::fromJson(const web::json::value& val)

}
}
if(val.has_field(utility::conversions::to_string_t(U("message"))))
if(val.has_field(utility::conversions::to_string_t(_XPLATSTR("message"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("message")));
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(_XPLATSTR("message")));
if(!fieldValue.is_null())
{
utility::string_t refVal_setMessage;
Expand All @@ -101,49 +101,49 @@ bool ApiResponse::fromJson(const web::json::value& val)
void ApiResponse::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const
{
utility::string_t namePrefix = prefix;
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U(".")))
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(_XPLATSTR(".")))
{
namePrefix += utility::conversions::to_string_t(U("."));
namePrefix += utility::conversions::to_string_t(_XPLATSTR("."));
}
if(m_CodeIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("code")), m_Code));
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(_XPLATSTR("code")), m_Code));
}
if(m_TypeIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("type")), m_Type));
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(_XPLATSTR("type")), m_Type));
}
if(m_MessageIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("message")), m_Message));
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(_XPLATSTR("message")), m_Message));
}
}

bool ApiResponse::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
{
bool ok = true;
utility::string_t namePrefix = prefix;
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U(".")))
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(_XPLATSTR(".")))
{
namePrefix += utility::conversions::to_string_t(U("."));
namePrefix += utility::conversions::to_string_t(_XPLATSTR("."));
}

if(multipart->hasContent(utility::conversions::to_string_t(U("code"))))
if(multipart->hasContent(utility::conversions::to_string_t(_XPLATSTR("code"))))
{
int32_t refVal_setCode;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("code"))), refVal_setCode );
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(_XPLATSTR("code"))), refVal_setCode );
setCode(refVal_setCode);
}
if(multipart->hasContent(utility::conversions::to_string_t(U("type"))))
if(multipart->hasContent(utility::conversions::to_string_t(_XPLATSTR("type"))))
{
utility::string_t refVal_setType;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("type"))), refVal_setType );
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(_XPLATSTR("type"))), refVal_setType );
setType(refVal_setType);
}
if(multipart->hasContent(utility::conversions::to_string_t(U("message"))))
if(multipart->hasContent(utility::conversions::to_string_t(_XPLATSTR("message"))))
{
utility::string_t refVal_setMessage;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("message"))), refVal_setMessage );
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(_XPLATSTR("message"))), refVal_setMessage );
setMessage(refVal_setMessage);
}
return ok;
Expand Down
32 changes: 16 additions & 16 deletions samples/client/petstore/cpp-restsdk/client/src/model/Category.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ web::json::value Category::toJson() const
if(m_IdIsSet)
{

val[utility::conversions::to_string_t(U("id"))] = ModelBase::toJson(m_Id);
val[utility::conversions::to_string_t(_XPLATSTR("id"))] = ModelBase::toJson(m_Id);
}
if(m_NameIsSet)
{

val[utility::conversions::to_string_t(U("name"))] = ModelBase::toJson(m_Name);
val[utility::conversions::to_string_t(_XPLATSTR("name"))] = ModelBase::toJson(m_Name);
}

return val;
Expand All @@ -55,9 +55,9 @@ web::json::value Category::toJson() const
bool Category::fromJson(const web::json::value& val)
{
bool ok = true;
if(val.has_field(utility::conversions::to_string_t(U("id"))))
if(val.has_field(utility::conversions::to_string_t(_XPLATSTR("id"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("id")));
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(_XPLATSTR("id")));
if(!fieldValue.is_null())
{
int64_t refVal_setId;
Expand All @@ -66,9 +66,9 @@ bool Category::fromJson(const web::json::value& val)

}
}
if(val.has_field(utility::conversions::to_string_t(U("name"))))
if(val.has_field(utility::conversions::to_string_t(_XPLATSTR("name"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("name")));
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(_XPLATSTR("name")));
if(!fieldValue.is_null())
{
utility::string_t refVal_setName;
Expand All @@ -83,39 +83,39 @@ bool Category::fromJson(const web::json::value& val)
void Category::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const
{
utility::string_t namePrefix = prefix;
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U(".")))
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(_XPLATSTR(".")))
{
namePrefix += utility::conversions::to_string_t(U("."));
namePrefix += utility::conversions::to_string_t(_XPLATSTR("."));
}
if(m_IdIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("id")), m_Id));
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(_XPLATSTR("id")), m_Id));
}
if(m_NameIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("name")), m_Name));
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(_XPLATSTR("name")), m_Name));
}
}

bool Category::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
{
bool ok = true;
utility::string_t namePrefix = prefix;
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U(".")))
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(_XPLATSTR(".")))
{
namePrefix += utility::conversions::to_string_t(U("."));
namePrefix += utility::conversions::to_string_t(_XPLATSTR("."));
}

if(multipart->hasContent(utility::conversions::to_string_t(U("id"))))
if(multipart->hasContent(utility::conversions::to_string_t(_XPLATSTR("id"))))
{
int64_t refVal_setId;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("id"))), refVal_setId );
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(_XPLATSTR("id"))), refVal_setId );
setId(refVal_setId);
}
if(multipart->hasContent(utility::conversions::to_string_t(U("name"))))
if(multipart->hasContent(utility::conversions::to_string_t(_XPLATSTR("name"))))
{
utility::string_t refVal_setName;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("name"))), refVal_setName );
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(_XPLATSTR("name"))), refVal_setName );
setName(refVal_setName);
}
return ok;
Expand Down
Loading
Loading