Skip to content

Commit e2df6c3

Browse files
muttleyxdetherealjoy
authored andcommitted
[C++][Pistache] Add comparison operators (#4619)
* [C++][Pistache] Add comparison operators * [C++][Pistache] Update Petstore sample
1 parent fac83ce commit e2df6c3

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

modules/openapi-generator/src/main/resources/cpp-pistache-server/model-struct-header.mustache

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ struct {{classname}}
2424
{{^required}}Pistache::Optional<{{/required}}{{{dataType}}}{{^required}}>{{/required}} {{baseName}};
2525
{{/vars}}
2626

27+
bool operator==(const {{classname}}& other) const;
28+
bool operator!=(const {{classname}}& other) const;
29+
2730
nlohmann::json to_json() const;
2831
static {{classname}} from_json(const nlohmann::json& j);
2932
};

modules/openapi-generator/src/main/resources/cpp-pistache-server/model-struct-source.mustache

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ nlohmann::json {{classname}}::to_json() const
2121
return o;
2222
}
2323

24+
bool {{classname}}::operator==(const {{classname}}& other) const
25+
{
26+
return {{#vars}}{{baseName}} == other.{{baseName}}{{#hasMore}} && {{/hasMore}}{{/vars}};
27+
}
28+
29+
bool {{classname}}::operator!=(const {{classname}}& other) const
30+
{
31+
return !(*this == other);
32+
}
33+
2434
void to_json(nlohmann::json& j, const {{classname}}& o)
2535
{
2636
{{#vars}}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.2.1-SNAPSHOT
1+
4.2.2-SNAPSHOT

0 commit comments

Comments
 (0)