Skip to content

Commit 16d75cf

Browse files
committed
update to the latest oatpp API version.
1 parent e0b4895 commit 16d75cf

File tree

18 files changed

+61
-60
lines changed

18 files changed

+61
-60
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
55
## use these variables to configure module installation
66

77
set(OATPP_THIS_MODULE_NAME oatpp-mongo) ## name of the module (also name of folders in installation dirs)
8-
set(OATPP_THIS_MODULE_VERSION "1.2.5") ## version of the module (also sufix of folders in installation dirs)
8+
set(OATPP_THIS_MODULE_VERSION "1.3.0") ## version of the module (also sufix of folders in installation dirs)
99
set(OATPP_THIS_MODULE_LIBRARIES oatpp-mongo) ## list of libraries to find when find_package is called
1010
set(OATPP_THIS_MODULE_TARGETS oatpp-mongo) ## list of targets to install
1111
set(OATPP_THIS_MODULE_DIRECTORIES oatpp-mongo) ## list of directories to install

azure-pipelines.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
# https://aka.ms/yaml
55

66
jobs:
7-
- job: ubuntu_16_04
8-
displayName: 'Build - Ubuntu 16.04'
7+
- job: ubuntu_20_04
8+
displayName: 'Build - Ubuntu 20.04'
99
continueOnError: false
1010
pool:
11-
vmImage: 'Ubuntu 16.04'
11+
vmImage: 'ubuntu-20.04'
1212
container:
1313
image: lganzzzo/ubuntu-cmake-mongocxx:latest
1414
workspace:

