From eb17e0c257371de6bf27fb6a79812e8093fe1b30 Mon Sep 17 00:00:00 2001 From: lganzzzo Date: Thu, 5 Dec 2019 04:49:53 +0200 Subject: [PATCH] minor code cleanup --- src/CMakeLists.txt | 3 -- src/oatpp/core/collection/FastQueue.cpp | 26 ---------- src/oatpp/core/collection/LinkedList.cpp | 26 ---------- src/oatpp/core/collection/LinkedList.hpp | 46 ++++++++--------- src/oatpp/core/collection/ListMap.cpp | 26 ---------- src/oatpp/network/Connection.cpp | 50 ++++++++++--------- .../client/SimpleTCPConnectionProvider.cpp | 15 +++--- .../server/SimpleTCPConnectionProvider.cpp | 18 +++---- 8 files changed, 66 insertions(+), 144 deletions(-) delete mode 100644 src/oatpp/core/collection/FastQueue.cpp delete mode 100644 src/oatpp/core/collection/LinkedList.cpp delete mode 100644 src/oatpp/core/collection/ListMap.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 64a9dcdb..8f6745eb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -57,11 +57,8 @@ add_library(oatpp oatpp/core/base/memory/MemoryPool.hpp oatpp/core/base/memory/ObjectPool.cpp oatpp/core/base/memory/ObjectPool.hpp - oatpp/core/collection/FastQueue.cpp oatpp/core/collection/FastQueue.hpp - oatpp/core/collection/LinkedList.cpp oatpp/core/collection/LinkedList.hpp - oatpp/core/collection/ListMap.cpp oatpp/core/collection/ListMap.hpp oatpp/core/concurrency/SpinLock.cpp oatpp/core/concurrency/SpinLock.hpp diff --git a/src/oatpp/core/collection/FastQueue.cpp b/src/oatpp/core/collection/FastQueue.cpp deleted file mode 100644 index 151eddaf..00000000 --- a/src/oatpp/core/collection/FastQueue.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/*************************************************************************** - * - * Project _____ __ ____ _ _ - * ( _ ) /__\ (_ _)_| |_ _| |_ - * )(_)( /(__)\ )( (_ _)(_ _) - * (_____)(__)(__)(__) |_| |_| - * - * - * Copyright 2018-present, Leonid Stryzhevskyi - * - * 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 "FastQueue.hpp" - diff --git a/src/oatpp/core/collection/LinkedList.cpp b/src/oatpp/core/collection/LinkedList.cpp deleted file mode 100644 index e0b2a2f9..00000000 --- a/src/oatpp/core/collection/LinkedList.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/*************************************************************************** - * - * Project _____ __ ____ _ _ - * ( _ ) /__\ (_ _)_| |_ _| |_ - * )(_)( /(__)\ )( (_ _)(_ _) - * (_____)(__)(__)(__) |_| |_| - * - * - * Copyright 2018-present, Leonid Stryzhevskyi - * - * 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 "LinkedList.hpp" - diff --git a/src/oatpp/core/collection/LinkedList.hpp b/src/oatpp/core/collection/LinkedList.hpp index 1cbc3486..86df4c87 100644 --- a/src/oatpp/core/collection/LinkedList.hpp +++ b/src/oatpp/core/collection/LinkedList.hpp @@ -85,29 +85,6 @@ private: node->~LinkedListNode(); oatpp::base::memory::MemoryPool::free(node); } - - LinkedListNode* getNode(v_int32 index) const{ - - if(index >= m_count){ - return nullptr; - } - - v_int32 i = 0; - LinkedListNode* curr = m_first; - - while(curr != nullptr){ - - if(i == index){ - return curr; - } - - curr = curr->next; - i++; - } - - return nullptr; - - } public: @@ -218,6 +195,29 @@ public: throw std::runtime_error("[oatpp::collection::LinkedList::get(index)]: index out of bounds"); } + + LinkedListNode* getNode(v_int32 index) const { + + if(index >= m_count){ + return nullptr; + } + + v_int32 i = 0; + LinkedListNode* curr = m_first; + + while(curr != nullptr){ + + if(i == index){ + return curr; + } + + curr = curr->next; + i++; + } + + return nullptr; + + } LinkedListNode* getFirstNode() const { return m_first; diff --git a/src/oatpp/core/collection/ListMap.cpp b/src/oatpp/core/collection/ListMap.cpp deleted file mode 100644 index 681f1308..00000000 --- a/src/oatpp/core/collection/ListMap.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/*************************************************************************** - * - * Project _____ __ ____ _ _ - * ( _ ) /__\ (_ _)_| |_ _| |_ - * )(_)( /(__)\ )( (_ _)(_ _) - * (_____)(__)(__)(__) |_| |_| - * - * - * Copyright 2018-present, Leonid Stryzhevskyi - * - * 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 "ListMap.hpp" - diff --git a/src/oatpp/network/Connection.cpp b/src/oatpp/network/Connection.cpp index af64ffe7..a909a0ad 100644 --- a/src/oatpp/network/Connection.cpp +++ b/src/oatpp/network/Connection.cpp @@ -25,12 +25,13 @@ #include "./Connection.hpp" #if defined(WIN32) || defined(_WIN32) -#include -#include + #include + #include #else -#include -#include + #include + #include #endif + #include #include #include @@ -152,24 +153,25 @@ data::v_io_size Connection::read(void *buff, v_buff_size count){ #if defined(WIN32) || defined(_WIN32) void Connection::setStreamIOMode(oatpp::data::stream::IOMode ioMode) { - u_long flags; + u_long flags; + + switch(ioMode) { + case data::stream::BLOCKING: + flags = 0; + if(NO_ERROR != ioctlsocket(m_handle, FIONBIO, &flags)) { + throw std::runtime_error("[oatpp::network::Connection::setStreamIOMode()]: Error. Can't set stream I/O mode to IOMode::BLOCKING."); + } + m_mode = data::stream::BLOCKING; + break; + case data::stream::NON_BLOCKING: + flags = 1; + if(NO_ERROR != ioctlsocket(m_handle, FIONBIO, &flags)) { + throw std::runtime_error("[oatpp::network::Connection::setStreamIOMode()]: Error. Can't set stream I/O mode to IOMode::NON_BLOCKING."); + } + m_mode = data::stream::NON_BLOCKING; + break; + } - switch(ioMode) { - case data::stream::BLOCKING: - flags = 0; - if(NO_ERROR != ioctlsocket(m_handle, FIONBIO, &flags)) { - throw std::runtime_error("[oatpp::network::Connection::setStreamIOMode()]: Error. Can't set stream I/O mode to IOMode::BLOCKING."); - } - m_mode = data::stream::BLOCKING; - break; - case data::stream::NON_BLOCKING: - flags = 1; - if(NO_ERROR != ioctlsocket(m_handle, FIONBIO, &flags)) { - throw std::runtime_error("[oatpp::network::Connection::setStreamIOMode()]: Error. Can't set stream I/O mode to IOMode::NON_BLOCKING."); - } - m_mode = data::stream::NON_BLOCKING; - break; - } } #else void Connection::setStreamIOMode(oatpp::data::stream::IOMode ioMode) { @@ -201,7 +203,7 @@ void Connection::setStreamIOMode(oatpp::data::stream::IOMode ioMode) { #if defined(WIN32) || defined(_WIN32) oatpp::data::stream::IOMode Connection::getStreamIOMode() { - return m_mode; + return m_mode; } #else oatpp::data::stream::IOMode Connection::getStreamIOMode() { @@ -233,7 +235,7 @@ oatpp::async::Action Connection::suggestOutputStreamAction(data::v_io_size ioRes return oatpp::async::Action::createIORepeatAction(m_handle, oatpp::async::Action::IOEventType::IO_EVENT_WRITE); } - throw std::runtime_error("[oatpp::network::virtual_::Pipe::Reader::suggestInputStreamAction()]: Error. Unable to suggest async action for I/O result."); + throw std::runtime_error("[oatpp::network::Connection::suggestInputStreamAction()]: Error. Unable to suggest async action for I/O result."); } @@ -250,7 +252,7 @@ oatpp::async::Action Connection::suggestInputStreamAction(data::v_io_size ioResu return oatpp::async::Action::createIORepeatAction(m_handle, oatpp::async::Action::IOEventType::IO_EVENT_READ); } - throw std::runtime_error("[oatpp::network::virtual_::Pipe::Reader::suggestInputStreamAction()]: Error. Unable to suggest async action for I/O result."); + throw std::runtime_error("[oatpp::network::Connection::suggestInputStreamAction()]: Error. Unable to suggest async action for I/O result."); } diff --git a/src/oatpp/network/client/SimpleTCPConnectionProvider.cpp b/src/oatpp/network/client/SimpleTCPConnectionProvider.cpp index 1619505e..94651d6f 100644 --- a/src/oatpp/network/client/SimpleTCPConnectionProvider.cpp +++ b/src/oatpp/network/client/SimpleTCPConnectionProvider.cpp @@ -29,15 +29,16 @@ #include "oatpp/core/utils/ConversionUtils.hpp" #include + #if defined(WIN32) || defined(_WIN32) -#include -#include -#include + #include + #include + #include #else -#include -#include -#include -#include + #include + #include + #include + #include #endif namespace oatpp { namespace network { namespace client { diff --git a/src/oatpp/network/server/SimpleTCPConnectionProvider.cpp b/src/oatpp/network/server/SimpleTCPConnectionProvider.cpp index 79c8dd7f..2f52fbf9 100644 --- a/src/oatpp/network/server/SimpleTCPConnectionProvider.cpp +++ b/src/oatpp/network/server/SimpleTCPConnectionProvider.cpp @@ -25,20 +25,20 @@ #include "./SimpleTCPConnectionProvider.hpp" #include "oatpp/network/Connection.hpp" - #include "oatpp/core/utils/ConversionUtils.hpp" #include + #if defined(WIN32) || defined(_WIN32) -#include -#include -#include + #include + #include + #include #else -#include -#include -#include -#include -#include + #include + #include + #include + #include + #include #endif namespace oatpp { namespace network { namespace server {