From 902a83bc36e8bb09e391880e825782ba959bec90 Mon Sep 17 00:00:00 2001 From: Leonid Stryzhevskyi Date: Sat, 9 May 2020 23:02:24 +0300 Subject: [PATCH] Update 1.1.0.md --- changelog/1.1.0.md | 129 ++++++++++++++++++++++++--------------------- 1 file changed, 68 insertions(+), 61 deletions(-) diff --git a/changelog/1.1.0.md b/changelog/1.1.0.md index 367e4c9f..1b213fd2 100644 --- a/changelog/1.1.0.md +++ b/changelog/1.1.0.md @@ -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 `->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::` are based on `std::` + +Example: + +```cpp +oatpp::Vector vector = oatpp::Vector::createShared(); +oatpp::List list = oatpp::List::createShared(); +oatpp::Fields pairList= oatpp::Fields::createShared(); +oatpp::UnorderedFields hashMap = oatpp::UnorderedFields::createShared(); + +oatpp::Vector vector = {"a", "b", "c"}; +oatpp::List list = {"a", "b", "c"}; +oatpp::Fields pairList = {{"k1", "v1"}, {"k2", "v2"}, {"k3", "v3"}}; +oatpp::UnorderedFields 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::` are based on `std::` - -Example: - -```cpp -oatpp::Vector vector = oatpp::Vector::createShared(); -oatpp::List list = oatpp::List::createShared(); -oatpp::Fields pairList= oatpp::Fields::createShared(); -oatpp::UnorderedFields hashMap = oatpp::UnorderedFields::createShared(); - -oatpp::Vector vector = {"a", "b", "c"}; -oatpp::List list = {"a", "b", "c"}; -oatpp::Fields pairList = {{"k1", "v1"}, {"k2", "v2"}, {"k3", "v3"}}; -oatpp::UnorderedFields 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 `->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.