From d9824421a0dcf835986bb33373264efa852f8c8f Mon Sep 17 00:00:00 2001 From: Leonid Stryzhevskyi Date: Wed, 4 Aug 2021 01:23:29 +0300 Subject: [PATCH] Update 1.3.0.md --- changelog/1.3.0.md | 100 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/changelog/1.3.0.md b/changelog/1.3.0.md index e69de29b..df367940 100644 --- a/changelog/1.3.0.md +++ b/changelog/1.3.0.md @@ -0,0 +1,100 @@ +# Oat++ 1.3.0 + +Previous release - [1.2.5](1.2.5.md) + +Feel free to ask questions - [Chat on Gitter!](https://gitter.im/oatpp-framework/Lobby) + +Contents: + +- [The New oatpp::String](#the-new-oatppstring) +- [ConnectionPool::get() Timeout](#connectionpoolget-timeout) +- [JSON Serializer Escape Flags](#json-serializer-escape-flags) + + +## The New oatpp::String + +Now it's much easier to use `oatpp::String` since `oatpp::String` is now wrapper over `std::string` + +```cpp +{ + std::string s1 = Hello; + oatpp::String s2 = s1; +} + +{ + oatpp::String s1 = "Hello"; + std::string s2 = *s1; +} + +{ + oatpp::String s1 = "Hello"; + bool b = s1 == "Hello"; // compare s1 with const char* + assert(b); +} + +{ + oatpp::String s1 = "Hello"; + std::stringg s2 = "Hello"; + bool b = s1 == s2; // compare s1 with std::string + assert(b); +} + +{ + oatpp::String s1 = "Hello"; + std::string s2 = "World"; + + oatpp::String s3 = s1 + " " + s2; // concat oatpp::String with const char* and std::string directly + + OATPP_LOGD("TEST", "str='%s'", s3->c_str()); // prints 'Hello World' +} +``` + +## ConnectionPool::get() Timeout + +[#408](https://github.com/oatpp/oatpp/issues/408) + +```cpp +auto connectionPool = std::make_shared( + connectionProvider /* connection provider */, + 10 /* max connections */, + std::chrono::seconds(5) /* max lifetime of idle connection */ + std::chrono::seconds(10) /* optional timeout to get available connection from the pool */ +); +``` + +## JSON Serializer Escape Flags + +[#381](https://github.com/oatpp/oatpp/issues/381) + +Now you can control if solidus is escaped or not. + +### Default Behavior + +```cpp + oatpp::parser::json::mapping::ObjectMapper mapper; + // mapper.getSerializer()->getConfig()->escapeFlags = 0; // by default FLAG_ESCAPE_SOLIDUS is ON + auto res = mapper.writeToString(oatpp::String("https://oatpp.io/")); + OATPP_LOGD("TEST", "res='%s'", res->c_str()); +``` + +Output: + +``` +res='"https:\/\/oatpp.io\/"' # by default, solidus is escaped +``` + +### Clear Escape Flags + +```cpp + oatpp::parser::json::mapping::ObjectMapper mapper; + mapper.getSerializer()->getConfig()->escapeFlags = 0; + auto res = mapper.writeToString(oatpp::String("https://oatpp.io/")); + OATPP_LOGD("TEST", "res='%s'", res->c_str()); +``` + +Output: + +``` +res='"https://oatpp.io/"' # solidus isn't escaped +``` +