Skip to content

Commit 954ddc2

Browse files
committed
release 0.0.9-beta source code
1 parent cadc00a commit 954ddc2

File tree

2,163 files changed

+11791
-6559
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,163 files changed

+11791
-6559
lines changed

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
# 0.0.9-beta 2023-10-30
2+
3+
### G42Cloud SDK MPC
4+
5+
- _Features_
6+
- None
7+
- _Bug Fix_
8+
- None
9+
- _Change_
10+
- **CreateThumbnailsTask**
11+
- changes of request param
12+
- `- thumbnail_para.percent`
13+
- `- thumbnail_para.type: enum value [PERCENT]`
14+
- **CreateTranscodingTask**
15+
- changes of request param
16+
- `- thumbnail.params.percent`
17+
- `- thumbnail.params.type: enum value [PERCENT]`
18+
119
# 0.0.8-beta 2023-08-26
220

321
### G42Cloud SDK MPC

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<p align="center">
2-
<a href="https://www.g42cloud.com/"><img src="https://upload.wikimedia.org/wikipedia/en/4/43/Group_42_Logo.jpg"></a>
2+
<a href="https://www.g42cloud.com/"><img src="https://upload.wikimedia.org/wikipedia/en/thumb/9/94/Group_42_logo.png/330px-Group_42_logo.png"></a>
33
</p>
44

55
<h1 align="center">G42 Cloud C++ Software Development Kit (C++ SDK)</h1>

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.8-beta
1+
0.0.9-beta

core/CMakeLists.txt

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,40 @@ else()
2222
find_package(Boost REQUIRED COMPONENTS filesystem thread system regex date_time program_options)
2323
endif()
2424