src/oatpp-mongo/bson/Types.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,13 @@ namespace __class {
204204
* Inline Document - is a binary buffer containing a valid BSON document. <br>
205205
* May be useful in some cases.
206206
*/
207-
typedef oatpp::data::mapping::type::ObjectWrapper<oatpp::base::StrBuffer, __class::InlineDocument> InlineDocument;
207+
typedef oatpp::data::mapping::type::ObjectWrapper<std::string, __class::InlineDocument> InlineDocument;
208208

209209
/**
210210
* Inline Array - is a binary buffer containing a valid BSON Array. <br>
211211
* May be useful in some cases.
212212
*/
213-
typedef oatpp::data::mapping::type::ObjectWrapper<oatpp::base::StrBuffer, __class::InlineArray> InlineArray;
213+
typedef oatpp::data::mapping::type::ObjectWrapper<std::string, __class::InlineArray> InlineArray;
214214

215215
/**
216216
* ObjectId as oatpp primitive type.

src/oatpp-mongo/bson/Utils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ v_int32 Utils::readInt32(parser::Caret& caret, BO_TYPE valueBO) {
126126
break;
127127

128128
default: {
129-
p_char8 data = caret.getCurrData();
129+
auto data = caret.getCurrData();
130130
result = data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24);
131131
}
132132

@@ -177,7 +177,7 @@ v_int64 Utils::readInt64(parser::Caret& caret, BO_TYPE valueBO) {
177177
break;
178178

179179
default: {
180-
p_char8 data = caret.getCurrData();
180+
p_char8 data = (p_char8) caret.getCurrData();
181181
result = ((v_int64) data[0] ) | ((v_int64) data[1] << 8) | ((v_int64) data[2] << 16) | ((v_int64) data[3] << 24) |
182182
((v_int64) data[4] << 32) | ((v_int64) data[5] << 40) | ((v_int64) data[6] << 48) | ((v_int64) data[7] << 56);
183183
}
@@ -229,7 +229,7 @@ v_uint64 Utils::readUInt64(parser::Caret& caret, BO_TYPE valueBO) {
229229
break;
230230

231231
default: {
232-
p_char8 data = caret.getCurrData();
232+
p_char8 data = (p_char8) caret.getCurrData();
233233
result = ((v_uint64) data[0] ) | ((v_uint64) data[1] << 8) | ((v_uint64) data[2] << 16) | ((v_uint64) data[3] << 24) |
234234
((v_uint64) data[4] << 32) | ((v_uint64) data[5] << 40) | ((v_uint64) data[6] << 48) | ((v_uint64) data[7] << 56);
235235
}

src/oatpp-mongo/bson/mapping/Deserializer.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ oatpp::Void Deserializer::deserializeString(Deserializer* deserializer,
246246
}
247247
auto label = caret.putLabel();
248248
caret.inc(size);
249-
return oatpp::Void(base::StrBuffer::createShared(label.getData(), label.getSize() - 1), String::Class::getType());
249+
return oatpp::String(label.getData(), label.getSize() - 1);
250250

251251
}
252252

@@ -285,10 +285,10 @@ oatpp::Void Deserializer::deserializeInlineDocs(Deserializer* deserializer,
285285
label.end();
286286

287287
if(bsonTypeCode == DOCUMENT_ARRAY) {
288-
return oatpp::Void(base::StrBuffer::createShared(label.getData(), label.getSize()), InlineArray::Class::getType());
288+
return oatpp::Void(std::make_shared<std::string>(label.getData(), label.getSize()), InlineArray::Class::getType());
289289
}
290290

291-
return oatpp::Void(base::StrBuffer::createShared(label.getData(), label.getSize()), InlineDocument::Class::getType());
291+
return oatpp::Void(std::make_shared<std::string>(label.getData(), label.getSize()), InlineDocument::Class::getType());
292292

293293
}
294294

@@ -321,7 +321,7 @@ oatpp::Void Deserializer::deserializeObjectId(Deserializer* deserializer,
321321
auto label = caret.putLabel();
322322
caret.inc(12);
323323

324-
return oatpp::Void(std::make_shared<type::ObjectId>(label.getData()), ObjectId::Class::getType());
324+
return oatpp::Void(std::make_shared<type::ObjectId>((p_char8)label.getData()), ObjectId::Class::getType());
325325

326326
}
327327

@@ -343,7 +343,7 @@ oatpp::Void Deserializer::deserializeAny(Deserializer* deserializer,
343343
const Type *const fieldType = guessType(bsonTypeCode);
344344
if (fieldType != nullptr) {
345345
auto fieldValue = deserializer->deserialize(caret, fieldType, bsonTypeCode);
346-
auto anyHandle = std::make_shared<data::mapping::type::AnyHandle>(fieldValue.getPtr(), fieldValue.valueType);
346+
auto anyHandle = std::make_shared<data::mapping::type::AnyHandle>(fieldValue.getPtr(), fieldValue.getValueType());
347347
return oatpp::Void(anyHandle, Any::Class::getType());
348348
}
349349

@@ -424,7 +424,7 @@ oatpp::Void Deserializer::deserializeObject(Deserializer* deserializer,
424424
return nullptr;
425425
}
426426

427-
auto fieldIterator = fieldsMap.find(key->std_str());
427+
auto fieldIterator = fieldsMap.find(*key);
428428
if(fieldIterator != fieldsMap.end()){
429429

430430
auto field = fieldIterator->second;

src/oatpp-mongo/bson/mapping/Deserializer.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ class Deserializer {
179179
}
180180

181181
caret.inc(innerCaret.getPosition());
182-
return oatpp::Void(list.getPtr(), list.valueType);
182+
return oatpp::Void(list.getPtr(), list.getValueType());
183183

184184
}
185185

@@ -256,7 +256,7 @@ class Deserializer {
256256
}
257257

258258
caret.inc(innerCaret.getPosition());
259-
return oatpp::Void(map.getPtr(), map.valueType);
259+
return oatpp::Void(map.getPtr(), map.getValueType());
260260

261261
}
262262

src/oatpp-mongo/bson/mapping/Serializer.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ void Serializer::serializeString(Serializer* serializer,
123123

124124
bson::Utils::writeKey(stream, TypeCode::STRING, key);
125125

126-
auto str = static_cast<oatpp::base::StrBuffer *>(polymorph.get());
127-
bson::Utils::writeInt32(stream, str->getSize() + 1);
128-
stream->writeSimple(str->getData(), str->getSize());
126+
auto str = static_cast<std::string*>(polymorph.get());
127+
bson::Utils::writeInt32(stream, str->size() + 1);
128+
stream->writeSimple(str->data(), str->size());
129129
stream->writeCharSimple(0);
130130

131131
} else {
@@ -145,20 +145,20 @@ void Serializer::serializeInlineDocs(Serializer* serializer,
145145

146146
if(polymorph) {
147147

148-
auto str = static_cast<oatpp::base::StrBuffer*>(polymorph.get());
149-
if(str->getSize() < 5) {
148+
auto str = static_cast<std::string*>(polymorph.get());
149+
if(str->size() < 5) {
150150
throw std::runtime_error("[oatpp::mongo::bson::mapping::Serializer::serializeInlineDocs()]: Error. Invalid inline object size.");
151151
}
152152

153-
oatpp::parser::Caret caret(str->getData(), str->getSize());
153+
oatpp::parser::Caret caret(str->data(), str->size());
154154
v_int32 inlineSize = bson::Utils::readInt32(caret);
155155

156-
if(inlineSize != str->getSize()) {
156+
if(inlineSize != str->size()) {
157157
throw std::runtime_error("[oatpp::mongo::bson::mapping::Serializer::serializeInlineDocs()]: Error. Invalid inline object.");
158158
}
159159

160160
bson::Utils::writeKey(stream, typeCode, key);
161-
stream->writeSimple(str->getData(), str->getSize());
161+
stream->writeSimple(str->data(), str->size());
162162

163163
} else if(key) {
164164
bson::Utils::writeKey(stream, TypeCode::NULL_VALUE, key);
@@ -232,7 +232,7 @@ void Serializer::serializeEnum(Serializer* serializer,
232232
{
233233

234234
auto polymorphicDispatcher = static_cast<const data::mapping::type::__class::AbstractEnum::PolymorphicDispatcher*>(
235-
polymorph.valueType->polymorphicDispatcher
235+
polymorph.getValueType()->polymorphicDispatcher
236236
);
237237

238238
data::mapping::type::EnumInterpreterError e = data::mapping::type::EnumInterpreterError::OK;
@@ -263,7 +263,7 @@ void Serializer::serializeObject(Serializer* serializer,
263263

264264
data::stream::BufferOutputStream innerStream;
265265

266-
auto dispatcher = static_cast<const oatpp::data::mapping::type::__class::AbstractObject::PolymorphicDispatcher*>(polymorph.valueType->polymorphicDispatcher);
266+
auto dispatcher = static_cast<const oatpp::data::mapping::type::__class::AbstractObject::PolymorphicDispatcher*>(polymorph.getValueType()->polymorphicDispatcher);
267267
auto fields = dispatcher->getProperties()->getList();
268268
auto object = static_cast<oatpp::BaseObject*>(polymorph.get());
269269

@@ -292,18 +292,18 @@ void Serializer::serialize(data::stream::ConsistentOutputStream* stream,
292292
const data::share::StringKeyLabel& key,
293293
const oatpp::Void& polymorph)
294294
{
295-
auto id = polymorph.valueType->classId.id;
295+
auto id = polymorph.getValueType()->classId.id;
296296
auto& method = m_methods[id];
297297
if(method) {
298298
(*method)(this, stream, key, polymorph);
299299
} else {
300300

301-
auto* interpretation = polymorph.valueType->findInterpretation(m_config->enableInterpretations);
301+
auto* interpretation = polymorph.getValueType()->findInterpretation(m_config->enableInterpretations);
302302
if(interpretation) {
303303
serialize(stream, key, interpretation->toInterpretation(polymorph));
304304
} else {
305305
throw std::runtime_error("[oatpp::mongo::bson::mapping::Serializer::serialize()]: "
306-
"Error. No serialize method for type '" + std::string(polymorph.valueType->classId.name) + "'");
306+
"Error. No serialize method for type '" + std::string(polymorph.getValueType()->classId.name) + "'");
307307
}
308308

309309
}

src/oatpp-mongo/bson/type/ObjectId.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ v_uint32 ObjectId::getTimestamp() const {
8787
oatpp::String ObjectId::toString() const {
8888
static const v_char8 alphabet[16] {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
8989
oatpp::String result(DATA_SIZE * 2);
90-
p_char8 rdata = result->getData();
90+
p_char8 rdata = (p_char8) result->data();
9191
for(v_buff_size i = 0; i < DATA_SIZE; i ++) {
9292
auto a = m_data[i];
9393
v_char8 b1 = 0x0F & (a >> 4);

src/oatpp-mongo/driver/command/Delete.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ wire::Message Delete::toMessage(ObjectMapper* commandObjectMapper) {
6161

6262
auto data = payloadStream.toString();
6363

64-
return wire::Message(16 + (v_int32) data->getSize(), wire::OpMsg::OP_CODE, data);
64+
return wire::Message(16 + (v_int32) data->size(), wire::OpMsg::OP_CODE, data);
6565

6666
}
6767

src/oatpp-mongo/driver/command/Find.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ wire::Message Find::toMessage(ObjectMapper* commandObjectMapper) {
5252

5353
auto data = payloadStream.toString();
5454

55-
return wire::Message(16 + (v_int32) data->getSize(), wire::OpMsg::OP_CODE, data);
55+
return wire::Message(16 + (v_int32) data->size(), wire::OpMsg::OP_CODE, data);
5656

5757
}
5858

src/oatpp-mongo/driver/command/Insert.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ wire::Message Insert::toMessage(ObjectMapper* commandObjectMapper) {
6161

6262
auto data = payloadStream.toString();
6363

64-
return wire::Message(16 + (v_int32) data->getSize(), wire::OpMsg::OP_CODE, data);
64+
return wire::Message(16 + (v_int32) data->size(), wire::OpMsg::OP_CODE, data);
6565

6666
}
6767

src/oatpp-mongo/driver/command/Update.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ wire::Message Update::toMessage(ObjectMapper* commandObjectMapper) {
6161

6262
auto data = payloadStream.toString();
6363

64-
return wire::Message(16 + (v_int32) data->getSize(), wire::OpMsg::OP_CODE, data);
64+
return wire::Message(16 + (v_int32) data->size(), wire::OpMsg::OP_CODE, data);
6565

6666
}
6767

src/oatpp-mongo/driver/wire/Connection.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,26 @@
3030

3131
namespace oatpp { namespace mongo { namespace driver { namespace wire {
3232

33-
Connection::Connection(const std::shared_ptr<data::stream::IOStream>& connection)
33+
Connection::Connection(const provider::ResourceHandle<data::stream::IOStream>& connection)
3434
: m_connection(connection)
3535
{}
3636

3737
v_io_size Connection::write(const Message& message) {
3838

39-
if(message.header.messageLength != 16 + message.data->getSize()) {
39+
if(message.header.messageLength != 16 + message.data->size()) {
4040
throw std::runtime_error("[oatpp::mongo::driver::wire::Connection::write()]: Error. Invalid message header.");
4141
}
4242

4343
data::stream::BufferOutputStream stream(16);
4444
message.header.writeToStream(&stream);
4545

46-
auto res1 = m_connection->writeExactSizeDataSimple(stream.getData(), stream.getCurrentPosition());
46+
auto res1 = m_connection.object->writeExactSizeDataSimple(stream.getData(), stream.getCurrentPosition());
4747

4848
if(res1 < stream.getCurrentPosition()) {
4949
return res1;
5050
}
5151

52-
auto res2 = m_connection->writeExactSizeDataSimple(message.data->getData(), message.data->getSize());
52+
auto res2 = m_connection.object->writeExactSizeDataSimple(message.data->data(), message.data->size());
5353
if(res2 < 0) {
5454
return res2;
5555
}
@@ -62,16 +62,16 @@ v_io_size Connection::read(Message& message) {
6262

6363
const v_buff_size headerSize = 16;
6464
v_char8 headerDataBuffer[headerSize];
65-
auto res1 = m_connection->readExactSizeDataSimple(headerDataBuffer, headerSize);
65+
auto res1 = m_connection.object->readExactSizeDataSimple(headerDataBuffer, headerSize);
6666
if(res1 != headerSize) {
6767
return res1;
6868
}
6969

70-
parser::Caret caret(headerDataBuffer, headerSize);
70+
parser::Caret caret((const char*)headerDataBuffer, headerSize);
7171
message.header.readFromCaret(caret);
7272

7373
oatpp::String dataBuffer(message.header.messageLength - headerSize);
74-
auto res2 = m_connection->readExactSizeDataSimple(dataBuffer->getData(), dataBuffer->getSize());
74+
auto res2 = m_connection.object->readExactSizeDataSimple((void*)dataBuffer->data(), dataBuffer->size());
7575

7676
if(res2 < 0) {
7777
return res2;

src/oatpp-mongo/driver/wire/Connection.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#define oatpp_mongo_driver_wire_Connection_hpp
2828

2929
#include "./Message.hpp"
30+
#include "oatpp/core/provider/Provider.hpp"
3031
#include "oatpp/core/data/stream/Stream.hpp"
3132

3233
namespace oatpp { namespace mongo { namespace driver { namespace wire {
@@ -36,10 +37,10 @@ namespace oatpp { namespace mongo { namespace driver { namespace wire {
3637
*/
3738
class Connection {
3839
private:
39-
std::shared_ptr<data::stream::IOStream> m_connection;
40+
provider::ResourceHandle<data::stream::IOStream> m_connection;
4041
public:
4142

42-
Connection(const std::shared_ptr<data::stream::IOStream>& connection);
43+
Connection(const provider::ResourceHandle<data::stream::IOStream>& connection);
4344

4445
v_io_size write(const Message& message);
4546
v_io_size read(Message& message);

src/oatpp-mongo/driver/wire/OpMsg.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ void DocumentSequenceSection::writeToStream(data::stream::ConsistentOutputStream
117117

118118
stream->writeCharSimple(TYPE_DOCUMENT_SEQUENCE);
119119

120-
v_int32 size = 4 + identifier->getSize() + 1;
120+
v_int32 size = 4 + identifier->size() + 1;
121121
for(auto& doc : documents) {
122-
size += doc->getSize();
122+
size += doc->size();
123123
}
124124
bson::Utils::writeInt32(stream, size);
125125

@@ -150,7 +150,7 @@ bool DocumentSequenceSection::readFromCaret(parser::Caret& caret) {
150150
return false;
151151
}
152152

153-
progress += identifier->getSize() + 1;
153+
progress += identifier->size() + 1;
154154

155155
while(caret.canContinue() && progress < overallSize) {
156156

@@ -164,7 +164,7 @@ bool DocumentSequenceSection::readFromCaret(parser::Caret& caret) {
164164
oatpp::String document = label.toString();
165165
documents.push_back(document);
166166

167-
progress += document->getSize();
167+
progress += document->size();
168168

169169
}
170170

0 commit comments

Comments
 (0)