diff --git a/src/oatpp-test/web/ClientServerTestRunner.hpp b/src/oatpp-test/web/ClientServerTestRunner.hpp index 0e03e8c0..4e2a2774 100644 --- a/src/oatpp-test/web/ClientServerTestRunner.hpp +++ b/src/oatpp-test/web/ClientServerTestRunner.hpp @@ -104,7 +104,7 @@ public: m_connectionProvider->getProperty("port").toString()->c_str(), timeout.count()) - std::function condition = [&runConditionForLambda](){ + std::function condition = [&runConditionForLambda]() noexcept { return runConditionForLambda; }; diff --git a/src/oatpp/async/worker/IOEventWorker_epoll.cpp b/src/oatpp/async/worker/IOEventWorker_epoll.cpp index d70bd07b..b211e9e5 100644 --- a/src/oatpp/async/worker/IOEventWorker_epoll.cpp +++ b/src/oatpp/async/worker/IOEventWorker_epoll.cpp @@ -168,7 +168,7 @@ void IOEventWorker::waitEvents() { "specialization={}", errno, m_inEventsCount, reinterpret_cast(m_foreman), reinterpret_cast(this), - m_specialization) + static_cast(m_specialization)) throw std::runtime_error("[oatpp::async::worker::IOEventWorker::waitEvents()]: Error. Event loop failed."); } @@ -222,7 +222,7 @@ void IOEventWorker::waitEvents() { OATPP_LOGe( "[oatpp::async::worker::IOEventWorker::waitEvents()]", "Error. Call to epoll_ctl failed. operation={}, errno={}. action_code={}, worker_specialization={}", - EPOLL_CTL_DEL, errno, action.getIOEventCode(), m_specialization + EPOLL_CTL_DEL, errno, action.getIOEventCode(), static_cast(m_specialization) ) throw std::runtime_error("[oatpp::async::worker::IOEventWorker::waitEvents()]: Error. Call to epoll_ctl failed."); } @@ -239,7 +239,7 @@ void IOEventWorker::waitEvents() { OATPP_LOGe( "[oatpp::async::worker::IOEventWorker::waitEvents()]", "Error. Call to epoll_ctl failed. operation={}, errno={}. action_code={}, worker_specialization={}", - EPOLL_CTL_DEL, errno, action.getIOEventCode(), m_specialization + EPOLL_CTL_DEL, errno, action.getIOEventCode(), static_cast(m_specialization) ) throw std::runtime_error("[oatpp::async::worker::IOEventWorker::waitEvents()]: Error. Call to epoll_ctl failed."); } diff --git a/src/oatpp/base/Log.cpp b/src/oatpp/base/Log.cpp index bfba8106..673e222d 100644 --- a/src/oatpp/base/Log.cpp +++ b/src/oatpp/base/Log.cpp @@ -93,6 +93,34 @@ LogMessage& LogMessage::operator << (bool value) { return *this; } +LogMessage& LogMessage::operator << (char value) { + if(writeNextChunk()) { + m_stream.writeAsString(static_cast(value)); + } + return *this; +} + +LogMessage& LogMessage::operator << (unsigned char value) { + if(writeNextChunk()) { + m_stream.writeAsString(static_cast(value)); + } + return *this; +} + +LogMessage& LogMessage::operator << (short value) { + if(writeNextChunk()) { + m_stream.writeAsString(static_cast(value)); + } + return *this; +} + +LogMessage& LogMessage::operator << (unsigned short value) { + if(writeNextChunk()) { + m_stream.writeAsString(static_cast(value)); + } + return *this; +} + LogMessage& LogMessage::operator << (int value) { if(writeNextChunk()) { m_stream.writeAsString(value); diff --git a/src/oatpp/base/Log.hpp b/src/oatpp/base/Log.hpp index 1a4f3cce..75e44469 100644 --- a/src/oatpp/base/Log.hpp +++ b/src/oatpp/base/Log.hpp @@ -54,6 +54,10 @@ public: LogMessage& operator << (const char* str); LogMessage& operator << (bool value); + LogMessage& operator << (char value); + LogMessage& operator << (unsigned char value); + LogMessage& operator << (short value); + LogMessage& operator << (unsigned short value); LogMessage& operator << (int value); LogMessage& operator << (unsigned value); LogMessage& operator << (long value); diff --git a/src/oatpp/data/stream/BufferStream.cpp b/src/oatpp/data/stream/BufferStream.cpp index 5c22e91d..68db5564 100644 --- a/src/oatpp/data/stream/BufferStream.cpp +++ b/src/oatpp/data/stream/BufferStream.cpp @@ -193,7 +193,7 @@ BufferInputStream::BufferInputStream(const std::shared_ptr& memoryH {} BufferInputStream::BufferInputStream(const oatpp::String& data, const std::shared_ptr& captureData) - : BufferInputStream(data.getPtr(), reinterpret_cast(const_cast(data->data())), static_cast(data->size()), captureData) + : BufferInputStream(data.getPtr(), reinterpret_cast(data->data()), static_cast(data->size()), captureData) {} void BufferInputStream::reset(const std::shared_ptr& memoryHandle, diff --git a/src/oatpp/data/stream/FIFOStream.cpp b/src/oatpp/data/stream/FIFOStream.cpp index 16f2199a..bd1454ef 100644 --- a/src/oatpp/data/stream/FIFOStream.cpp +++ b/src/oatpp/data/stream/FIFOStream.cpp @@ -32,7 +32,7 @@ data::stream::DefaultInitializedContext FIFOInputStream::DEFAULT_CONTEXT(data::s FIFOInputStream::FIFOInputStream(v_buff_size initialSize) : m_memoryHandle(std::make_shared(initialSize, static_cast(0))) - , m_fifo(std::make_shared(reinterpret_cast(const_cast(m_memoryHandle->data())), m_memoryHandle->size(), 0, 0, false)) + , m_fifo(std::make_shared(reinterpret_cast(m_memoryHandle->data()), m_memoryHandle->size(), 0, 0, false)) , m_maxCapacity(-1) { } @@ -87,8 +87,8 @@ void FIFOInputStream::reserveBytesUpfront(v_buff_size count) { // ToDo: In-Memory-Resize auto newHandle = std::make_shared(newCapacity, static_cast(0)); v_io_size oldSize = m_fifo->availableToRead(); - m_fifo->read(reinterpret_cast(const_cast(newHandle->data())), oldSize); - auto newFifo = std::make_shared(reinterpret_cast(const_cast(newHandle->data())), newHandle->size(), 0, oldSize, oldSize > 0); + m_fifo->read(reinterpret_cast(newHandle->data()), oldSize); + auto newFifo = std::make_shared(reinterpret_cast(newHandle->data()), newHandle->size(), 0, oldSize, oldSize > 0); m_memoryHandle = newHandle; m_fifo = newFifo; } diff --git a/src/oatpp/data/type/Primitive.cpp b/src/oatpp/data/type/Primitive.cpp index 6ad660e7..e652f2b6 100644 --- a/src/oatpp/data/type/Primitive.cpp +++ b/src/oatpp/data/type/Primitive.cpp @@ -45,7 +45,7 @@ String String::loadFromFile(const char* filename) { if (file.is_open()) { auto result = data::type::String(file.tellg()); file.seekg(0, std::ios::beg); - file.read(const_cast(result->data()), static_cast(result->size())); + file.read(result->data(), static_cast(result->size())); file.close(); return result; } diff --git a/src/oatpp/encoding/Base64.cpp b/src/oatpp/encoding/Base64.cpp index e07f1cf1..f4bc8466 100644 --- a/src/oatpp/encoding/Base64.cpp +++ b/src/oatpp/encoding/Base64.cpp @@ -109,8 +109,8 @@ oatpp::String Base64::encode(const void* data, v_buff_size size, const char* alp auto result = oatpp::String(resultSize); - p_char8 bdata = reinterpret_cast(const_cast(data)); - p_char8 resultData = reinterpret_cast(const_cast(result->data())); + auto bdata = reinterpret_cast(data); + auto resultData = reinterpret_cast(result->data()); v_buff_size pos = 0; while (pos + 2 < size) { @@ -159,7 +159,7 @@ oatpp::String Base64::decode(const char* data, v_buff_size size, const char* aux } auto result = oatpp::String(resultSize); - p_char8 resultData = reinterpret_cast(const_cast(result->data())); + auto resultData = reinterpret_cast(result->data()); v_buff_size pos = 0; while (pos + 3 < base64StrLength) { v_char8 b0 = getAlphabetCharIndex(static_cast(data[pos]), auxiliaryChars); diff --git a/src/oatpp/json/Utils.cpp b/src/oatpp/json/Utils.cpp index 22903d47..ff520d1c 100644 --- a/src/oatpp/json/Utils.cpp +++ b/src/oatpp/json/Utils.cpp @@ -225,8 +225,8 @@ oatpp::String Utils::escapeString(const char* data, v_buff_size size, v_uint32 f if(escapedSize == size) { return String(data, size); } - auto result = String(escapedSize); - p_char8 resultData = reinterpret_cast(const_cast(result->data())); + String result(escapedSize); + auto resultData = reinterpret_cast(result->data()); v_buff_size pos = 0; { @@ -375,11 +375,11 @@ oatpp::String Utils::unescapeString(const char* data, v_buff_size size, v_int64& if(errorCode != 0){ return nullptr; } - auto result = String(unescapedSize); + String result(unescapedSize); if(unescapedSize == size) { - std::memcpy(reinterpret_cast(const_cast(result->data())), data, static_cast(size)); + std::memcpy(reinterpret_cast(result->data()), data, static_cast(size)); } else { - unescapeStringToBuffer(data, size, reinterpret_cast(const_cast(result->data()))); + unescapeStringToBuffer(data, size, reinterpret_cast(result->data())); } return result; @@ -394,9 +394,9 @@ std::string Utils::unescapeStringToStdString(const char* data, v_buff_size size, std::string result; result.resize(static_cast(unescapedSize)); if(unescapedSize == size) { - std::memcpy(reinterpret_cast(const_cast(result.data())), data, static_cast(size)); + std::memcpy(reinterpret_cast(result.data()), data, static_cast(size)); } else { - unescapeStringToBuffer(data, size, reinterpret_cast(const_cast(result.data()))); + unescapeStringToBuffer(data, size, reinterpret_cast(result.data())); } return result; diff --git a/src/oatpp/network/tcp/client/ConnectionProvider.cpp b/src/oatpp/network/tcp/client/ConnectionProvider.cpp index 24af2463..2e4229d9 100644 --- a/src/oatpp/network/tcp/client/ConnectionProvider.cpp +++ b/src/oatpp/network/tcp/client/ConnectionProvider.cpp @@ -124,7 +124,7 @@ provider::ResourceHandle ConnectionProvider::get() { if(clientHandle >= 0) { - if(connect(clientHandle, currResult->ai_addr, static_cast(currResult->ai_addrlen)) == 0) { + if(connect(clientHandle, currResult->ai_addr, currResult->ai_addrlen) == 0) { break; } else { err = errno; @@ -283,7 +283,7 @@ oatpp::async::CoroutineStarterForResultai_addr, static_cast(m_currentResult->ai_addrlen)); + auto res = connect(m_clientHandle, m_currentResult->ai_addr, m_currentResult->ai_addrlen); #if defined(WIN32) || defined(_WIN32) diff --git a/src/oatpp/network/tcp/server/ConnectionProvider.cpp b/src/oatpp/network/tcp/server/ConnectionProvider.cpp index 4f14ed98..c1f2884d 100644 --- a/src/oatpp/network/tcp/server/ConnectionProvider.cpp +++ b/src/oatpp/network/tcp/server/ConnectionProvider.cpp @@ -285,7 +285,7 @@ oatpp::v_io_handle ConnectionProvider::instantiateServer(){ "Warning. Failed to set {} for accepting socket: {}", "SO_REUSEADDR", strerror(errno)) } - if (bind(serverHandle, currResult->ai_addr, static_cast(currResult->ai_addrlen)) == 0 && + if (bind(serverHandle, currResult->ai_addr, currResult->ai_addrlen) == 0 && listen(serverHandle, 10000) == 0) { break; diff --git a/src/oatpp/web/protocol/http/encoding/Chunked.cpp b/src/oatpp/web/protocol/http/encoding/Chunked.cpp index d30ef524..a22ad14a 100644 --- a/src/oatpp/web/protocol/http/encoding/Chunked.cpp +++ b/src/oatpp/web/protocol/http/encoding/Chunked.cpp @@ -69,7 +69,7 @@ v_int32 EncoderChunked::iterate(data::buffer::InlineReadData& dataIn, data::buff stream.write("\r\n", 2, action); m_chunkHeader = stream.toString(); - dataOut.set(reinterpret_cast(const_cast(m_chunkHeader->data())), static_cast(m_chunkHeader->size())); + dataOut.set(reinterpret_cast(m_chunkHeader->data()), static_cast(m_chunkHeader->size())); m_firstChunk = false; m_writeChunkHeader = false; @@ -96,7 +96,7 @@ v_int32 EncoderChunked::iterate(data::buffer::InlineReadData& dataIn, data::buff stream.write("0\r\n\r\n", 5, action); m_chunkHeader = stream.toString(); - dataOut.set(reinterpret_cast(const_cast(m_chunkHeader->data())), static_cast(m_chunkHeader->size())); + dataOut.set(reinterpret_cast(m_chunkHeader->data()), static_cast(m_chunkHeader->size())); m_firstChunk = false; m_writeChunkHeader = false; diff --git a/src/oatpp/web/protocol/http/outgoing/BufferBody.cpp b/src/oatpp/web/protocol/http/outgoing/BufferBody.cpp index eb852e96..29fd3e90 100644 --- a/src/oatpp/web/protocol/http/outgoing/BufferBody.cpp +++ b/src/oatpp/web/protocol/http/outgoing/BufferBody.cpp @@ -29,7 +29,7 @@ namespace oatpp { namespace web { namespace protocol { namespace http { namespac BufferBody::BufferBody(const oatpp::String &buffer, const data::share::StringKeyLabel &contentType) : m_buffer(buffer ? buffer : "") , m_contentType(contentType) - , m_inlineData(reinterpret_cast(const_cast(m_buffer->data())), static_cast(m_buffer->size())) + , m_inlineData(reinterpret_cast(m_buffer->data()), static_cast(m_buffer->size())) {} std::shared_ptr BufferBody::createShared(const oatpp::String &buffer, @@ -67,7 +67,7 @@ void BufferBody::declareHeaders(Headers &headers) { } p_char8 BufferBody::getKnownData() { - return reinterpret_cast(const_cast(m_buffer->data())); + return reinterpret_cast(m_buffer->data()); } v_int64 BufferBody::getKnownSize() { diff --git a/src/oatpp/web/protocol/http/outgoing/MultipartBody.cpp b/src/oatpp/web/protocol/http/outgoing/MultipartBody.cpp index 5ee867ae..eb3d5c85 100644 --- a/src/oatpp/web/protocol/http/outgoing/MultipartBody.cpp +++ b/src/oatpp/web/protocol/http/outgoing/MultipartBody.cpp @@ -135,7 +135,7 @@ v_io_size MultipartBody::readBoundary(const std::shared_ptr& multipar boundary = "\r\n--" + multipart->getBoundary() + "\r\n"; } - readStream.reset(boundary.getPtr(), reinterpret_cast(const_cast(boundary->data())), static_cast(boundary->size())); + readStream.reset(boundary.getPtr(), reinterpret_cast(boundary->data()), static_cast(boundary->size())); } @@ -162,7 +162,7 @@ v_io_size MultipartBody::readHeaders(const std::shared_ptr& multipart http::Utils::writeHeaders(part->getHeaders(), &stream); stream.writeSimple("\r\n", 2); auto str = stream.toString(); - readStream.reset(str.getPtr(), reinterpret_cast(const_cast(str->data())), static_cast(str->size())); + readStream.reset(str.getPtr(), reinterpret_cast(str->data()), static_cast(str->size())); } diff --git a/src/oatpp/web/url/mapping/Pattern.cpp b/src/oatpp/web/url/mapping/Pattern.cpp index 0cff94fb..31035413 100644 --- a/src/oatpp/web/url/mapping/Pattern.cpp +++ b/src/oatpp/web/url/mapping/Pattern.cpp @@ -103,7 +103,7 @@ std::shared_ptr Pattern::parse(const char* data){ } std::shared_ptr Pattern::parse(const oatpp::String& data){ - return parse(reinterpret_cast(const_cast(data->data())), static_cast(data->size())); + return parse(reinterpret_cast(data->data()), static_cast(data->size())); } v_char8 Pattern::findSysChar(oatpp::utils::parser::Caret& caret) { diff --git a/test/oatpp/async/ConditionVariableTest.cpp b/test/oatpp/async/ConditionVariableTest.cpp index 77290ea8..178cc298 100644 --- a/test/oatpp/async/ConditionVariableTest.cpp +++ b/test/oatpp/async/ConditionVariableTest.cpp @@ -51,7 +51,7 @@ public: {} Action act() override { - return m_cv->wait(m_lockGuard, [this]{return m_resource->counter == 100;}) + return m_cv->wait(m_lockGuard, [this]() noexcept {return m_resource->counter == 100;}) .next(yieldTo(&TestCoroutineWait::onReady)); } @@ -78,7 +78,7 @@ public: {} Action act() override { - return m_cv->waitFor(m_lockGuard, [this]{return m_resource->counter == 100;}, std::chrono::seconds(5)) + return m_cv->waitFor(m_lockGuard, [this]() noexcept{return m_resource->counter == 100;}, std::chrono::seconds(5)) .next(yieldTo(&TestCoroutineWaitWithTimeout::onReady)); } @@ -105,7 +105,7 @@ public: {} Action act() override { - return m_cv->waitFor(m_lockGuard, []{return false;}, std::chrono::seconds(1)) + return m_cv->waitFor(m_lockGuard, []() noexcept{return false;}, std::chrono::seconds(1)) .next(yieldTo(&TestCoroutineTimeout::onReady)); } diff --git a/test/oatpp/async/LockTest.cpp b/test/oatpp/async/LockTest.cpp index c051cf50..51175c7e 100644 --- a/test/oatpp/async/LockTest.cpp +++ b/test/oatpp/async/LockTest.cpp @@ -141,7 +141,7 @@ bool checkSymbol(char symbol, const char* data, v_buff_size size) { for (v_buff_size j = 0; j < NUM_SYMBOLS; j++) { if (data[i + j] != symbol) { - OATPP_LOGd("aaa", "j pos={}", static_cast(j)) + OATPP_LOGd("aaa", "j pos={}", j) return false; } diff --git a/test/oatpp/base/LogTest.cpp b/test/oatpp/base/LogTest.cpp index 410cc51d..6842a7d5 100644 --- a/test/oatpp/base/LogTest.cpp +++ b/test/oatpp/base/LogTest.cpp @@ -61,11 +61,24 @@ void LogTest::onRun() { } { + + v_int8 i8 = -8; + v_uint8 u8 = 8; + + v_int16 i16 = -16; + v_uint16 u16 = 16; + + v_int32 i32 = -32; + v_uint32 u32 = 32; + + v_int64 i64 = -64; + v_uint64 u64 = 64; + LogMessage msg("{} {} {} {} {} {} {} {}"); - msg << v_int8(-8) << v_uint8(8); - msg << v_int16(-16) << v_uint16(16); - msg << v_int32(-32) << v_uint32(32); - msg << v_int64(-64) << v_uint64(64); + msg << i8 << u8; + msg << i16 << u16; + msg << i32 << u32; + msg << i64 << u64; OATPP_ASSERT(msg.toStdString() == "-8 8 -16 16 -32 32 -64 64") } diff --git a/test/oatpp/data/share/StringTemplateTest.cpp b/test/oatpp/data/share/StringTemplateTest.cpp index f7e6431d..c9901ab3 100644 --- a/test/oatpp/data/share/StringTemplateTest.cpp +++ b/test/oatpp/data/share/StringTemplateTest.cpp @@ -30,8 +30,6 @@ namespace oatpp { namespace data { namespace share { void StringTemplateTest::onRun() { - typedef oatpp::data::share::StringTemplate StringTemplate; - { OATPP_LOGi(TAG, "Case1 ...") StringTemplate t("{} World!", {{0, 1, "p1", nullptr}}); diff --git a/test/oatpp/encoding/UrlTest.cpp b/test/oatpp/encoding/UrlTest.cpp index 844883cd..1088f0d1 100644 --- a/test/oatpp/encoding/UrlTest.cpp +++ b/test/oatpp/encoding/UrlTest.cpp @@ -38,7 +38,7 @@ void UrlTest::onRun(){ for(v_int32 i = 0; i < 100; i++) { oatpp::String buff(100); - utils::random::Random::randomBytes(reinterpret_cast(const_cast(buff->data())), static_cast(buff->size())); + utils::random::Random::randomBytes(reinterpret_cast(buff->data()), static_cast(buff->size())); auto encoded = oatpp::encoding::Url::encode(buff, config); auto decoded = oatpp::encoding::Url::decode(encoded); OATPP_ASSERT(decoded == buff) @@ -51,7 +51,7 @@ void UrlTest::onRun(){ for(v_int32 i = 0; i < 100; i++) { oatpp::String buff(100); - utils::random::Random::randomBytes(reinterpret_cast(const_cast(buff->data())), static_cast(buff->size())); + utils::random::Random::randomBytes(reinterpret_cast(buff->data()), static_cast(buff->size())); auto encoded = oatpp::encoding::Url::encode(buff, config); auto decoded = oatpp::encoding::Url::decode(encoded); OATPP_ASSERT(decoded == buff)