forked from loafle/openapi-generator-original
Implemented missing definitions of declared methods inside modelbase-header.mustache, added two missing body of methods definitions (#19569)
* Fix #19566 implemented the missing definition of declared methods inside openapi-generator/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/modelbase-header.mustache, have also be added two missing body of methods definitions * Regenerated cpp-restsdk client samples * Fixed shared_ptr creation
This commit is contained in:
parent
2f3f25dee2
commit
9163e00932
@ -255,7 +255,7 @@ bool ModelBase::fromString( const utility::string_t& val, std::shared_ptr<T>& ou
|
||||
bool ok = false;
|
||||
if(outVal == nullptr)
|
||||
{
|
||||
outVal = std::shared_ptr<T>(new T());
|
||||
outVal = std::make_shared<T>();
|
||||
}
|
||||
if( outVal != nullptr )
|
||||
{
|
||||
@ -264,12 +264,78 @@ bool ModelBase::fromString( const utility::string_t& val, std::shared_ptr<T>& ou
|
||||
return ok;
|
||||
}
|
||||
template<typename T>
|
||||
bool ModelBase::fromString(const utility::string_t& val, std::vector<T>& outVal )
|
||||
{
|
||||
bool ok = true;
|
||||
web::json::value jsonValue = web::json::value::parse(val);
|
||||
if (jsonValue.is_array())
|
||||
{
|
||||
for (const web::json::value& jitem : jsonValue.as_array())
|
||||
{
|
||||
T item;
|
||||
ok &= fromJson(jitem, item);
|
||||
outVal.push_back(item);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
T item;
|
||||
ok = fromJson(jsonValue, item);
|
||||
outVal.push_back(item);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
template<typename T>
|
||||
bool ModelBase::fromString(const utility::string_t& val, std::set<T>& outVal )
|
||||
{
|
||||
bool ok = true;
|
||||
web::json::value jsonValue = web::json::value::parse(val);
|
||||
if (jsonValue.is_array())
|
||||
{
|
||||
for (const web::json::value& jitem : jsonValue.as_array())
|
||||
{
|
||||
T item;
|
||||
ok &= fromJson(jitem, item);
|
||||
outVal.insert(item);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
T item;
|
||||
ok = fromJson(jsonValue, item);
|
||||
outVal.insert(item);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
template<typename T>
|
||||
bool ModelBase::fromString(const utility::string_t& val, std::map<utility::string_t, T>& outVal )
|
||||
{
|
||||
bool ok = false;
|
||||
web::json::value jsonValue = web::json::value::parse(val);
|
||||
if (jsonValue.is_array())
|
||||
{
|
||||
for (const web::json::value& jitem : jsonValue.as_array())
|
||||
{
|
||||
T item;
|
||||
ok &= fromJson(jitem, item);
|
||||
outVal.insert({ val, item });
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
T item;
|
||||
ok = fromJson(jsonValue, item);
|
||||
outVal.insert({ val, item });
|
||||
}
|
||||
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());
|
||||
outVal = std::make_shared<T>();
|
||||
}
|
||||
if( outVal != nullptr )
|
||||
{
|
||||
@ -297,6 +363,27 @@ bool ModelBase::fromJson( const web::json::value& val, std::vector<T> &outVal )
|
||||
return ok;
|
||||
}
|
||||
template<typename T>
|
||||
bool ModelBase::fromJson(const web::json::value& val, std::set<T>& outVal )
|
||||
{
|
||||
bool ok = true;
|
||||
if (val.is_array())
|
||||
{
|
||||
for (const web::json::value& jitem : val.as_array())
|
||||
{
|
||||
T item;
|
||||
ok &= fromJson(jitem, item);
|
||||
outVal.insert(item);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
T item;
|
||||
ok = fromJson(val, item);
|
||||
outVal.insert(item);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
template<typename T>
|
||||
bool ModelBase::fromJson( const web::json::value& jval, std::map<utility::string_t, T> &outVal )
|
||||
{
|
||||
bool ok = true;
|
||||
@ -319,13 +406,13 @@ bool ModelBase::fromJson( const web::json::value& jval, std::map<utility::string
|
||||
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 );
|
||||
std::shared_ptr<HttpContent> content = std::make_shared<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() ) ) ) );
|
||||
content->setData( std::make_shared<std::stringstream>( utility::conversions::to_utf8string(value->toJson().serialize()) ) );
|
||||
}
|
||||
return content;
|
||||
}
|
||||
@ -334,23 +421,33 @@ 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);
|
||||
std::shared_ptr<HttpContent> content( new HttpContent );
|
||||
std::shared_ptr<HttpContent> content = std::make_shared<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(json_array.serialize()) ) ) );
|
||||
content->setData( std::make_shared<std::stringstream>( utility::conversions::to_utf8string(json_array.serialize()) ) );
|
||||
return content;
|
||||
}
|
||||
template <typename T>
|
||||
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, const std::set<T>& value, const utility::string_t& contentType )
|
||||
{
|
||||
web::json::value json_array = ModelBase::toJson(value);
|
||||
std::shared_ptr<HttpContent> content = std::make_shared<HttpContent>();
|
||||
content->setName(name);
|
||||
content->setContentDisposition(utility::conversions::to_string_t("form-data"));
|
||||
content->setContentType(contentType);
|
||||
content->setData( std::make_shared<std::stringstream>( utility::conversions::to_utf8string(json_array.serialize()) ) );
|
||||
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 );
|
||||
std::shared_ptr<HttpContent> content = std::make_shared<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()) ) ) );
|
||||
content->setData( std::make_shared<std::stringstream>( utility::conversions::to_utf8string(jobj.serialize()) ) );
|
||||
return content;
|
||||
}
|
||||
template <typename T>
|
||||
@ -360,20 +457,34 @@ bool ModelBase::fromHttpContent( std::shared_ptr<HttpContent> val, std::shared_
|
||||
if(val == nullptr) return false;
|
||||
if( outVal == nullptr )
|
||||
{
|
||||
outVal = std::shared_ptr<T>(new T());
|
||||
outVal = std::make_shared<T>();
|
||||
}
|
||||
ModelBase::fromHttpContent(val, str);
|
||||
return fromString(str, outVal);
|
||||
}
|
||||
template <typename T>
|
||||
bool ModelBase::fromHttpContent( std::shared_ptr<HttpContent> val, std::vector<T> & )
|
||||
bool ModelBase::fromHttpContent( std::shared_ptr<HttpContent> val, std::vector<T> & outVal )
|
||||
{
|
||||
return true;
|
||||
utility::string_t str;
|
||||
if (val == nullptr) return false;
|
||||
ModelBase::fromHttpContent(val, str);
|
||||
return fromString(str, outVal);
|
||||
}
|
||||
template <typename T>
|
||||
bool ModelBase::fromHttpContent( std::shared_ptr<HttpContent> val, std::map<utility::string_t, T> & )
|
||||
bool ModelBase::fromHttpContent(std::shared_ptr<HttpContent> val, std::set<T>& outVal )
|
||||
{
|
||||
return true;
|
||||
utility::string_t str;
|
||||
if (val == nullptr) return false;
|
||||
ModelBase::fromHttpContent(val, str);
|
||||
return fromString(str, outVal);
|
||||
}
|
||||
template <typename T>
|
||||
bool ModelBase::fromHttpContent( std::shared_ptr<HttpContent> val, std::map<utility::string_t, T> & outVal )
|
||||
{
|
||||
utility::string_t str;
|
||||
if (val == nullptr) return false;
|
||||
ModelBase::fromHttpContent(val, str);
|
||||
return fromString(str, outVal);
|
||||
}
|
||||
{{#modelNamespaceDeclarations}}
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ bool ModelBase::fromString( const utility::string_t& val, std::shared_ptr<T>& ou
|
||||
bool ok = false;
|
||||
if(outVal == nullptr)
|
||||
{
|
||||
outVal = std::shared_ptr<T>(new T());
|
||||
outVal = std::make_shared<T>();
|
||||
}
|
||||
if( outVal != nullptr )
|
||||
{
|
||||
@ -275,12 +275,78 @@ bool ModelBase::fromString( const utility::string_t& val, std::shared_ptr<T>& ou
|
||||
return ok;
|
||||
}
|
||||
template<typename T>
|
||||
bool ModelBase::fromString(const utility::string_t& val, std::vector<T>& outVal )
|
||||
{
|
||||
bool ok = true;
|
||||
web::json::value jsonValue = web::json::value::parse(val);
|
||||
if (jsonValue.is_array())
|
||||
{
|
||||
for (const web::json::value& jitem : jsonValue.as_array())
|
||||
{
|
||||
T item;
|
||||
ok &= fromJson(jitem, item);
|
||||
outVal.push_back(item);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
T item;
|
||||
ok = fromJson(jsonValue, item);
|
||||
outVal.push_back(item);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
template<typename T>
|
||||
bool ModelBase::fromString(const utility::string_t& val, std::set<T>& outVal )
|
||||
{
|
||||
bool ok = true;
|
||||
web::json::value jsonValue = web::json::value::parse(val);
|
||||
if (jsonValue.is_array())
|
||||
{
|
||||
for (const web::json::value& jitem : jsonValue.as_array())
|
||||
{
|
||||
T item;
|
||||
ok &= fromJson(jitem, item);
|
||||
outVal.insert(item);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
T item;
|
||||
ok = fromJson(jsonValue, item);
|
||||
outVal.insert(item);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
template<typename T>
|
||||
bool ModelBase::fromString(const utility::string_t& val, std::map<utility::string_t, T>& outVal )
|
||||
{
|
||||
bool ok = false;
|
||||
web::json::value jsonValue = web::json::value::parse(val);
|
||||
if (jsonValue.is_array())
|
||||
{
|
||||
for (const web::json::value& jitem : jsonValue.as_array())
|
||||
{
|
||||
T item;
|
||||
ok &= fromJson(jitem, item);
|
||||
outVal.insert({ val, item });
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
T item;
|
||||
ok = fromJson(jsonValue, item);
|
||||
outVal.insert({ val, item });
|
||||
}
|
||||
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());
|
||||
outVal = std::make_shared<T>();
|
||||
}
|
||||
if( outVal != nullptr )
|
||||
{
|
||||
@ -308,6 +374,27 @@ bool ModelBase::fromJson( const web::json::value& val, std::vector<T> &outVal )
|
||||
return ok;
|
||||
}
|
||||
template<typename T>
|
||||
bool ModelBase::fromJson(const web::json::value& val, std::set<T>& outVal )
|
||||
{
|
||||
bool ok = true;
|
||||
if (val.is_array())
|
||||
{
|
||||
for (const web::json::value& jitem : val.as_array())
|
||||
{
|
||||
T item;
|
||||
ok &= fromJson(jitem, item);
|
||||
outVal.insert(item);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
T item;
|
||||
ok = fromJson(val, item);
|
||||
outVal.insert(item);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
template<typename T>
|
||||
bool ModelBase::fromJson( const web::json::value& jval, std::map<utility::string_t, T> &outVal )
|
||||
{
|
||||
bool ok = true;
|
||||
@ -330,13 +417,13 @@ bool ModelBase::fromJson( const web::json::value& jval, std::map<utility::string
|
||||
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 );
|
||||
std::shared_ptr<HttpContent> content = std::make_shared<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() ) ) ) );
|
||||
content->setData( std::make_shared<std::stringstream>( utility::conversions::to_utf8string(value->toJson().serialize()) ) );
|
||||
}
|
||||
return content;
|
||||
}
|
||||
@ -345,23 +432,33 @@ 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);
|
||||
std::shared_ptr<HttpContent> content( new HttpContent );
|
||||
std::shared_ptr<HttpContent> content = std::make_shared<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(json_array.serialize()) ) ) );
|
||||
content->setData( std::make_shared<std::stringstream>( utility::conversions::to_utf8string(json_array.serialize()) ) );
|
||||
return content;
|
||||
}
|
||||
template <typename T>
|
||||
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, const std::set<T>& value, const utility::string_t& contentType )
|
||||
{
|
||||
web::json::value json_array = ModelBase::toJson(value);
|
||||
std::shared_ptr<HttpContent> content = std::make_shared<HttpContent>();
|
||||
content->setName(name);
|
||||
content->setContentDisposition(utility::conversions::to_string_t("form-data"));
|
||||
content->setContentType(contentType);
|
||||
content->setData( std::make_shared<std::stringstream>( utility::conversions::to_utf8string(json_array.serialize()) ) );
|
||||
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 );
|
||||
std::shared_ptr<HttpContent> content = std::make_shared<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()) ) ) );
|
||||
content->setData( std::make_shared<std::stringstream>( utility::conversions::to_utf8string(jobj.serialize()) ) );
|
||||
return content;
|
||||
}
|
||||
template <typename T>
|
||||
@ -371,20 +468,34 @@ bool ModelBase::fromHttpContent( std::shared_ptr<HttpContent> val, std::shared_
|
||||
if(val == nullptr) return false;
|
||||
if( outVal == nullptr )
|
||||
{
|
||||
outVal = std::shared_ptr<T>(new T());
|
||||
outVal = std::make_shared<T>();
|
||||
}
|
||||
ModelBase::fromHttpContent(val, str);
|
||||
return fromString(str, outVal);
|
||||
}
|
||||
template <typename T>
|
||||
bool ModelBase::fromHttpContent( std::shared_ptr<HttpContent> val, std::vector<T> & )
|
||||
bool ModelBase::fromHttpContent( std::shared_ptr<HttpContent> val, std::vector<T> & outVal )
|
||||
{
|
||||
return true;
|
||||
utility::string_t str;
|
||||
if (val == nullptr) return false;
|
||||
ModelBase::fromHttpContent(val, str);
|
||||
return fromString(str, outVal);
|
||||
}
|
||||
template <typename T>
|
||||
bool ModelBase::fromHttpContent( std::shared_ptr<HttpContent> val, std::map<utility::string_t, T> & )
|
||||
bool ModelBase::fromHttpContent(std::shared_ptr<HttpContent> val, std::set<T>& outVal )
|
||||
{
|
||||
return true;
|
||||
utility::string_t str;
|
||||
if (val == nullptr) return false;
|
||||
ModelBase::fromHttpContent(val, str);
|
||||
return fromString(str, outVal);
|
||||
}
|
||||
template <typename T>
|
||||
bool ModelBase::fromHttpContent( std::shared_ptr<HttpContent> val, std::map<utility::string_t, T> & outVal )
|
||||
{
|
||||
utility::string_t str;
|
||||
if (val == nullptr) return false;
|
||||
ModelBase::fromHttpContent(val, str);
|
||||
return fromString(str, outVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user