mirror of
https://github.com/oatpp/oatpp.git
synced 2025-04-06 18:40:24 +08:00
Update 1.3.0.md
This commit is contained in:
parent
c804239cb4
commit
d9824421a0
@ -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<ClientConnectionPool>(
|
||||
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
|
||||
```
|
||||
|
Loading…
x
Reference in New Issue
Block a user