Skip to content

Commit 1e5f140

Browse files
authored
Include files cleanup and minor API changes (minio#124)
* use namespace::subnamespace where applicable * make minio::error::SUCCESS declared only once * make more constructors explicit (minio::error) * moved constants that seem private into .cc files * added .clang-format file to enforce more formatting rules Co-authored-by: Petr Kobalicek <[email protected]>
1 parent 238f465 commit 1e5f140

30 files changed

+748
-728
lines changed

.clang-format

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
BasedOnStyle: Google
3+
IndentWidth: 2
4+
---
5+
Language: Cpp
6+
DerivePointerAlignment: false
7+
PointerAlignment: Left
8+
---

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ set(MINIO_CPP_SOURCES
8888
src/baseclient.cc
8989
src/client.cc
9090
src/credentials.cc
91+
src/error.cc
9192
src/http.cc
9293
src/providers.cc
9394
src/request.cc

include/miniocpp/args.h

Lines changed: 58 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@
3030
#include "types.h"
3131
#include "utils.h"
3232

33-
namespace minio {
34-
namespace s3 {
33+
namespace minio::s3 {
3534

3635
struct BaseArgs {
3736
utils::Multimap extra_headers;
@@ -63,9 +62,9 @@ struct ObjectArgs : public BucketArgs {
6362
struct ObjectWriteArgs : public ObjectArgs {
6463
utils::Multimap headers;
6564
utils::Multimap user_metadata;
66-
Sse *sse = nullptr;
65+
Sse* sse = nullptr;
6766
std::map<std::string, std::string> tags;
68-
Retention *retention = nullptr;
67+
Retention* retention = nullptr;
6968
bool legal_hold = false;
7069

7170
ObjectWriteArgs() = default;
@@ -82,15 +81,15 @@ struct ObjectVersionArgs : public ObjectArgs {
8281
}; // struct ObjectVersionArgs
8382

8483
struct ObjectReadArgs : public ObjectVersionArgs {
85-
SseCustomerKey *ssec = nullptr;
84+
SseCustomerKey* ssec = nullptr;
8685

8786
ObjectReadArgs() = default;
8887
~ObjectReadArgs() = default;
8988
}; // struct ObjectReadArgs
9089

9190
struct ObjectConditionalReadArgs : public ObjectReadArgs {
92-
size_t *offset = nullptr;
93-
size_t *length = nullptr;
91+
size_t* offset = nullptr;
92+
size_t* length = nullptr;
9493
std::string match_etag;
9594
std::string not_match_etag;
9695
utils::UtcTime modified_since;
@@ -158,7 +157,7 @@ struct PutObjectApiArgs : public PutObjectBaseArgs {
158157
std::string_view data;
159158
utils::Multimap query_params;
160159
http::ProgressFunction progressfunc = nullptr;
161-
void *progress_userdata = nullptr;
160+
void* progress_userdata = nullptr;
162161

163162
PutObjectApiArgs() = default;
164163
~PutObjectApiArgs() = default;
@@ -169,7 +168,7 @@ struct UploadPartArgs : public ObjectWriteArgs {
169168
unsigned int part_number;
170169
std::string_view data;
171170
http::ProgressFunction progressfunc = nullptr;
172-
void *progress_userdata = nullptr;
171+
void* progress_userdata = nullptr;
173172

174173
UploadPartArgs() = default;
175174
~UploadPartArgs() = default;
@@ -196,7 +195,7 @@ struct DownloadObjectArgs : public ObjectReadArgs {
196195
std::string filename;
197196
bool overwrite;
198197
http::ProgressFunction progressfunc = nullptr;
199-
void *progress_userdata = nullptr;
198+
void* progress_userdata = nullptr;
200199

201200
DownloadObjectArgs() = default;
202201
~DownloadObjectArgs() = default;
@@ -206,9 +205,9 @@ struct DownloadObjectArgs : public ObjectReadArgs {
206205

207206
struct GetObjectArgs : public ObjectConditionalReadArgs {
208207
http::DataFunction datafunc;
209-
void *userdata = nullptr;
208+
void* userdata = nullptr;
210209
http::ProgressFunction progressfunc = nullptr;
211-
void *progress_userdata = nullptr;
210+
void* progress_userdata = nullptr;
212211

213212
GetObjectArgs() = default;
214213
~GetObjectArgs() = default;
@@ -235,11 +234,11 @@ struct ListObjectsArgs : public BucketArgs {
235234
ListObjectsArgs() = default;
236235
~ListObjectsArgs() = default;
237236

238-
ListObjectsArgs(const ListObjectsArgs &) = default;
239-
ListObjectsArgs &operator=(const ListObjectsArgs &) = default;
237+
ListObjectsArgs(const ListObjectsArgs&) = default;
238+
ListObjectsArgs& operator=(const ListObjectsArgs&) = default;
240239

241-
ListObjectsArgs(ListObjectsArgs &&) = default;
242-
ListObjectsArgs &operator=(ListObjectsArgs &&) = default;
240+
ListObjectsArgs(ListObjectsArgs&&) = default;
241+
ListObjectsArgs& operator=(ListObjectsArgs&&) = default;
243242
}; // struct ListObjectsArgs
244243

245244
struct ListObjectsCommonArgs : public BucketArgs {
@@ -251,11 +250,11 @@ struct ListObjectsCommonArgs : public BucketArgs {
251250
ListObjectsCommonArgs() = default;
252251
~ListObjectsCommonArgs() = default;
253252

254-
ListObjectsCommonArgs(const ListObjectsCommonArgs &) = default;
255-
ListObjectsCommonArgs &operator=(const ListObjectsCommonArgs &) = default;
253+
ListObjectsCommonArgs(const ListObjectsCommonArgs&) = default;
254+
ListObjectsCommonArgs& operator=(const ListObjectsCommonArgs&) = default;
256255

257-
ListObjectsCommonArgs(ListObjectsCommonArgs &&) = default;
258-
ListObjectsCommonArgs &operator=(ListObjectsCommonArgs &&) = default;
256+
ListObjectsCommonArgs(ListObjectsCommonArgs&&) = default;
257+
ListObjectsCommonArgs& operator=(ListObjectsCommonArgs&&) = default;
259258
}; // struct ListObjectsCommonArgs
260259

261260
struct ListObjectsV1Args : public ListObjectsCommonArgs {
@@ -264,15 +263,15 @@ struct ListObjectsV1Args : public ListObjectsCommonArgs {
264263
ListObjectsV1Args();
265264

266265
explicit ListObjectsV1Args(ListObjectsArgs args);
267-
ListObjectsV1Args &operator=(ListObjectsArgs args);
266+
ListObjectsV1Args& operator=(ListObjectsArgs args);
268267

269268
~ListObjectsV1Args() = default;
270269

271-
ListObjectsV1Args(const ListObjectsV1Args &) = default;
272-
ListObjectsV1Args &operator=(const ListObjectsV1Args &) = default;
270+
ListObjectsV1Args(const ListObjectsV1Args&) = default;
271+
ListObjectsV1Args& operator=(const ListObjectsV1Args&) = default;
273272

274-
ListObjectsV1Args(ListObjectsV1Args &&) = default;
275-
ListObjectsV1Args &operator=(ListObjectsV1Args &&) = default;
273+
ListObjectsV1Args(ListObjectsV1Args&&) = default;
274+
ListObjectsV1Args& operator=(ListObjectsV1Args&&) = default;
276275
}; // struct ListObjectsV1Args
277276

278277
struct ListObjectsV2Args : public ListObjectsCommonArgs {
@@ -284,15 +283,15 @@ struct ListObjectsV2Args : public ListObjectsCommonArgs {
284283
ListObjectsV2Args();
285284

286285
explicit ListObjectsV2Args(ListObjectsArgs args);
287-
ListObjectsV2Args &operator=(ListObjectsArgs args);
286+
ListObjectsV2Args& operator=(ListObjectsArgs args);
288287

289288
~ListObjectsV2Args() = default;
290289

291-
ListObjectsV2Args(const ListObjectsV2Args &) = default;
292-
ListObjectsV2Args &operator=(const ListObjectsV2Args &) = default;
290+
ListObjectsV2Args(const ListObjectsV2Args&) = default;
291+
ListObjectsV2Args& operator=(const ListObjectsV2Args&) = default;
293292

294-
ListObjectsV2Args(ListObjectsV2Args &&) = default;
295-
ListObjectsV2Args &operator=(ListObjectsV2Args &&) = default;
293+
ListObjectsV2Args(ListObjectsV2Args&&) = default;
294+
ListObjectsV2Args& operator=(ListObjectsV2Args&&) = default;
296295
}; // struct ListObjectsV2Args
297296

298297
struct ListObjectVersionsArgs : public ListObjectsCommonArgs {
@@ -302,23 +301,23 @@ struct ListObjectVersionsArgs : public ListObjectsCommonArgs {
302301
ListObjectVersionsArgs();
303302

304303
explicit ListObjectVersionsArgs(ListObjectsArgs args);
305-
ListObjectVersionsArgs &operator=(ListObjectsArgs args);
304+
ListObjectVersionsArgs& operator=(ListObjectsArgs args);
306305

307306
~ListObjectVersionsArgs() = default;
308307

309-
ListObjectVersionsArgs(const ListObjectVersionsArgs &) = default;
310-
ListObjectVersionsArgs &operator=(const ListObjectVersionsArgs &) = default;
308+
ListObjectVersionsArgs(const ListObjectVersionsArgs&) = default;
309+
ListObjectVersionsArgs& operator=(const ListObjectVersionsArgs&) = default;
311310

312-
ListObjectVersionsArgs(ListObjectVersionsArgs &&) = default;
313-
ListObjectVersionsArgs &operator=(ListObjectVersionsArgs &&) = default;
311+
ListObjectVersionsArgs(ListObjectVersionsArgs&&) = default;
312+
ListObjectVersionsArgs& operator=(ListObjectVersionsArgs&&) = default;
314313
}; // struct ListObjectVersionsArgs
315314

316315
struct PutObjectArgs : public PutObjectBaseArgs {
317-
std::istream &stream;
316+
std::istream& stream;
318317
http::ProgressFunction progressfunc = nullptr;
319-
void *progress_userdata = nullptr;
318+
void* progress_userdata = nullptr;
320319

321-
PutObjectArgs(std::istream &stream, long object_size, long part_size);
320+
PutObjectArgs(std::istream& stream, long object_size, long part_size);
322321
~PutObjectArgs() = default;
323322

324323
error::Error Validate();
@@ -328,8 +327,8 @@ using CopySource = ObjectConditionalReadArgs;
328327

329328
struct CopyObjectArgs : public ObjectWriteArgs {
330329
CopySource source;
331-
Directive *metadata_directive = nullptr;
332-
Directive *tagging_directive = nullptr;
330+
Directive* metadata_directive = nullptr;
331+
Directive* tagging_directive = nullptr;
333332

334333
CopyObjectArgs() = default;
335334
~CopyObjectArgs() = default;
@@ -341,7 +340,7 @@ struct ComposeSource : public ObjectConditionalReadArgs {
341340
ComposeSource() = default;
342341
~ComposeSource() = default;
343342

344-
error::Error BuildHeaders(size_t object_size, const std::string &etag);
343+
error::Error BuildHeaders(size_t object_size, const std::string& etag);
345344
size_t ObjectSize() const;
346345
utils::Multimap Headers() const;
347346

@@ -362,7 +361,7 @@ struct ComposeObjectArgs : public ObjectWriteArgs {
362361
struct UploadObjectArgs : public PutObjectBaseArgs {
363362
std::string filename;
364363
http::ProgressFunction progressfunc = nullptr;
365-
void *progress_userdata = nullptr;
364+
void* progress_userdata = nullptr;
366365

367366
UploadObjectArgs() = default;
368367
~UploadObjectArgs() = default;
@@ -379,7 +378,7 @@ struct RemoveObjectsApiArgs : public BucketArgs {
379378
~RemoveObjectsApiArgs() = default;
380379
}; // struct RemoveObjectsApiArgs
381380

382-
using DeleteObjectFunction = std::function<bool(DeleteObject &)>;
381+
using DeleteObjectFunction = std::function<bool(DeleteObject&)>;
383382

384383
struct RemoveObjectsArgs : public BucketArgs {
385384
bool bypass_governance_mode = false;
@@ -392,10 +391,10 @@ struct RemoveObjectsArgs : public BucketArgs {
392391
}; // struct RemoveObjectsArgs
393392

394393
struct SelectObjectContentArgs : public ObjectReadArgs {
395-
SelectRequest &request;
394+
SelectRequest& request;
396395
SelectResultFunction resultfunc = nullptr;
397396

398-
SelectObjectContentArgs(SelectRequest &req, SelectResultFunction func)
397+
SelectObjectContentArgs(SelectRequest& req, SelectResultFunction func)
399398
: request(req), resultfunc(func) {}
400399

401400
~SelectObjectContentArgs() = default;
@@ -433,9 +432,9 @@ using DeleteBucketNotificationArgs = BucketArgs;
433432
using GetBucketNotificationArgs = BucketArgs;
434433

435434
struct SetBucketNotificationArgs : public BucketArgs {
436-
NotificationConfig &config;
435+
NotificationConfig& config;
437436

438-
explicit SetBucketNotificationArgs(NotificationConfig &configvalue)
437+
explicit SetBucketNotificationArgs(NotificationConfig& configvalue)
439438
: config(configvalue) {}
440439

441440
~SetBucketNotificationArgs() = default;
@@ -446,9 +445,9 @@ using DeleteBucketEncryptionArgs = BucketArgs;
446445
using GetBucketEncryptionArgs = BucketArgs;
447446

448447
struct SetBucketEncryptionArgs : public BucketArgs {
449-
SseConfig &config;
448+
SseConfig& config;
450449

451-
explicit SetBucketEncryptionArgs(SseConfig &sseconfig) : config(sseconfig) {}
450+
explicit SetBucketEncryptionArgs(SseConfig& sseconfig) : config(sseconfig) {}
452451

453452
~SetBucketEncryptionArgs() = default;
454453

@@ -472,9 +471,9 @@ using DeleteBucketReplicationArgs = BucketArgs;
472471
using GetBucketReplicationArgs = BucketArgs;
473472

474473
struct SetBucketReplicationArgs : public BucketArgs {
475-
ReplicationConfig &config;
474+
ReplicationConfig& config;
476475

477-
explicit SetBucketReplicationArgs(ReplicationConfig &value) : config(value) {}
476+
explicit SetBucketReplicationArgs(ReplicationConfig& value) : config(value) {}
478477

479478
~SetBucketReplicationArgs() = default;
480479
}; // struct SetBucketReplication
@@ -484,9 +483,9 @@ using DeleteBucketLifecycleArgs = BucketArgs;
484483
using GetBucketLifecycleArgs = BucketArgs;
485484

486485
struct SetBucketLifecycleArgs : public BucketArgs {
487-
LifecycleConfig &config;
486+
LifecycleConfig& config;
488487

489-
explicit SetBucketLifecycleArgs(LifecycleConfig &value) : config(value) {}
488+
explicit SetBucketLifecycleArgs(LifecycleConfig& value) : config(value) {}
490489

491490
~SetBucketLifecycleArgs() = default;
492491
}; // struct SetBucketLifecycle
@@ -581,14 +580,14 @@ struct PostPolicy {
581580
size_t upper_limit);
582581
void RemoveContentLengthRangeCondition();
583582

584-
error::Error FormData(std::map<std::string, std::string> &data,
583+
error::Error FormData(std::map<std::string, std::string>& data,
585584
std::string access_key, std::string secret_key,
586585
std::string session_token, std::string region);
587586

588587
private:
589-
static constexpr const char *eq_ = "eq";
590-
static constexpr const char *starts_with_ = "starts-with";
591-
static constexpr const char *algorithm_ = "AWS4-HMAC-SHA256";
588+
static constexpr const char* eq_ = "eq";
589+
static constexpr const char* starts_with_ = "starts-with";
590+
static constexpr const char* algorithm_ = "AWS4-HMAC-SHA256";
592591

593592
utils::UtcTime expiration_;
594593
std::map<std::string, std::map<std::string, std::string>> conditions_;
@@ -601,7 +600,7 @@ struct PostPolicy {
601600
std::string region);
602601
static bool isReservedElement(std::string element);
603602
}; // struct PostPolicy
604-
} // namespace s3
605-
} // namespace minio
603+
604+
} // namespace minio::s3
606605

607606
#endif // _MINIO_CPP_ARGS_H_INCLUDED

include/miniocpp/baseclient.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
#include "response.h"
3232
#include "utils.h"
3333

34-
namespace minio {
35-
namespace s3 {
34+
namespace minio::s3 {
35+
3636
utils::Multimap GetCommonListObjectsQueryParams(
3737
const std::string& delimiter, const std::string& encoding_type,
3838
unsigned int max_keys, const std::string& prefix);
@@ -151,7 +151,7 @@ class BaseClient {
151151
UploadPartResponse UploadPart(UploadPartArgs args);
152152
UploadPartCopyResponse UploadPartCopy(UploadPartCopyArgs args);
153153
}; // class BaseClient
154-
} // namespace s3
155-
} // namespace minio
154+
155+
} // namespace minio::s3
156156

157157
#endif // MINIO_CPP_BASECLIENT_H_INCLUDED

include/miniocpp/client.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
#include "request.h"
2929
#include "response.h"
3030

31-
namespace minio {
32-
namespace s3 {
31+
namespace minio::s3 {
3332

3433
class Client;
3534

@@ -125,7 +124,6 @@ class Client : public BaseClient {
125124
RemoveObjectsResult RemoveObjects(RemoveObjectsArgs args);
126125
}; // class Client
127126

128-
} // namespace s3
129-
} // namespace minio
127+
} // namespace minio::s3
130128

131129
#endif // MINIO_CPP_CLIENT_H_INCLUDED

include/miniocpp/credentials.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
#include "error.h"
2525
#include "utils.h"
2626

27-
namespace minio {
28-
namespace creds {
27+
namespace minio::creds {
2928

3029
bool expired(const utils::UtcTime& expiration);
3130

@@ -76,7 +75,6 @@ struct Credentials {
7675
static Credentials ParseXML(std::string_view data, const std::string& root);
7776
}; // class Credentials
7877

79-
} // namespace creds
80-
} // namespace minio
78+
} // namespace minio::creds
8179

8280
#endif // MINIO_CPP_CREDENTIALS_H_INCLUDED

0 commit comments

Comments
 (0)