Skip to content

Commit ef8f8ea

Browse files
committed
Follow "rule of 5" for client input types
1 parent 2f990d1 commit ef8f8ea

File tree

7 files changed

+85
-22
lines changed

7 files changed

+85
-22
lines changed

samples/client/multiple/MultipleQueriesClient.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ const peg::ast& GetRequestObject() noexcept
121121
return s_request;
122122
}
123123

124+
CompleteTaskInput::CompleteTaskInput() noexcept
125+
{
126+
}
127+
124128
CompleteTaskInput::CompleteTaskInput(
125129
response::IdType idArg,
126130
std::optional<TaskState> testTaskStateArg,
@@ -149,6 +153,10 @@ CompleteTaskInput::CompleteTaskInput(CompleteTaskInput&& other) noexcept
149153
{
150154
}
151155

156+
CompleteTaskInput::~CompleteTaskInput()
157+
{
158+
}
159+
152160
CompleteTaskInput& CompleteTaskInput::operator=(const CompleteTaskInput& other)
153161
{
154162
return *this = CompleteTaskInput { other };

samples/client/multiple/MultipleQueriesClient.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,15 @@ enum class [[nodiscard]] TaskState
127127

128128
struct [[nodiscard]] CompleteTaskInput
129129
{
130-
explicit CompleteTaskInput() noexcept = default;
130+
explicit CompleteTaskInput() noexcept;
131131
explicit CompleteTaskInput(
132132
response::IdType idArg,
133133
std::optional<TaskState> testTaskStateArg,
134134
std::optional<bool> isCompleteArg,
135135
std::optional<std::string> clientMutationIdArg) noexcept;
136136
CompleteTaskInput(const CompleteTaskInput& other);
137137
CompleteTaskInput(CompleteTaskInput&& other) noexcept;
138+
~CompleteTaskInput();
138139

139140
CompleteTaskInput& operator=(const CompleteTaskInput& other);
140141
CompleteTaskInput& operator=(CompleteTaskInput&& other) noexcept;

samples/client/mutate/MutateClient.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ const peg::ast& GetRequestObject() noexcept
5454
return s_request;
5555
}
5656

57+
CompleteTaskInput::CompleteTaskInput() noexcept
58+
{
59+
}
60+
5761
CompleteTaskInput::CompleteTaskInput(
5862
response::IdType idArg,
5963
std::optional<TaskState> testTaskStateArg,
@@ -82,6 +86,10 @@ CompleteTaskInput::CompleteTaskInput(CompleteTaskInput&& other) noexcept
8286
{
8387
}
8488

89+
CompleteTaskInput::~CompleteTaskInput()
90+
{
91+
}
92+
8593
CompleteTaskInput& CompleteTaskInput::operator=(const CompleteTaskInput& other)
8694
{
8795
return *this = CompleteTaskInput { other };

samples/client/mutate/MutateClient.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,15 @@ enum class [[nodiscard]] TaskState
6060

6161
struct [[nodiscard]] CompleteTaskInput
6262
{
63-
explicit CompleteTaskInput() noexcept = default;
63+
explicit CompleteTaskInput() noexcept;
6464
explicit CompleteTaskInput(
6565
response::IdType idArg,
6666
std::optional<TaskState> testTaskStateArg,
6767
std::optional<bool> isCompleteArg,
6868
std::optional<std::string> clientMutationIdArg) noexcept;
6969
CompleteTaskInput(const CompleteTaskInput& other);
7070
CompleteTaskInput(CompleteTaskInput&& other) noexcept;
71+
~CompleteTaskInput();
7172

7273
CompleteTaskInput& operator=(const CompleteTaskInput& other);
7374
CompleteTaskInput& operator=(CompleteTaskInput&& other) noexcept;

samples/client/nestedinput/NestedInputClient.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ const peg::ast& GetRequestObject() noexcept
4848
return s_request;
4949
}
5050

51+
InputA::InputA() noexcept
52+
{
53+
}
54+
5155
InputA::InputA(
5256
bool aArg) noexcept
5357
: a { std::move(aArg) }
@@ -64,6 +68,10 @@ InputA::InputA(InputA&& other) noexcept
6468
{
6569
}
6670

71+
InputA::~InputA()
72+
{
73+
}
74+
6775
InputA& InputA::operator=(const InputA& other)
6876
{
6977
return *this = InputA { other };
@@ -76,6 +84,10 @@ InputA& InputA::operator=(InputA&& other) noexcept
7684
return *this;
7785
}
7886

87+
InputB::InputB() noexcept
88+
{
89+
}
90+
7991
InputB::InputB(
8092
double bArg) noexcept
8193
: b { std::move(bArg) }
@@ -92,6 +104,10 @@ InputB::InputB(InputB&& other) noexcept
92104
{
93105
}
94106

107+
InputB::~InputB()
108+
{
109+
}
110+
95111
InputB& InputB::operator=(const InputB& other)
96112
{
97113
return *this = InputB { other };
@@ -104,6 +120,10 @@ InputB& InputB::operator=(InputB&& other) noexcept
104120
return *this;
105121
}
106122

123+
InputABCD::InputABCD() noexcept
124+
{
125+
}
126+
107127
InputABCD::InputABCD(
108128
std::string dArg,
109129
InputA aArg,
@@ -136,6 +156,10 @@ InputABCD::InputABCD(InputABCD&& other) noexcept
136156
{
137157
}
138158

159+
InputABCD::~InputABCD()
160+
{
161+
}
162+
139163
InputABCD& InputABCD::operator=(const InputABCD& other)
140164
{
141165
return *this = InputABCD { other };
@@ -152,6 +176,10 @@ InputABCD& InputABCD::operator=(InputABCD&& other) noexcept
152176
return *this;
153177
}
154178

179+
InputBC::InputBC() noexcept
180+
{
181+
}
182+
155183
InputBC::InputBC(
156184
response::IdType cArg,
157185
InputB bArg) noexcept
@@ -172,6 +200,10 @@ InputBC::InputBC(InputBC&& other) noexcept
172200
{
173201
}
174202

203+
InputBC::~InputBC()
204+
{
205+
}
206+
175207
InputBC& InputBC::operator=(const InputBC& other)
176208
{
177209
return *this = InputBC { other };

samples/client/nestedinput/NestedInputClient.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,12 @@ namespace nestedinput {
4646

4747
struct [[nodiscard]] InputA
4848
{
49-
explicit InputA() noexcept = default;
49+
explicit InputA() noexcept;
5050
explicit InputA(
5151
bool aArg) noexcept;
5252
InputA(const InputA& other);
5353
InputA(InputA&& other) noexcept;
54+
~InputA();
5455

5556
InputA& operator=(const InputA& other);
5657
InputA& operator=(InputA&& other) noexcept;
@@ -60,11 +61,12 @@ struct [[nodiscard]] InputA
6061

6162
struct [[nodiscard]] InputB
6263
{
63-
explicit InputB() noexcept = default;
64+
explicit InputB() noexcept;
6465
explicit InputB(
6566
double bArg) noexcept;
6667
InputB(const InputB& other);
6768
InputB(InputB&& other) noexcept;
69+
~InputB();
6870

6971
InputB& operator=(const InputB& other);
7072
InputB& operator=(InputB&& other) noexcept;
@@ -76,7 +78,7 @@ struct InputBC;
7678

7779
struct [[nodiscard]] InputABCD
7880
{
79-
explicit InputABCD() noexcept = default;
81+
explicit InputABCD() noexcept;
8082
explicit InputABCD(
8183
std::string dArg,
8284
InputA aArg,
@@ -85,6 +87,7 @@ struct [[nodiscard]] InputABCD
8587
int valueArg) noexcept;
8688
InputABCD(const InputABCD& other);
8789
InputABCD(InputABCD&& other) noexcept;
90+
~InputABCD();
8891

8992
InputABCD& operator=(const InputABCD& other);
9093
InputABCD& operator=(InputABCD&& other) noexcept;
@@ -98,12 +101,13 @@ struct [[nodiscard]] InputABCD
98101

99102
struct [[nodiscard]] InputBC
100103
{
101-
explicit InputBC() noexcept = default;
104+
explicit InputBC() noexcept;
102105
explicit InputBC(
103106
response::IdType cArg,
104107
InputB bArg) noexcept;
105108
InputBC(const InputBC& other);
106109
InputBC(InputBC&& other) noexcept;
110+
~InputBC();
107111

108112
InputBC& operator=(const InputBC& other);
109113
InputBC& operator=(InputBC&& other) noexcept;

src/ClientGenerator.cpp

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,8 @@ static_assert(graphql::internal::MinorVersion == )cpp"
280280
{
281281
if (firstField)
282282
{
283-
headerFile << R"cpp() noexcept = default;
284-
explicit )cpp" << cppType
285-
<< R"cpp(()cpp";
283+
headerFile << R"cpp() noexcept;
284+
explicit )cpp" << cppType << R"cpp(()cpp";
286285
}
287286
else
288287
{
@@ -304,6 +303,7 @@ static_assert(graphql::internal::MinorVersion == )cpp"
304303
<< cppType << R"cpp(& other);
305304
)cpp" << cppType << R"cpp(()cpp"
306305
<< cppType << R"cpp(&& other) noexcept;
306+
~)cpp" << cppType << R"cpp(();
307307
308308
)cpp" << cppType << R"cpp(& operator=(const )cpp"
309309
<< cppType << R"cpp(& other);
@@ -646,7 +646,12 @@ using namespace std::literals;
646646

647647
pendingSeparator.reset();
648648

649-
sourceFile << cppType << R"cpp(::)cpp" << cppType << R"cpp(()cpp";
649+
sourceFile << cppType << R"cpp(::)cpp" << cppType << R"cpp(() noexcept
650+
{
651+
}
652+
653+
)cpp" << cppType << R"cpp(::)cpp"
654+
<< cppType << R"cpp(()cpp";
650655

651656
bool firstField = true;
652657

@@ -728,10 +733,16 @@ using namespace std::literals;
728733
sourceFile << R"cpp({
729734
}
730735
736+
)cpp" << cppType << R"cpp(::~)cpp"
737+
<< cppType << R"cpp(()
738+
{
739+
}
740+
731741
)cpp" << cppType << R"cpp(& )cpp"
732742
<< cppType << R"cpp(::operator=(const )cpp" << cppType << R"cpp(& other)
733743
{
734-
return *this = )cpp" << cppType << R"cpp( { other };
744+
return *this = )cpp"
745+
<< cppType << R"cpp( { other };
735746
}
736747
737748
)cpp" << cppType << R"cpp(& )cpp"
@@ -1036,21 +1047,20 @@ Response parseResponse(response::Value&& response)
10361047
10371048
[[nodiscard]] const std::string& Traits::GetRequestText() noexcept
10381049
{
1039-
return )cpp"
1040-
<< _schemaLoader.getSchemaNamespace() << R"cpp(::GetRequestText();
1050+
return )cpp" << _schemaLoader.getSchemaNamespace()
1051+
<< R"cpp(::GetRequestText();
10411052
}
10421053
10431054
[[nodiscard]] const peg::ast& Traits::GetRequestObject() noexcept
10441055
{
1045-
return )cpp"
1046-
<< _schemaLoader.getSchemaNamespace() << R"cpp(::GetRequestObject();
1056+
return )cpp" << _schemaLoader.getSchemaNamespace()
1057+
<< R"cpp(::GetRequestObject();
10471058
}
10481059
10491060
[[nodiscard]] const std::string& Traits::GetOperationName() noexcept
10501061
{
1051-
return )cpp"
1052-
<< _requestLoader.getOperationNamespace(operation)
1053-
<< R"cpp(::GetOperationName();
1062+
return )cpp" << _requestLoader.getOperationNamespace(operation)
1063+
<< R"cpp(::GetOperationName();
10541064
}
10551065
)cpp";
10561066

@@ -1060,17 +1070,16 @@ Response parseResponse(response::Value&& response)
10601070
[[nodiscard]] response::Value Traits::serializeVariables(Traits::Variables&& variables)
10611071
{
10621072
return )cpp" << _requestLoader.getOperationNamespace(operation)
1063-
<< R"cpp(::serializeVariables(std::move(variables));
1073+
<< R"cpp(::serializeVariables(std::move(variables));
10641074
}
10651075
)cpp";
10661076
}
10671077

10681078
sourceFile << R"cpp(
10691079
[[nodiscard]] Traits::Response Traits::parseResponse(response::Value&& response)
10701080
{
1071-
return )cpp"
1072-
<< _requestLoader.getOperationNamespace(operation)
1073-
<< R"cpp(::parseResponse(std::move(response));
1081+
return )cpp" << _requestLoader.getOperationNamespace(operation)
1082+
<< R"cpp(::parseResponse(std::move(response));
10741083
}
10751084
10761085
)cpp";

0 commit comments

Comments
 (0)