Skip to content

Commit 869dc09

Browse files
committed
Enclose everything in namespace to avoid symbol collision
1 parent 793648f commit 869dc09

16 files changed

Lines changed: 1879 additions & 1696 deletions

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ add_library(s3cpplib STATIC
2626
src/s3cpp/types.h
2727
src/s3cpp/s3.cpp
2828
)
29-
target_include_directories(s3cpplib PUBLIC src include)
29+
target_include_directories(s3cpplib PUBLIC src)
3030
target_link_libraries(s3cpplib PUBLIC CURL::libcurl OpenSSL::Crypto)
3131

3232
set_target_properties(s3cpplib PROPERTIES
@@ -43,6 +43,7 @@ add_executable(tests
4343
test/auth_test.cpp
4444
test/xml_test.cpp
4545
test/s3_test.cpp
46+
test/aws_test.cpp
4647
)
4748

4849
target_link_libraries(tests s3cpplib GTest::gtest_main GTest::gmock_main CURL::libcurl OpenSSL::Crypto)

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ A lightweight C++ client library for AWS S3, with zero 3rd party C++ dependencie
1515

1616
Each S3 Client is organized onto modular components:
1717

18-
- `src/s3cpp/httpclient`: HTTP/1.1 client built on libCurl
19-
- `src/s3cpp/auth`: AWS Signature V4 auth protocol (SigV4a pending)
20-
- `src/s3cpp/xml`: A custom FSM for parsing XML
18+
- `src/s3cpp/httpclient`
19+
- `src/s3cpp/auth`: AWS Signature V4 auth protocol
20+
- `src/s3cpp/xml`: A custom FSM for parsing valid XML
2121

2222
## Basic Usage
2323

@@ -27,7 +27,7 @@ Create a bucket:
2727
#include <s3cpp/s3.h>
2828

2929
int main() {
30-
S3Client client("access_key", "secret_key");
30+
s3cpp::S3Client client("access_key", "secret_key");
3131

3232
auto result = client.CreateBucket("my-bucket", {
3333
.LocationConstraint = "us-east-1"
@@ -47,7 +47,7 @@ List all buckets:
4747
#include <s3cpp/s3.h>
4848

4949
int main() {
50-
S3Client client("access_key", "secret_key");
50+
s3cpp::S3Client client("access_key", "secret_key");
5151

5252
auto result = client.ListBuckets();
5353

@@ -69,7 +69,7 @@ List objects in a bucket:
6969
#include <s3cpp/s3.h>
7070

7171
int main() {
72-
S3Client client("access_key", "secret_key");
72+
s3cpp::S3Client client("access_key", "secret_key");
7373

7474
// List 100 objects with a prefix
7575
auto result = client.ListObjects("my-bucket", {
@@ -95,13 +95,13 @@ For buckets with many objects, use the paginator to automatically handle continu
9595
#include <s3cpp/s3.h>
9696

9797
int main() {
98-
S3Client client("access_key", "secret_key");
99-
ListObjectsPaginator paginator(client, "my-bucket", "path/to/", 100);
98+
s3cpp::S3Client client("access_key", "secret_key");
99+
s3cpp::ListObjectsPaginator paginator(client, "my-bucket", "path/to/", 100);
100100

101101
int totalObjects = 0;
102102

103103
while (paginator.HasMorePages()) {
104-
std::expected<ListObjectsResult, Error> page = paginator.NextPage();
104+
std::expected<s3cpp::ListObjectsResult, s3cpp::Error> page = paginator.NextPage();
105105

106106
if (!page) {
107107
std::println("Error: {}", page.error().Message);
@@ -123,13 +123,13 @@ Checking if a bucket exists:
123123
```cpp
124124
#include <s3cpp/s3.h>
125125

126-
bool BucketExists(S3Client& client, const std::string& bucketName) {
126+
bool BucketExists(s3cpp::S3Client& client, const std::string& bucketName) {
127127
auto result = client.HeadBucket(bucketName);
128128
return result.has_value();
129129
}
130130

131131
int main() {
132-
S3Client client("access_key", "secret_key");
132+
s3cpp::S3Client client("access_key", "secret_key");
133133

134134
if (BucketExists(client, "my-bucket")) {
135135
std::println("Bucket exists");
@@ -147,10 +147,10 @@ Delete a non-empty bucket:
147147
#include <s3cpp/s3.h>
148148
149149
int main() {
150-
S3Client client("access_key", "secret_key");
150+
s3cpp::S3Client client("access_key", "secret_key");
151151
152152
// To delete a bucket we first need to delete all its contents
153-
ListObjectsPaginator paginator(client, "my-bucket", "", 1000);
153+
s3cpp::ListObjectsPaginator paginator(client, "my-bucket", "", 1000);
154154
155155
while (paginator.HasMorePages()) {
156156
auto page = paginator.NextPage();
@@ -199,4 +199,4 @@ $ docker run -d -p 9000:9000 -p 9001:9001 \
199199
server /data --console-address ":9001"
200200
```
201201

202-
The full test suite contains 60 tests
202+
The full test suite contains 62 tests

main.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
#include <s3cpp/s3.h>
33

44
int main() {
5-
S3Client client("minio_access", "minio_secret");
6-
ListObjectsPaginator paginator(client, "my-bucket", "path/to/", 100);
5+
s3cpp::S3Client client("minio_access", "minio_secret");
6+
s3cpp::ListObjectsPaginator paginator(client, "my-bucket", "path/to/", 100);
77

88
int totalObjects = 0;
99

1010
while (paginator.HasMorePages()) {
11-
std::expected<ListObjectsResult, Error> page = paginator.NextPage();
11+
std::expected<s3cpp::ListObjectsResult, s3cpp::Error> page =
12+
paginator.NextPage();
1213

1314
if (!page) {
1415
std::println("Error: {}", page.error().Message);

0 commit comments

Comments
 (0)