@@ -65,7 +65,7 @@ struct TRequestWithBody: public TGenericRequest<TDerived, EventType, T> {
65
65
using TBase = TRequestWithBody<TDerived, EventType, T>;
66
66
};
67
67
68
- template <typename TDerived, ui32 EventType, typename T, typename U = T>
68
+ template <typename TDerived, ui32 EventType, typename T, typename U = T, bool HasKey = true >
69
69
struct TGenericResponse : public NActors ::TEventLocal<TDerived, EventType> {
70
70
private:
71
71
IRequestContext::TPtr RequestContext;
@@ -90,6 +90,7 @@ struct TGenericResponse: public NActors::TEventLocal<TDerived, EventType> {
90
90
, Key(key)
91
91
, Result(TDerived::ResultFromOutcome(outcome))
92
92
{
93
+ static_assert (HasKey, " Object has no key" );
93
94
}
94
95
95
96
bool IsSuccess () const {
@@ -114,11 +115,17 @@ struct TGenericResponse: public NActors::TEventLocal<TDerived, EventType> {
114
115
return outcome;
115
116
}
116
117
118
+ virtual TString ToStringBody () const {
119
+ auto result = TStringBuilder ();
120
+ if constexpr (HasKey) {
121
+ result << " Key: " << (Key ? " null" : *Key);
122
+ }
123
+ result << " Result: " << Result;
124
+ return result;
125
+ }
126
+
117
127
TString ToString () const override {
118
- return TStringBuilder () << this ->ToStringHeader () << " {"
119
- << " Key: " << (Key ? " null" : *Key)
120
- << " Result: " << Result
121
- << " }" ;
128
+ return TStringBuilder () << this ->ToStringHeader () << " {" << ToStringBody () << " }" ;
122
129
}
123
130
};
124
131
@@ -143,12 +150,10 @@ struct TResponseWithBody: public TGenericResponse<TDerived, EventType, T, U> {
143
150
{
144
151
}
145
152
146
- TString ToString () const override {
147
- return TStringBuilder () << this ->ToStringHeader () << " {"
148
- << " Key: " << (this ->Key ? " null" : *this ->Key )
149
- << " Result: " << this ->Result
150
- << " Body: " << Body.size () << " b"
151
- << " }" ;
153
+ TString ToStringBody () const override {
154
+ return TStringBuilder ()
155
+ << TBase::ToStringBody ()
156
+ << " Body: " << Body.size () << " b" ;
152
157
}
153
158
};
154
159
@@ -160,48 +165,48 @@ struct TResponseWithBody: public TGenericResponse<TDerived, EventType, T, U> {
160
165
#define DEFINE_GENERIC_REQUEST (name ) \
161
166
DEFINE_REQUEST (name, TGenericRequest)
162
167
163
- #define DECLARE_GENERIC_RESPONSE (name ) \
164
- struct TEv ##name##Response: public TGenericResponse<TEv##name##Response, Ev##name##Response, Aws::S3::Model::name##Result> { \
168
+ #define DECLARE_GENERIC_RESPONSE_K (name, hasKey ) \
169
+ struct TEv ##name##Response: public TGenericResponse<TEv##name##Response, Ev##name##Response, Aws::S3::Model::name##Result, Aws::S3::Model::name##Result, hasKey > { \
165
170
private: \
166
- using TBase = TGenericResponse<TEv##name##Response, Ev##name##Response, Aws::S3::Model::name##Result>; \
171
+ using TBase = TGenericResponse<TEv##name##Response, Ev##name##Response, Aws::S3::Model::name##Result, Aws::S3::Model::name##Result, hasKey >; \
167
172
public: \
168
173
using TBase::TBase;
169
174
170
- #define DECLARE_RESPONSE_WITH_BODY (name, result_t ) \
171
- struct TEv ##name##Response: public TResponseWithBody<TEv##name##Response, Ev##name##Response, Aws::S3::Model::name##Result, result_t > { \
172
- private: \
173
- using TBase = TResponseWithBody<TEv##name##Response, Ev##name##Response, Aws::S3::Model::name##Result, result_t >; \
174
- public: \
175
- using TBase::TBase;
175
+ #define DEFINE_GENERIC_RESPONSE_K (name, hasKey ) \
176
+ DECLARE_GENERIC_RESPONSE_K (name, hasKey) \
177
+ }
176
178
177
179
#define DEFINE_GENERIC_RESPONSE (name ) \
178
- DECLARE_GENERIC_RESPONSE (name) \
179
- }
180
+ DEFINE_GENERIC_RESPONSE_K (name, true )
180
181
181
- #define DEFINE_GENERIC_REQUEST_RESPONSE (name ) \
182
+ #define DEFINE_GENERIC_REQUEST_RESPONSE_K (name, hasKey ) \
182
183
DEFINE_GENERIC_REQUEST (name); \
183
- DEFINE_GENERIC_RESPONSE (name)
184
+ DEFINE_GENERIC_RESPONSE_K (name, hasKey)
185
+
186
+ #define DEFINE_GENERIC_REQUEST_RESPONSE (name ) \
187
+ DEFINE_GENERIC_REQUEST_RESPONSE_K (name, true )
184
188
185
189
DEFINE_REQUEST(PutObject, TRequestWithBody);
186
190
DEFINE_GENERIC_RESPONSE (PutObject);
187
191
188
192
DEFINE_REQUEST (UploadPart, TRequestWithBody);
189
193
DEFINE_GENERIC_RESPONSE (UploadPart);
190
194
191
- DEFINE_GENERIC_REQUEST_RESPONSE (HeadObject);
192
- DEFINE_GENERIC_REQUEST_RESPONSE (DeleteObject);
193
- DEFINE_GENERIC_REQUEST_RESPONSE (CreateMultipartUpload);
194
- DEFINE_GENERIC_REQUEST_RESPONSE (CompleteMultipartUpload);
195
195
DEFINE_GENERIC_REQUEST_RESPONSE (AbortMultipartUpload);
196
-
197
- DEFINE_GENERIC_REQUEST (UploadPartCopy);
198
- DEFINE_GENERIC_RESPONSE (UploadPartCopy);
196
+ DEFINE_GENERIC_REQUEST_RESPONSE (CompleteMultipartUpload);
197
+ DEFINE_GENERIC_REQUEST_RESPONSE (CreateMultipartUpload);
198
+ DEFINE_GENERIC_REQUEST_RESPONSE (DeleteObject);
199
+ DEFINE_GENERIC_REQUEST_RESPONSE_K (DeleteObjects, false );
200
+ DEFINE_GENERIC_REQUEST_RESPONSE (HeadObject);
201
+ DEFINE_GENERIC_REQUEST_RESPONSE_K (ListObjects, false );
202
+ DEFINE_GENERIC_REQUEST_RESPONSE (UploadPartCopy);
199
203
200
204
#undef DEFINE_REQUEST
201
205
#undef DEFINE_GENERIC_REQUEST
202
- #undef DECLARE_GENERIC_RESPONSE
203
- #undef DECLARE_RESPONSE_WITH_BODY
206
+ #undef DECLARE_GENERIC_RESPONSE_K
204
207
#undef DEFINE_GENERIC_RESPONSE
208
+ #undef DEFINE_GENERIC_RESPONSE_K
205
209
#undef DEFINE_GENERIC_REQUEST_RESPONSE
210
+ #undef DEFINE_GENERIC_REQUEST_RESPONSE_K
206
211
207
212
}
0 commit comments