From 8b91751bbe7633a34876b77beadacb4a0594a51f Mon Sep 17 00:00:00 2001 From: lganzzzo Date: Wed, 27 Jun 2018 02:07:08 +0300 Subject: [PATCH] Fixed string concat --- core/base/StrBuffer.cpp | 23 ----------------------- core/base/StrBuffer.hpp | 9 --------- core/data/mapping/type/Primitive.cpp | 12 ++++++++++++ core/data/mapping/type/Primitive.hpp | 12 ++++-------- 4 files changed, 16 insertions(+), 40 deletions(-) diff --git a/core/base/StrBuffer.cpp b/core/base/StrBuffer.cpp index 960762f1..19ec4ee0 100644 --- a/core/base/StrBuffer.cpp +++ b/core/base/StrBuffer.cpp @@ -269,28 +269,5 @@ void StrBuffer::upperCase(const void* data, v_int32 size) { if(a >= 'a' && a <= 'z') ((p_char8) data)[i] = a & 223; } } - -// Operator -/* -oatpp::data::mapping::type::PolymorphicWrapper operator + (const char* a, const oatpp::data::mapping::type::PolymorphicWrapper& b){ - return StrBuffer::createSharedConcatenated(a, (v_int32) std::strlen(a), b->getData(), b->getSize()); -} - -oatpp::data::mapping::type::PolymorphicWrapper operator + (const oatpp::data::mapping::type::PolymorphicWrapper& b, const char* a){ - return StrBuffer::createSharedConcatenated(b->getData(), b->getSize(), a, (v_int32) std::strlen(a)); -} - -oatpp::data::mapping::type::PolymorphicWrapper operator + (const oatpp::data::mapping::type::PolymorphicWrapper& a, const oatpp::data::mapping::type::PolymorphicWrapper& b) { - return StrBuffer::createSharedConcatenated(a->getData(), a->getSize(), b->getData(), b->getSize()); -} - -std::shared_ptr operator + (const char* a, const std::shared_ptr& b){ - return StrBuffer::createSharedConcatenated(a, (v_int32) std::strlen(a), b->getData(), b->getSize()); -} - -std::shared_ptr operator + (const std::shared_ptr& b, const char* a){ - return StrBuffer::createSharedConcatenated(b->getData(), b->getSize(), a, (v_int32) std::strlen(a)); -} - */ }} diff --git a/core/base/StrBuffer.hpp b/core/base/StrBuffer.hpp index 5e775329..f5375ba8 100644 --- a/core/base/StrBuffer.hpp +++ b/core/base/StrBuffer.hpp @@ -141,15 +141,6 @@ public: }; -/* -oatpp::data::mapping::type::PolymorphicWrapper operator + (const char* a, const oatpp::data::mapping::type::PolymorphicWrapper& b); -oatpp::data::mapping::type::PolymorphicWrapper operator + (const oatpp::data::mapping::type::PolymorphicWrapper& b, const char* a); -oatpp::data::mapping::type::PolymorphicWrapper operator + (const oatpp::data::mapping::type::PolymorphicWrapper& a, const oatpp::data::mapping::type::PolymorphicWrapper& b); - -std::shared_ptr operator + (const char* a, const std::shared_ptr& b); -std::shared_ptr operator + (const std::shared_ptr& b, const char* a); - */ - }} #endif /* oatpp_base_StrBuffer_hpp */ diff --git a/core/data/mapping/type/Primitive.cpp b/core/data/mapping/type/Primitive.cpp index 980e1982..54e45b16 100644 --- a/core/data/mapping/type/Primitive.cpp +++ b/core/data/mapping/type/Primitive.cpp @@ -36,6 +36,18 @@ String::String(const std::shared_ptr& ptr, const type::T } } +String operator + (const char* a, const String& b) { + return oatpp::base::StrBuffer::createSharedConcatenated(a, (v_int32) std::strlen(a), b->getData(), b->getSize()); +} + +String operator + (const String& b, const char* a) { + return oatpp::base::StrBuffer::createSharedConcatenated(b->getData(), b->getSize(), a, (v_int32) std::strlen(a)); +} + +String operator + (const String& a, const String& b) { + return oatpp::base::StrBuffer::createSharedConcatenated(a->getData(), a->getSize(), b->getData(), b->getSize()); +} + namespace __class { type::Int32 Int32::parseFromString(const oatpp::String& str, bool& success) { diff --git a/core/data/mapping/type/Primitive.hpp b/core/data/mapping/type/Primitive.hpp index 02b00d93..8012e3b9 100644 --- a/core/data/mapping/type/Primitive.hpp +++ b/core/data/mapping/type/Primitive.hpp @@ -100,14 +100,6 @@ public: return *this; } - String operator + (const char* str) const{ - return oatpp::base::StrBuffer::createSharedConcatenated(m_ptr->getData(), m_ptr->getSize(), str, (v_int32) std::strlen(str)); - } - - String operator + (const String& other) const{ - return oatpp::base::StrBuffer::createSharedConcatenated(m_ptr->getData(), m_ptr->getSize(), other->getData(), other->getSize()); - } - static const String& empty(){ static String empty; return empty; @@ -123,6 +115,10 @@ public: }; +String operator + (const char* a, const String& b); +String operator + (const String& b, const char* a); +String operator + (const String& a, const String& b); + template class Primitive : public oatpp::base::Controllable { public: