Update 1.1.0.md

This commit is contained in:
Leonid Stryzhevskyi 2020-05-09 23:02:24 +03:00 committed by GitHub
parent b46bcfc7b1
commit 902a83bc36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,7 +3,14 @@
Oat++ `1.1.0` is introducing breaking changes.
Please read carefully to prepare for migration.
## No more explicit 'ObjectWrapper'
Contents:
- [No more explicit ObjectWrapper]()
- [Object-Mapping Simplified Primitives]()
- [Object-Mapping std Collections]()
- [Type oatpp::Any]()
- [Type oatpp::Enum]
## No more explicit ObjectWrapper
Do not explicitly write `ObjectWrapper`
@ -30,7 +37,66 @@ ENDPOINT("POST", "body-dto", postWithBody,
}
```
## Object-Mapping type Any
## Object-Mapping Simplified Primitives
No more `<primitive>->getValue()`.
```cpp
oatpp::Int32 objV = 32;
v_int32 v = objV; // You may check for nullptr before doing this
bool equals = v == objV; // <--- NO NEED to check for nullptr here
bool isNull = objV == nullptr;
bool isNull = !objV;
```
## Object-Mapping std Collections
Now `oatpp::<mapping-enabled-collections>` are based on `std::<collections>`
Example:
```cpp
oatpp::Vector<oatpp::String> vector = oatpp::Vector<oatpp::String>::createShared();
oatpp::List<oatpp::String> list = oatpp::List<oatpp::String>::createShared();
oatpp::Fields<oatpp::String> pairList= oatpp::Fields<oatpp::String>::createShared();
oatpp::UnorderedFields<oatpp::String> hashMap = oatpp::UnorderedFields<oatpp::String>::createShared();
oatpp::Vector<oatpp::String> vector = {"a", "b", "c"};
oatpp::List<oatpp::String> list = {"a", "b", "c"};
oatpp::Fields<oatpp::String> pairList = {{"k1", "v1"}, {"k2", "v2"}, {"k3", "v3"}};
oatpp::UnorderedFields<oatpp::String> hashMap = {{"k1", "v1"}, {"k2", "v2"}, {"k3", "v3"}};
vector[0] = "z"; // <--- Complexity = O(1);
vector->push_back("www");
list[0] = "z"; // <--- Complexity = O(n);
list->push_back("www");
pairList["k1"] = "z"; // <--- Complexity = O(n);
pairList->push_back({"key_z", "z"});
hashMap["k1"] = "z" // <--- Complexity = O(1);
hashMap->insert({"key_z", "z"});
for(auto& item : *vector) {
...
}
for(auto& item : *list) {
...
}
for(auto& pair : *pairList) {
...
}
for(auto& pair : *hashMap) {
...
}
```
## Type oatpp::Any
The new Type Introduced - `oatpp::Any`.
@ -93,65 +159,6 @@ auto json = mapper->writeToString(map);
}
```
## Object-Mapping Collections
Now `oatpp::<mapping-enabled-collections>` are based on `std::<collections>`
Example:
```cpp
oatpp::Vector<oatpp::String> vector = oatpp::Vector<oatpp::String>::createShared();
oatpp::List<oatpp::String> list = oatpp::List<oatpp::String>::createShared();
oatpp::Fields<oatpp::String> pairList= oatpp::Fields<oatpp::String>::createShared();
oatpp::UnorderedFields<oatpp::String> hashMap = oatpp::UnorderedFields<oatpp::String>::createShared();
oatpp::Vector<oatpp::String> vector = {"a", "b", "c"};
oatpp::List<oatpp::String> list = {"a", "b", "c"};
oatpp::Fields<oatpp::String> pairList = {{"k1", "v1"}, {"k2", "v2"}, {"k3", "v3"}};
oatpp::UnorderedFields<oatpp::String> hashMap = {{"k1", "v1"}, {"k2", "v2"}, {"k3", "v3"}};
vector[0] = "z"; // <--- Complexity = O(1);
vector->push_back("www");
list[0] = "z"; // <--- Complexity = O(n);
list->push_back("www");
pairList["k1"] = "z"; // <--- Complexity = O(n);
pairList->push_back({"key_z", "z"});
hashMap["k1"] = "z" // <--- Complexity = O(1);
hashMap->insert({"key_z", "z"});
for(auto& item : *vector) {
...
}
for(auto& item : *list) {
...
}
for(auto& pair : *pairList) {
...
}
for(auto& pair : *hashMap) {
...
}
```
## Object-Mapping Simplified Primitives
No more `<primitive>->getValue()`.
```cpp
oatpp::Int32 objV = 32;
v_int32 v = objV; // You may check for nullptr before doing this
bool equals = v == objV; // <--- NO NEED to check for nullptr here
bool isNull = objV == nullptr;
bool isNull = !objV;
```
## Object-Mapping Enum
Enum is added to DTO codegen.