[C++][Pistache] Add comparison operators (#4619)

* [C++][Pistache] Add comparison operators

* [C++][Pistache] Update Petstore sample
This commit is contained in:
Mateusz Szychowski (Muttley) 2019-11-27 22:28:51 +01:00 committed by sunn
parent fac83ce760
commit e2df6c32e0
3 changed files with 14 additions and 1 deletions

View File

@ -24,6 +24,9 @@ struct {{classname}}
{{^required}}Pistache::Optional<{{/required}}{{{dataType}}}{{^required}}>{{/required}} {{baseName}};
{{/vars}}
bool operator==(const {{classname}}& other) const;
bool operator!=(const {{classname}}& other) const;
nlohmann::json to_json() const;
static {{classname}} from_json(const nlohmann::json& j);
};

View File

@ -21,6 +21,16 @@ nlohmann::json {{classname}}::to_json() const
return o;
}
bool {{classname}}::operator==(const {{classname}}& other) const
{
return {{#vars}}{{baseName}} == other.{{baseName}}{{#hasMore}} && {{/hasMore}}{{/vars}};
}
bool {{classname}}::operator!=(const {{classname}}& other) const
{
return !(*this == other);
}
void to_json(nlohmann::json& j, const {{classname}}& o)
{
{{#vars}}

View File

@ -1 +1 @@
4.2.1-SNAPSHOT
4.2.2-SNAPSHOT