Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented missing definitions of declared methods inside modelbase-header.mustache, added two missing body of methods definitions #19569

Merged
merged 3 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -264,6 +264,72 @@ 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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -341,7 +428,17 @@ 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()) ) ) );
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(new HttpContent);
SaverioCode marked this conversation as resolved.
Show resolved Hide resolved
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()))));
SaverioCode marked this conversation as resolved.
Show resolved Hide resolved
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 )
{
Expand All @@ -366,14 +463,28 @@ bool ModelBase::fromHttpContent( std::shared_ptr<HttpContent> val, std::shared_
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}}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,72 @@ 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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -352,7 +439,17 @@ 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()) ) ) );
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(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(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 )
{
Expand All @@ -377,14 +474,28 @@ bool ModelBase::fromHttpContent( std::shared_ptr<HttpContent> val, std::shared_
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);
}
}
}
Expand Down