25-
file(GLOB source_file "src/*.cpp" "src/auth/*.cpp" "src/http/*.cpp" "src/utils/*.cpp" "src/exception/*.cpp")
25+
if(ENABLE_BSON)
26+
file(GLOB source_file "src/*.cpp" "src/auth/*.cpp" "src/http/*.cpp" "src/utils/*.cpp" "src/exception/*.cpp" "src/bson/*.cpp" "src/bson/impl/*.cpp")
27+
file(GLOB core_bson_header ${CMAKE_CURRENT_SOURCE_DIR}/include/g42cloud/core/bson/*.h)
28+
file(GLOB core_bson_impl_header ${CMAKE_CURRENT_SOURCE_DIR}/include/g42cloud/core/bson/impl/*.h)
29+
else()
30+
file(GLOB source_file "src/*.cpp" "src/auth/*.cpp" "src/http/*.cpp" "src/utils/*.cpp" "src/exception/*.cpp")
31+
endif ()
2632
file(GLOB core_header ${CMAKE_CURRENT_SOURCE_DIR}/include/g42cloud/core/*.h)
2733
file(GLOB core_auth_header ${CMAKE_CURRENT_SOURCE_DIR}/include/g42cloud/core/auth/*.h)
2834
file(GLOB core_exception_header ${CMAKE_CURRENT_SOURCE_DIR}/include/g42cloud/core/exception/*.h)
2935
file(GLOB core_http_header ${CMAKE_CURRENT_SOURCE_DIR}/include/g42cloud/core/http/*.h)
3036
file(GLOB core_utils_header ${CMAKE_CURRENT_SOURCE_DIR}/include/g42cloud/core/utils/*.h)
3137

32-
add_library(core ${LIB_TYPE}
33-
${source_file}
34-
${core_header}
35-
${core_auth_header}
36-
${core_exception_header}
37-
${core_http_header}
38-
${core_utils_header})
38+
if(ENABLE_BSON)
39+
add_library(core ${LIB_TYPE}
40+
${source_file}
41+
${core_header}
42+
${core_auth_header}
43+
${core_exception_header}
44+
${core_http_header}
45+
${core_utils_header}
46+
${core_bson_header}
47+
${core_bson_impl_header}
48+
)
49+
else()
50+
add_library(core ${LIB_TYPE}
51+
${source_file}
52+
${core_header}
53+
${core_auth_header}
54+
${core_exception_header}
55+
${core_http_header}
56+
${core_utils_header}
57+
)
58+
endif()
3959

4060
set_target_properties(core
4161
PROPERTIES
@@ -52,6 +72,17 @@ if(${LIB_TYPE} STREQUAL "SHARED")
5272
DEFINE_SYMBOL G42CLOUD_CORE_SHARED)
5373
endif()
5474

75+
if(ENABLE_BSON)
76+
if(NOT LIBBSON_DIR)
77+
message(FATAL_ERROR "Please manual set variable LIBBSON_DIR for search libbson root dir")
78+
endif()
79+
set(LIBBSON_LIBRARY_DIR ${LIBBSON_DIR}/lib)
80+
set(LIBBSON_INCLUDE_DIR ${LIBBSON_DIR}/include/libbson-1.0)
81+
target_include_directories(core PUBLIC ${LIBBSON_INCLUDE_DIR})
82+
target_link_libraries(core PUBLIC bson-1.0)
83+
target_link_directories(core PUBLIC ${LIBBSON_LIBRARY_DIR})
84+
endif()
85+
5586
target_include_directories(core PUBLIC
5687
${CMAKE_CURRENT_SOURCE_DIR}/include
5788
)
@@ -90,4 +121,10 @@ install(TARGETS core
90121
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
91122
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
92123
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
93-
)
124+
)
125+
if(ENABLE_BSON)
126+
install(FILES ${core_bson_header}
127+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/g42cloud/core/bson)
128+
install(FILES ${core_bson_impl_header}
129+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/g42cloud/core/bson/impl)
130+
endif()

core/include/g42cloud/core/Client.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#include <g42cloud/core/http/HttpClient.h>
3333
#include <g42cloud/core/CoreExport.h>
3434
#include <g42cloud/core/auth/Region.h>
35-
35+
#include <g42cloud/core/http/HttpRequestDef.h>
3636

3737
namespace G42Cloud {
3838
namespace Sdk {
@@ -71,7 +71,7 @@ class G42CLOUD_CORE_EXPORT Client {
7171
void processRegionAuth();
7272
std::unique_ptr<HttpResponse> callApi(const std::string &method, const std::string &resourcePath,
7373
const std::map<std::string, std::string> &pathParams, const std::map<std::string, std::string> &queryParams,
74-
const std::map<std::string, std::string> &headerParams, const std::string &body);
74+
const std::map<std::string, std::string> &headerParams, const std::string &body, const HttpRequestDef& def);
7575

7676
private:
7777
std::string parseUrl(const RequestParams &requestParams);
@@ -80,6 +80,12 @@ class G42CLOUD_CORE_EXPORT Client {
8080

8181
static void parseEndPoint(const std::string &str, std::string &scheme, std::string &host);
8282

83+
std::string buildEndpoint(const HttpRequestDef& ref, const std::map<std::string, std::string>& pathParams,
84+
const std::map<std::string, std::string> &queryParams);
85+
86+
std::string getFieldValueByName(std::string key, std::map<std::string, std::string>& pathParams,
87+
std::map<std::string, std::string> &queryParams);
88+
8389
std::string getResourcePath(const std::string &uri, const std::map<std::string, std::string> &pathParams,
8490
const std::map<std::string, std::string> &updatePathParams);
8591
std::string getQueryParams(const std::map<std::string, std::string> &map);
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache LICENSE, Version 2.0 (the
7+
* "LICENSE"); you may not use this file except in compliance
8+
* with the LICENSE. You may obtain a copy of the LICENSE at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the LICENSE is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the LICENSE for the
16+
* specific language governing permissions and limitations
17+
* under the LICENSE.
18+
*/
19+
20+
#ifndef G42CLOUD_CPP_SDK_CORE_BSON_BSON_H
21+
#define G42CLOUD_CPP_SDK_CORE_BSON_BSON_H
22+
23+
#include <g42cloud/core/bson/Builder.h>
24+
#include <g42cloud/core/bson/Decimal128.h>
25+
#include <g42cloud/core/bson/Document.h>
26+
#include <g42cloud/core/bson/Oid.h>
27+
#include <g42cloud/core/bson/Types.h>
28+
#include <g42cloud/core/bson/Viewer.h>
29+
30+
#endif //G42CLOUD_CPP_SDK_CORE_BSON_BSON_H
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache LICENSE, Version 2.0 (the
7+
* "LICENSE"); you may not use this file except in compliance
8+
* with the LICENSE. You may obtain a copy of the LICENSE at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the LICENSE is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the LICENSE for the
16+
* specific language governing permissions and limitations
17+
* under the LICENSE.
18+
*/
19+
20+
#ifndef G42CLOUD_CPP_SDK_CORE_BSON_BUILDER_H
21+
#define G42CLOUD_CPP_SDK_CORE_BSON_BUILDER_H
22+
23+
#include <string>
24+
25+
#include <g42cloud/core/bson/Types.h>
26+
#include <g42cloud/core/bson/impl/LibBsonEncoder.h>
27+
#include <g42cloud/core/exception/SdkException.h>
28+
29+
using namespace G42Cloud::Sdk::Core::Exception;
30+
31+
namespace G42Cloud {
32+
namespace Sdk {
33+
namespace Core {
34+
namespace Bson {
35+
36+
/**************************** Stream manipulator ***************************/
37+
// Begin append child document
38+
struct OpenDocumentType {
39+
constexpr OpenDocumentType() = default;
40+
};
41+
42+
// End append child document
43+
struct CloseDocumentType {
44+
constexpr CloseDocumentType() = default;
45+
};
46+
47+
// Begin append child array.
48+
struct OpenArrayType {
49+
constexpr OpenArrayType() = default;
50+
};
51+
52+
// End append child array.
53+
struct CloseArrayType {
54+
constexpr CloseArrayType() = default;
55+
};
56+
57+
// Builder should generate document bson object.
58+
struct BuildDocumentType {
59+
constexpr BuildDocumentType() = default;
60+
};
61+
62+
// Builder should generate array bson object.
63+
struct BuildArrayType {
64+
constexpr BuildArrayType() = default;
65+
};
66+
/**************************** Stream manipulator end ***************************/
67+
68+
/**
69+
* Builder bson object with stream style, which is based capacity of LibBsonEncoder.
70+
*/
71+
class Builder {
72+
public:
73+
Builder(Builder && other) noexcept : key_(std::move(other.key_)), encoder_(other.encoder_) {
74+
other.encoder_ = nullptr;
75+
}
76+
77+
virtual ~Builder() {
78+
delete encoder_;
79+
}
80+
81+
static Builder array() {
82+
return Builder(true);
83+
}
84+
85+
static Builder document() {
86+
return Builder(false);
87+
}
88+
89+
Builder &operator<<(const OpenDocumentType &value);
90+
91+
Builder &operator<<(const CloseDocumentType &value);
92+
93+
Builder &operator<<(const OpenArrayType &value);
94+
95+
Builder &operator<<(const CloseArrayType &value);
96+
97+
virtual Builder &operator<<(const char *value);
98+
99+
virtual Builder &operator<<(const std::string &value);
100+
101+
Document operator<<(const BuildDocumentType &value);
102+
103+
Array operator<<(const BuildArrayType &value);
104+
105+
template<class T>
106+
Builder &operator<<(const T &value);
107+
108+
static constexpr OpenDocumentType SubDocumentBegin{};
109+
static constexpr CloseDocumentType SubDocumentEnd{};
110+
static constexpr OpenArrayType SubArrayBegin{};
111+
static constexpr CloseArrayType SubArrayEnd{};
112+
static constexpr BuildDocumentType DocumentEnd{};
113+
static constexpr BuildArrayType ArrayEnd{};
114+
115+
private:
116+
explicit Builder(bool isArray) : encoder_(new LibBsonEncoder(isArray)) {}
117+
118+
Builder(const Builder &) = default;
119+
120+
Builder &operator=(const Builder &) = default;
121+
122+
BsonEncoder *encoder_{nullptr};
123+
std::string key_;
124+
};
125+
126+
#define ENSURE_KEY_SET_IN_ARRAY() \
127+
if (encoder_->isArray()) { \
128+
key_ = encoder_->nextKey(); \
129+
}
130+
131+
#define THROW_EXCEPTION_IF_KEY_ABSENT() \
132+
if (key_.empty()) { \
133+
throw SdkException("Document key is empty."); \
134+
}
135+
136+
#define CLEAR_AFTER_APPEND() \
137+
key_.clear();
138+
139+
template<class T>
140+
Builder &Builder::operator<<(const T &value) {
141+
ENSURE_KEY_SET_IN_ARRAY()
142+
THROW_EXCEPTION_IF_KEY_ABSENT()
143+
144+
encoder_->append(key_, value);
145+
146+
CLEAR_AFTER_APPEND()
147+
148+
return *this;
149+
}
150+
151+
} // namespace Bson
152+
} // namespace Core
153+
} // namespace Sdk
154+
} // namespace G42Cloud
155+
156+
#endif //G42CLOUD_CPP_SDK_CORE_BSON_BUILDER_H

0 commit comments

Comments
 (0)