Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converting constructor removal; distinct types; thread-safe time access #118

Merged
merged 5 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 49 additions & 7 deletions include/args.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,12 @@ struct ListObjectsArgs : public BucketArgs {

ListObjectsArgs() = default;
~ListObjectsArgs() = default;

ListObjectsArgs(const ListObjectsArgs &) = default;
ListObjectsArgs &operator=(const ListObjectsArgs &) = default;

ListObjectsArgs(ListObjectsArgs &&) = default;
ListObjectsArgs &operator=(ListObjectsArgs &&) = default;
}; // struct ListObjectsArgs

struct ListObjectsCommonArgs : public BucketArgs {
Expand All @@ -241,14 +247,29 @@ struct ListObjectsCommonArgs : public BucketArgs {

ListObjectsCommonArgs() = default;
~ListObjectsCommonArgs() = default;

ListObjectsCommonArgs(const ListObjectsCommonArgs &) = default;
ListObjectsCommonArgs &operator=(const ListObjectsCommonArgs &) = default;

ListObjectsCommonArgs(ListObjectsCommonArgs &&) = default;
ListObjectsCommonArgs &operator=(ListObjectsCommonArgs &&) = default;
}; // struct ListObjectsCommonArgs

struct ListObjectsV1Args : public ListObjectsCommonArgs {
std::string marker;

ListObjectsV1Args();
ListObjectsV1Args(ListObjectsArgs args);

explicit ListObjectsV1Args(ListObjectsArgs args);
ListObjectsV1Args &operator=(ListObjectsArgs args);

~ListObjectsV1Args() = default;

ListObjectsV1Args(const ListObjectsV1Args &) = default;
ListObjectsV1Args &operator=(const ListObjectsV1Args &) = default;

ListObjectsV1Args(ListObjectsV1Args &&) = default;
ListObjectsV1Args &operator=(ListObjectsV1Args &&) = default;
}; // struct ListObjectsV1Args

struct ListObjectsV2Args : public ListObjectsCommonArgs {
Expand All @@ -258,17 +279,35 @@ struct ListObjectsV2Args : public ListObjectsCommonArgs {
bool include_user_metadata = false;

ListObjectsV2Args();
ListObjectsV2Args(ListObjectsArgs args);

explicit ListObjectsV2Args(ListObjectsArgs args);
ListObjectsV2Args &operator=(ListObjectsArgs args);

~ListObjectsV2Args() = default;

ListObjectsV2Args(const ListObjectsV2Args &) = default;
ListObjectsV2Args &operator=(const ListObjectsV2Args &) = default;

ListObjectsV2Args(ListObjectsV2Args &&) = default;
ListObjectsV2Args &operator=(ListObjectsV2Args &&) = default;
}; // struct ListObjectsV2Args

struct ListObjectVersionsArgs : public ListObjectsCommonArgs {
std::string key_marker;
std::string version_id_marker;

ListObjectVersionsArgs();
ListObjectVersionsArgs(ListObjectsArgs args);

explicit ListObjectVersionsArgs(ListObjectsArgs args);
ListObjectVersionsArgs &operator=(ListObjectsArgs args);

~ListObjectVersionsArgs() = default;

ListObjectVersionsArgs(const ListObjectVersionsArgs &) = default;
ListObjectVersionsArgs &operator=(const ListObjectVersionsArgs &) = default;

ListObjectVersionsArgs(ListObjectVersionsArgs &&) = default;
ListObjectVersionsArgs &operator=(ListObjectVersionsArgs &&) = default;
}; // struct ListObjectVersionsArgs

struct PutObjectArgs : public PutObjectBaseArgs {
Expand Down Expand Up @@ -393,7 +432,7 @@ using GetBucketNotificationArgs = BucketArgs;
struct SetBucketNotificationArgs : public BucketArgs {
NotificationConfig &config;

SetBucketNotificationArgs(NotificationConfig &configvalue)
explicit SetBucketNotificationArgs(NotificationConfig &configvalue)
: config(configvalue) {}

~SetBucketNotificationArgs() = default;
Expand All @@ -406,7 +445,8 @@ using GetBucketEncryptionArgs = BucketArgs;
struct SetBucketEncryptionArgs : public BucketArgs {
SseConfig &config;

SetBucketEncryptionArgs(SseConfig &sseconfig) : config(sseconfig) {}
explicit SetBucketEncryptionArgs(SseConfig &sseconfig) : config(sseconfig) {}

~SetBucketEncryptionArgs() = default;

error::Error Validate() const;
Expand All @@ -431,7 +471,8 @@ using GetBucketReplicationArgs = BucketArgs;
struct SetBucketReplicationArgs : public BucketArgs {
ReplicationConfig &config;

SetBucketReplicationArgs(ReplicationConfig &value) : config(value) {}
explicit SetBucketReplicationArgs(ReplicationConfig &value) : config(value) {}

~SetBucketReplicationArgs() = default;
}; // struct SetBucketReplication

Expand All @@ -442,7 +483,8 @@ using GetBucketLifecycleArgs = BucketArgs;
struct SetBucketLifecycleArgs : public BucketArgs {
LifecycleConfig &config;

SetBucketLifecycleArgs(LifecycleConfig &value) : config(value) {}
explicit SetBucketLifecycleArgs(LifecycleConfig &value) : config(value) {}

~SetBucketLifecycleArgs() = default;
}; // struct SetBucketLifecycle

Expand Down
1 change: 1 addition & 0 deletions include/baseclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class BaseClient {
public:
explicit BaseClient(BaseUrl base_url,
creds::Provider* const provider = nullptr);

virtual ~BaseClient() = default;

void Debug(bool flag) { debug_ = flag; }
Expand Down
8 changes: 5 additions & 3 deletions include/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,22 @@ class ListObjectsResult {
void Populate();

public:
ListObjectsResult(error::Error err);
explicit ListObjectsResult(error::Error err);
ListObjectsResult(Client* const client, const ListObjectsArgs& args);
ListObjectsResult(Client* const client, ListObjectsArgs&& args);
~ListObjectsResult() = default;

Item& operator*() const { return *itr_; }
explicit operator bool() const { return itr_ != resp_.contents.end(); }

ListObjectsResult& operator++() {
itr_++;
if (!failed_ && itr_ == resp_.contents.end() && resp_.is_truncated) {
Populate();
}
return *this;
}

ListObjectsResult operator++(int) {
ListObjectsResult curr = *this;
++(*this);
Expand All @@ -73,7 +75,7 @@ class RemoveObjectsResult {
void Populate();

public:
RemoveObjectsResult(error::Error err);
explicit RemoveObjectsResult(error::Error err);
RemoveObjectsResult(Client* const client, const RemoveObjectsArgs& args);
RemoveObjectsResult(Client* const client, RemoveObjectsArgs&& args);
~RemoveObjectsResult() = default;
Expand Down Expand Up @@ -108,7 +110,7 @@ class Client : public BaseClient {
char* buf);

public:
Client(BaseUrl& base_url, creds::Provider* const provider = nullptr);
explicit Client(BaseUrl& base_url, creds::Provider* const provider = nullptr);
~Client() = default;

ComposeObjectResponse ComposeObject(ComposeObjectArgs args);
Expand Down
15 changes: 7 additions & 8 deletions include/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,8 @@ class Error {
Error(const Error&) = default;
Error& operator=(const Error&) = default;

Error(Error&& v) noexcept : msg_(std::move(v.msg_)) {}

Error& operator=(Error&& v) noexcept {
if (this != &v) {
msg_ = std::move(v.msg_);
}
return *this;
}
Error(Error&& v) = default;
Error& operator=(Error&& v) = default;

~Error() = default;

Expand All @@ -53,6 +47,11 @@ class Error {
}; // class Error

const static Error SUCCESS;

template <typename T_RESULT, typename... TA>
inline T_RESULT make(TA&&... args) {
return T_RESULT{Error(std::forward<TA>(args)...)};
}
} // namespace error
} // namespace minio

Expand Down
10 changes: 6 additions & 4 deletions include/providers.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class ChainedProvider : public Provider {
Provider* provider_ = nullptr;

public:
ChainedProvider(std::list<Provider*> providers)
explicit ChainedProvider(std::list<Provider*> providers)
: providers_(std::move(providers)) {}

virtual ~ChainedProvider();
Expand Down Expand Up @@ -108,15 +108,17 @@ class EnvMinioProvider : public Provider {

class AwsConfigProvider : public Provider {
public:
AwsConfigProvider(std::string filename = {}, std::string profile = {});
explicit AwsConfigProvider(std::string filename = {},
std::string profile = {});
virtual ~AwsConfigProvider();

virtual Credentials Fetch() override;
}; // class AwsConfigProvider

class MinioClientConfigProvider : public Provider {
public:
MinioClientConfigProvider(std::string filename = {}, std::string alias = {});
explicit MinioClientConfigProvider(std::string filename = {},
std::string alias = {});
virtual ~MinioClientConfigProvider();

virtual Credentials Fetch() override;
Expand Down Expand Up @@ -204,7 +206,7 @@ class IamAwsProvider : public Provider {
std::string full_uri_;

public:
IamAwsProvider(http::Url custom_endpoint = http::Url());
explicit IamAwsProvider(http::Url custom_endpoint = http::Url());
virtual ~IamAwsProvider();

virtual Credentials Fetch() override;
Expand Down
7 changes: 5 additions & 2 deletions include/request.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ struct BaseUrl {
bool virtual_style = false;

BaseUrl() = default;
BaseUrl(std::string host, bool https = true, std::string region = {});
explicit BaseUrl(std::string host, bool https = true,
std::string region = {});
~BaseUrl() = default;

error::Error BuildUrl(http::Url& url, http::Method method,
Expand All @@ -83,7 +84,9 @@ struct BaseUrl {
explicit operator bool() const { return !err_ && !host.empty(); }

error::Error Error() const {
if (host.empty() && !err_) return error::Error("empty host");
if (host.empty() && !err_) {
return error::Error("empty host");
}
return err_;
}

Expand Down
Loading
Loading