refactor json namespaces

This commit is contained in:
Leonid Stryzhevskyi 2024-04-23 01:20:20 +03:00
parent 60d879473a
commit 06232810f7
47 changed files with 291 additions and 311 deletions

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
cmake_minimum_required(VERSION 3.25 FATAL_ERROR)
file(STRINGS "${CMAKE_CURRENT_LIST_DIR}/src/oatpp/core/base/Environment.hpp" OATPP_VERSION_MACRO REGEX "#define OATPP_VERSION \"[0-9]+.[0-9]+.[0-9]+\"$")
string(REGEX REPLACE "#define OATPP_VERSION \"([0-9]+.[0-9]+.[0-9]+)\"$" "\\1" oatpp_VERSION "${OATPP_VERSION_MACRO}")

View File

@ -8,6 +8,7 @@ Contents:
- [URL Encoder And Decoder](#url-encoder-and-decoder)
- [Introduce async::ConditionVariable](#async-condition-variable)
- [Restructuring](#restructuring)
## URL Encoder And Decoder
@ -47,3 +48,11 @@ OATPP_ASSERT(decoded == data)
}
...
```
## Restructuring
| old namespace | new namespace |
|-----------------------------------|-----------------|
| `oatpp::parser::json::*` | `oatpp::json::*`|
| `oatpp::parser::json::mapping::*` | `oatpp::json::*`|

View File

@ -1,9 +1,9 @@
#include "oatpp/parser/json/mapping/ObjectMapper.hpp"
#include "oatpp/json/ObjectMapper.hpp"
#include "oatpp/core/macro/codegen.hpp"
typedef oatpp::parser::Caret ParsingCaret;
typedef oatpp::parser::json::mapping::Serializer Serializer;
typedef oatpp::parser::json::mapping::Deserializer Deserializer;
typedef oatpp::json::Serializer Serializer;
typedef oatpp::json::Deserializer Deserializer;
#include OATPP_CODEGEN_BEGIN(DTO)
@ -18,7 +18,7 @@ class Test1 : public oatpp::DTO {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
oatpp::String input(reinterpret_cast<const char*>(data), size);
oatpp::parser::json::mapping::ObjectMapper mapper;
oatpp::json::ObjectMapper mapper;
try {
mapper.readFromString<oatpp::Object<Test1>>(input);
} catch(...) {}

View File

@ -148,6 +148,16 @@ add_library(oatpp
oatpp/encoding/Unicode.hpp
oatpp/encoding/Url.cpp
oatpp/encoding/Url.hpp
oatpp/json/Beautifier.cpp
oatpp/json/Beautifier.hpp
oatpp/json/Deserializer.cpp
oatpp/json/Deserializer.hpp
oatpp/json/ObjectMapper.cpp
oatpp/json/ObjectMapper.hpp
oatpp/json/Serializer.cpp
oatpp/json/Serializer.hpp
oatpp/json/Utils.cpp
oatpp/json/Utils.hpp
oatpp/network/Address.cpp
oatpp/network/Address.hpp
oatpp/network/ConnectionHandler.hpp
@ -197,16 +207,6 @@ add_library(oatpp
oatpp/orm/SchemaMigration.hpp
oatpp/orm/Transaction.cpp
oatpp/orm/Transaction.hpp
oatpp/parser/json/Beautifier.cpp
oatpp/parser/json/Beautifier.hpp
oatpp/parser/json/Utils.cpp
oatpp/parser/json/Utils.hpp
oatpp/parser/json/mapping/Deserializer.cpp
oatpp/parser/json/mapping/Deserializer.hpp
oatpp/parser/json/mapping/ObjectMapper.cpp
oatpp/parser/json/mapping/ObjectMapper.hpp
oatpp/parser/json/mapping/Serializer.cpp
oatpp/parser/json/mapping/Serializer.hpp
oatpp/web/client/ApiClient.cpp
oatpp/web/client/ApiClient.hpp
oatpp/web/client/HttpRequestExecutor.cpp

View File

@ -39,7 +39,7 @@
#include <stdexcept>
#include <cstdlib>
#define OATPP_VERSION "1.3.0"
#define OATPP_VERSION "1.4.0"
typedef unsigned char v_char8;
typedef v_char8 *p_char8;

View File

@ -26,7 +26,7 @@
#include "oatpp/core/data/stream/BufferStream.hpp"
namespace oatpp { namespace parser { namespace json {
namespace oatpp { namespace json {
Beautifier::Beautifier(ConsistentOutputStream* outputStream, const oatpp::String& indent, const oatpp::String& newLine)
: m_outputStream(outputStream)
@ -163,4 +163,4 @@ Beautifier::Context& Beautifier::getOutputStreamContext() {
return m_outputStream->getOutputStreamContext();
}
}}}
}}

View File

@ -22,12 +22,12 @@
*
***************************************************************************/
#ifndef oatpp_parser_json_Beautifier_hpp
#define oatpp_parser_json_Beautifier_hpp
#ifndef oatpp_json_Beautifier_hpp
#define oatpp_json_Beautifier_hpp
#include "oatpp/core/data/stream/Stream.hpp"
namespace oatpp { namespace parser { namespace json {
namespace oatpp { namespace json {
/**
* JSON output stream beautifier.
@ -87,6 +87,6 @@ public:
};
}}}
}}
#endif // oatpp_parser_json_Beautifier_hpp
#endif // oatpp_json_Beautifier_hpp

View File

@ -26,7 +26,7 @@
#include "oatpp/core/utils/ConversionUtils.hpp"
namespace oatpp { namespace parser { namespace json { namespace mapping {
namespace oatpp { namespace json {
Deserializer::Deserializer(const std::shared_ptr<Config>& config)
: m_config(config)
@ -192,7 +192,7 @@ oatpp::Void Deserializer::deserializeBoolean(Deserializer* deserializer, parser:
} else if(caret.isAtText("false", true)) {
return Boolean(false);
} else {
caret.setError("[oatpp::parser::json::mapping::Deserializer::readBooleanValue()]: Error. 'true' or 'false' - expected.", ERROR_CODE_VALUE_BOOLEAN);
caret.setError("[oatpp::json::Deserializer::readBooleanValue()]: Error. 'true' or 'false' - expected.", ERROR_CODE_VALUE_BOOLEAN);
return oatpp::Void(Boolean::Class::getType());
}
}
@ -207,7 +207,7 @@ oatpp::Void Deserializer::deserializeString(Deserializer* deserializer, parser::
if(caret.isAtText("null", true)){
return oatpp::Void(String::Class::getType());
} else {
return oatpp::Void(oatpp::parser::json::Utils::parseString(caret).getPtr(), String::Class::getType());
return oatpp::Void(Utils::parseString(caret).getPtr(), String::Class::getType());
}
}
@ -245,7 +245,7 @@ const data::mapping::type::Type* Deserializer::guessType(oatpp::parser::Caret& c
}
}
}
caret.setError("[oatpp::parser::json::mapping::Deserializer::guessType()]: Error. Can't guess type for oatpp::Any.");
caret.setError("[oatpp::json::Deserializer::guessType()]: Error. Can't guess type for oatpp::Any.");
return nullptr;
}
@ -283,14 +283,14 @@ oatpp::Void Deserializer::deserializeEnum(Deserializer* deserializer, parser::Ca
switch(e) {
case data::mapping::type::EnumInterpreterError::CONSTRAINT_NOT_NULL:
caret.setError("[oatpp::parser::json::mapping::Deserializer::deserializeEnum()]: Error. Enum constraint violated - 'NotNull'.");
caret.setError("[oatpp::json::Deserializer::deserializeEnum()]: Error. Enum constraint violated - 'NotNull'.");
break;
case data::mapping::type::EnumInterpreterError::OK:
case data::mapping::type::EnumInterpreterError::TYPE_MISMATCH_ENUM:
case data::mapping::type::EnumInterpreterError::TYPE_MISMATCH_ENUM_VALUE:
case data::mapping::type::EnumInterpreterError::ENTRY_NOT_FOUND:
default:
caret.setError("[oatpp::parser::json::mapping::Deserializer::deserializeEnum()]: Error. Can't deserialize Enum.");
caret.setError("[oatpp::json::Deserializer::deserializeEnum()]: Error. Can't deserialize Enum.");
}
return nullptr;
@ -329,7 +329,7 @@ oatpp::Void Deserializer::deserializeCollection(Deserializer* deserializer, pars
if(!caret.canContinueAtChar(']', 1)){
if(!caret.hasError()){
caret.setError("[oatpp::parser::json::mapping::Deserializer::deserializeCollection()]: Error. ']' - expected", ERROR_CODE_ARRAY_SCOPE_CLOSE);
caret.setError("[oatpp::json::Deserializer::deserializeCollection()]: Error. ']' - expected", ERROR_CODE_ARRAY_SCOPE_CLOSE);
}
return nullptr;
}
@ -337,7 +337,7 @@ oatpp::Void Deserializer::deserializeCollection(Deserializer* deserializer, pars
return collection;
} else {
caret.setError("[oatpp::parser::json::mapping::Deserializer::deserializeCollection()]: Error. '[' - expected", ERROR_CODE_ARRAY_SCOPE_OPEN);
caret.setError("[oatpp::json::Deserializer::deserializeCollection()]: Error. '[' - expected", ERROR_CODE_ARRAY_SCOPE_OPEN);
return nullptr;
}
@ -356,7 +356,7 @@ oatpp::Void Deserializer::deserializeMap(Deserializer* deserializer, parser::Car
auto keyType = dispatcher->getKeyType();
if(keyType->classId != oatpp::String::Class::CLASS_ID){
throw std::runtime_error("[oatpp::parser::json::mapping::Deserializer::deserializeMap()]: Invalid json map key. Key should be String");
throw std::runtime_error("[oatpp::json::Deserializer::deserializeMap()]: Invalid json map key. Key should be String");
}
auto valueType = dispatcher->getValueType();
@ -372,7 +372,7 @@ oatpp::Void Deserializer::deserializeMap(Deserializer* deserializer, parser::Car
caret.skipBlankChars();
if(!caret.canContinueAtChar(':', 1)){
caret.setError("[oatpp::parser::json::mapping::Deserializer::deserializeMap()]: Error. ':' - expected", ERROR_CODE_OBJECT_SCOPE_COLON_MISSING);
caret.setError("[oatpp::json::Deserializer::deserializeMap()]: Error. ':' - expected", ERROR_CODE_OBJECT_SCOPE_COLON_MISSING);
return nullptr;
}
@ -391,7 +391,7 @@ oatpp::Void Deserializer::deserializeMap(Deserializer* deserializer, parser::Car
if(!caret.canContinueAtChar('}', 1)){
if(!caret.hasError()){
caret.setError("[oatpp::parser::json::mapping::Deserializer::deserializeMap()]: Error. '}' - expected", ERROR_CODE_OBJECT_SCOPE_CLOSE);
caret.setError("[oatpp::json::Deserializer::deserializeMap()]: Error. '}' - expected", ERROR_CODE_OBJECT_SCOPE_CLOSE);
}
return nullptr;
}
@ -399,7 +399,7 @@ oatpp::Void Deserializer::deserializeMap(Deserializer* deserializer, parser::Car
return map;
} else {
caret.setError("[oatpp::parser::json::mapping::Deserializer::deserializeMap()]: Error. '{' - expected", ERROR_CODE_OBJECT_SCOPE_OPEN);
caret.setError("[oatpp::json::Deserializer::deserializeMap()]: Error. '{' - expected", ERROR_CODE_OBJECT_SCOPE_OPEN);
}
return nullptr;
@ -434,7 +434,7 @@ oatpp::Void Deserializer::deserializeObject(Deserializer* deserializer, parser::
caret.skipBlankChars();
if(!caret.canContinueAtChar(':', 1)){
caret.setError("[oatpp::parser::json::mapping::Deserializer::readObject()]: Error. ':' - expected", ERROR_CODE_OBJECT_SCOPE_COLON_MISSING);
caret.setError("[oatpp::json::Deserializer::readObject()]: Error. ':' - expected", ERROR_CODE_OBJECT_SCOPE_COLON_MISSING);
return nullptr;
}
@ -449,7 +449,7 @@ oatpp::Void Deserializer::deserializeObject(Deserializer* deserializer, parser::
} else {
auto value = deserializer->deserialize(caret, field->type);
if(field->info.required && value == nullptr) {
throw std::runtime_error("[oatpp::parser::json::mapping::Deserializer::deserialize()]: "
throw std::runtime_error("[oatpp::json::Deserializer::deserialize()]: "
"Error. " + std::string(type->nameQualifier) + "::"
+ std::string(field->name) + " is required!");
}
@ -459,13 +459,13 @@ oatpp::Void Deserializer::deserializeObject(Deserializer* deserializer, parser::
} else if (deserializer->getConfig()->allowUnknownFields) {
caret.skipBlankChars();
if(!caret.canContinueAtChar(':', 1)){
caret.setError("[oatpp::parser::json::mapping::Deserializer::readObject()/if(config->allowUnknownFields){}]: Error. ':' - expected", ERROR_CODE_OBJECT_SCOPE_COLON_MISSING);
caret.setError("[oatpp::json::Deserializer::readObject()/if(config->allowUnknownFields){}]: Error. ':' - expected", ERROR_CODE_OBJECT_SCOPE_COLON_MISSING);
return nullptr;
}
caret.skipBlankChars();
skipValue(caret);
} else {
caret.setError("[oatpp::parser::json::mapping::Deserializer::readObject()]: Error. Unknown field", ERROR_CODE_OBJECT_SCOPE_UNKNOWN_FIELD);
caret.setError("[oatpp::json::Deserializer::readObject()]: Error. Unknown field", ERROR_CODE_OBJECT_SCOPE_UNKNOWN_FIELD);
return nullptr;
}
@ -476,7 +476,7 @@ oatpp::Void Deserializer::deserializeObject(Deserializer* deserializer, parser::
if(!caret.canContinueAtChar('}', 1)){
if(!caret.hasError()){
caret.setError("[oatpp::parser::json::mapping::Deserializer::readObject()]: Error. '}' - expected", ERROR_CODE_OBJECT_SCOPE_CLOSE);
caret.setError("[oatpp::json::Deserializer::readObject()]: Error. '}' - expected", ERROR_CODE_OBJECT_SCOPE_CLOSE);
}
return nullptr;
}
@ -486,7 +486,7 @@ oatpp::Void Deserializer::deserializeObject(Deserializer* deserializer, parser::
auto selectedType = p.first->info.typeSelector->selectType(static_cast<oatpp::BaseObject *>(object.get()));
auto value = deserializer->deserialize(polyCaret, selectedType);
if(p.first->info.required && value == nullptr) {
throw std::runtime_error("[oatpp::parser::json::mapping::Deserializer::deserialize()]: "
throw std::runtime_error("[oatpp::json::Deserializer::deserialize()]: "
"Error. " + std::string(type->nameQualifier) + "::"
+ std::string(p.first->name) + " is required!");
}
@ -497,7 +497,7 @@ oatpp::Void Deserializer::deserializeObject(Deserializer* deserializer, parser::
return object;
} else {
caret.setError("[oatpp::parser::json::mapping::Deserializer::readObject()]: Error. '{' - expected", ERROR_CODE_OBJECT_SCOPE_OPEN);
caret.setError("[oatpp::json::Deserializer::readObject()]: Error. '{' - expected", ERROR_CODE_OBJECT_SCOPE_OPEN);
}
return nullptr;
@ -516,7 +516,7 @@ oatpp::Void Deserializer::deserialize(parser::Caret& caret, const Type* const ty
return interpretation->fromInterpretation(deserialize(caret, interpretation->getInterpretationType()));
}
throw std::runtime_error("[oatpp::parser::json::mapping::Deserializer::deserialize()]: "
throw std::runtime_error("[oatpp::json::Deserializer::deserialize()]: "
"Error. No deserialize method for type '" + std::string(type->classId.name) + "'");
}
}
@ -525,4 +525,4 @@ const std::shared_ptr<Deserializer::Config>& Deserializer::getConfig() {
return m_config;
}
}}}}
}}

View File

@ -22,16 +22,16 @@
*
***************************************************************************/
#ifndef oatpp_parser_json_mapping_Deserializer_hpp
#define oatpp_parser_json_mapping_Deserializer_hpp
#ifndef oatpp_json_Deserializer_hpp
#define oatpp_json_Deserializer_hpp
#include "oatpp/parser/json/Utils.hpp"
#include "./Utils.hpp"
#include "oatpp/core/parser/Caret.hpp"
#include "oatpp/core/Types.hpp"
#include <vector>
namespace oatpp { namespace parser { namespace json { namespace mapping {
namespace oatpp { namespace json {
/**
* Json Deserializer.
@ -209,6 +209,6 @@ public:
};
}}}}
}}
#endif /* oatpp_parser_json_mapping_Deserializer_hpp */
#endif /* oatpp_json_Deserializer_hpp */

View File

@ -24,7 +24,7 @@
#include "ObjectMapper.hpp"
namespace oatpp { namespace parser { namespace json { namespace mapping {
namespace oatpp { namespace json {
ObjectMapper::ObjectMapper(const std::shared_ptr<Serializer::Config>& serializerConfig,
const std::shared_ptr<Deserializer::Config>& deserializerConfig)
@ -41,12 +41,14 @@ ObjectMapper::ObjectMapper(const std::shared_ptr<Serializer>& serializer,
{}
std::shared_ptr<ObjectMapper> ObjectMapper::createShared(const std::shared_ptr<Serializer::Config>& serializerConfig,
const std::shared_ptr<Deserializer::Config>& deserializerConfig){
const std::shared_ptr<Deserializer::Config>& deserializerConfig)
{
return std::make_shared<ObjectMapper>(serializerConfig, deserializerConfig);
}
std::shared_ptr<ObjectMapper> ObjectMapper::createShared(const std::shared_ptr<Serializer>& serializer,
const std::shared_ptr<Deserializer>& deserializer){
const std::shared_ptr<Deserializer>& deserializer)
{
return std::make_shared<ObjectMapper>(serializer, deserializer);
}
@ -55,8 +57,7 @@ void ObjectMapper::write(data::stream::ConsistentOutputStream* stream,
m_serializer->serializeToStream(stream, variant);
}
oatpp::Void ObjectMapper::read(oatpp::parser::Caret& caret,
const oatpp::data::mapping::type::Type* const type) const {
oatpp::Void ObjectMapper::read(oatpp::parser::Caret& caret, const oatpp::data::mapping::type::Type* const type) const {
return m_deserializer->deserialize(caret, type);
}
@ -68,4 +69,4 @@ std::shared_ptr<Deserializer> ObjectMapper::getDeserializer() {
return m_deserializer;
}
}}}}
}}

View File

@ -22,15 +22,15 @@
*
***************************************************************************/
#ifndef oatpp_parser_json_mapping_ObjectMapper_hpp
#define oatpp_parser_json_mapping_ObjectMapper_hpp
#ifndef oatpp_json_ObjectMapper_hpp
#define oatpp_json_ObjectMapper_hpp
#include "./Serializer.hpp"
#include "./Deserializer.hpp"
#include "oatpp/core/data/mapping/ObjectMapper.hpp"
namespace oatpp { namespace parser { namespace json { namespace mapping {
namespace oatpp { namespace json {
/**
* Json ObjectMapper. Serialized/Deserializes oatpp DTO objects to/from JSON.
@ -49,8 +49,8 @@ private:
public:
/**
* Constructor.
* @param serializerConfig - &id:oatpp::parser::json::mapping::Serializer::Config;.
* @param deserializerConfig - &id:oatpp::parser::json::mapping::Deserializer::Config;.
* @param serializerConfig - &id:oatpp::json::Serializer::Config;.
* @param deserializerConfig - &id:oatpp::json::Deserializer::Config;.
*/
ObjectMapper(const std::shared_ptr<Serializer::Config>& serializerConfig,
const std::shared_ptr<Deserializer::Config>& deserializerConfig);
@ -66,8 +66,8 @@ public:
/**
* Create shared ObjectMapper.
* @param serializerConfig - &id:oatpp::parser::json::mapping::Serializer::Config;.
* @param deserializerConfig - &id:oatpp::parser::json::mapping::Deserializer::Config;.
* @param serializerConfig - &id:oatpp::json::Serializer::Config;.
* @param deserializerConfig - &id:oatpp::json::Deserializer::Config;.
* @return - `std::shared_ptr` to ObjectMapper.
*/
static std::shared_ptr<ObjectMapper>
@ -114,6 +114,6 @@ public:
};
}}}}
}}
#endif /* oatpp_parser_json_mapping_ObjectMapper_hpp */
#endif /* oatpp_json_ObjectMapper_hpp */

View File

@ -24,10 +24,10 @@
#include "Serializer.hpp"
#include "oatpp/parser/json/Utils.hpp"
#include "./Utils.hpp"
#include "oatpp/core/data/mapping/type/Any.hpp"
namespace oatpp { namespace parser { namespace json { namespace mapping {
namespace oatpp { namespace json {
Serializer::Serializer(const std::shared_ptr<Config>& config)
: m_config(config)
@ -129,13 +129,13 @@ void Serializer::serializeEnum(Serializer* serializer,
switch(e) {
case data::mapping::type::EnumInterpreterError::CONSTRAINT_NOT_NULL:
throw std::runtime_error("[oatpp::parser::json::mapping::Serializer::serializeEnum()]: Error. Enum constraint violated - 'NotNull'.");
throw std::runtime_error("[oatpp::json::Serializer::serializeEnum()]: Error. Enum constraint violated - 'NotNull'.");
case data::mapping::type::EnumInterpreterError::OK:
case data::mapping::type::EnumInterpreterError::TYPE_MISMATCH_ENUM:
case data::mapping::type::EnumInterpreterError::TYPE_MISMATCH_ENUM_VALUE:
case data::mapping::type::EnumInterpreterError::ENTRY_NOT_FOUND:
default:
throw std::runtime_error("[oatpp::parser::json::mapping::Serializer::serializeEnum()]: Error. Can't serialize Enum.");
throw std::runtime_error("[oatpp::json::Serializer::serializeEnum()]: Error. Can't serialize Enum.");
}
}
@ -188,7 +188,7 @@ void Serializer::serializeMap(Serializer* serializer,
auto keyType = dispatcher->getKeyType();
if(keyType->classId != oatpp::String::Class::CLASS_ID){
throw std::runtime_error("[oatpp::parser::json::mapping::Serializer::serializeMap()]: Invalid json map key. Key should be String");
throw std::runtime_error("[oatpp::json::Serializer::serializeMap()]: Invalid json map key. Key should be String");
}
stream->writeCharSimple('{');
@ -245,7 +245,7 @@ void Serializer::serializeObject(Serializer* serializer,
}
if(field->info.required && value == nullptr) {
throw std::runtime_error("[oatpp::parser::json::mapping::Serializer::serialize()]: "
throw std::runtime_error("[oatpp::json::Serializer::serialize()]: "
"Error. " + std::string(type->nameQualifier) + "::"
+ std::string(field->name) + " is required!");
}
@ -276,7 +276,7 @@ void Serializer::serialize(data::stream::ConsistentOutputStream* stream,
if(interpretation) {
serialize(stream, interpretation->toInterpretation(polymorph));
} else {
throw std::runtime_error("[oatpp::parser::json::mapping::Serializer::serialize()]: "
throw std::runtime_error("[oatpp::json::Serializer::serialize()]: "
"Error. No serialize method for type '" +
std::string(polymorph.getValueType()->classId.name) + "'");
}
@ -299,4 +299,4 @@ const std::shared_ptr<Serializer::Config>& Serializer::getConfig() {
return m_config;
}
}}}}
}}

View File

@ -22,15 +22,15 @@
*
***************************************************************************/
#ifndef oatpp_parser_json_mapping_Serializer_hpp
#define oatpp_parser_json_mapping_Serializer_hpp
#ifndef oatpp_json_Serializer_hpp
#define oatpp_json_Serializer_hpp
#include "oatpp/parser/json/Utils.hpp"
#include "oatpp/parser/json/Beautifier.hpp"
#include "./Utils.hpp"
#include "./Beautifier.hpp"
#include "oatpp/core/Types.hpp"
#include <vector>
namespace oatpp { namespace parser { namespace json { namespace mapping {
namespace oatpp { namespace json {
/**
* Json Serializer.
@ -197,6 +197,6 @@ public:
};
}}}}
}}
#endif /* oatpp_parser_json_mapping_Serializer_hpp */
#endif /* oatpp_json_Serializer_hpp */

View File

@ -27,7 +27,7 @@
#include "oatpp/encoding/Unicode.hpp"
#include "oatpp/encoding/Hex.hpp"
namespace oatpp { namespace parser { namespace json{
namespace oatpp { namespace json{
v_buff_size Utils::calcEscapedStringSize(const char* data, v_buff_size size, v_buff_size& safeSize, v_uint32 flags) {
v_buff_size result = 0;
@ -423,9 +423,9 @@ const char* Utils::preparseString(ParsingCaret& caret, v_buff_size& size){
}
}
caret.setPosition(caret.getDataSize());
caret.setError("[oatpp::parser::json::Utils::preparseString()]: Error. '\"' - expected", ERROR_CODE_PARSER_QUOTE_EXPECTED);
caret.setError("[oatpp::json::Utils::preparseString()]: Error. '\"' - expected", ERROR_CODE_PARSER_QUOTE_EXPECTED);
} else {
caret.setError("[oatpp::parser::json::Utils::preparseString()]: Error. '\"' - expected", ERROR_CODE_PARSER_QUOTE_EXPECTED);
caret.setError("[oatpp::json::Utils::preparseString()]: Error. '\"' - expected", ERROR_CODE_PARSER_QUOTE_EXPECTED);
}
return nullptr;
@ -445,7 +445,7 @@ oatpp::String Utils::parseString(ParsingCaret& caret) {
v_buff_size errorPosition;
auto result = unescapeString(data, size, errorCode, errorPosition);
if(errorCode != 0){
caret.setError("[oatpp::parser::json::Utils::parseString()]: Error. Call to unescapeString() failed", errorCode);
caret.setError("[oatpp::json::Utils::parseString()]: Error. Call to unescapeString() failed", errorCode);
caret.setPosition(pos + errorPosition);
} else {
caret.setPosition(pos + size + 1);
@ -472,7 +472,7 @@ std::string Utils::parseStringToStdString(ParsingCaret& caret){
v_buff_size errorPosition;
const std::string& result = unescapeStringToStdString(data, size, errorCode, errorPosition);
if(errorCode != 0){
caret.setError("[oatpp::parser::json::Utils::parseStringToStdString()]: Error. Call to unescapeStringToStdString() failed", errorCode);
caret.setError("[oatpp::json::Utils::parseStringToStdString()]: Error. Call to unescapeStringToStdString() failed", errorCode);
caret.setPosition(pos + errorPosition);
} else {
caret.setPosition(pos + size + 1);
@ -502,4 +502,4 @@ bool Utils::findDecimalSeparatorInCurrentNumber(ParsingCaret& caret) {
return false;
}
}}}
}}

View File

@ -22,19 +22,19 @@
*
***************************************************************************/
#ifndef oatpp_parser_json_Utils_hpp
#define oatpp_parser_json_Utils_hpp
#ifndef oatpp_json_Utils_hpp
#define oatpp_json_Utils_hpp
#include "oatpp/core/parser/Caret.hpp"
#include "oatpp/core/Types.hpp"
#include <string>
namespace oatpp { namespace parser { namespace json {
namespace oatpp { namespace json {
/**
* Utility class for json serializer/deserializer.
* Used by &id:oatpp::parser::json::mapping::Serializer;, &id:oatpp::parser::json::mapping::Deserializer;.
* Used by &id:oatpp::json::Serializer;, &id:oatpp::json::Deserializer;.
*/
class Utils {
public:
@ -143,6 +143,6 @@ public:
};
}}}
}}
#endif /* oatpp_parser_json_Utils_hpp */
#endif /* oatpp_json_Utils_hpp */

View File

@ -61,6 +61,18 @@ add_executable(oatppAllTests
oatpp/encoding/UnicodeTest.hpp
oatpp/encoding/UrlTest.cpp
oatpp/encoding/UrlTest.hpp
oatpp/json/BooleanTest.cpp
oatpp/json/BooleanTest.hpp
oatpp/json/DeserializerTest.cpp
oatpp/json/DeserializerTest.hpp
oatpp/json/DTOMapperPerfTest.cpp
oatpp/json/DTOMapperPerfTest.hpp
oatpp/json/DTOMapperTest.cpp
oatpp/json/DTOMapperTest.hpp
oatpp/json/EnumTest.cpp
oatpp/json/EnumTest.hpp
oatpp/json/UnorderedSetTest.cpp
oatpp/json/UnorderedSetTest.hpp
oatpp/network/ConnectionPoolTest.cpp
oatpp/network/ConnectionPoolTest.hpp
oatpp/network/UrlTest.cpp
@ -71,18 +83,6 @@ add_executable(oatppAllTests
oatpp/network/virtual_/InterfaceTest.hpp
oatpp/network/virtual_/PipeTest.cpp
oatpp/network/virtual_/PipeTest.hpp
oatpp/parser/json/mapping/BooleanTest.cpp
oatpp/parser/json/mapping/BooleanTest.hpp
oatpp/parser/json/mapping/DeserializerTest.cpp
oatpp/parser/json/mapping/DeserializerTest.hpp
oatpp/parser/json/mapping/DTOMapperPerfTest.cpp
oatpp/parser/json/mapping/DTOMapperPerfTest.hpp
oatpp/parser/json/mapping/DTOMapperTest.cpp
oatpp/parser/json/mapping/DTOMapperTest.hpp
oatpp/parser/json/mapping/EnumTest.cpp
oatpp/parser/json/mapping/EnumTest.hpp
oatpp/parser/json/mapping/UnorderedSetTest.cpp
oatpp/parser/json/mapping/UnorderedSetTest.hpp
oatpp/web/ClientRetryTest.cpp
oatpp/web/ClientRetryTest.hpp
oatpp/web/FullAsyncClientTest.cpp

View File

@ -18,12 +18,12 @@
#include "oatpp/network/ConnectionPoolTest.hpp"
#include "oatpp/network/monitor/ConnectionMonitorTest.hpp"
#include "oatpp/parser/json/mapping/DeserializerTest.hpp"
#include "oatpp/parser/json/mapping/DTOMapperPerfTest.hpp"
#include "oatpp/parser/json/mapping/DTOMapperTest.hpp"
#include "oatpp/parser/json/mapping/EnumTest.hpp"
#include "oatpp/parser/json/mapping/BooleanTest.hpp"
#include "oatpp/parser/json/mapping/UnorderedSetTest.hpp"
#include "oatpp/json/DeserializerTest.hpp"
#include "oatpp/json/DTOMapperPerfTest.hpp"
#include "oatpp/json/DTOMapperTest.hpp"
#include "oatpp/json/EnumTest.hpp"
#include "oatpp/json/BooleanTest.hpp"
#include "oatpp/json/UnorderedSetTest.hpp"
#include "oatpp/encoding/Base64Test.hpp"
#include "oatpp/encoding/UnicodeTest.hpp"
@ -126,14 +126,14 @@ void runTests() {
OATPP_RUN_TEST(oatpp::test::core::provider::PoolTest);
OATPP_RUN_TEST(oatpp::test::core::provider::PoolTemplateTest);
OATPP_RUN_TEST(oatpp::test::parser::json::mapping::EnumTest);
OATPP_RUN_TEST(oatpp::test::parser::json::mapping::BooleanTest);
OATPP_RUN_TEST(oatpp::json::test::EnumTest);
OATPP_RUN_TEST(oatpp::json::test::BooleanTest);
OATPP_RUN_TEST(oatpp::test::parser::json::mapping::UnorderedSetTest);
OATPP_RUN_TEST(oatpp::json::test::UnorderedSetTest);
OATPP_RUN_TEST(oatpp::test::parser::json::mapping::DeserializerTest);
OATPP_RUN_TEST(oatpp::test::parser::json::mapping::DTOMapperPerfTest);
OATPP_RUN_TEST(oatpp::test::parser::json::mapping::DTOMapperTest);
OATPP_RUN_TEST(oatpp::json::test::DeserializerTest);
OATPP_RUN_TEST(oatpp::json::test::DTOMapperPerfTest);
OATPP_RUN_TEST(oatpp::json::test::DTOMapperTest);
OATPP_RUN_TEST(oatpp::test::encoding::Base64Test);
OATPP_RUN_TEST(oatpp::test::encoding::UnicodeTest);

View File

@ -26,7 +26,7 @@
#include "oatpp/core/data/mapping/type/Any.hpp"
#include "oatpp/parser/json/mapping/ObjectMapper.hpp"
#include "oatpp/json/ObjectMapper.hpp"
#include "oatpp/core/macro/codegen.hpp"
namespace oatpp { namespace test { namespace core { namespace data { namespace mapping { namespace type {

View File

@ -24,7 +24,7 @@
#include "InterpretationTest.hpp"
#include "oatpp/parser/json/mapping/ObjectMapper.hpp"
#include "oatpp/json/ObjectMapper.hpp"
#include "oatpp/core/data/mapping/TypeResolver.hpp"
#include "oatpp/core/Types.hpp"
#include "oatpp/core/macro/codegen.hpp"
@ -173,7 +173,7 @@ namespace __class {
void InterpretationTest::onRun() {
oatpp::parser::json::mapping::ObjectMapper mapper;
oatpp::json::ObjectMapper mapper;
{
auto config = mapper.getSerializer()->getConfig();

View File

@ -24,7 +24,7 @@
#include "ObjectTest.hpp"
#include "oatpp/parser/json/mapping/ObjectMapper.hpp"
#include "oatpp/json/ObjectMapper.hpp"
#include "oatpp/core/macro/codegen.hpp"
#include "oatpp/core/Types.hpp"
@ -477,7 +477,7 @@ void ObjectTest::onRun() {
{
OATPP_LOGI(TAG, "Test 16...")
oatpp::parser::json::mapping::ObjectMapper mapper;
oatpp::json::ObjectMapper mapper;
auto dto = PolymorphicDto1::createShared();
@ -509,7 +509,7 @@ void ObjectTest::onRun() {
{
OATPP_LOGI(TAG, "Test 17...")
oatpp::parser::json::mapping::ObjectMapper mapper;
oatpp::json::ObjectMapper mapper;
auto dto = PolymorphicDto3::createShared();
@ -541,7 +541,7 @@ void ObjectTest::onRun() {
{
OATPP_LOGI(TAG, "Test 18...")
oatpp::parser::json::mapping::ObjectMapper mapper;
oatpp::json::ObjectMapper mapper;
auto dto = PolymorphicDto3::createShared();

View File

@ -24,7 +24,6 @@
#include "TypeTest.hpp"
#include "oatpp/parser/json/mapping/ObjectMapper.hpp"
#include "oatpp/core/macro/codegen.hpp"
#include "oatpp/core/Types.hpp"

View File

@ -22,33 +22,42 @@
*
***************************************************************************/
#ifndef oatpp_test_parser_json_mapping_BooleanTest_hpp
#define oatpp_test_parser_json_mapping_BooleanTest_hpp
#include "BooleanTest.hpp"
#include "oatpp-test/UnitTest.hpp"
#include "oatpp/json/ObjectMapper.hpp"
namespace oatpp
{
namespace test
{
namespace parser
{
namespace json
{
namespace mapping
{
namespace oatpp { namespace json { namespace test {
class BooleanTest : public UnitTest
{
public:
BooleanTest() : UnitTest("TEST[parser::json::mapping::BooleanTest]") {}
void onRun() override;
};
void BooleanTest::onRun() {
oatpp::json::ObjectMapper mapper;
} // namespace mapping
} // namespace json
} // namespace parser
} // namespace test
} // namespace oatpp
{
OATPP_LOGI(TAG, "Serialize true to string...")
auto value = mapper.writeToString(Boolean(true));
OATPP_ASSERT(value == "true")
OATPP_LOGI(TAG, "OK")
}
#endif /* oatpp_test_parser_json_mapping_BooleanTest_hpp */
{
OATPP_LOGI(TAG, "Serialize false to string...")
auto value = mapper.writeToString(Boolean(false));
OATPP_ASSERT(value == "false")
OATPP_LOGI(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Deserialize true string...")
Boolean value = mapper.readFromString<Boolean>("true");
OATPP_ASSERT(static_cast<bool>(value))
OATPP_LOGI(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Deserialize false string...")
Boolean value = mapper.readFromString<Boolean>("false");
OATPP_ASSERT(!static_cast<bool>(value))
OATPP_LOGI(TAG, "OK")
}
}
}}}

View File

@ -0,0 +1,40 @@
/***************************************************************************
*
* Project _____ __ ____ _ _
* ( _ ) /__\ (_ _)_| |_ _| |_
* )(_)( /(__)\ )( (_ _)(_ _)
* (_____)(__)(__)(__) |_| |_|
*
*
* Copyright 2018-present, Leonid Stryzhevskyi <lganzzzo@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
***************************************************************************/
#ifndef oatpp_json_test_BooleanTest_hpp
#define oatpp_json_test_BooleanTest_hpp
#include "oatpp-test/UnitTest.hpp"
namespace oatpp { namespace json { namespace test {
class BooleanTest : public oatpp::test::UnitTest {
public:
BooleanTest() : UnitTest("TEST[oatpp::json::BooleanTest]") {}
void onRun() override;
};
}}}
#endif /* oatpp_json_test_BooleanTest_hpp */

View File

@ -24,9 +24,9 @@
#include "DTOMapperPerfTest.hpp"
#include "oatpp/parser/json/mapping/ObjectMapper.hpp"
#include "oatpp/parser/json/mapping/Serializer.hpp"
#include "oatpp/parser/json/mapping/Deserializer.hpp"
#include "oatpp/json/ObjectMapper.hpp"
#include "oatpp/json/Serializer.hpp"
#include "oatpp/json/Deserializer.hpp"
#include "oatpp/core/data/stream/BufferStream.hpp"
@ -35,12 +35,12 @@
#include "oatpp-test/Checker.hpp"
namespace oatpp { namespace test { namespace parser { namespace json { namespace mapping {
namespace oatpp { namespace json { namespace test {
namespace {
typedef oatpp::parser::json::mapping::Serializer Serializer;
typedef oatpp::parser::json::mapping::Deserializer Deserializer;
typedef oatpp::json::Serializer Serializer;
typedef oatpp::json::Deserializer Deserializer;
#include OATPP_CODEGEN_BEGIN(DTO)
@ -73,22 +73,22 @@ void DTOMapperPerfTest::onRun() {
v_int32 numIterations = 1000000;
auto serializer2 = std::make_shared<oatpp::parser::json::mapping::Serializer>();
auto mapper = oatpp::parser::json::mapping::ObjectMapper::createShared();
auto serializer2 = std::make_shared<oatpp::json::Serializer>();
auto mapper = oatpp::json::ObjectMapper::createShared();
auto test1 = Test1::createTestInstance();
auto test1_Text = mapper->writeToString(test1);
OATPP_LOGV(TAG, "json='%s'", test1_Text->c_str())
{
PerformanceChecker checker("Serializer");
oatpp::test::PerformanceChecker checker("Serializer");
for(v_int32 i = 0; i < numIterations; i ++) {
mapper->writeToString(test1);
}
}
{
PerformanceChecker checker("Deserializer");
oatpp::test::PerformanceChecker checker("Deserializer");
oatpp::parser::Caret caret(test1_Text);
for(v_int32 i = 0; i < numIterations; i ++) {
caret.setPosition(0);
@ -98,4 +98,4 @@ void DTOMapperPerfTest::onRun() {
}
}}}}}
}}}

View File

@ -22,21 +22,21 @@
*
***************************************************************************/
#ifndef oatpp_test_parser_json_mapping_DTOMapperPerfTest_hpp
#define oatpp_test_parser_json_mapping_DTOMapperPerfTest_hpp
#ifndef oatpp_json_test_DTOMapperPerfTest_hpp
#define oatpp_json_test_DTOMapperPerfTest_hpp
#include "oatpp-test/UnitTest.hpp"
namespace oatpp { namespace test { namespace parser { namespace json { namespace mapping {
namespace oatpp { namespace json { namespace test {
class DTOMapperPerfTest : public UnitTest{
class DTOMapperPerfTest : public oatpp::test::UnitTest {
public:
DTOMapperPerfTest():UnitTest("TEST[parser::json::mapping::DTOMapperPerfTest]"){}
DTOMapperPerfTest():UnitTest("TEST[oatpp::json::DTOMapperPerfTest]"){}
void onRun() override;
};
}}}}}
}}}
#endif /* oatpp_test_parser_json_mapping_DTOMapperPerfTest_hpp */
#endif /* oatpp_json_test_DTOMapperPerfTest_hpp */

View File

@ -26,7 +26,7 @@
#include <cmath>
#include "oatpp/parser/json/mapping/ObjectMapper.hpp"
#include "oatpp/json/ObjectMapper.hpp"
#include "oatpp/core/data/mapping/type/Object.hpp"
#include "oatpp/core/data/mapping/type/List.hpp"
@ -36,7 +36,7 @@
#include "oatpp/core/macro/codegen.hpp"
namespace oatpp { namespace test { namespace parser { namespace json { namespace mapping {
namespace oatpp { namespace json { namespace test {
namespace {
@ -164,7 +164,7 @@ class TestAnyNested : public oatpp::DTO {
void DTOMapperTest::onRun(){
auto mapper = oatpp::parser::json::mapping::ObjectMapper::createShared();
auto mapper = oatpp::json::ObjectMapper::createShared();
mapper->getSerializer()->getConfig()->useBeautifier = true;
{
@ -402,4 +402,4 @@ void DTOMapperTest::onRun(){
#include OATPP_CODEGEN_END(DTO)
}}}}}
}}}

View File

@ -22,21 +22,21 @@
*
***************************************************************************/
#ifndef oatpp_test_parser_json_mapping_DTOMapperTest_hpp
#define oatpp_test_parser_json_mapping_DTOMapperTest_hpp
#ifndef oatpp_json_test_DTOMapperTest_hpp
#define oatpp_json_test_DTOMapperTest_hpp
#include "oatpp-test/UnitTest.hpp"
namespace oatpp { namespace test { namespace parser { namespace json { namespace mapping {
namespace oatpp { namespace json { namespace test {
class DTOMapperTest : public UnitTest{
class DTOMapperTest : public oatpp::test::UnitTest {
public:
DTOMapperTest():UnitTest("TEST[parser::json::mapping::DTOMapperTest]"){}
DTOMapperTest():UnitTest("TEST[oatpp::json::DTOMapperTest]"){}
void onRun() override;
};
}}}}}
}}}
#endif /* oatpp_test_parser_json_mapping_DTOMapperTest_hpp */
#endif /* oatpp_json_test_DTOMapperTest_hpp */

View File

@ -26,18 +26,18 @@
#include <cmath>
#include "oatpp/parser/json/mapping/ObjectMapper.hpp"
#include "oatpp/json/ObjectMapper.hpp"
#include "oatpp/core/macro/codegen.hpp"
namespace oatpp { namespace test { namespace parser { namespace json { namespace mapping {
namespace oatpp { namespace json { namespace test {
namespace {
#include OATPP_CODEGEN_BEGIN(DTO)
typedef oatpp::parser::Caret ParsingCaret;
typedef oatpp::parser::json::mapping::Serializer Serializer;
typedef oatpp::parser::json::mapping::Deserializer Deserializer;
typedef oatpp::json::Serializer Serializer;
typedef oatpp::json::Deserializer Deserializer;
class EmptyDto : public oatpp::DTO {
@ -145,7 +145,7 @@ class AnyDto : public oatpp::DTO {
void DeserializerTest::onRun(){
auto mapper = oatpp::parser::json::mapping::ObjectMapper::createShared();
auto mapper = oatpp::json::ObjectMapper::createShared();
auto obj1 = mapper->readFromString<oatpp::Object<Test1>>("{}");
@ -324,4 +324,4 @@ void DeserializerTest::onRun(){
}
}}}}}
}}}

View File

@ -22,21 +22,21 @@
*
***************************************************************************/
#ifndef oatpp_test_parser_json_mapping_DeserializerTest_hpp
#define oatpp_test_parser_json_mapping_DeserializerTest_hpp
#ifndef oatpp_json_test_DeserializerTest_hpp
#define oatpp_json_test_DeserializerTest_hpp
#include "oatpp-test/UnitTest.hpp"
namespace oatpp { namespace test { namespace parser { namespace json { namespace mapping {
namespace oatpp { namespace json { namespace test {
class DeserializerTest : public UnitTest{
class DeserializerTest : public oatpp::test::UnitTest {
public:
DeserializerTest():UnitTest("TEST[parser::json::mapping::DeserializerTest]"){}
DeserializerTest():UnitTest("TEST[oatpp::json::DeserializerTest]"){}
void onRun() override;
};
}}}}}
}}}
#endif /* oatpp_test_parser_json_mapping_DeserializerTest_hpp */
#endif /* oatpp_json_test_DeserializerTest_hpp */

View File

@ -24,11 +24,11 @@
#include "EnumTest.hpp"
#include "oatpp/parser/json/mapping/ObjectMapper.hpp"
#include "oatpp/json/ObjectMapper.hpp"
#include "oatpp/core/macro/codegen.hpp"
namespace oatpp { namespace test { namespace parser { namespace json { namespace mapping {
namespace oatpp { namespace json { namespace test {
namespace {
@ -56,7 +56,7 @@ class DTO1 : public oatpp::DTO {
void EnumTest::onRun() {
oatpp::parser::json::mapping::ObjectMapper mapper;
oatpp::json::ObjectMapper mapper;
{
OATPP_LOGI(TAG, "Serializer as string...")
@ -184,4 +184,4 @@ void EnumTest::onRun() {
}
}}}}}
}}}

View File

@ -22,21 +22,21 @@
*
***************************************************************************/
#ifndef oatpp_test_parser_json_mapping_EnumTest_hpp
#define oatpp_test_parser_json_mapping_EnumTest_hpp
#ifndef oatpp_json_test_EnumTest_hpp
#define oatpp_json_test_EnumTest_hpp
#include "oatpp-test/UnitTest.hpp"
namespace oatpp { namespace test { namespace parser { namespace json { namespace mapping {
namespace oatpp { namespace json { namespace test {
class EnumTest : public UnitTest{
class EnumTest : public oatpp::test::UnitTest {
public:
EnumTest():UnitTest("TEST[parser::json::mapping::EnumTest]"){}
EnumTest():UnitTest("TEST[oatpp::json::EnumTest]"){}
void onRun() override;
};
}}}}}
}}}
#endif /* oatpp_test_parser_json_mapping_EnumTest_hpp */
#endif /* oatpp_json_test_EnumTest_hpp */

View File

@ -24,13 +24,13 @@
#include "UnorderedSetTest.hpp"
#include "oatpp/parser/json/mapping/ObjectMapper.hpp"
#include "oatpp/json/ObjectMapper.hpp"
namespace oatpp { namespace test { namespace parser { namespace json { namespace mapping {
namespace oatpp { namespace json { namespace test {
void UnorderedSetTest::onRun() {
oatpp::parser::json::mapping::ObjectMapper mapper;
oatpp::json::ObjectMapper mapper;
{
oatpp::UnorderedSet<oatpp::String> set = {"Hello", "World", "!"};
@ -50,4 +50,4 @@ void UnorderedSetTest::onRun() {
}
}}}}}
}}}

View File

@ -22,21 +22,21 @@
*
***************************************************************************/
#ifndef oatpp_test_parser_json_mapping_UnorderedSetTest_hpp
#define oatpp_test_parser_json_mapping_UnorderedSetTest_hpp
#ifndef oatpp_json_test_UnorderedSetTest_hpp
#define oatpp_json_test_UnorderedSetTest_hpp
#include "oatpp-test/UnitTest.hpp"
namespace oatpp { namespace test { namespace parser { namespace json { namespace mapping {
namespace oatpp { namespace json { namespace test {
class UnorderedSetTest : public UnitTest{
class UnorderedSetTest : public oatpp::test::UnitTest {
public:
UnorderedSetTest():UnitTest("TEST[parser::json::mapping::UnorderedSetTest]"){}
UnorderedSetTest():UnitTest("TEST[oatpp::json::UnorderedSetTest]"){}
void onRun() override;
};
}}}}}
}}}
#endif /* oatpp_test_parser_json_mapping_UnorderedSetTest_hpp */
#endif /* oatpp_json_test_UnorderedSetTest_hpp */

View File

@ -1,78 +0,0 @@
/***************************************************************************
*
* Project _____ __ ____ _ _
* ( _ ) /__\ (_ _)_| |_ _| |_
* )(_)( /(__)\ )( (_ _)(_ _)
* (_____)(__)(__)(__) |_| |_|
*
*
* Copyright 2018-present, Leonid Stryzhevskyi <lganzzzo@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
***************************************************************************/
#include "BooleanTest.hpp"
#include "oatpp/parser/json/mapping/ObjectMapper.hpp"
#include "oatpp/core/macro/codegen.hpp"
namespace oatpp
{
namespace test
{
namespace parser
{
namespace json
{
namespace mapping
{
void BooleanTest::onRun()
{
oatpp::parser::json::mapping::ObjectMapper mapper;
{
OATPP_LOGI(TAG, "Serialize true to string...")
auto value = mapper.writeToString(Boolean(true));
OATPP_ASSERT(value == "true")
OATPP_LOGI(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Serialize false to string...")
auto value = mapper.writeToString(Boolean(false));
OATPP_ASSERT(value == "false")
OATPP_LOGI(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Deserialize true string...")
Boolean value = mapper.readFromString<Boolean>("true");
OATPP_ASSERT(static_cast<bool>(value))
OATPP_LOGI(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Deserialize false string...")
Boolean value = mapper.readFromString<Boolean>("false");
OATPP_ASSERT(!static_cast<bool>(value))
OATPP_LOGI(TAG, "OK")
}
}
} // namespace mapping
} // namespace json
} // namespace parser
} // namespace test
} // namespace oatpp

View File

@ -36,7 +36,7 @@
#include "oatpp/web/server/HttpConnectionHandler.hpp"
#include "oatpp/web/server/HttpRouter.hpp"
#include "oatpp/parser/json/mapping/ObjectMapper.hpp"
#include "oatpp/json/ObjectMapper.hpp"
#include "oatpp/network/tcp/server/ConnectionProvider.hpp"
#include "oatpp/network/tcp/client/ConnectionProvider.hpp"
@ -92,7 +92,7 @@ public:
}());
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::data::mapping::ObjectMapper>, objectMapper)([] {
return oatpp::parser::json::mapping::ObjectMapper::createShared();
return oatpp::json::ObjectMapper::createShared();
}());
};
@ -153,7 +153,7 @@ void ClientRetryTest::onRun() {
TestClientComponent component(m_port);
auto objectMapper = oatpp::parser::json::mapping::ObjectMapper::createShared();
auto objectMapper = oatpp::json::ObjectMapper::createShared();
auto controller = app::Controller::createShared(objectMapper);
OATPP_COMPONENT(std::shared_ptr<oatpp::network::ClientConnectionProvider>, connectionProvider);

View File

@ -33,7 +33,7 @@
#include "oatpp/web/server/AsyncHttpConnectionHandler.hpp"
#include "oatpp/web/server/HttpRouter.hpp"
#include "oatpp/parser/json/mapping/ObjectMapper.hpp"
#include "oatpp/json/ObjectMapper.hpp"
#include "oatpp/network/tcp/server/ConnectionProvider.hpp"
#include "oatpp/network/tcp/client/ConnectionProvider.hpp"
@ -95,7 +95,7 @@ public:
}());
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::data::mapping::ObjectMapper>, objectMapper)([] {
return oatpp::parser::json::mapping::ObjectMapper::createShared();
return oatpp::json::ObjectMapper::createShared();
}());
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::network::ClientConnectionProvider>, clientConnectionProvider)([this] {

View File

@ -34,7 +34,7 @@
#include "oatpp/web/server/AsyncHttpConnectionHandler.hpp"
#include "oatpp/web/server/HttpRouter.hpp"
#include "oatpp/parser/json/mapping/ObjectMapper.hpp"
#include "oatpp/json/ObjectMapper.hpp"
#include "oatpp/network/tcp/server/ConnectionProvider.hpp"
#include "oatpp/network/tcp/client/ConnectionProvider.hpp"
@ -98,7 +98,7 @@ public:
}());
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::data::mapping::ObjectMapper>, objectMapper)([] {
return oatpp::parser::json::mapping::ObjectMapper::createShared();
return oatpp::json::ObjectMapper::createShared();
}());
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::network::ClientConnectionProvider>, clientConnectionProvider)([this] {

View File

@ -37,7 +37,7 @@
#include "oatpp/web/server/HttpConnectionHandler.hpp"
#include "oatpp/web/server/HttpRouter.hpp"
#include "oatpp/parser/json/mapping/ObjectMapper.hpp"
#include "oatpp/json/ObjectMapper.hpp"
#include "oatpp/network/tcp/server/ConnectionProvider.hpp"
#include "oatpp/network/tcp/client/ConnectionProvider.hpp"
@ -96,7 +96,7 @@ public:
}());
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::data::mapping::ObjectMapper>, objectMapper)([] {
return oatpp::parser::json::mapping::ObjectMapper::createShared();
return oatpp::json::ObjectMapper::createShared();
}());
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::network::ClientConnectionProvider>, clientConnectionProvider)([this] {

View File

@ -29,7 +29,7 @@
#include "oatpp/web/server/AsyncHttpConnectionHandler.hpp"
#include "oatpp/web/server/HttpRouter.hpp"
#include "oatpp/parser/json/mapping/ObjectMapper.hpp"
#include "oatpp/json/ObjectMapper.hpp"
#include "oatpp/network/tcp/server/ConnectionProvider.hpp"
#include "oatpp/network/tcp/client/ConnectionProvider.hpp"
@ -90,7 +90,7 @@ public:
}());
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::data::mapping::ObjectMapper>, objectMapper)([] {
return oatpp::parser::json::mapping::ObjectMapper::createShared();
return oatpp::json::ObjectMapper::createShared();
}());
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::network::ClientConnectionProvider>, clientConnectionProvider)([this] {

View File

@ -29,7 +29,7 @@
#include "oatpp/web/server/HttpConnectionHandler.hpp"
#include "oatpp/web/server/HttpRouter.hpp"
#include "oatpp/parser/json/mapping/ObjectMapper.hpp"
#include "oatpp/json/ObjectMapper.hpp"
#include "oatpp/network/tcp/server/ConnectionProvider.hpp"
#include "oatpp/network/tcp/client/ConnectionProvider.hpp"
@ -85,7 +85,7 @@ public:
}());
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::data::mapping::ObjectMapper>, objectMapper)([] {
return oatpp::parser::json::mapping::ObjectMapper::createShared();
return oatpp::json::ObjectMapper::createShared();
}());
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::network::ClientConnectionProvider>, clientConnectionProvider)([this] {

View File

@ -28,7 +28,7 @@
#include "./DTOs.hpp"
#include "oatpp/web/server/api/ApiController.hpp"
#include "oatpp/parser/json/mapping/ObjectMapper.hpp"
#include "oatpp/json/ObjectMapper.hpp"
#include "oatpp/core/utils/ConversionUtils.hpp"
#include "oatpp/core/macro/codegen.hpp"
#include "oatpp/core/macro/component.hpp"

View File

@ -28,7 +28,7 @@
#include "./DTOs.hpp"
#include "oatpp/web/server/api/ApiController.hpp"
#include "oatpp/parser/json/mapping/ObjectMapper.hpp"
#include "oatpp/json/ObjectMapper.hpp"
#include "oatpp/core/utils/ConversionUtils.hpp"
#include "oatpp/core/macro/codegen.hpp"
#include "oatpp/core/macro/component.hpp"

View File

@ -36,7 +36,7 @@
#include "oatpp/web/protocol/http/outgoing/StreamingBody.hpp"
#include "oatpp/web/server/api/ApiController.hpp"
#include "oatpp/parser/json/mapping/ObjectMapper.hpp"
#include "oatpp/json/ObjectMapper.hpp"
#include "oatpp/core/data/resource/File.hpp"
#include "oatpp/core/data/stream/FileStream.hpp"

View File

@ -36,7 +36,7 @@
#include "oatpp/web/protocol/http/outgoing/StreamingBody.hpp"
#include "oatpp/web/server/api/ApiController.hpp"
#include "oatpp/parser/json/mapping/ObjectMapper.hpp"
#include "oatpp/json/ObjectMapper.hpp"
#include "oatpp/core/data/resource/File.hpp"
#include "oatpp/core/data/stream/FileStream.hpp"

View File

@ -26,7 +26,7 @@
#define oatpp_test_web_app_ControllerWithErrorHandler_hpp
#include "oatpp/web/server/api/ApiController.hpp"
#include "oatpp/parser/json/mapping/ObjectMapper.hpp"
#include "oatpp/json/ObjectMapper.hpp"
#include "oatpp/core/utils/ConversionUtils.hpp"
#include "oatpp/core/macro/codegen.hpp"
#include "oatpp/core/macro/component.hpp"

View File

@ -26,7 +26,7 @@
#define oatpp_test_web_app_ControllerWithInterceptors_hpp
#include "oatpp/web/server/api/ApiController.hpp"
#include "oatpp/parser/json/mapping/ObjectMapper.hpp"
#include "oatpp/json/ObjectMapper.hpp"
#include "oatpp/core/utils/ConversionUtils.hpp"
#include "oatpp/core/macro/codegen.hpp"
#include "oatpp/core/macro/component.hpp"

View File

@ -26,7 +26,7 @@
#define oatpp_test_web_app_ControllerWithInterceptorsAsync_hpp
#include "oatpp/web/server/api/ApiController.hpp"
#include "oatpp/parser/json/mapping/ObjectMapper.hpp"
#include "oatpp/json/ObjectMapper.hpp"
#include "oatpp/core/utils/ConversionUtils.hpp"
#include "oatpp/core/macro/codegen.hpp"
#include "oatpp/core/macro/component.hpp"