mirror of
https://github.com/oatpp/oatpp.git
synced 2025-01-30 16:59:30 +08:00
restructuring and code cleanup
This commit is contained in:
parent
4b4cafc21d
commit
751d525539
@ -25,9 +25,9 @@
|
||||
#ifndef oatpp_async_Coroutine_hpp
|
||||
#define oatpp_async_Coroutine_hpp
|
||||
|
||||
#include "../collection/FastQueue.hpp"
|
||||
#include "../base/memory/MemoryPool.hpp"
|
||||
#include "../base/Environment.hpp"
|
||||
#include "oatpp/core/collection/FastQueue.hpp"
|
||||
#include "oatpp/core/base/memory/MemoryPool.hpp"
|
||||
#include "oatpp/core/base/Environment.hpp"
|
||||
|
||||
namespace oatpp { namespace async {
|
||||
|
@ -26,7 +26,7 @@
|
||||
#define oatpp_async_Processor_hpp
|
||||
|
||||
#include "./Coroutine.hpp"
|
||||
#include "../collection/FastQueue.hpp"
|
||||
#include "oatpp/core/collection/FastQueue.hpp"
|
||||
|
||||
namespace oatpp { namespace async {
|
||||
|
@ -23,7 +23,7 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include "MemoryPool.hpp"
|
||||
#include "../../utils/ConversionUtils.hpp"
|
||||
#include "oatpp/core/utils/ConversionUtils.hpp"
|
||||
|
||||
namespace oatpp { namespace base { namespace memory {
|
||||
|
@ -25,8 +25,8 @@
|
||||
#ifndef oatpp_base_memory_MemoryPool_hpp
|
||||
#define oatpp_base_memory_MemoryPool_hpp
|
||||
|
||||
#include "../../concurrency/SpinLock.hpp"
|
||||
#include "../Environment.hpp"
|
||||
#include "oatpp/core/concurrency/SpinLock.hpp"
|
||||
#include "oatpp/core/base/Environment.hpp"
|
||||
|
||||
#include <atomic>
|
||||
#include <list>
|
@ -9,8 +9,8 @@
|
||||
#ifndef oatpp_collection_FastQueue_hpp
|
||||
#define oatpp_collection_FastQueue_hpp
|
||||
|
||||
#include "../concurrency/SpinLock.hpp"
|
||||
#include "../base/Environment.hpp"
|
||||
#include "oatpp/core/concurrency/SpinLock.hpp"
|
||||
#include "oatpp/core/base/Environment.hpp"
|
||||
|
||||
namespace oatpp { namespace collection {
|
||||
|
@ -25,11 +25,11 @@
|
||||
#ifndef oatpp_collection_LinkedList_hpp
|
||||
#define oatpp_collection_LinkedList_hpp
|
||||
|
||||
#include "../base/memory/ObjectPool.hpp"
|
||||
#include "oatpp/core/base/memory/ObjectPool.hpp"
|
||||
|
||||
#include "../base/PtrWrapper.hpp"
|
||||
#include "../base/Controllable.hpp"
|
||||
#include "../base/Environment.hpp"
|
||||
#include "oatpp/core/base/PtrWrapper.hpp"
|
||||
#include "oatpp/core/base/Controllable.hpp"
|
||||
#include "oatpp/core/base/Environment.hpp"
|
||||
|
||||
namespace oatpp { namespace collection {
|
||||
|
@ -25,8 +25,8 @@
|
||||
#ifndef oatpp_collection_ListMap_hpp
|
||||
#define oatpp_collection_ListMap_hpp
|
||||
|
||||
#include "../base/memory/ObjectPool.hpp"
|
||||
#include "../base/Controllable.hpp"
|
||||
#include "oatpp/core/base/memory/ObjectPool.hpp"
|
||||
#include "oatpp/core/base/Controllable.hpp"
|
||||
|
||||
namespace oatpp { namespace collection {
|
||||
|
@ -25,7 +25,7 @@
|
||||
#ifndef concurrency_Runnable_hpp
|
||||
#define concurrency_Runnable_hpp
|
||||
|
||||
#include "../base/PtrWrapper.hpp"
|
||||
#include "oatpp/core/base/PtrWrapper.hpp"
|
||||
|
||||
namespace oatpp { namespace concurrency {
|
||||
|
@ -27,10 +27,10 @@
|
||||
|
||||
#include "./Runnable.hpp"
|
||||
|
||||
#include "../base/memory/ObjectPool.hpp"
|
||||
#include "oatpp/core/base/memory/ObjectPool.hpp"
|
||||
|
||||
#include "../base/Controllable.hpp"
|
||||
#include "../base/PtrWrapper.hpp"
|
||||
#include "oatpp/core/base/Controllable.hpp"
|
||||
#include "oatpp/core/base/PtrWrapper.hpp"
|
||||
|
||||
#include <thread>
|
||||
#include <atomic>
|
@ -25,9 +25,9 @@
|
||||
#ifndef oatpp_data_buffer_IOBuffer_hpp
|
||||
#define oatpp_data_buffer_IOBuffer_hpp
|
||||
|
||||
#include "../../base/memory/ObjectPool.hpp"
|
||||
#include "../../base/Controllable.hpp"
|
||||
#include "../../base/PtrWrapper.hpp"
|
||||
#include "oatpp/core/base/memory/ObjectPool.hpp"
|
||||
#include "oatpp/core/base/Controllable.hpp"
|
||||
#include "oatpp/core/base/PtrWrapper.hpp"
|
||||
|
||||
namespace oatpp { namespace data{ namespace buffer {
|
||||
|
@ -25,14 +25,14 @@
|
||||
#ifndef oatpp_data_mapping_ObjectMapper_hpp
|
||||
#define oatpp_data_mapping_ObjectMapper_hpp
|
||||
|
||||
#include "./type/Object.hpp"
|
||||
#include "./type/Object.hpp"
|
||||
#include "./type/Type.hpp"
|
||||
#include "type/Object.hpp"
|
||||
#include "type/Object.hpp"
|
||||
#include "type/Type.hpp"
|
||||
|
||||
#include "../stream/ChunkedBuffer.hpp"
|
||||
#include "../stream/Stream.hpp"
|
||||
#include "oatpp/core/data/stream/ChunkedBuffer.hpp"
|
||||
#include "oatpp/core/data/stream/Stream.hpp"
|
||||
|
||||
#include "../../parser/ParsingCaret.hpp"
|
||||
#include "oatpp/core/parser/ParsingCaret.hpp"
|
||||
|
||||
namespace oatpp { namespace data { namespace mapping {
|
||||
|
@ -27,12 +27,12 @@
|
||||
|
||||
#include "./Type.hpp"
|
||||
|
||||
#include "../../../collection/LinkedList.hpp"
|
||||
#include "oatpp/core/collection/LinkedList.hpp"
|
||||
|
||||
#include "../../../base/memory/ObjectPool.hpp"
|
||||
#include "../../../base/Controllable.hpp"
|
||||
#include "../../../base/String.hpp"
|
||||
#include "../../../base/PtrWrapper.hpp"
|
||||
#include "oatpp/core/base/memory/ObjectPool.hpp"
|
||||
#include "oatpp/core/base/Controllable.hpp"
|
||||
#include "oatpp/core/base/String.hpp"
|
||||
#include "oatpp/core/base/PtrWrapper.hpp"
|
||||
|
||||
namespace oatpp { namespace data { namespace mapping { namespace type {
|
||||
|
@ -30,10 +30,10 @@
|
||||
#include "./Primitive.hpp"
|
||||
#include "./List.hpp"
|
||||
|
||||
#include "../../../base/memory/ObjectPool.hpp"
|
||||
#include "../../../base/Controllable.hpp"
|
||||
#include "../../../base/String.hpp"
|
||||
#include "../../../base/PtrWrapper.hpp"
|
||||
#include "oatpp/core/base/memory/ObjectPool.hpp"
|
||||
#include "oatpp/core/base/Controllable.hpp"
|
||||
#include "oatpp/core/base/String.hpp"
|
||||
#include "oatpp/core/base/PtrWrapper.hpp"
|
||||
|
||||
namespace oatpp { namespace data { namespace mapping { namespace type {
|
||||
|
@ -27,13 +27,13 @@
|
||||
|
||||
#include "./Type.hpp"
|
||||
|
||||
#include "../../../utils/ConversionUtils.hpp"
|
||||
#include "oatpp/core/utils/ConversionUtils.hpp"
|
||||
|
||||
#include "../../../base/memory/ObjectPool.hpp"
|
||||
#include "../../../base/Controllable.hpp"
|
||||
#include "../../../base/String.hpp"
|
||||
#include "oatpp/core/base/memory/ObjectPool.hpp"
|
||||
#include "oatpp/core/base/Controllable.hpp"
|
||||
#include "oatpp/core/base/String.hpp"
|
||||
|
||||
#include "../../../base/PtrWrapper.hpp"
|
||||
#include "oatpp/core/base/PtrWrapper.hpp"
|
||||
|
||||
namespace oatpp { namespace data { namespace mapping { namespace type {
|
||||
|
@ -25,7 +25,7 @@
|
||||
#ifndef oatpp_data_type_Type_hpp
|
||||
#define oatpp_data_type_Type_hpp
|
||||
|
||||
#include "../../../base/PtrWrapper.hpp"
|
||||
#include "oatpp/core/base/PtrWrapper.hpp"
|
||||
|
||||
#include <list>
|
||||
#include <unordered_map>
|
@ -22,8 +22,8 @@
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#include "../../../../macro/basic.hpp"
|
||||
#include "../../../../macro/codegen.hpp"
|
||||
#include "oatpp/core/macro/basic.hpp"
|
||||
#include "oatpp/core/macro/codegen.hpp"
|
||||
|
||||
// Defaults
|
||||
|
@ -25,10 +25,10 @@
|
||||
#ifndef oatpp_data_stream_ChunkedBuffer_hpp
|
||||
#define oatpp_data_stream_ChunkedBuffer_hpp
|
||||
|
||||
#include "./Stream.hpp"
|
||||
#include "Stream.hpp"
|
||||
|
||||
#include "../../collection/LinkedList.hpp"
|
||||
#include "../../async/Coroutine.hpp"
|
||||
#include "oatpp/core/collection/LinkedList.hpp"
|
||||
#include "oatpp/core/async/Coroutine.hpp"
|
||||
|
||||
namespace oatpp { namespace data{ namespace stream {
|
||||
|
@ -23,7 +23,7 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include "./Stream.hpp"
|
||||
#include "../../utils/ConversionUtils.hpp"
|
||||
#include "oatpp/core/utils/ConversionUtils.hpp"
|
||||
|
||||
namespace oatpp { namespace data{ namespace stream {
|
||||
|
@ -25,14 +25,14 @@
|
||||
#ifndef oatpp_data_Stream
|
||||
#define oatpp_data_Stream
|
||||
|
||||
#include "../../base/memory/ObjectPool.hpp"
|
||||
#include "oatpp/core/base/memory/ObjectPool.hpp"
|
||||
|
||||
#include "../../base/String.hpp"
|
||||
#include "oatpp/core/base/String.hpp"
|
||||
|
||||
#include "../../os/io/Library.hpp"
|
||||
#include "oatpp/core/os/io/Library.hpp"
|
||||
|
||||
#include "../../base/PtrWrapper.hpp"
|
||||
#include "../../base/Environment.hpp"
|
||||
#include "oatpp/core/base/PtrWrapper.hpp"
|
||||
#include "oatpp/core/base/Environment.hpp"
|
||||
|
||||
namespace oatpp { namespace data{ namespace stream {
|
||||
|
@ -25,9 +25,9 @@
|
||||
#ifndef oatpp_data_stream_StreamBufferedProxy_hpp
|
||||
#define oatpp_data_stream_StreamBufferedProxy_hpp
|
||||
|
||||
#include "./Stream.hpp"
|
||||
#include "../buffer/IOBuffer.hpp"
|
||||
#include "../../async/Coroutine.hpp"
|
||||
#include "Stream.hpp"
|
||||
#include "oatpp/core/data/buffer/IOBuffer.hpp"
|
||||
#include "oatpp/core/async/Coroutine.hpp"
|
||||
|
||||
namespace oatpp { namespace data{ namespace stream {
|
||||
|
@ -25,8 +25,8 @@
|
||||
#ifndef oatpp_macro_component_hpp
|
||||
#define oatpp_macro_component_hpp
|
||||
|
||||
#include "../base/Environment.hpp"
|
||||
#include "./basic.hpp"
|
||||
#include "oatpp/core/base/Environment.hpp"
|
||||
|
||||
#define OATPP_MACRO_GET_COMPONENT_0(TYPE, LIST) \
|
||||
(*((TYPE*) oatpp::base::Environment::getComponent(typeid(TYPE).name())))
|
@ -25,7 +25,7 @@
|
||||
#ifndef oatpp_os_io_Library_hpp
|
||||
#define oatpp_os_io_Library_hpp
|
||||
|
||||
#include "../../base/Environment.hpp"
|
||||
#include "oatpp/core/base/Environment.hpp"
|
||||
|
||||
namespace oatpp { namespace os { namespace io {
|
||||
|
@ -25,8 +25,8 @@
|
||||
#ifndef oatpp_parser_ParsingCaret_hpp
|
||||
#define oatpp_parser_ParsingCaret_hpp
|
||||
|
||||
#include "../collection/LinkedList.hpp"
|
||||
#include "../base/String.hpp"
|
||||
#include "oatpp/core/collection/LinkedList.hpp"
|
||||
#include "oatpp/core/base/String.hpp"
|
||||
|
||||
namespace oatpp { namespace parser {
|
||||
|
@ -1,297 +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 "RegRuleTest.hpp"
|
||||
|
||||
#include "../../src/data/mapping/type/Primitive.hpp"
|
||||
#include "../../src/base/String.hpp"
|
||||
|
||||
namespace oatpp { namespace test { namespace base {
|
||||
|
||||
namespace {
|
||||
|
||||
class BaseClass : public oatpp::base::Controllable {
|
||||
public:
|
||||
|
||||
template<class T>
|
||||
static T create1() {
|
||||
return new BaseClass();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
static T create2() {
|
||||
return T(new BaseClass());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class ChildClass : public BaseClass {
|
||||
public:
|
||||
|
||||
template<class T>
|
||||
static T create1() {
|
||||
return new ChildClass();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
static T create2() {
|
||||
return T(new ChildClass());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
typedef oatpp::base::String String;
|
||||
|
||||
template<typename T>
|
||||
using PtrWrapper = oatpp::base::PtrWrapper<T>;
|
||||
|
||||
template<typename T>
|
||||
using PolymorphicWrapper = oatpp::data::mapping::type::PolymorphicWrapper<T>;
|
||||
|
||||
template<typename T>
|
||||
using TypePtrWrapper = oatpp::data::mapping::type::PtrWrapper<T, oatpp::data::mapping::type::__class::Void>;
|
||||
|
||||
typedef oatpp::data::mapping::type::StringPtrWrapper StringPtrWrapper;
|
||||
typedef oatpp::data::mapping::type::Int32 Int32;
|
||||
typedef oatpp::data::mapping::type::Int64 Int64;
|
||||
typedef oatpp::data::mapping::type::Float32 Float32;
|
||||
typedef oatpp::data::mapping::type::Float64 Float64;
|
||||
typedef oatpp::data::mapping::type::Boolean Boolean;
|
||||
|
||||
template <class PtrWrapperBC, class PtrWrapperCC, class BC, class CC>
|
||||
void checkPtrWrapper(){
|
||||
{
|
||||
PtrWrapperBC reg1(new BC);
|
||||
PtrWrapperBC reg2(reg1);
|
||||
OATPP_ASSERT(!reg1.isNull());
|
||||
PtrWrapperBC reg3(std::move(reg1));
|
||||
OATPP_ASSERT(reg1.isNull());
|
||||
PtrWrapperBC reg4(BC::template create1<PtrWrapperBC>());
|
||||
PtrWrapperBC reg5(BC::template create2<PtrWrapperBC>());
|
||||
}
|
||||
|
||||
{
|
||||
PtrWrapperBC reg1 = new BC;
|
||||
PtrWrapperBC reg2 = reg1;
|
||||
OATPP_ASSERT(!reg1.isNull());
|
||||
PtrWrapperBC reg3 = std::move(reg1);
|
||||
OATPP_ASSERT(reg1.isNull());
|
||||
PtrWrapperBC reg4 = BC::template create1<PtrWrapperBC>();
|
||||
PtrWrapperBC reg5 = BC::template create2<PtrWrapperBC>();
|
||||
}
|
||||
|
||||
{
|
||||
PtrWrapperBC reg1 = new BC;
|
||||
PtrWrapperBC reg2;
|
||||
reg2 = reg1;
|
||||
OATPP_ASSERT(!reg1.isNull());
|
||||
PtrWrapperBC reg3;
|
||||
reg3 = std::move(reg1);
|
||||
OATPP_ASSERT(reg1.isNull());
|
||||
PtrWrapperBC reg4;
|
||||
reg4 = BC::template create1<PtrWrapperBC>();
|
||||
PtrWrapperBC reg5;
|
||||
reg5 = BC::template create2<PtrWrapperBC>();
|
||||
}
|
||||
|
||||
//---
|
||||
|
||||
{
|
||||
PtrWrapperCC reg1(new CC);
|
||||
PtrWrapperBC reg2(reg1);
|
||||
OATPP_ASSERT(!reg1.isNull());
|
||||
PtrWrapperBC reg3(std::move(reg1));
|
||||
OATPP_ASSERT(!reg1.isNull());
|
||||
PtrWrapperBC reg4(CC::template create1<PtrWrapperCC>());
|
||||
PtrWrapperBC reg5(CC::template create2<PtrWrapperCC>());
|
||||
}
|
||||
|
||||
{
|
||||
PtrWrapperCC reg1 = new CC;
|
||||
PtrWrapperBC reg2 = reg1;
|
||||
OATPP_ASSERT(!reg1.isNull());
|
||||
PtrWrapperBC reg3 = std::move(reg1);
|
||||
OATPP_ASSERT(!reg1.isNull());
|
||||
PtrWrapperBC reg4 = CC::template create1<PtrWrapperCC>();
|
||||
PtrWrapperBC reg5 = CC::template create2<PtrWrapperCC>();
|
||||
}
|
||||
|
||||
{
|
||||
PtrWrapperCC reg1 = new CC;
|
||||
PtrWrapperBC reg2;
|
||||
reg2 = reg1;
|
||||
OATPP_ASSERT(!reg1.isNull());
|
||||
PtrWrapperBC reg3;
|
||||
reg3 = std::move(reg1);
|
||||
OATPP_ASSERT(!reg1.isNull());
|
||||
PtrWrapperBC reg4;
|
||||
reg4 = CC::template create1<PtrWrapperCC>();
|
||||
PtrWrapperBC reg5;
|
||||
reg5 = CC::template create2<PtrWrapperCC>();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool RegRuleTest::onRun() {
|
||||
|
||||
//checkPtrWrapper<PtrWrapper<BaseClass>, PtrWrapper<ChildClass>, BaseClass, ChildClass>();
|
||||
|
||||
{
|
||||
String::PtrWrapper reg1("");
|
||||
String::PtrWrapper reg2(reg1);
|
||||
OATPP_ASSERT(!reg1.isNull());
|
||||
String::PtrWrapper reg3(std::move(reg1));
|
||||
OATPP_ASSERT(reg1.isNull());
|
||||
String::PtrWrapper reg4 = String::createShared(100);
|
||||
}
|
||||
|
||||
{
|
||||
String::PtrWrapper reg1("");
|
||||
base::PtrWrapper<String> reg2(reg1);
|
||||
OATPP_ASSERT(!reg1.isNull());
|
||||
base::PtrWrapper<String> reg3(std::move(reg1));
|
||||
OATPP_ASSERT(reg1.isNull());
|
||||
base::PtrWrapper<String> reg4 = String::createShared(100) + "Leonid";
|
||||
}
|
||||
|
||||
{
|
||||
base::PtrWrapper<String> reg1 = String::createShared(100);
|
||||
String::PtrWrapper reg2(reg1);
|
||||
OATPP_ASSERT(!reg1.isNull());
|
||||
String::PtrWrapper reg3(std::move(reg1));
|
||||
OATPP_ASSERT(reg1.isNull());
|
||||
}
|
||||
|
||||
{
|
||||
String::PtrWrapper reg1(String::createShared(100) + "Leonid");
|
||||
StringPtrWrapper reg2(reg1);
|
||||
OATPP_ASSERT(!reg1.isNull());
|
||||
StringPtrWrapper reg3(std::move(reg1));
|
||||
OATPP_ASSERT(reg1.isNull());
|
||||
StringPtrWrapper reg4 = String::createShared(100);
|
||||
}
|
||||
|
||||
{
|
||||
StringPtrWrapper reg1 = String::createShared(100);
|
||||
String::PtrWrapper reg2(reg1);
|
||||
OATPP_ASSERT(!reg1.isNull());
|
||||
String::PtrWrapper reg3(std::move(reg1));
|
||||
OATPP_ASSERT(reg1.isNull());
|
||||
}
|
||||
|
||||
{
|
||||
base::PtrWrapper<String> reg1 = String::createShared(100);
|
||||
StringPtrWrapper reg2(reg1);
|
||||
OATPP_ASSERT(!reg1.isNull());
|
||||
StringPtrWrapper reg3(std::move(reg1));
|
||||
OATPP_ASSERT(reg1.isNull());
|
||||
}
|
||||
|
||||
{
|
||||
StringPtrWrapper reg1 = String::createShared(100);
|
||||
base::PtrWrapper<String> reg2(reg1);
|
||||
OATPP_ASSERT(!reg1.isNull());
|
||||
base::PtrWrapper<String> reg3(std::move(reg1));
|
||||
OATPP_ASSERT(reg1.isNull());
|
||||
}
|
||||
|
||||
|
||||
//checkPtrWrapper<PolymorphicPtrWrapper<BaseClass>, PolymorphicPtrWrapper<ChildClass>, BaseClass, ChildClass>();
|
||||
|
||||
/*
|
||||
{
|
||||
PtrWrapper<BaseClass> reg1(new BaseClass);
|
||||
PtrWrapper<BaseClass> reg2(reg1);
|
||||
OATPP_ASSERT(!reg1.isNull());
|
||||
PtrWrapper<BaseClass> reg3(std::move(reg1));
|
||||
OATPP_ASSERT(reg1.isNull());
|
||||
PtrWrapper<BaseClass> reg4(BaseClass::create1<PtrWrapper<BaseClass>>());
|
||||
PtrWrapper<BaseClass> reg5(BaseClass::create2<PtrWrapper<BaseClass>>());
|
||||
}
|
||||
|
||||
{
|
||||
PtrWrapper<BaseClass> reg1 = new BaseClass;
|
||||
PtrWrapper<BaseClass> reg2 = reg1;
|
||||
OATPP_ASSERT(!reg1.isNull());
|
||||
PtrWrapper<BaseClass> reg3 = std::move(reg1);
|
||||
OATPP_ASSERT(reg1.isNull());
|
||||
PtrWrapper<BaseClass> reg4 = BaseClass::create1<PtrWrapper<BaseClass>>();
|
||||
PtrWrapper<BaseClass> reg5 = BaseClass::create2<PtrWrapper<BaseClass>>();
|
||||
}
|
||||
|
||||
{
|
||||
PtrWrapper<BaseClass> reg1 = new BaseClass;
|
||||
PtrWrapper<BaseClass> reg2;
|
||||
reg2 = reg1;
|
||||
OATPP_ASSERT(!reg1.isNull());
|
||||
PtrWrapper<BaseClass> reg3;
|
||||
reg3 = std::move(reg1);
|
||||
OATPP_ASSERT(reg1.isNull());
|
||||
PtrWrapper<BaseClass> reg4;
|
||||
reg4 = BaseClass::create1<PtrWrapper<BaseClass>>();
|
||||
PtrWrapper<BaseClass> reg5;
|
||||
reg5 = BaseClass::create2<PtrWrapper<BaseClass>>();
|
||||
}
|
||||
|
||||
//---
|
||||
|
||||
{
|
||||
PtrWrapper<ChildClass> reg1(new ChildClass);
|
||||
PtrWrapper<BaseClass> reg2(reg1);
|
||||
OATPP_ASSERT(!reg1.isNull());
|
||||
PtrWrapper<BaseClass> reg3(std::move(reg1));
|
||||
OATPP_ASSERT(!reg1.isNull());
|
||||
PtrWrapper<BaseClass> reg4(ChildClass::create1<PtrWrapper<ChildClass>>());
|
||||
PtrWrapper<BaseClass> reg5(ChildClass::create2<PtrWrapper<ChildClass>>());
|
||||
}
|
||||
|
||||
{
|
||||
PtrWrapper<ChildClass> reg1 = new ChildClass;
|
||||
PtrWrapper<BaseClass> reg2 = reg1;
|
||||
OATPP_ASSERT(!reg1.isNull());
|
||||
PtrWrapper<BaseClass> reg3 = std::move(reg1);
|
||||
OATPP_ASSERT(!reg1.isNull());
|
||||
PtrWrapper<BaseClass> reg4 = ChildClass::create1<PtrWrapper<ChildClass>>();
|
||||
PtrWrapper<BaseClass> reg5 = ChildClass::create2<PtrWrapper<ChildClass>>();
|
||||
}
|
||||
|
||||
{
|
||||
PtrWrapper<ChildClass> reg1 = new ChildClass;
|
||||
PtrWrapper<BaseClass> reg2;
|
||||
reg2 = reg1;
|
||||
OATPP_ASSERT(!reg1.isNull());
|
||||
PtrWrapper<BaseClass> reg3;
|
||||
reg3 = std::move(reg1);
|
||||
OATPP_ASSERT(!reg1.isNull());
|
||||
PtrWrapper<BaseClass> reg4;
|
||||
reg4 = ChildClass::create1<PtrWrapper<ChildClass>>();
|
||||
PtrWrapper<BaseClass> reg5;
|
||||
reg5 = ChildClass::create2<PtrWrapper<ChildClass>>();
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
}}}
|
@ -25,11 +25,11 @@
|
||||
#ifndef oatpp_utils_ConversionUtils_hpp
|
||||
#define oatpp_utils_ConversionUtils_hpp
|
||||
|
||||
#include "../base/String.hpp"
|
||||
#include "oatpp/core/base/String.hpp"
|
||||
|
||||
#include "../base/PtrWrapper.hpp"
|
||||
#include "../base/Controllable.hpp"
|
||||
#include "../base/Environment.hpp"
|
||||
#include "oatpp/core/base/PtrWrapper.hpp"
|
||||
#include "oatpp/core/base/Controllable.hpp"
|
||||
#include "oatpp/core/base/Environment.hpp"
|
||||
|
||||
#include <string>
|
||||
|
@ -25,10 +25,10 @@
|
||||
#ifndef oatpp_encoding_Hex_hpp
|
||||
#define oatpp_encoding_Hex_hpp
|
||||
|
||||
#include "../../../oatpp/core/src/data/stream/Stream.hpp"
|
||||
#include "oatpp/core/data/stream/Stream.hpp"
|
||||
|
||||
#include "../../../oatpp/core/src/base/PtrWrapper.hpp"
|
||||
#include "../../../oatpp/core/src/base/Environment.hpp"
|
||||
#include "oatpp/core/base/PtrWrapper.hpp"
|
||||
#include "oatpp/core/base/Environment.hpp"
|
||||
|
||||
namespace oatpp { namespace encoding {
|
||||
|
@ -25,7 +25,7 @@
|
||||
#ifndef oatpp_encoding_Unicode_hpp
|
||||
#define oatpp_encoding_Unicode_hpp
|
||||
|
||||
#include "../../../oatpp/core/src/base/Environment.hpp"
|
||||
#include "oatpp/core/base/Environment.hpp"
|
||||
|
||||
namespace oatpp { namespace encoding {
|
||||
|
@ -40,23 +40,25 @@ Connection::~Connection(){
|
||||
}
|
||||
|
||||
Connection::Library::v_size Connection::write(const void *buff, Library::v_size count){
|
||||
return Library::handle_write(m_handle, buff, count);
|
||||
auto result = Library::handle_write(m_handle, buff, count);
|
||||
if(result < 0) {
|
||||
auto e = errno;
|
||||
if(e == EAGAIN || e == EWOULDBLOCK){
|
||||
return ERROR_TRY_AGAIN; // For async io. In case socket is non_blocking
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Connection::Library::v_size Connection::read(void *buff, Library::v_size count){
|
||||
return Library::handle_read(m_handle, buff, count);
|
||||
}
|
||||
|
||||
v_int32 Connection::shutdown(){
|
||||
return ::shutdown(m_handle, SHUT_RDWR);
|
||||
}
|
||||
|
||||
v_int32 Connection::shutdownRead(){
|
||||
return ::shutdown(m_handle, SHUT_RD);
|
||||
}
|
||||
|
||||
v_int32 Connection::shutdownWrite(){
|
||||
return ::shutdown(m_handle, SHUT_WR);
|
||||
auto result = Library::handle_read(m_handle, buff, count);
|
||||
if(result < 0) {
|
||||
auto e = errno;
|
||||
if(e == EAGAIN || e == EWOULDBLOCK){
|
||||
return ERROR_TRY_AGAIN; // For async io. In case socket is non_blocking
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void Connection::close(){
|
@ -25,15 +25,8 @@
|
||||
#ifndef oatpp_network_Connection_hpp
|
||||
#define oatpp_network_Connection_hpp
|
||||
|
||||
#include "../../../oatpp/core/src/base/memory/ObjectPool.hpp"
|
||||
|
||||
#include "../../../oatpp/core/src/data/stream/Stream.hpp"
|
||||
|
||||
#include "../../../oatpp/core/src/base/Controllable.hpp"
|
||||
#include "../../../oatpp/core/src/base/PtrWrapper.hpp"
|
||||
#include "../../../oatpp/core/src/base/Environment.hpp"
|
||||
|
||||
#include "../../../oatpp/core/src/os/io/Library.hpp"
|
||||
#include "oatpp/core/base/memory/ObjectPool.hpp"
|
||||
#include "oatpp/core/data/stream/Stream.hpp"
|
||||
|
||||
namespace oatpp { namespace network {
|
||||
|
||||
@ -58,10 +51,6 @@ public:
|
||||
Library::v_size write(const void *buff, Library::v_size count) override;
|
||||
Library::v_size read(void *buff, Library::v_size count) override;
|
||||
|
||||
v_int32 shutdown();
|
||||
v_int32 shutdownRead();
|
||||
v_int32 shutdownWrite();
|
||||
|
||||
void close();
|
||||
|
||||
Library::v_handle getHandle(){
|
@ -25,7 +25,7 @@
|
||||
#ifndef oatpp_netword_ConnectionsProvider_hpp
|
||||
#define oatpp_netword_ConnectionsProvider_hpp
|
||||
|
||||
#include "../../../oatpp/core/src/data/stream/Stream.hpp"
|
||||
#include "oatpp/core/data/stream/Stream.hpp"
|
||||
|
||||
namespace oatpp { namespace network {
|
||||
|
@ -24,10 +24,10 @@
|
||||
|
||||
#include "./SimpleTCPConnectionProvider.hpp"
|
||||
|
||||
#include "../Connection.hpp"
|
||||
#include "oatpp/network/Connection.hpp"
|
||||
#include "oatpp/core/data/stream/ChunkedBuffer.hpp"
|
||||
|
||||
#include "../../../../oatpp/core/src/data/stream/ChunkedBuffer.hpp"
|
||||
#include "../../../../oatpp/core/test/Checker.hpp"
|
||||
#include "oatpp/test/Checker.hpp"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <netdb.h>
|
@ -25,10 +25,10 @@
|
||||
#ifndef oatpp_netword_client_SimpleTCPConnectionProvider_hpp
|
||||
#define oatpp_netword_client_SimpleTCPConnectionProvider_hpp
|
||||
|
||||
#include "../ConnectionProvider.hpp"
|
||||
#include "ConnectionProvider.hpp"
|
||||
|
||||
#include "../../../../oatpp/core/src/data/stream/Stream.hpp"
|
||||
#include "../../../../oatpp/core/src/base/String.hpp"
|
||||
#include "oatpp/core/data/stream/Stream.hpp"
|
||||
#include "oatpp/core/base/String.hpp"
|
||||
|
||||
namespace oatpp { namespace network { namespace client {
|
||||
|
@ -25,8 +25,8 @@
|
||||
#ifndef network_server_ConnectionHandler_hpp
|
||||
#define network_server_ConnectionHandler_hpp
|
||||
|
||||
#include "../../../../oatpp/core/src/data/stream/Stream.hpp"
|
||||
#include "../../../../oatpp/core/src/base/PtrWrapper.hpp"
|
||||
#include "oatpp/core/data/stream/Stream.hpp"
|
||||
#include "oatpp/core/base/PtrWrapper.hpp"
|
||||
|
||||
namespace oatpp { namespace network { namespace server {
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include "Server.hpp"
|
||||
|
||||
#include "../../../../oatpp/core/test/Checker.hpp"
|
||||
#include "oatpp/test/Checker.hpp"
|
||||
|
||||
#include <thread>
|
||||
#include <chrono>
|
@ -25,19 +25,18 @@
|
||||
#ifndef network_server_Server_hpp
|
||||
#define network_server_Server_hpp
|
||||
|
||||
#include "../ConnectionProvider.hpp"
|
||||
|
||||
#include "./ConnectionHandler.hpp"
|
||||
|
||||
#include "../../../../oatpp/core/src/concurrency/Runnable.hpp"
|
||||
#include "oatpp/network/ConnectionProvider.hpp"
|
||||
|
||||
#include "../../../../oatpp/core/src/base/String.hpp"
|
||||
#include "oatpp/core/concurrency/Runnable.hpp"
|
||||
|
||||
#include "../../../../oatpp/core/src/os/io/Library.hpp"
|
||||
#include "oatpp/core/base/String.hpp"
|
||||
#include "oatpp/core/base/PtrWrapper.hpp"
|
||||
#include "oatpp/core/base/Controllable.hpp"
|
||||
#include "oatpp/core/base/Environment.hpp"
|
||||
|
||||
#include "../../../../oatpp/core/src/base/PtrWrapper.hpp"
|
||||
#include "../../../../oatpp/core/src/base/Controllable.hpp"
|
||||
#include "../../../../oatpp/core/src/base/Environment.hpp"
|
||||
#include "oatpp/core/os/io/Library.hpp"
|
||||
|
||||
#include <atomic>
|
||||
|
@ -24,11 +24,10 @@
|
||||
|
||||
#include "./SimpleTCPConnectionProvider.hpp"
|
||||
|
||||
#include "../AsyncConnection.hpp"
|
||||
#include "../Connection.hpp"
|
||||
#include "oatpp/network/Connection.hpp"
|
||||
|
||||
#include "../../../../oatpp/core/src/utils/ConversionUtils.hpp"
|
||||
#include "../../../../oatpp/core/test/Checker.hpp"
|
||||
#include "oatpp/core/utils/ConversionUtils.hpp"
|
||||
#include "oatpp/test/Checker.hpp"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <netdb.h>
|
||||
@ -105,11 +104,7 @@ std::shared_ptr<oatpp::data::stream::IOStream> SimpleTCPConnectionProvider::getC
|
||||
|
||||
fcntl(handle, F_SETFL, flags);
|
||||
|
||||
if(m_nonBlocking) {
|
||||
return AsyncConnection::createShared(handle);
|
||||
} else {
|
||||
return Connection::createShared(handle);
|
||||
}
|
||||
return Connection::createShared(handle);
|
||||
|
||||
}
|
||||
|
@ -25,11 +25,11 @@
|
||||
#ifndef oatpp_netword_server_SimpleTCPConnectionProvider_hpp
|
||||
#define oatpp_netword_server_SimpleTCPConnectionProvider_hpp
|
||||
|
||||
#include "../ConnectionProvider.hpp"
|
||||
#include "oatpp/network/ConnectionProvider.hpp"
|
||||
|
||||
#include "../../../../oatpp/core/src/data/stream/Stream.hpp"
|
||||
#include "../../../../oatpp/core/src/base/String.hpp"
|
||||
#include "../../../../oatpp/core/src/os/io/Library.hpp"
|
||||
#include "oatpp/core/data/stream/Stream.hpp"
|
||||
#include "oatpp/core/base/String.hpp"
|
||||
#include "oatpp/core/os/io/Library.hpp"
|
||||
|
||||
namespace oatpp { namespace network { namespace server {
|
||||
|
@ -1,53 +0,0 @@
|
||||
//
|
||||
// AsyncConnection.cpp
|
||||
// crud
|
||||
//
|
||||
// Created by Leonid on 3/16/18.
|
||||
// Copyright © 2018 oatpp. All rights reserved.
|
||||
//
|
||||
|
||||
#include "AsyncConnection.hpp"
|
||||
|
||||
namespace oatpp { namespace network {
|
||||
|
||||
AsyncConnection::AsyncConnection(Library::v_handle handle)
|
||||
: m_handle(handle)
|
||||
{}
|
||||
|
||||
AsyncConnection::~AsyncConnection(){
|
||||
close();
|
||||
}
|
||||
|
||||
AsyncConnection::Library::v_size AsyncConnection::write(const void *buff, Library::v_size count){
|
||||
auto result = Library::handle_write(m_handle, buff, count); // Socket should be non blocking!!!
|
||||
|
||||
if(result < 0) {
|
||||
auto e = errno;
|
||||
//OATPP_LOGD("write", "errno=%d", e);
|
||||
if(e == EAGAIN || e == EWOULDBLOCK){
|
||||
return ERROR_TRY_AGAIN;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
AsyncConnection::Library::v_size AsyncConnection::read(void *buff, Library::v_size count){
|
||||
//OATPP_LOGD("AsyncConnection", "read. handler=%d", m_handle);
|
||||
auto result = Library::handle_read(m_handle, buff, count); // Socket should be non blocking!!!
|
||||
if(result < 0) {
|
||||
auto e = errno;
|
||||
//OATPP_LOGD("read", "errno=%d", e);
|
||||
if(e == EAGAIN || e == EWOULDBLOCK){
|
||||
return ERROR_TRY_AGAIN;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void AsyncConnection::close(){
|
||||
//OATPP_LOGD("Connection", "close()");
|
||||
Library::handle_close(m_handle);
|
||||
}
|
||||
|
||||
}}
|
@ -1,49 +0,0 @@
|
||||
//
|
||||
// AsyncConnection.hpp
|
||||
// crud
|
||||
//
|
||||
// Created by Leonid on 3/16/18.
|
||||
// Copyright © 2018 oatpp. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef oatpp_network_AsyncConnection_hpp
|
||||
#define oatpp_network_AsyncConnection_hpp
|
||||
|
||||
#include "../../../oatpp/core/src/base/memory/ObjectPool.hpp"
|
||||
#include "../../../oatpp/core/src/data/stream/Stream.hpp"
|
||||
#include "../../../oatpp/core/src/os/io/Library.hpp"
|
||||
|
||||
namespace oatpp { namespace network {
|
||||
|
||||
class AsyncConnection : public oatpp::base::Controllable, public oatpp::data::stream::IOStream {
|
||||
public:
|
||||
typedef oatpp::os::io::Library Library;
|
||||
public:
|
||||
OBJECT_POOL(AsyncConnection_Pool, AsyncConnection, 32);
|
||||
SHARED_OBJECT_POOL(Shared_AsyncConnection_Pool, AsyncConnection, 32);
|
||||
private:
|
||||
Library::v_handle m_handle;
|
||||
public:
|
||||
AsyncConnection(Library::v_handle handle);
|
||||
public:
|
||||
|
||||
static std::shared_ptr<AsyncConnection> createShared(Library::v_handle handle){
|
||||
return Shared_AsyncConnection_Pool::allocateShared(handle);
|
||||
}
|
||||
|
||||
~AsyncConnection();
|
||||
|
||||
Library::v_size write(const void *buff, Library::v_size count) override;
|
||||
Library::v_size read(void *buff, Library::v_size count) override;
|
||||
|
||||
void close();
|
||||
|
||||
Library::v_handle getHandle(){
|
||||
return m_handle;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif /* oatpp_network_AsyncConnection_hpp */
|
@ -1,17 +0,0 @@
|
||||
//
|
||||
// IORequest.cpp
|
||||
// crud
|
||||
//
|
||||
// Created by Leonid on 3/15/18.
|
||||
// Copyright © 2018 oatpp. All rights reserved.
|
||||
//
|
||||
|
||||
#include "IORequest.hpp"
|
||||
|
||||
namespace oatpp { namespace network { namespace io {
|
||||
|
||||
const v_int32 IORequest::TYPE_DONE = 0;
|
||||
const v_int32 IORequest::TYPE_READ = 1;
|
||||
const v_int32 IORequest::TYPE_WRITE = 2;
|
||||
|
||||
}}}
|
@ -1,46 +0,0 @@
|
||||
//
|
||||
// IORequest.hpp
|
||||
// crud
|
||||
//
|
||||
// Created by Leonid on 3/15/18.
|
||||
// Copyright © 2018 oatpp. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef oatpp_web_server_io_IORequest_hpp
|
||||
#define oatpp_web_server_io_IORequest_hpp
|
||||
|
||||
#include "../../../core/src/data/stream/Stream.hpp"
|
||||
|
||||
#include <atomic>
|
||||
|
||||
namespace oatpp { namespace network { namespace io {
|
||||
|
||||
class IORequest {
|
||||
public:
|
||||
static const v_int32 TYPE_DONE;
|
||||
static const v_int32 TYPE_READ;
|
||||
static const v_int32 TYPE_WRITE;
|
||||
public:
|
||||
|
||||
IORequest(const std::shared_ptr<oatpp::data::stream::IOStream>& pStream,
|
||||
void* pData,
|
||||
os::io::Library::v_size pSize,
|
||||
v_int32 pType)
|
||||
: stream(pStream)
|
||||
, data(pData)
|
||||
, size(pSize)
|
||||
, type(pType)
|
||||
, actualSize(0)
|
||||
{}
|
||||
|
||||
const std::shared_ptr<oatpp::data::stream::IOStream>& stream;
|
||||
void* data;
|
||||
const os::io::Library::v_size size;
|
||||
v_int32 type;
|
||||
os::io::Library::v_size actualSize;
|
||||
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
#endif /* oatpp_web_server_io_IORequest_hpp */
|
@ -1,9 +0,0 @@
|
||||
//
|
||||
// Queue.cpp
|
||||
// crud
|
||||
//
|
||||
// Created by Leonid on 3/15/18.
|
||||
// Copyright © 2018 oatpp. All rights reserved.
|
||||
//
|
||||
|
||||
#include "Queue.hpp"
|
@ -1,81 +0,0 @@
|
||||
//
|
||||
// Queue.hpp
|
||||
// crud
|
||||
//
|
||||
// Created by Leonid on 3/15/18.
|
||||
// Copyright © 2018 oatpp. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef oatpp_web_server_io_Queue_hpp
|
||||
#define oatpp_web_server_io_Queue_hpp
|
||||
|
||||
#include "./IORequest.hpp"
|
||||
|
||||
#include "../../../core/src/base/memory/ObjectPool.hpp"
|
||||
#include "../../../core/src/concurrency/SpinLock.hpp"
|
||||
|
||||
namespace oatpp { namespace network { namespace io {
|
||||
|
||||
class Queue {
|
||||
public:
|
||||
static Queue& getInstance(){
|
||||
static Queue queue;
|
||||
return queue;
|
||||
}
|
||||
public:
|
||||
class Entry {
|
||||
public:
|
||||
OBJECT_POOL_THREAD_LOCAL(IO_Queue_Entry_Pool, Entry, 32)
|
||||
public:
|
||||
Entry(IORequest& pRequest, Entry* pNext)
|
||||
: request(pRequest)
|
||||
, next(pNext)
|
||||
{}
|
||||
IORequest& request;
|
||||
Entry* next;
|
||||
};
|
||||
private:
|
||||
oatpp::concurrency::SpinLock::Atom m_atom;
|
||||
Entry* m_first;
|
||||
Entry* m_last;
|
||||
public:
|
||||
|
||||
Queue()
|
||||
: m_atom(false)
|
||||
, m_first(nullptr)
|
||||
, m_last(nullptr)
|
||||
{}
|
||||
|
||||
Entry* popFront() {
|
||||
oatpp::concurrency::SpinLock lock(m_atom);
|
||||
auto result = m_first;
|
||||
if(m_first != nullptr) {
|
||||
m_first = m_first->next;
|
||||
if(m_first == nullptr) {
|
||||
m_last = nullptr;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void pushBack(IORequest& request) {
|
||||
pushBack(new Entry(request, nullptr));
|
||||
}
|
||||
|
||||
void pushBack(Entry* entry) {
|
||||
oatpp::concurrency::SpinLock lock(m_atom);
|
||||
entry->next = nullptr;
|
||||
if(m_last != nullptr) {
|
||||
m_last->next = entry;
|
||||
m_last = entry;
|
||||
} else {
|
||||
m_first = entry;
|
||||
m_last = entry;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
#endif /* oatpp_web_server_io_Queue_hpp */
|
@ -24,8 +24,8 @@
|
||||
|
||||
#include "Utils.hpp"
|
||||
|
||||
#include "../../../../oatpp/encoding/src/Unicode.hpp"
|
||||
#include "../../../../oatpp/encoding/src/Hex.hpp"
|
||||
#include "oatpp/encoding/Unicode.hpp"
|
||||
#include "oatpp/encoding/Hex.hpp"
|
||||
|
||||
namespace oatpp { namespace parser { namespace json{
|
||||
|
@ -25,8 +25,8 @@
|
||||
#ifndef oatpp_parser_json_Utils_hpp
|
||||
#define oatpp_parser_json_Utils_hpp
|
||||
|
||||
#include "../../../../oatpp/core/src/parser/ParsingCaret.hpp"
|
||||
#include "../../../../oatpp/core/src/base/String.hpp"
|
||||
#include "oatpp/core/parser/ParsingCaret.hpp"
|
||||
#include "oatpp/core/base/String.hpp"
|
||||
|
||||
#include <string>
|
||||
|
@ -24,8 +24,8 @@
|
||||
|
||||
#include "./Deserializer.hpp"
|
||||
|
||||
#include "../Utils.hpp"
|
||||
#include "../../../../../oatpp/core/src/utils/ConversionUtils.hpp"
|
||||
#include "oatpp/parser/json/Utils.hpp"
|
||||
#include "oatpp/core/utils/ConversionUtils.hpp"
|
||||
|
||||
namespace oatpp { namespace parser { namespace json { namespace mapping {
|
||||
|
@ -25,15 +25,15 @@
|
||||
#ifndef oatpp_parser_json_mapping_Deserializer_hpp
|
||||
#define oatpp_parser_json_mapping_Deserializer_hpp
|
||||
|
||||
#include "../../../../../oatpp/core/src/data/mapping/type/List.hpp"
|
||||
#include "../../../../../oatpp/core/src/data/mapping/type/Object.hpp"
|
||||
#include "../../../../../oatpp/core/src/data/mapping/type/Primitive.hpp"
|
||||
#include "../../../../../oatpp/core/src/data/mapping/type/Type.hpp"
|
||||
#include "oatpp/core/data/mapping/type/List.hpp"
|
||||
#include "oatpp/core/data/mapping/type/Object.hpp"
|
||||
#include "oatpp/core/data/mapping/type/Primitive.hpp"
|
||||
#include "oatpp/core/data/mapping/type/Type.hpp"
|
||||
|
||||
#include "../../../../../oatpp/core/src/parser/ParsingCaret.hpp"
|
||||
#include "oatpp/core/parser/ParsingCaret.hpp"
|
||||
|
||||
#include "../../../../../oatpp/core/src/collection/LinkedList.hpp"
|
||||
#include "../../../../../oatpp/core/src/base/String.hpp"
|
||||
#include "oatpp/core/collection/LinkedList.hpp"
|
||||
#include "oatpp/core/base/String.hpp"
|
||||
|
||||
namespace oatpp { namespace parser { namespace json { namespace mapping {
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "./Serializer.hpp"
|
||||
#include "./Deserializer.hpp"
|
||||
|
||||
#include "../../../../../oatpp/core/src/data/mapping/ObjectMapper.hpp"
|
||||
#include "oatpp/core/data/mapping/ObjectMapper.hpp"
|
||||
|
||||
namespace oatpp { namespace parser { namespace json { namespace mapping {
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include "./Serializer.hpp"
|
||||
|
||||
#include "../Utils.hpp"
|
||||
#include "oatpp/parser/json/Utils.hpp"
|
||||
|
||||
namespace oatpp { namespace parser { namespace json { namespace mapping {
|
||||
|
@ -25,16 +25,16 @@
|
||||
#ifndef oatpp_parser_json_mapping_Serializer_hpp
|
||||
#define oatpp_parser_json_mapping_Serializer_hpp
|
||||
|
||||
#include "../../../../../oatpp/core/src/data/mapping/type/List.hpp"
|
||||
#include "../../../../../oatpp/core/src/data/mapping/type/Object.hpp"
|
||||
#include "../../../../../oatpp/core/src/data/mapping/type/Primitive.hpp"
|
||||
#include "../../../../../oatpp/core/src/data/mapping/type/Type.hpp"
|
||||
#include "../../../../../oatpp/core/src/data/stream/ChunkedBuffer.hpp"
|
||||
#include "oatpp/core/data/mapping/type/List.hpp"
|
||||
#include "oatpp/core/data/mapping/type/Object.hpp"
|
||||
#include "oatpp/core/data/mapping/type/Primitive.hpp"
|
||||
#include "oatpp/core/data/mapping/type/Type.hpp"
|
||||
#include "oatpp/core/data/stream/ChunkedBuffer.hpp"
|
||||
|
||||
#include "../../../../../oatpp/core/src/parser/ParsingCaret.hpp"
|
||||
#include "oatpp/core/parser/ParsingCaret.hpp"
|
||||
|
||||
#include "../../../../../oatpp/core/src/collection/LinkedList.hpp"
|
||||
#include "../../../../../oatpp/core/src/base/String.hpp"
|
||||
#include "oatpp/core/collection/LinkedList.hpp"
|
||||
#include "oatpp/core/base/String.hpp"
|
||||
|
||||
namespace oatpp { namespace parser { namespace json { namespace mapping {
|
||||
|
@ -25,7 +25,7 @@
|
||||
#ifndef oatpp_test_Checker_hpp
|
||||
#define oatpp_test_Checker_hpp
|
||||
|
||||
#include "../src/base/Environment.hpp"
|
||||
#include "oatpp/core/base/Environment.hpp"
|
||||
|
||||
namespace oatpp { namespace test {
|
||||
|
@ -24,8 +24,8 @@
|
||||
|
||||
#include "UnitTest.hpp"
|
||||
|
||||
#include "../src/base/memory/MemoryPool.hpp" // delete
|
||||
#include "../src/base/Controllable.hpp" // delete
|
||||
#include "oatpp/core/base/memory/MemoryPool.hpp" // delete
|
||||
#include "oatpp/core/base/Controllable.hpp" // delete
|
||||
|
||||
#include <chrono>
|
||||
|
@ -22,10 +22,10 @@
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef __testbase__UnitTest__
|
||||
#define __testbase__UnitTest__
|
||||
#ifndef oatpp_test_UnitTest_hpp
|
||||
#define oatpp_test_UnitTest_hpp
|
||||
|
||||
#include "../src/base/Environment.hpp"
|
||||
#include "oatpp/core/base/Environment.hpp"
|
||||
|
||||
namespace oatpp { namespace test {
|
||||
|
||||
@ -63,4 +63,4 @@ public:
|
||||
|
||||
}}
|
||||
|
||||
#endif /* defined(__testbase__UnitTest__) */
|
||||
#endif /* oatpp_test_UnitTest_hpp */
|
148
test/core/base/RegRuleTest.cpp
Normal file
148
test/core/base/RegRuleTest.cpp
Normal file
@ -0,0 +1,148 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* 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 "RegRuleTest.hpp"
|
||||
|
||||
#include "oatpp/core/data/mapping/type/Primitive.hpp"
|
||||
#include "oatpp/core/base/String.hpp"
|
||||
|
||||
namespace oatpp { namespace test { namespace base {
|
||||
|
||||
namespace {
|
||||
|
||||
class BaseClass : public oatpp::base::Controllable {
|
||||
public:
|
||||
|
||||
template<class T>
|
||||
static T create1() {
|
||||
return new BaseClass();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
static T create2() {
|
||||
return T(new BaseClass());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class ChildClass : public BaseClass {
|
||||
public:
|
||||
|
||||
template<class T>
|
||||
static T create1() {
|
||||
return new ChildClass();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
static T create2() {
|
||||
return T(new ChildClass());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
typedef oatpp::base::String String;
|
||||
|
||||
template<typename T>
|
||||
using PtrWrapper = oatpp::base::PtrWrapper<T>;
|
||||
|
||||
template<typename T>
|
||||
using PolymorphicWrapper = oatpp::data::mapping::type::PolymorphicWrapper<T>;
|
||||
|
||||
template<typename T>
|
||||
using TypePtrWrapper = oatpp::data::mapping::type::PtrWrapper<T, oatpp::data::mapping::type::__class::Void>;
|
||||
|
||||
typedef oatpp::data::mapping::type::StringPtrWrapper StringPtrWrapper;
|
||||
typedef oatpp::data::mapping::type::Int32 Int32;
|
||||
typedef oatpp::data::mapping::type::Int64 Int64;
|
||||
typedef oatpp::data::mapping::type::Float32 Float32;
|
||||
typedef oatpp::data::mapping::type::Float64 Float64;
|
||||
typedef oatpp::data::mapping::type::Boolean Boolean;
|
||||
|
||||
}
|
||||
|
||||
bool RegRuleTest::onRun() {
|
||||
|
||||
{
|
||||
String::PtrWrapper reg1("");
|
||||
String::PtrWrapper reg2(reg1);
|
||||
OATPP_ASSERT(!reg1.isNull());
|
||||
String::PtrWrapper reg3(std::move(reg1));
|
||||
OATPP_ASSERT(reg1.isNull());
|
||||
String::PtrWrapper reg4 = String::createShared(100);
|
||||
}
|
||||
|
||||
{
|
||||
String::PtrWrapper reg1("");
|
||||
base::PtrWrapper<String> reg2(reg1);
|
||||
OATPP_ASSERT(!reg1.isNull());
|
||||
base::PtrWrapper<String> reg3(std::move(reg1));
|
||||
OATPP_ASSERT(reg1.isNull());
|
||||
base::PtrWrapper<String> reg4 = String::createShared(100) + "Leonid";
|
||||
}
|
||||
|
||||
{
|
||||
base::PtrWrapper<String> reg1 = String::createShared(100);
|
||||
String::PtrWrapper reg2(reg1);
|
||||
OATPP_ASSERT(!reg1.isNull());
|
||||
String::PtrWrapper reg3(std::move(reg1));
|
||||
OATPP_ASSERT(reg1.isNull());
|
||||
}
|
||||
|
||||
{
|
||||
String::PtrWrapper reg1(String::createShared(100) + "Leonid");
|
||||
StringPtrWrapper reg2(reg1);
|
||||
OATPP_ASSERT(!reg1.isNull());
|
||||
StringPtrWrapper reg3(std::move(reg1));
|
||||
OATPP_ASSERT(reg1.isNull());
|
||||
StringPtrWrapper reg4 = String::createShared(100);
|
||||
}
|
||||
|
||||
{
|
||||
StringPtrWrapper reg1 = String::createShared(100);
|
||||
String::PtrWrapper reg2(reg1);
|
||||
OATPP_ASSERT(!reg1.isNull());
|
||||
String::PtrWrapper reg3(std::move(reg1));
|
||||
OATPP_ASSERT(reg1.isNull());
|
||||
}
|
||||
|
||||
{
|
||||
base::PtrWrapper<String> reg1 = String::createShared(100);
|
||||
StringPtrWrapper reg2(reg1);
|
||||
OATPP_ASSERT(!reg1.isNull());
|
||||
StringPtrWrapper reg3(std::move(reg1));
|
||||
OATPP_ASSERT(reg1.isNull());
|
||||
}
|
||||
|
||||
{
|
||||
StringPtrWrapper reg1 = String::createShared(100);
|
||||
base::PtrWrapper<String> reg2(reg1);
|
||||
OATPP_ASSERT(!reg1.isNull());
|
||||
base::PtrWrapper<String> reg3(std::move(reg1));
|
||||
OATPP_ASSERT(reg1.isNull());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}}}
|
@ -25,7 +25,7 @@
|
||||
#ifndef oatpp_test_base_RegRuleTest_hpp
|
||||
#define oatpp_test_base_RegRuleTest_hpp
|
||||
|
||||
#include "../UnitTest.hpp"
|
||||
#include "UnitTest.hpp"
|
||||
|
||||
namespace oatpp { namespace test { namespace base {
|
||||
|
@ -24,9 +24,9 @@
|
||||
|
||||
#include "LinkedListTest.hpp"
|
||||
|
||||
#include "../../../src/base/String.hpp"
|
||||
#include "../../../src/collection/LinkedList.hpp"
|
||||
#include "../../Checker.hpp"
|
||||
#include "oatpp/core/base/String.hpp"
|
||||
#include "oatpp/core/collection/LinkedList.hpp"
|
||||
#include "oatpp/test/Checker.hpp"
|
||||
#include <list>
|
||||
|
||||
namespace oatpp { namespace test { namespace collection {
|
@ -25,7 +25,7 @@
|
||||
#ifndef oatpp_test_base_collection_LinkedListTest_hpp
|
||||
#define oatpp_test_base_collection_LinkedListTest_hpp
|
||||
|
||||
#include "../../UnitTest.hpp"
|
||||
#include "UnitTest.hpp"
|
||||
|
||||
namespace oatpp { namespace test { namespace collection {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user