mirror of
https://gitee.com/zyjblog/oatpp.git
synced 2024-12-22 22:16:37 +08:00
move oatpp/core/utils --> oatpp/utils. move oatpp/algorithm/CRC --> oatpp/utils/CRC32
This commit is contained in:
parent
06232810f7
commit
ec1b0523ef
@ -51,8 +51,10 @@ OATPP_ASSERT(decoded == data)
|
||||
|
||||
## Restructuring
|
||||
|
||||
| old namespace | new namespace |
|
||||
|-----------------------------------|-----------------|
|
||||
| `oatpp::parser::json::*` | `oatpp::json::*`|
|
||||
| `oatpp::parser::json::mapping::*` | `oatpp::json::*`|
|
||||
| old namespace | new namespace |
|
||||
|-----------------------------------|----------------------|
|
||||
| `oatpp::parser::json::*` | `oatpp::json::*` |
|
||||
| `oatpp::parser::json::mapping::*` | `oatpp::json::*` |
|
||||
| `oatpp::algorithm::CRC` | `oatpp::utils::CRC32`|
|
||||
|
||||
|
||||
|
@ -3,8 +3,6 @@
|
||||
## oatpp
|
||||
|
||||
add_library(oatpp
|
||||
oatpp/algorithm/CRC.cpp
|
||||
oatpp/algorithm/CRC.hpp
|
||||
oatpp/codegen/ApiClient_define.hpp
|
||||
oatpp/codegen/ApiClient_undef.hpp
|
||||
oatpp/codegen/ApiController_define.hpp
|
||||
@ -132,14 +130,6 @@ add_library(oatpp
|
||||
oatpp/core/provider/Invalidator.hpp
|
||||
oatpp/core/provider/Pool.hpp
|
||||
oatpp/core/provider/Provider.hpp
|
||||
oatpp/core/utils/Binary.cpp
|
||||
oatpp/core/utils/Binary.hpp
|
||||
oatpp/core/utils/ConversionUtils.cpp
|
||||
oatpp/core/utils/ConversionUtils.hpp
|
||||
oatpp/core/utils/Random.cpp
|
||||
oatpp/core/utils/Random.hpp
|
||||
oatpp/core/utils/String.cpp
|
||||
oatpp/core/utils/String.hpp
|
||||
oatpp/encoding/Base64.cpp
|
||||
oatpp/encoding/Base64.hpp
|
||||
oatpp/encoding/Hex.cpp
|
||||
@ -207,6 +197,16 @@ add_library(oatpp
|
||||
oatpp/orm/SchemaMigration.hpp
|
||||
oatpp/orm/Transaction.cpp
|
||||
oatpp/orm/Transaction.hpp
|
||||
oatpp/utils/Binary.cpp
|
||||
oatpp/utils/Binary.hpp
|
||||
oatpp/utils/Conversion.cpp
|
||||
oatpp/utils/Conversion.hpp
|
||||
oatpp/utils/CRC32.cpp
|
||||
oatpp/utils/CRC32.hpp
|
||||
oatpp/utils/Random.cpp
|
||||
oatpp/utils/Random.hpp
|
||||
oatpp/utils/String.cpp
|
||||
oatpp/utils/String.hpp
|
||||
oatpp/web/client/ApiClient.cpp
|
||||
oatpp/web/client/ApiClient.hpp
|
||||
oatpp/web/client/HttpRequestExecutor.cpp
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "./Primitive.hpp"
|
||||
|
||||
#include "oatpp/core/data/stream/BufferStream.hpp"
|
||||
#include "oatpp/core/utils/ConversionUtils.hpp"
|
||||
#include "oatpp/utils/Conversion.hpp"
|
||||
#include "oatpp/core/data/share/MemoryLabel.hpp"
|
||||
|
||||
#include <fstream>
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "oatpp/core/data/stream/FileStream.hpp"
|
||||
#include "oatpp/core/data/stream/BufferStream.hpp"
|
||||
#include "oatpp/encoding/Hex.hpp"
|
||||
#include "oatpp/core/utils/Random.hpp"
|
||||
#include "oatpp/utils/Random.hpp"
|
||||
|
||||
namespace oatpp { namespace data { namespace resource {
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
#define oatpp_data_share_MemoryLabel_hpp
|
||||
|
||||
#include "oatpp/core/data/mapping/type/Primitive.hpp"
|
||||
#include "oatpp/core/utils/String.hpp"
|
||||
#include "oatpp/utils/String.hpp"
|
||||
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include "BufferStream.hpp"
|
||||
|
||||
#include "oatpp/core/utils/Binary.hpp"
|
||||
#include "oatpp/utils/Binary.hpp"
|
||||
|
||||
namespace oatpp { namespace data{ namespace stream {
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
|
||||
#include "FIFOStream.hpp"
|
||||
#include "oatpp/core/utils/Binary.hpp"
|
||||
#include "oatpp/utils/Binary.hpp"
|
||||
|
||||
namespace oatpp { namespace data { namespace stream {
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include "./Stream.hpp"
|
||||
#include "oatpp/core/utils/ConversionUtils.hpp"
|
||||
#include "oatpp/utils/Conversion.hpp"
|
||||
|
||||
namespace oatpp { namespace data{ namespace stream {
|
||||
|
||||
@ -327,7 +327,7 @@ async::CoroutineStarter IOStream::initContextsAsync() {
|
||||
|
||||
v_io_size ConsistentOutputStream::writeAsString(v_int8 value){
|
||||
v_char8 a[16];
|
||||
auto size = utils::conversion::int32ToCharSequence(value, &a[0], 16);
|
||||
auto size = utils::Conversion::int32ToCharSequence(value, &a[0], 16);
|
||||
if(size > 0){
|
||||
return writeSimple(&a[0], size);
|
||||
}
|
||||
@ -336,7 +336,7 @@ v_io_size ConsistentOutputStream::writeAsString(v_int8 value){
|
||||
|
||||
v_io_size ConsistentOutputStream::writeAsString(v_uint8 value){
|
||||
v_char8 a[16];
|
||||
auto size = utils::conversion::uint32ToCharSequence(value, &a[0], 16);
|
||||
auto size = utils::Conversion::uint32ToCharSequence(value, &a[0], 16);
|
||||
if(size > 0){
|
||||
return writeSimple(&a[0], size);
|
||||
}
|
||||
@ -345,7 +345,7 @@ v_io_size ConsistentOutputStream::writeAsString(v_uint8 value){
|
||||
|
||||
v_io_size ConsistentOutputStream::writeAsString(v_int16 value){
|
||||
v_char8 a[16];
|
||||
auto size = utils::conversion::int32ToCharSequence(value, &a[0], 16);
|
||||
auto size = utils::Conversion::int32ToCharSequence(value, &a[0], 16);
|
||||
if(size > 0){
|
||||
return writeSimple(&a[0], size);
|
||||
}
|
||||
@ -354,7 +354,7 @@ v_io_size ConsistentOutputStream::writeAsString(v_int16 value){
|
||||
|
||||
v_io_size ConsistentOutputStream::writeAsString(v_uint16 value){
|
||||
v_char8 a[16];
|
||||
auto size = utils::conversion::uint32ToCharSequence(value, &a[0], 16);
|
||||
auto size = utils::Conversion::uint32ToCharSequence(value, &a[0], 16);
|
||||
if(size > 0){
|
||||
return writeSimple(&a[0], size);
|
||||
}
|
||||
@ -363,7 +363,7 @@ v_io_size ConsistentOutputStream::writeAsString(v_uint16 value){
|
||||
|
||||
v_io_size ConsistentOutputStream::writeAsString(v_int32 value){
|
||||
v_char8 a[16];
|
||||
auto size = utils::conversion::int32ToCharSequence(value, &a[0], 16);
|
||||
auto size = utils::Conversion::int32ToCharSequence(value, &a[0], 16);
|
||||
if(size > 0){
|
||||
return writeSimple(&a[0], size);
|
||||
}
|
||||
@ -372,7 +372,7 @@ v_io_size ConsistentOutputStream::writeAsString(v_int32 value){
|
||||
|
||||
v_io_size ConsistentOutputStream::writeAsString(v_uint32 value){
|
||||
v_char8 a[16];
|
||||
auto size = utils::conversion::uint32ToCharSequence(value, &a[0], 16);
|
||||
auto size = utils::Conversion::uint32ToCharSequence(value, &a[0], 16);
|
||||
if(size > 0){
|
||||
return writeSimple(&a[0], size);
|
||||
}
|
||||
@ -381,7 +381,7 @@ v_io_size ConsistentOutputStream::writeAsString(v_uint32 value){
|
||||
|
||||
v_io_size ConsistentOutputStream::writeAsString(v_int64 value){
|
||||
v_char8 a[32];
|
||||
auto size = utils::conversion::int64ToCharSequence(value, &a[0], 32);
|
||||
auto size = utils::Conversion::int64ToCharSequence(value, &a[0], 32);
|
||||
if(size > 0){
|
||||
return writeSimple(&a[0], size);
|
||||
}
|
||||
@ -390,7 +390,7 @@ v_io_size ConsistentOutputStream::writeAsString(v_int64 value){
|
||||
|
||||
v_io_size ConsistentOutputStream::writeAsString(v_uint64 value){
|
||||
v_char8 a[32];
|
||||
auto size = utils::conversion::uint64ToCharSequence(value, &a[0], 32);
|
||||
auto size = utils::Conversion::uint64ToCharSequence(value, &a[0], 32);
|
||||
if(size > 0){
|
||||
return writeSimple(&a[0], size);
|
||||
}
|
||||
@ -399,7 +399,7 @@ v_io_size ConsistentOutputStream::writeAsString(v_uint64 value){
|
||||
|
||||
v_io_size ConsistentOutputStream::writeAsString(v_float32 value){
|
||||
v_char8 a[100];
|
||||
auto size = utils::conversion::float32ToCharSequence(value, &a[0], 100);
|
||||
auto size = utils::Conversion::float32ToCharSequence(value, &a[0], 100);
|
||||
if(size > 0){
|
||||
return writeSimple(&a[0], size);
|
||||
}
|
||||
@ -408,7 +408,7 @@ v_io_size ConsistentOutputStream::writeAsString(v_float32 value){
|
||||
|
||||
v_io_size ConsistentOutputStream::writeAsString(v_float64 value){
|
||||
v_char8 a[100];
|
||||
auto size = utils::conversion::float64ToCharSequence(value, &a[0], 100);
|
||||
auto size = utils::Conversion::float64ToCharSequence(value, &a[0], 100);
|
||||
if(size > 0){
|
||||
return writeSimple(&a[0], size);
|
||||
}
|
||||
|
@ -1,237 +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 "ConversionUtils.hpp"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
namespace oatpp { namespace utils { namespace conversion {
|
||||
|
||||
v_int32 strToInt32(const char* str){
|
||||
char* end;
|
||||
return static_cast<v_int32>(std::strtol(str, &end, 10));
|
||||
}
|
||||
|
||||
v_int32 strToInt32(const oatpp::String& str, bool& success){
|
||||
char* end;
|
||||
v_int32 result = static_cast<v_int32>(std::strtol(str->data(), &end, 10));
|
||||
success = ((reinterpret_cast<v_buff_size>(end) - reinterpret_cast<v_buff_size>(str->data())) == static_cast<v_buff_size>(str->size()));
|
||||
return result;
|
||||
}
|
||||
|
||||
v_uint32 strToUInt32(const char* str){
|
||||
char* end;
|
||||
return static_cast<v_uint32>(std::strtoul(str, &end, 10));
|
||||
}
|
||||
|
||||
v_uint32 strToUInt32(const oatpp::String& str, bool& success){
|
||||
char* end;
|
||||
v_uint32 result = static_cast<v_uint32>(std::strtoul(str->data(), &end, 10));
|
||||
success = ((reinterpret_cast<v_buff_size>(end) - reinterpret_cast<v_buff_size>(str->data())) == static_cast<v_buff_size>(str->size()));
|
||||
return result;
|
||||
}
|
||||
|
||||
v_int64 strToInt64(const char* str){
|
||||
char* end;
|
||||
return std::strtoll(str, &end, 10);
|
||||
}
|
||||
|
||||
v_int64 strToInt64(const oatpp::String& str, bool& success){
|
||||
char* end;
|
||||
v_int64 result = std::strtoll(str->data(), &end, 10);
|
||||
success = ((reinterpret_cast<v_buff_size>(end) - reinterpret_cast<v_buff_size>(str->data())) == static_cast<v_buff_size>(str->size()));
|
||||
return result;
|
||||
}
|
||||
|
||||
v_uint64 strToUInt64(const char* str){
|
||||
char* end;
|
||||
return std::strtoull(str, &end, 10);
|
||||
}
|
||||
|
||||
v_uint64 strToUInt64(const oatpp::String& str, bool& success){
|
||||
char* end;
|
||||
v_uint64 result = std::strtoull(str->data(), &end, 10);
|
||||
success = ((reinterpret_cast<v_buff_size>(end) - reinterpret_cast<v_buff_size>(str->data())) == static_cast<v_buff_size>(str->size()));
|
||||
return result;
|
||||
}
|
||||
|
||||
v_buff_size int32ToCharSequence(v_int32 value, p_char8 data, v_buff_size n) {
|
||||
return snprintf(reinterpret_cast<char*>(data), static_cast<size_t>(n), "%ld", static_cast<long>(value));
|
||||
}
|
||||
|
||||
v_buff_size uint32ToCharSequence(v_uint32 value, p_char8 data, v_buff_size n) {
|
||||
return snprintf(reinterpret_cast<char*>(data), static_cast<size_t>(n), "%lu", static_cast<unsigned long>(value));
|
||||
}
|
||||
|
||||
v_buff_size int64ToCharSequence(v_int64 value, p_char8 data, v_buff_size n) {
|
||||
return snprintf(reinterpret_cast<char*>(data), static_cast<size_t>(n), "%lld", static_cast<long long int>(value));
|
||||
}
|
||||
|
||||
v_buff_size uint64ToCharSequence(v_uint64 value, p_char8 data, v_buff_size n) {
|
||||
return snprintf(reinterpret_cast<char*>(data), static_cast<size_t>(n), "%llu", static_cast<long long unsigned int>(value));
|
||||
}
|
||||
|
||||
oatpp::String int32ToStr(v_int32 value){
|
||||
v_char8 buff [16]; // Max 10 digits with 1 sign. 16 is plenty enough.
|
||||
auto size = int32ToCharSequence(value, &buff[0], 16);
|
||||
if(size > 0){
|
||||
return oatpp::String(reinterpret_cast<const char*>(&buff[0]), size);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
oatpp::String uint32ToStr(v_uint32 value){
|
||||
v_char8 buff [16]; // Max 10 digits. 16 is plenty enough.
|
||||
auto size = uint32ToCharSequence(value, &buff[0], 16);
|
||||
if(size > 0){
|
||||
return oatpp::String(reinterpret_cast<const char*>(&buff[0]), size);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
oatpp::String int64ToStr(v_int64 value){
|
||||
v_char8 buff [32]; // Max 20 digits unsigned, 19 digits +1 sign signed.
|
||||
auto size = int64ToCharSequence(value, &buff[0], 32);
|
||||
if(size > 0){
|
||||
return oatpp::String(reinterpret_cast<const char*>(&buff[0]), size);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
oatpp::String uint64ToStr(v_uint64 value){
|
||||
v_char8 buff [32]; // Max 20 digits.
|
||||
auto size = uint64ToCharSequence(value, &buff[0], 32);
|
||||
if(size > 0){
|
||||
return oatpp::String(reinterpret_cast<const char*>(&buff[0]), size);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::string int32ToStdStr(v_int32 value){
|
||||
v_char8 buff [16];
|
||||
auto size = int32ToCharSequence(value, &buff[0], 16);
|
||||
if(size > 0){
|
||||
return std::string(reinterpret_cast<const char*>(buff), static_cast<size_t>(size));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::string uint32ToStdStr(v_uint32 value){
|
||||
v_char8 buff [16];
|
||||
auto size = uint32ToCharSequence(value, &buff[0], 16);
|
||||
if(size > 0){
|
||||
return std::string(reinterpret_cast<const char*>(buff), static_cast<size_t>(size));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::string int64ToStdStr(v_int64 value){
|
||||
v_char8 buff [32];
|
||||
v_int32 size = v_int32(int64ToCharSequence(value, &buff[0], 32));
|
||||
if(size > 0){
|
||||
return std::string(reinterpret_cast<const char*>(buff), static_cast<size_t>(size));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::string uint64ToStdStr(v_uint64 value){
|
||||
v_char8 buff [32];
|
||||
auto size = uint64ToCharSequence(value, &buff[0], 32);
|
||||
if(size > 0){
|
||||
return std::string(reinterpret_cast<const char*>(buff), static_cast<size_t>(size));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
v_float32 strToFloat32(const char* str){
|
||||
char* end;
|
||||
return std::strtof(str, &end);
|
||||
}
|
||||
|
||||
v_float32 strToFloat32(const oatpp::String& str, bool& success) {
|
||||
char* end;
|
||||
v_float32 result = std::strtof(str->data(), &end);
|
||||
success = ((reinterpret_cast<v_buff_size>(end) - reinterpret_cast<v_buff_size>(str->data())) == static_cast<v_buff_size>(str->size()));
|
||||
return result;
|
||||
}
|
||||
|
||||
v_float64 strToFloat64(const char* str){
|
||||
char* end;
|
||||
return std::strtod(str, &end);
|
||||
}
|
||||
|
||||
v_float64 strToFloat64(const oatpp::String& str, bool& success) {
|
||||
char* end;
|
||||
v_float64 result = std::strtod(str->data(), &end);
|
||||
success = ((reinterpret_cast<v_buff_size>(end) - reinterpret_cast<v_buff_size>(str->data())) == static_cast<v_buff_size>(str->size()));
|
||||
return result;
|
||||
}
|
||||
|
||||
v_buff_size float32ToCharSequence(v_float32 value, p_char8 data, v_buff_size n, const char* format) {
|
||||
return snprintf(reinterpret_cast<char*>(data), static_cast<size_t>(n), format, static_cast<double>(value));
|
||||
}
|
||||
|
||||
v_buff_size float64ToCharSequence(v_float64 value, p_char8 data, v_buff_size n, const char* format) {
|
||||
return snprintf(reinterpret_cast<char*>(data), static_cast<size_t>(n), format, value);
|
||||
}
|
||||
|
||||
oatpp::String float32ToStr(v_float32 value, const char* format) {
|
||||
v_char8 buff [100];
|
||||
auto size = float32ToCharSequence(value, &buff[0], 100, format);
|
||||
if(size > 0){
|
||||
return oatpp::String(reinterpret_cast<const char*>(&buff[0]), size);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
oatpp::String float64ToStr(v_float64 value, const char* format) {
|
||||
v_char8 buff [100];
|
||||
auto size = float64ToCharSequence(value, &buff[0], 100, format);
|
||||
if(size > 0){
|
||||
return oatpp::String(reinterpret_cast<const char*>(&buff[0]), size);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
oatpp::String boolToStr(bool value) {
|
||||
if(value){
|
||||
return oatpp::String("true", 4);
|
||||
} else {
|
||||
return oatpp::String("false", 5);
|
||||
}
|
||||
}
|
||||
|
||||
bool strToBool(const oatpp::String& str, bool& success) {
|
||||
if(str == "true"){
|
||||
success = true;
|
||||
return true;
|
||||
} else if(str == "false"){
|
||||
success = true;
|
||||
return false;
|
||||
}
|
||||
success = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
}}}
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include "Deserializer.hpp"
|
||||
|
||||
#include "oatpp/core/utils/ConversionUtils.hpp"
|
||||
#include "oatpp/utils/Conversion.hpp"
|
||||
|
||||
namespace oatpp { namespace json {
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "./ConnectionProvider.hpp"
|
||||
|
||||
#include "oatpp/network/tcp/Connection.hpp"
|
||||
#include "oatpp/core/utils/ConversionUtils.hpp"
|
||||
#include "oatpp/utils/Conversion.hpp"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
@ -74,12 +74,12 @@ ConnectionProvider::ConnectionProvider(const network::Address& address)
|
||||
, m_address(address)
|
||||
{
|
||||
setProperty(PROPERTY_HOST, address.host);
|
||||
setProperty(PROPERTY_PORT, oatpp::utils::conversion::int32ToStr(address.port));
|
||||
setProperty(PROPERTY_PORT, oatpp::utils::Conversion::int32ToStr(address.port));
|
||||
}
|
||||
|
||||
provider::ResourceHandle<data::stream::IOStream> ConnectionProvider::get() {
|
||||
|
||||
auto portStr = oatpp::utils::conversion::int32ToStr(m_address.port);
|
||||
auto portStr = oatpp::utils::Conversion::int32ToStr(m_address.port);
|
||||
|
||||
addrinfo hints;
|
||||
|
||||
@ -192,7 +192,7 @@ oatpp::async::CoroutineStarterForResult<const provider::ResourceHandle<data::str
|
||||
|
||||
Action act() override {
|
||||
|
||||
auto portStr = oatpp::utils::conversion::int32ToStr(m_address.port);
|
||||
auto portStr = oatpp::utils::Conversion::int32ToStr(m_address.port);
|
||||
|
||||
addrinfo hints;
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include "./ConnectionProvider.hpp"
|
||||
|
||||
#include "oatpp/core/utils/ConversionUtils.hpp"
|
||||
#include "oatpp/utils/Conversion.hpp"
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
@ -129,7 +129,7 @@ ConnectionProvider::ConnectionProvider(const network::Address& address, bool use
|
||||
, m_useExtendedConnections(useExtendedConnections)
|
||||
{
|
||||
setProperty(PROPERTY_HOST, m_address.host);
|
||||
setProperty(PROPERTY_PORT, oatpp::utils::conversion::int32ToStr(m_address.port));
|
||||
setProperty(PROPERTY_PORT, oatpp::utils::Conversion::int32ToStr(m_address.port));
|
||||
m_serverHandle = instantiateServer();
|
||||
}
|
||||
|
||||
@ -174,7 +174,7 @@ oatpp::v_io_handle ConnectionProvider::instantiateServer(){
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
}
|
||||
|
||||
auto portStr = oatpp::utils::conversion::int32ToStr(m_address.port);
|
||||
auto portStr = oatpp::utils::Conversion::int32ToStr(m_address.port);
|
||||
|
||||
const int iResult = getaddrinfo(m_address.host->c_str(), portStr->c_str(), &hints, &result);
|
||||
if (iResult != 0) {
|
||||
@ -234,7 +234,7 @@ oatpp::v_io_handle ConnectionProvider::instantiateServer(){
|
||||
::memset(&s_in, 0, sizeof(s_in));
|
||||
oatpp::v_sock_size s_in_len = sizeof(s_in);
|
||||
::getsockname(serverHandle, (struct sockaddr *)&s_in, &s_in_len);
|
||||
setProperty(PROPERTY_PORT, oatpp::utils::conversion::int32ToStr(ntohs(s_in.sin_port)));
|
||||
setProperty(PROPERTY_PORT, oatpp::utils::Conversion::int32ToStr(ntohs(s_in.sin_port)));
|
||||
|
||||
return serverHandle;
|
||||
|
||||
@ -264,7 +264,7 @@ oatpp::v_io_handle ConnectionProvider::instantiateServer(){
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
}
|
||||
|
||||
auto portStr = oatpp::utils::conversion::int32ToStr(m_address.port);
|
||||
auto portStr = oatpp::utils::Conversion::int32ToStr(m_address.port);
|
||||
|
||||
ret = getaddrinfo(m_address.host->c_str(), portStr->c_str(), &hints, &result);
|
||||
if (ret != 0) {
|
||||
@ -315,7 +315,7 @@ oatpp::v_io_handle ConnectionProvider::instantiateServer(){
|
||||
::memset(&s_in, 0, sizeof(s_in));
|
||||
oatpp::v_sock_size s_in_len = sizeof(s_in);//FIXME trace
|
||||
::getsockname(serverHandle, reinterpret_cast<sockaddr*>(&s_in), &s_in_len);
|
||||
setProperty(PROPERTY_PORT, oatpp::utils::conversion::int32ToStr(ntohs(s_in.sin_port)));
|
||||
setProperty(PROPERTY_PORT, oatpp::utils::Conversion::int32ToStr(ntohs(s_in.sin_port)));
|
||||
|
||||
return serverHandle;
|
||||
|
||||
@ -377,7 +377,7 @@ provider::ResourceHandle<data::stream::IOStream> ConnectionProvider::getExtended
|
||||
|
||||
properties.put_LockFree(ExtendedConnection::PROPERTY_PEER_ADDRESS, oatpp::String(reinterpret_cast<const char*>(strIp)));
|
||||
properties.put_LockFree(ExtendedConnection::PROPERTY_PEER_ADDRESS_FORMAT, "ipv4");
|
||||
properties.put_LockFree(ExtendedConnection::PROPERTY_PEER_PORT, oatpp::utils::conversion::int32ToStr(sockAddress->sin_port));
|
||||
properties.put_LockFree(ExtendedConnection::PROPERTY_PEER_PORT, oatpp::utils::Conversion::int32ToStr(sockAddress->sin_port));
|
||||
|
||||
} else if (clientAddress.ss_family == AF_INET6) {
|
||||
|
||||
@ -387,7 +387,7 @@ provider::ResourceHandle<data::stream::IOStream> ConnectionProvider::getExtended
|
||||
|
||||
properties.put_LockFree(ExtendedConnection::PROPERTY_PEER_ADDRESS, oatpp::String(reinterpret_cast<const char*>(strIp)));
|
||||
properties.put_LockFree(ExtendedConnection::PROPERTY_PEER_ADDRESS_FORMAT, "ipv6");
|
||||
properties.put_LockFree(ExtendedConnection::PROPERTY_PEER_PORT, oatpp::utils::conversion::int32ToStr(sockAddress->sin6_port));
|
||||
properties.put_LockFree(ExtendedConnection::PROPERTY_PEER_PORT, oatpp::utils::Conversion::int32ToStr(sockAddress->sin6_port));
|
||||
|
||||
} else {
|
||||
|
||||
|
@ -22,9 +22,9 @@
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#include "CRC.hpp"
|
||||
#include "CRC32.hpp"
|
||||
|
||||
namespace oatpp { namespace algorithm {
|
||||
namespace oatpp { namespace utils {
|
||||
|
||||
const p_uint32 CRC32::TABLE_04C11DB7 = generateTable(0x04C11DB7);
|
||||
|
@ -22,14 +22,14 @@
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef oatpp_algorithm_CRC_hpp
|
||||
#define oatpp_algorithm_CRC_hpp
|
||||
#ifndef oatpp_utils_CRC32_hpp
|
||||
#define oatpp_utils_CRC32_hpp
|
||||
|
||||
#include "oatpp/core/base/Environment.hpp"
|
||||
|
||||
#include "oatpp/encoding/Hex.hpp"
|
||||
|
||||
namespace oatpp { namespace algorithm {
|
||||
namespace oatpp { namespace utils {
|
||||
|
||||
/**
|
||||
* Implementation of CRC-32. Cyclic redundancy check algorithm.
|
||||
@ -66,4 +66,4 @@ public:
|
||||
|
||||
}}
|
||||
|
||||
#endif /* oatpp_algorithm_CRC_hpp */
|
||||
#endif /* oatpp_utils_CRC32_hpp */
|
237
src/oatpp/utils/Conversion.cpp
Normal file
237
src/oatpp/utils/Conversion.cpp
Normal file
@ -0,0 +1,237 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* 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 "Conversion.hpp"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
namespace oatpp { namespace utils {
|
||||
|
||||
v_int32 Conversion::strToInt32(const char* str){
|
||||
char* end;
|
||||
return static_cast<v_int32>(std::strtol(str, &end, 10));
|
||||
}
|
||||
|
||||
v_int32 Conversion::strToInt32(const oatpp::String& str, bool& success){
|
||||
char* end;
|
||||
v_int32 result = static_cast<v_int32>(std::strtol(str->data(), &end, 10));
|
||||
success = ((reinterpret_cast<v_buff_size>(end) - reinterpret_cast<v_buff_size>(str->data())) == static_cast<v_buff_size>(str->size()));
|
||||
return result;
|
||||
}
|
||||
|
||||
v_uint32 Conversion::strToUInt32(const char* str){
|
||||
char* end;
|
||||
return static_cast<v_uint32>(std::strtoul(str, &end, 10));
|
||||
}
|
||||
|
||||
v_uint32 Conversion::strToUInt32(const oatpp::String& str, bool& success){
|
||||
char* end;
|
||||
v_uint32 result = static_cast<v_uint32>(std::strtoul(str->data(), &end, 10));
|
||||
success = ((reinterpret_cast<v_buff_size>(end) - reinterpret_cast<v_buff_size>(str->data())) == static_cast<v_buff_size>(str->size()));
|
||||
return result;
|
||||
}
|
||||
|
||||
v_int64 Conversion::strToInt64(const char* str){
|
||||
char* end;
|
||||
return std::strtoll(str, &end, 10);
|
||||
}
|
||||
|
||||
v_int64 Conversion::strToInt64(const oatpp::String& str, bool& success){
|
||||
char* end;
|
||||
v_int64 result = std::strtoll(str->data(), &end, 10);
|
||||
success = ((reinterpret_cast<v_buff_size>(end) - reinterpret_cast<v_buff_size>(str->data())) == static_cast<v_buff_size>(str->size()));
|
||||
return result;
|
||||
}
|
||||
|
||||
v_uint64 Conversion::strToUInt64(const char* str){
|
||||
char* end;
|
||||
return std::strtoull(str, &end, 10);
|
||||
}
|
||||
|
||||
v_uint64 Conversion::strToUInt64(const oatpp::String& str, bool& success){
|
||||
char* end;
|
||||
v_uint64 result = std::strtoull(str->data(), &end, 10);
|
||||
success = ((reinterpret_cast<v_buff_size>(end) - reinterpret_cast<v_buff_size>(str->data())) == static_cast<v_buff_size>(str->size()));
|
||||
return result;
|
||||
}
|
||||
|
||||
v_buff_size Conversion::int32ToCharSequence(v_int32 value, p_char8 data, v_buff_size n) {
|
||||
return snprintf(reinterpret_cast<char*>(data), static_cast<size_t>(n), "%ld", static_cast<long>(value));
|
||||
}
|
||||
|
||||
v_buff_size Conversion::uint32ToCharSequence(v_uint32 value, p_char8 data, v_buff_size n) {
|
||||
return snprintf(reinterpret_cast<char*>(data), static_cast<size_t>(n), "%lu", static_cast<unsigned long>(value));
|
||||
}
|
||||
|
||||
v_buff_size Conversion::int64ToCharSequence(v_int64 value, p_char8 data, v_buff_size n) {
|
||||
return snprintf(reinterpret_cast<char*>(data), static_cast<size_t>(n), "%lld", static_cast<long long int>(value));
|
||||
}
|
||||
|
||||
v_buff_size Conversion::uint64ToCharSequence(v_uint64 value, p_char8 data, v_buff_size n) {
|
||||
return snprintf(reinterpret_cast<char*>(data), static_cast<size_t>(n), "%llu", static_cast<long long unsigned int>(value));
|
||||
}
|
||||
|
||||
oatpp::String Conversion::int32ToStr(v_int32 value){
|
||||
v_char8 buff [16]; // Max 10 digits with 1 sign. 16 is plenty enough.
|
||||
auto size = int32ToCharSequence(value, &buff[0], 16);
|
||||
if(size > 0){
|
||||
return oatpp::String(reinterpret_cast<const char*>(&buff[0]), size);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
oatpp::String Conversion::uint32ToStr(v_uint32 value){
|
||||
v_char8 buff [16]; // Max 10 digits. 16 is plenty enough.
|
||||
auto size = uint32ToCharSequence(value, &buff[0], 16);
|
||||
if(size > 0){
|
||||
return oatpp::String(reinterpret_cast<const char*>(&buff[0]), size);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
oatpp::String Conversion::int64ToStr(v_int64 value){
|
||||
v_char8 buff [32]; // Max 20 digits unsigned, 19 digits +1 sign signed.
|
||||
auto size = int64ToCharSequence(value, &buff[0], 32);
|
||||
if(size > 0){
|
||||
return oatpp::String(reinterpret_cast<const char*>(&buff[0]), size);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
oatpp::String Conversion::uint64ToStr(v_uint64 value){
|
||||
v_char8 buff [32]; // Max 20 digits.
|
||||
auto size = uint64ToCharSequence(value, &buff[0], 32);
|
||||
if(size > 0){
|
||||
return oatpp::String(reinterpret_cast<const char*>(&buff[0]), size);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::string Conversion::int32ToStdStr(v_int32 value){
|
||||
v_char8 buff [16];
|
||||
auto size = int32ToCharSequence(value, &buff[0], 16);
|
||||
if(size > 0){
|
||||
return std::string(reinterpret_cast<const char*>(buff), static_cast<size_t>(size));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::string Conversion::uint32ToStdStr(v_uint32 value){
|
||||
v_char8 buff [16];
|
||||
auto size = uint32ToCharSequence(value, &buff[0], 16);
|
||||
if(size > 0){
|
||||
return std::string(reinterpret_cast<const char*>(buff), static_cast<size_t>(size));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::string Conversion::int64ToStdStr(v_int64 value){
|
||||
v_char8 buff [32];
|
||||
v_int32 size = v_int32(int64ToCharSequence(value, &buff[0], 32));
|
||||
if(size > 0){
|
||||
return std::string(reinterpret_cast<const char*>(buff), static_cast<size_t>(size));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::string Conversion::uint64ToStdStr(v_uint64 value){
|
||||
v_char8 buff [32];
|
||||
auto size = uint64ToCharSequence(value, &buff[0], 32);
|
||||
if(size > 0){
|
||||
return std::string(reinterpret_cast<const char*>(buff), static_cast<size_t>(size));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
v_float32 Conversion::strToFloat32(const char* str){
|
||||
char* end;
|
||||
return std::strtof(str, &end);
|
||||
}
|
||||
|
||||
v_float32 Conversion::strToFloat32(const oatpp::String& str, bool& success) {
|
||||
char* end;
|
||||
v_float32 result = std::strtof(str->data(), &end);
|
||||
success = ((reinterpret_cast<v_buff_size>(end) - reinterpret_cast<v_buff_size>(str->data())) == static_cast<v_buff_size>(str->size()));
|
||||
return result;
|
||||
}
|
||||
|
||||
v_float64 Conversion::strToFloat64(const char* str){
|
||||
char* end;
|
||||
return std::strtod(str, &end);
|
||||
}
|
||||
|
||||
v_float64 Conversion::strToFloat64(const oatpp::String& str, bool& success) {
|
||||
char* end;
|
||||
v_float64 result = std::strtod(str->data(), &end);
|
||||
success = ((reinterpret_cast<v_buff_size>(end) - reinterpret_cast<v_buff_size>(str->data())) == static_cast<v_buff_size>(str->size()));
|
||||
return result;
|
||||
}
|
||||
|
||||
v_buff_size Conversion::float32ToCharSequence(v_float32 value, p_char8 data, v_buff_size n, const char* format) {
|
||||
return snprintf(reinterpret_cast<char*>(data), static_cast<size_t>(n), format, static_cast<double>(value));
|
||||
}
|
||||
|
||||
v_buff_size Conversion::float64ToCharSequence(v_float64 value, p_char8 data, v_buff_size n, const char* format) {
|
||||
return snprintf(reinterpret_cast<char*>(data), static_cast<size_t>(n), format, value);
|
||||
}
|
||||
|
||||
oatpp::String Conversion::float32ToStr(v_float32 value, const char* format) {
|
||||
v_char8 buff [100];
|
||||
auto size = float32ToCharSequence(value, &buff[0], 100, format);
|
||||
if(size > 0){
|
||||
return oatpp::String(reinterpret_cast<const char*>(&buff[0]), size);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
oatpp::String Conversion::float64ToStr(v_float64 value, const char* format) {
|
||||
v_char8 buff [100];
|
||||
auto size = float64ToCharSequence(value, &buff[0], 100, format);
|
||||
if(size > 0){
|
||||
return oatpp::String(reinterpret_cast<const char*>(&buff[0]), size);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
oatpp::String Conversion::boolToStr(bool value) {
|
||||
if(value){
|
||||
return oatpp::String("true", 4);
|
||||
} else {
|
||||
return oatpp::String("false", 5);
|
||||
}
|
||||
}
|
||||
|
||||
bool Conversion::strToBool(const oatpp::String& str, bool& success) {
|
||||
if(str == "true"){
|
||||
success = true;
|
||||
return true;
|
||||
} else if(str == "false"){
|
||||
success = true;
|
||||
return false;
|
||||
}
|
||||
success = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
}}
|
@ -22,8 +22,8 @@
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef oatpp_utils_ConversionUtils_hpp
|
||||
#define oatpp_utils_ConversionUtils_hpp
|
||||
#ifndef oatpp_utils_Conversion_hpp
|
||||
#define oatpp_utils_Conversion_hpp
|
||||
|
||||
#include "oatpp/core/data/mapping/type/Primitive.hpp"
|
||||
#include "oatpp/core/Types.hpp"
|
||||
@ -34,14 +34,20 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace oatpp { namespace utils { namespace conversion {
|
||||
namespace oatpp { namespace utils {
|
||||
|
||||
/**
|
||||
* Conversion utils
|
||||
*/
|
||||
class Conversion {
|
||||
public:
|
||||
|
||||
/**
|
||||
* String to 32-bit integer.
|
||||
* @param str - string as `const char*`.
|
||||
* @return - 32-bit integer value.
|
||||
*/
|
||||
v_int32 strToInt32(const char* str);
|
||||
static v_int32 strToInt32(const char *str);
|
||||
|
||||
/**
|
||||
* String to 32-bit integer.
|
||||
@ -49,14 +55,14 @@ namespace oatpp { namespace utils { namespace conversion {
|
||||
* @param success - out parameter. `true` if operation was successful. `false` otherwise.
|
||||
* @return - 32-bit integer value.
|
||||
*/
|
||||
v_int32 strToInt32(const oatpp::String& str, bool& success);
|
||||
static v_int32 strToInt32(const oatpp::String &str, bool &success);
|
||||
|
||||
/**
|
||||
* String to 32-bit unsigned integer.
|
||||
* @param str - string as `const char*`.
|
||||
* @return - 32-bit unsigned integer value.
|
||||
*/
|
||||
v_uint32 strToUInt32(const char* str);
|
||||
static v_uint32 strToUInt32(const char *str);
|
||||
|
||||
/**
|
||||
* String to 32-bit unsigned integer.
|
||||
@ -64,14 +70,14 @@ namespace oatpp { namespace utils { namespace conversion {
|
||||
* @param success - out parameter. `true` if operation was successful. `false` otherwise.
|
||||
* @return - 32-bit unsigned integer value.
|
||||
*/
|
||||
v_uint32 strToUInt32(const oatpp::String& str, bool& success);
|
||||
static v_uint32 strToUInt32(const oatpp::String &str, bool &success);
|
||||
|
||||
/**
|
||||
* String to 64-bit integer.
|
||||
* @param str - string as `const char*`.
|
||||
* @return - 64-bit integer value.
|
||||
*/
|
||||
v_int64 strToInt64(const char* str);
|
||||
static v_int64 strToInt64(const char *str);
|
||||
|
||||
/**
|
||||
* String to 64-bit integer.
|
||||
@ -79,14 +85,14 @@ namespace oatpp { namespace utils { namespace conversion {
|
||||
* @param success - out parameter. `true` if operation was successful. `false` otherwise.
|
||||
* @return - 64-bit integer value.
|
||||
*/
|
||||
v_int64 strToInt64(const oatpp::String& str, bool& success);
|
||||
static v_int64 strToInt64(const oatpp::String &str, bool &success);
|
||||
|
||||
/**
|
||||
* String to 64-bit unsigned integer.
|
||||
* @param str - string as `const char*`.
|
||||
* @return - 64-bit unsigned integer value.
|
||||
*/
|
||||
v_uint64 strToUInt64(const char* str);
|
||||
static v_uint64 strToUInt64(const char *str);
|
||||
|
||||
/**
|
||||
* String to 64-bit unsigned integer.
|
||||
@ -94,7 +100,7 @@ namespace oatpp { namespace utils { namespace conversion {
|
||||
* @param success - out parameter. `true` if operation was successful. `false` otherwise.
|
||||
* @return - 64-bit unsigned integer value.
|
||||
*/
|
||||
v_uint64 strToUInt64(const oatpp::String& str, bool& success);
|
||||
static v_uint64 strToUInt64(const oatpp::String &str, bool &success);
|
||||
|
||||
/**
|
||||
* Convert 32-bit integer to it's string representation.
|
||||
@ -103,7 +109,7 @@ namespace oatpp { namespace utils { namespace conversion {
|
||||
* @param n - buffer size.
|
||||
* @return - length of the resultant string.
|
||||
*/
|
||||
v_buff_size int32ToCharSequence(v_int32 value, p_char8 data, v_buff_size n);
|
||||
static v_buff_size int32ToCharSequence(v_int32 value, p_char8 data, v_buff_size n);
|
||||
|
||||
/**
|
||||
* Convert 32-bit unsigned integer to it's string representation.
|
||||
@ -112,16 +118,16 @@ namespace oatpp { namespace utils { namespace conversion {
|
||||
* @param n - buffer size.
|
||||
* @return - length of the resultant string.
|
||||
*/
|
||||
v_buff_size uint32ToCharSequence(v_uint32 value, p_char8 data, v_buff_size n);
|
||||
static v_buff_size uint32ToCharSequence(v_uint32 value, p_char8 data, v_buff_size n);
|
||||
|
||||
/**
|
||||
* Convert 64-bit integer to it's string representation.
|
||||
* @param value - 64-bit integer value.
|
||||
* @param data - buffer to write data to.
|
||||
* @param n - buffer size.
|
||||
* @return - length of the resultant string.
|
||||
*/
|
||||
v_buff_size int64ToCharSequence(v_int64 value, p_char8 data, v_buff_size n);
|
||||
/**
|
||||
* Convert 64-bit integer to it's string representation.
|
||||
* @param value - 64-bit integer value.
|
||||
* @param data - buffer to write data to.
|
||||
* @param n - buffer size.
|
||||
* @return - length of the resultant string.
|
||||
*/
|
||||
static v_buff_size int64ToCharSequence(v_int64 value, p_char8 data, v_buff_size n);
|
||||
|
||||
/**
|
||||
* Convert 64-bit unsigned integer to it's string representation.
|
||||
@ -130,63 +136,63 @@ namespace oatpp { namespace utils { namespace conversion {
|
||||
* @param n - buffer size.
|
||||
* @return - length of the resultant string.
|
||||
*/
|
||||
v_buff_size uint64ToCharSequence(v_uint64 value, p_char8 data, v_buff_size n);
|
||||
static v_buff_size uint64ToCharSequence(v_uint64 value, p_char8 data, v_buff_size n);
|
||||
|
||||
/**
|
||||
* Convert 32-bit integer to it's string representation.
|
||||
* @param value - 32-bit integer value.
|
||||
* @return - value as `oatpp::String`
|
||||
*/
|
||||
oatpp::String int32ToStr(v_int32 value);
|
||||
static oatpp::String int32ToStr(v_int32 value);
|
||||
|
||||
/**
|
||||
* Convert 32-bit unsigned integer to it's string representation.
|
||||
* @param value - 32-bit unsigned integer value.
|
||||
* @return - value as `oatpp::String`
|
||||
*/
|
||||
oatpp::String uint32ToStr(v_uint32 value);
|
||||
static oatpp::String uint32ToStr(v_uint32 value);
|
||||
|
||||
/**
|
||||
* Convert 64-bit integer to it's string representation.
|
||||
* @param value - 64-bit integer value.
|
||||
* @return - value as `oatpp::String`
|
||||
*/
|
||||
oatpp::String int64ToStr(v_int64 value);
|
||||
static oatpp::String int64ToStr(v_int64 value);
|
||||
|
||||
/**
|
||||
* Convert 64-bit unsigned integer to it's string representation.
|
||||
* @param value - 64-bit unsigned integer value.
|
||||
* @return - value as `oatpp::String`
|
||||
*/
|
||||
oatpp::String uint64ToStr(v_uint64 value);
|
||||
static oatpp::String uint64ToStr(v_uint64 value);
|
||||
|
||||
/**
|
||||
* Convert 32-bit integer to it's string representation.
|
||||
* @param value - 32-bit integer value.
|
||||
* @return - value as `std::string`
|
||||
*/
|
||||
std::string int32ToStdStr(v_int32 value);
|
||||
static std::string int32ToStdStr(v_int32 value);
|
||||
|
||||
/**
|
||||
* Convert 32-bit unsigned integer to it's string representation.
|
||||
* @param value - 32-bit unsigned integer value.
|
||||
* @return - value as `std::string`
|
||||
*/
|
||||
std::string uint32ToStdStr(v_uint32 value);
|
||||
static std::string uint32ToStdStr(v_uint32 value);
|
||||
|
||||
/**
|
||||
* Convert 64-bit integer to it's string representation.
|
||||
* @param value - 64-bit integer value.
|
||||
* @return - value as `std::string`
|
||||
*/
|
||||
std::string int64ToStdStr(v_int64 value);
|
||||
static std::string int64ToStdStr(v_int64 value);
|
||||
|
||||
/**
|
||||
* Convert 64-bit unsigned integer to it's string representation.
|
||||
* @param value - 64-bit unsigned integer value.
|
||||
* @return - value as `std::string`
|
||||
*/
|
||||
std::string uint64ToStdStr(v_uint64 value);
|
||||
static std::string uint64ToStdStr(v_uint64 value);
|
||||
|
||||
/**
|
||||
* Write value of primitive type (int, float, etc.) as it's string representation with pattern.
|
||||
@ -198,8 +204,8 @@ namespace oatpp { namespace utils { namespace conversion {
|
||||
* @return - length of the resultant string.
|
||||
*/
|
||||
template<typename T>
|
||||
v_buff_size primitiveToCharSequence(T value, p_char8 data, v_buff_size n, const char *pattern) {
|
||||
return snprintf(reinterpret_cast<char*>(data), static_cast<size_t>(n), pattern, value);
|
||||
static v_buff_size primitiveToCharSequence(T value, p_char8 data, v_buff_size n, const char *pattern) {
|
||||
return snprintf(reinterpret_cast<char *>(data), static_cast<size_t>(n), pattern, value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -210,11 +216,11 @@ namespace oatpp { namespace utils { namespace conversion {
|
||||
* @return - length of the resultant string.
|
||||
*/
|
||||
template<typename T>
|
||||
oatpp::String primitiveToStr(T value, const char* pattern){
|
||||
v_char8 buff [100];
|
||||
static oatpp::String primitiveToStr(T value, const char *pattern) {
|
||||
v_char8 buff[100];
|
||||
auto size = primitiveToCharSequence(value, &buff[0], 100, pattern);
|
||||
if(size > 0){
|
||||
return oatpp::String(reinterpret_cast<const char*>(&buff[0]), size);
|
||||
if (size > 0) {
|
||||
return oatpp::String(reinterpret_cast<const char *>(&buff[0]), size);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@ -224,7 +230,7 @@ namespace oatpp { namespace utils { namespace conversion {
|
||||
* @param str - string as `const char*`.
|
||||
* @return - 32-bit float value.
|
||||
*/
|
||||
v_float32 strToFloat32(const char* str);
|
||||
static v_float32 strToFloat32(const char *str);
|
||||
|
||||
/**
|
||||
* String to 32-bit float.
|
||||
@ -232,14 +238,14 @@ namespace oatpp { namespace utils { namespace conversion {
|
||||
* @param success - out parameter. `true` if operation was successful. `false` otherwise.
|
||||
* @return - 32-bit float value.
|
||||
*/
|
||||
v_float32 strToFloat32(const oatpp::String& str, bool& success);
|
||||
static v_float32 strToFloat32(const oatpp::String &str, bool &success);
|
||||
|
||||
/**
|
||||
* String to 64-bit float.
|
||||
* @param str - string as `const char*`.
|
||||
* @return - 64-bit float value.
|
||||
*/
|
||||
v_float64 strToFloat64(const char* str);
|
||||
static v_float64 strToFloat64(const char *str);
|
||||
|
||||
/**
|
||||
* String to 64-bit float.
|
||||
@ -247,7 +253,7 @@ namespace oatpp { namespace utils { namespace conversion {
|
||||
* @param success - out parameter. `true` if operation was successful. `false` otherwise.
|
||||
* @return - 64-bit float value.
|
||||
*/
|
||||
v_float64 strToFloat64(const oatpp::String& str, bool& success);
|
||||
static v_float64 strToFloat64(const oatpp::String &str, bool &success);
|
||||
|
||||
/**
|
||||
* Convert 32-bit float to it's string representation.
|
||||
@ -256,7 +262,7 @@ namespace oatpp { namespace utils { namespace conversion {
|
||||
* @param n - buffer size.
|
||||
* @return - length of the resultant string.
|
||||
*/
|
||||
v_buff_size float32ToCharSequence(v_float32 value, p_char8 data, v_buff_size n, const char* format = OATPP_FLOAT_STRING_FORMAT);
|
||||
static v_buff_size float32ToCharSequence(v_float32 value, p_char8 data, v_buff_size n, const char *format = OATPP_FLOAT_STRING_FORMAT);
|
||||
|
||||
/**
|
||||
* Convert 64-bit float to it's string representation.
|
||||
@ -265,28 +271,28 @@ namespace oatpp { namespace utils { namespace conversion {
|
||||
* @param n - buffer size.
|
||||
* @return - length of the resultant string.
|
||||
*/
|
||||
v_buff_size float64ToCharSequence(v_float64 value, p_char8 data, v_buff_size n, const char* format = OATPP_FLOAT_STRING_FORMAT);
|
||||
static v_buff_size float64ToCharSequence(v_float64 value, p_char8 data, v_buff_size n, const char *format = OATPP_FLOAT_STRING_FORMAT);
|
||||
|
||||
/**
|
||||
* Convert 32-bit float to it's string representation.
|
||||
* @param value - 32-bit float value.
|
||||
* @return - value as `oatpp::String`
|
||||
*/
|
||||
oatpp::String float32ToStr(v_float32 value, const char* format = OATPP_FLOAT_STRING_FORMAT);
|
||||
static oatpp::String float32ToStr(v_float32 value, const char *format = OATPP_FLOAT_STRING_FORMAT);
|
||||
|
||||
/**
|
||||
* Convert 64-bit float to it's string representation.
|
||||
* @param value - 64-bit float value.
|
||||
* @return - value as `oatpp::String`
|
||||
*/
|
||||
oatpp::String float64ToStr(v_float64 value, const char* format = OATPP_FLOAT_STRING_FORMAT);
|
||||
static oatpp::String float64ToStr(v_float64 value, const char *format = OATPP_FLOAT_STRING_FORMAT);
|
||||
|
||||
/**
|
||||
* Convert boolean to it's string representation.
|
||||
* @param value - boolean value.
|
||||
* @return - value as `oatpp::String`;
|
||||
*/
|
||||
oatpp::String boolToStr(bool value);
|
||||
static oatpp::String boolToStr(bool value);
|
||||
|
||||
/**
|
||||
* parse string to boolean value.
|
||||
@ -294,8 +300,10 @@ namespace oatpp { namespace utils { namespace conversion {
|
||||
* @param success - out parameter. `true` if operation was successful. `false` otherwise.
|
||||
* @return - boolean value.
|
||||
*/
|
||||
bool strToBool(const oatpp::String& str, bool& success);
|
||||
|
||||
}}}
|
||||
static bool strToBool(const oatpp::String &str, bool &success);
|
||||
|
||||
#endif /* oatpp_utils_ConversionUtils_hpp */
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif /* oatpp_utils_Conversion_hpp */
|
@ -36,7 +36,7 @@
|
||||
#include "oatpp/core/data/mapping/ObjectMapper.hpp"
|
||||
#include "oatpp/core/Types.hpp"
|
||||
|
||||
#include "oatpp/core/utils/ConversionUtils.hpp"
|
||||
#include "oatpp/utils/Conversion.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
@ -258,7 +258,7 @@ struct ApiClient::TypeInterpretation<oatpp::Int8> {
|
||||
static oatpp::String toString(const oatpp::String &typeName, const oatpp::Int8 ¶meter) {
|
||||
(void) typeName;
|
||||
if (parameter) {
|
||||
return utils::conversion::int32ToStr(*parameter);
|
||||
return utils::Conversion::int32ToStr(*parameter);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@ -269,7 +269,7 @@ struct ApiClient::TypeInterpretation<oatpp::UInt8> {
|
||||
static oatpp::String toString(const oatpp::String &typeName, const oatpp::UInt8 ¶meter) {
|
||||
(void) typeName;
|
||||
if (parameter) {
|
||||
return utils::conversion::uint32ToStr(*parameter);
|
||||
return utils::Conversion::uint32ToStr(*parameter);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@ -280,7 +280,7 @@ struct ApiClient::TypeInterpretation<oatpp::Int16> {
|
||||
static oatpp::String toString(const oatpp::String &typeName, const oatpp::Int16 ¶meter) {
|
||||
(void) typeName;
|
||||
if (parameter) {
|
||||
return utils::conversion::int32ToStr(*parameter);
|
||||
return utils::Conversion::int32ToStr(*parameter);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@ -291,7 +291,7 @@ struct ApiClient::TypeInterpretation<oatpp::UInt16> {
|
||||
static oatpp::String toString(const oatpp::String &typeName, const oatpp::UInt16 ¶meter) {
|
||||
(void) typeName;
|
||||
if (parameter) {
|
||||
return utils::conversion::uint32ToStr(*parameter);
|
||||
return utils::Conversion::uint32ToStr(*parameter);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@ -302,7 +302,7 @@ struct ApiClient::TypeInterpretation<oatpp::Int32> {
|
||||
static oatpp::String toString(const oatpp::String &typeName, const oatpp::Int32 ¶meter) {
|
||||
(void) typeName;
|
||||
if (parameter) {
|
||||
return utils::conversion::int32ToStr(*parameter);
|
||||
return utils::Conversion::int32ToStr(*parameter);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@ -313,7 +313,7 @@ struct ApiClient::TypeInterpretation<oatpp::UInt32> {
|
||||
static oatpp::String toString(const oatpp::String &typeName, const oatpp::UInt32 ¶meter) {
|
||||
(void) typeName;
|
||||
if (parameter) {
|
||||
return utils::conversion::uint32ToStr(*parameter);
|
||||
return utils::Conversion::uint32ToStr(*parameter);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@ -324,7 +324,7 @@ struct ApiClient::TypeInterpretation<oatpp::Int64> {
|
||||
static oatpp::String toString(const oatpp::String &typeName, const oatpp::Int64 ¶meter) {
|
||||
(void) typeName;
|
||||
if (parameter) {
|
||||
return utils::conversion::int64ToStr(*parameter);
|
||||
return utils::Conversion::int64ToStr(*parameter);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@ -335,7 +335,7 @@ struct ApiClient::TypeInterpretation<oatpp::UInt64> {
|
||||
static oatpp::String toString(const oatpp::String &typeName, const oatpp::UInt64 ¶meter) {
|
||||
(void) typeName;
|
||||
if (parameter) {
|
||||
return utils::conversion::uint64ToStr(*parameter);
|
||||
return utils::Conversion::uint64ToStr(*parameter);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@ -346,7 +346,7 @@ struct ApiClient::TypeInterpretation<oatpp::Float32> {
|
||||
static oatpp::String toString(const oatpp::String &typeName, const oatpp::Float32 ¶meter) {
|
||||
(void) typeName;
|
||||
if (parameter) {
|
||||
return utils::conversion::float32ToStr(*parameter);
|
||||
return utils::Conversion::float32ToStr(*parameter);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@ -357,7 +357,7 @@ struct ApiClient::TypeInterpretation<oatpp::Float64> {
|
||||
static oatpp::String toString(const oatpp::String &typeName, const oatpp::Float64 ¶meter) {
|
||||
(void) typeName;
|
||||
if (parameter) {
|
||||
return utils::conversion::float64ToStr(*parameter);
|
||||
return utils::Conversion::float64ToStr(*parameter);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@ -368,7 +368,7 @@ struct ApiClient::TypeInterpretation<oatpp::Boolean> {
|
||||
static oatpp::String toString(const oatpp::String &typeName, const oatpp::Boolean ¶meter) {
|
||||
(void) typeName;
|
||||
if(parameter != nullptr) {
|
||||
return utils::conversion::boolToStr(*parameter);
|
||||
return utils::Conversion::boolToStr(*parameter);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
#include "oatpp/web/protocol/http/Http.hpp"
|
||||
#include "oatpp/encoding/Base64.hpp"
|
||||
#include "oatpp/core/utils/Random.hpp"
|
||||
#include "oatpp/utils/Random.hpp"
|
||||
|
||||
namespace oatpp { namespace web { namespace mime { namespace multipart {
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "./Http.hpp"
|
||||
|
||||
#include "oatpp/core/data/stream/BufferStream.hpp"
|
||||
#include "oatpp/core/utils/ConversionUtils.hpp"
|
||||
#include "oatpp/utils/Conversion.hpp"
|
||||
|
||||
namespace oatpp { namespace web { namespace protocol { namespace http {
|
||||
|
||||
@ -172,8 +172,8 @@ Range Range::parse(oatpp::parser::Caret& caret) {
|
||||
caret.findRN();
|
||||
endLabel.end();
|
||||
|
||||
auto start = oatpp::utils::conversion::strToInt64(startLabel.getData());
|
||||
auto end = oatpp::utils::conversion::strToInt64(endLabel.getData());
|
||||
auto start = oatpp::utils::Conversion::strToInt64(startLabel.getData());
|
||||
auto end = oatpp::utils::Conversion::strToInt64(endLabel.getData());
|
||||
return Range(unitsLabel.toString(), start, end);
|
||||
|
||||
}
|
||||
@ -232,13 +232,13 @@ ContentRange ContentRange::parse(oatpp::parser::Caret& caret) {
|
||||
caret.findRN();
|
||||
sizeLabel.end();
|
||||
|
||||
v_int64 start = oatpp::utils::conversion::strToInt64(startLabel.getData());
|
||||
v_int64 end = oatpp::utils::conversion::strToInt64(endLabel.getData());
|
||||
v_int64 start = oatpp::utils::Conversion::strToInt64(startLabel.getData());
|
||||
v_int64 end = oatpp::utils::Conversion::strToInt64(endLabel.getData());
|
||||
v_int64 size = 0;
|
||||
bool isSizeKnown = false;
|
||||
if(sizeLabel.getData()[0] != '*') {
|
||||
isSizeKnown = true;
|
||||
size = oatpp::utils::conversion::strToInt64(sizeLabel.getData());
|
||||
size = oatpp::utils::Conversion::strToInt64(sizeLabel.getData());
|
||||
}
|
||||
|
||||
return ContentRange(unitsLabel.toString(), start, end, size, isSizeKnown);
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include "Chunked.hpp"
|
||||
|
||||
#include "oatpp/core/utils/ConversionUtils.hpp"
|
||||
#include "oatpp/utils/Conversion.hpp"
|
||||
|
||||
namespace oatpp { namespace web { namespace protocol { namespace http { namespace encoding {
|
||||
|
||||
@ -65,7 +65,7 @@ v_int32 EncoderChunked::iterate(data::buffer::InlineReadData& dataIn, data::buff
|
||||
stream.write("\r\n", 2, action);
|
||||
}
|
||||
|
||||
stream << utils::conversion::primitiveToStr(dataIn.bytesLeft, "%X");
|
||||
stream << utils::Conversion::primitiveToStr(dataIn.bytesLeft, "%X");
|
||||
stream.write("\r\n", 2, action);
|
||||
|
||||
m_chunkHeader = stream.toString();
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "SimpleBodyDecoder.hpp"
|
||||
|
||||
#include "oatpp/web/protocol/http/encoding/Chunked.hpp"
|
||||
#include "oatpp/core/utils/ConversionUtils.hpp"
|
||||
#include "oatpp/utils/Conversion.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
@ -125,7 +125,7 @@ void SimpleBodyDecoder::decode(const Headers& headers,
|
||||
if(contentLengthStr) {
|
||||
|
||||
bool success;
|
||||
auto contentLength = utils::conversion::strToInt64(contentLengthStr.toString(), success);
|
||||
auto contentLength = utils::Conversion::strToInt64(contentLengthStr.toString(), success);
|
||||
|
||||
if (success && contentLength > 0) {
|
||||
|
||||
@ -179,7 +179,7 @@ async::CoroutineStarter SimpleBodyDecoder::decodeAsync(const Headers& headers,
|
||||
if(contentLengthStr) {
|
||||
|
||||
bool success;
|
||||
auto contentLength = utils::conversion::strToInt64(contentLengthStr.toString(), success);
|
||||
auto contentLength = utils::Conversion::strToInt64(contentLengthStr.toString(), success);
|
||||
|
||||
if (success && contentLength > 0) {
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "oatpp/web/protocol/http/encoding/Chunked.hpp"
|
||||
#include "oatpp/core/data/stream/BufferStream.hpp"
|
||||
#include "oatpp/core/data/buffer/IOBuffer.hpp"
|
||||
#include "oatpp/core/utils/ConversionUtils.hpp"
|
||||
#include "oatpp/utils/Conversion.hpp"
|
||||
|
||||
namespace oatpp { namespace web { namespace protocol { namespace http { namespace outgoing {
|
||||
|
||||
@ -112,7 +112,7 @@ void Request::send(data::stream::OutputStream* stream){
|
||||
bodySize = m_body->getKnownSize();
|
||||
|
||||
if(bodySize >= 0) {
|
||||
m_headers.put_LockFree(Header::CONTENT_LENGTH, utils::conversion::int64ToStr(bodySize));
|
||||
m_headers.put_LockFree(Header::CONTENT_LENGTH, utils::Conversion::int64ToStr(bodySize));
|
||||
} else {
|
||||
m_headers.put_LockFree(Header::TRANSFER_ENCODING, Header::Value::TRANSFER_ENCODING_CHUNKED);
|
||||
}
|
||||
@ -193,7 +193,7 @@ oatpp::async::CoroutineStarter Request::sendAsync(std::shared_ptr<Request> _this
|
||||
bodySize = m_this->m_body->getKnownSize();
|
||||
|
||||
if(bodySize >= 0) {
|
||||
m_this->m_headers.put_LockFree(Header::CONTENT_LENGTH, utils::conversion::int64ToStr(bodySize));
|
||||
m_this->m_headers.put_LockFree(Header::CONTENT_LENGTH, utils::Conversion::int64ToStr(bodySize));
|
||||
} else {
|
||||
m_this->m_headers.put_LockFree(Header::TRANSFER_ENCODING, Header::Value::TRANSFER_ENCODING_CHUNKED);
|
||||
}
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "./Response.hpp"
|
||||
|
||||
#include "oatpp/web/protocol/http/encoding/Chunked.hpp"
|
||||
#include "oatpp/core/utils/ConversionUtils.hpp"
|
||||
#include "oatpp/utils/Conversion.hpp"
|
||||
|
||||
namespace oatpp { namespace web { namespace protocol { namespace http { namespace outgoing {
|
||||
|
||||
@ -121,7 +121,7 @@ void Response::send(data::stream::OutputStream* stream,
|
||||
bodySize = m_body->getKnownSize();
|
||||
|
||||
if (bodySize >= 0) {
|
||||
m_headers.put_LockFree(Header::CONTENT_LENGTH, utils::conversion::int64ToStr(bodySize));
|
||||
m_headers.put_LockFree(Header::CONTENT_LENGTH, utils::Conversion::int64ToStr(bodySize));
|
||||
} else {
|
||||
m_headers.put_LockFree(Header::TRANSFER_ENCODING, Header::Value::TRANSFER_ENCODING_CHUNKED);
|
||||
}
|
||||
@ -238,7 +238,7 @@ oatpp::async::CoroutineStarter Response::sendAsync(const std::shared_ptr<Respons
|
||||
bodySize = m_this->m_body->getKnownSize();
|
||||
|
||||
if (bodySize >= 0) {
|
||||
m_this->m_headers.put_LockFree(Header::CONTENT_LENGTH, utils::conversion::int64ToStr(bodySize));
|
||||
m_this->m_headers.put_LockFree(Header::CONTENT_LENGTH, utils::Conversion::int64ToStr(bodySize));
|
||||
} else {
|
||||
m_this->m_headers.put_LockFree(Header::TRANSFER_ENCODING, Header::Value::TRANSFER_ENCODING_CHUNKED);
|
||||
}
|
||||
|
@ -34,7 +34,7 @@
|
||||
#include "oatpp/web/protocol/http/outgoing/Request.hpp"
|
||||
#include "oatpp/web/protocol/http/outgoing/ResponseFactory.hpp"
|
||||
|
||||
#include "oatpp/core/utils/ConversionUtils.hpp"
|
||||
#include "oatpp/utils/Conversion.hpp"
|
||||
|
||||
#include <list>
|
||||
#include <unordered_map>
|
||||
@ -461,7 +461,7 @@ struct ApiController::TypeInterpretation <oatpp::Int8> {
|
||||
static oatpp::Int8 fromString(const oatpp::String& typeName, const oatpp::String& text, bool& success) {
|
||||
(void) typeName;
|
||||
//TODO: check the range and perhaps throw an exception if the variable doesn't fit
|
||||
return static_cast<Int8::UnderlyingType>(utils::conversion::strToInt32(text, success));
|
||||
return static_cast<Int8::UnderlyingType>(utils::Conversion::strToInt32(text, success));
|
||||
}
|
||||
};
|
||||
|
||||
@ -470,7 +470,7 @@ struct ApiController::TypeInterpretation <oatpp::UInt8> {
|
||||
static oatpp::UInt8 fromString(const oatpp::String& typeName, const oatpp::String& text, bool& success) {
|
||||
(void) typeName;
|
||||
//TODO: check the range and perhaps throw an exception if the variable doesn't fit
|
||||
return static_cast<UInt8::UnderlyingType>(utils::conversion::strToUInt32(text, success));
|
||||
return static_cast<UInt8::UnderlyingType>(utils::Conversion::strToUInt32(text, success));
|
||||
}
|
||||
};
|
||||
|
||||
@ -479,7 +479,7 @@ struct ApiController::TypeInterpretation <oatpp::Int16> {
|
||||
static oatpp::Int16 fromString(const oatpp::String& typeName, const oatpp::String& text, bool& success) {
|
||||
(void) typeName;
|
||||
//TODO: check the range and perhaps throw an exception if the variable doesn't fit
|
||||
return static_cast<Int16::UnderlyingType>(utils::conversion::strToInt32(text, success));
|
||||
return static_cast<Int16::UnderlyingType>(utils::Conversion::strToInt32(text, success));
|
||||
}
|
||||
};
|
||||
|
||||
@ -488,7 +488,7 @@ struct ApiController::TypeInterpretation <oatpp::UInt16> {
|
||||
static oatpp::UInt16 fromString(const oatpp::String& typeName, const oatpp::String& text, bool& success) {
|
||||
(void) typeName;
|
||||
//TODO: check the range and perhaps throw an exception if the variable doesn't fit
|
||||
return static_cast<UInt16::UnderlyingType>(utils::conversion::strToUInt32(text, success));
|
||||
return static_cast<UInt16::UnderlyingType>(utils::Conversion::strToUInt32(text, success));
|
||||
}
|
||||
};
|
||||
|
||||
@ -496,7 +496,7 @@ template<>
|
||||
struct ApiController::TypeInterpretation <oatpp::Int32> {
|
||||
static oatpp::Int32 fromString(const oatpp::String& typeName, const oatpp::String& text, bool& success) {
|
||||
(void) typeName;
|
||||
return utils::conversion::strToInt32(text, success);
|
||||
return utils::Conversion::strToInt32(text, success);
|
||||
}
|
||||
};
|
||||
|
||||
@ -504,7 +504,7 @@ template<>
|
||||
struct ApiController::TypeInterpretation <oatpp::UInt32> {
|
||||
static oatpp::UInt32 fromString(const oatpp::String& typeName, const oatpp::String& text, bool& success) {
|
||||
(void) typeName;
|
||||
return utils::conversion::strToUInt32(text, success);
|
||||
return utils::Conversion::strToUInt32(text, success);
|
||||
}
|
||||
};
|
||||
|
||||
@ -512,7 +512,7 @@ template<>
|
||||
struct ApiController::TypeInterpretation <oatpp::Int64> {
|
||||
static oatpp::Int64 fromString(const oatpp::String& typeName, const oatpp::String& text, bool& success) {
|
||||
(void) typeName;
|
||||
return utils::conversion::strToInt64(text, success);
|
||||
return utils::Conversion::strToInt64(text, success);
|
||||
}
|
||||
};
|
||||
|
||||
@ -520,7 +520,7 @@ template<>
|
||||
struct ApiController::TypeInterpretation <oatpp::UInt64> {
|
||||
static oatpp::UInt64 fromString(const oatpp::String& typeName, const oatpp::String& text, bool& success) {
|
||||
(void) typeName;
|
||||
return utils::conversion::strToUInt64(text, success);
|
||||
return utils::Conversion::strToUInt64(text, success);
|
||||
}
|
||||
};
|
||||
|
||||
@ -528,7 +528,7 @@ template<>
|
||||
struct ApiController::TypeInterpretation <oatpp::Float32> {
|
||||
static oatpp::Float32 fromString(const oatpp::String& typeName, const oatpp::String& text, bool& success) {
|
||||
(void) typeName;
|
||||
return utils::conversion::strToFloat32(text, success);
|
||||
return utils::Conversion::strToFloat32(text, success);
|
||||
}
|
||||
};
|
||||
|
||||
@ -536,7 +536,7 @@ template<>
|
||||
struct ApiController::TypeInterpretation <oatpp::Float64> {
|
||||
static oatpp::Float64 fromString(const oatpp::String& typeName, const oatpp::String& text, bool& success) {
|
||||
(void) typeName;
|
||||
return utils::conversion::strToFloat64(text, success);
|
||||
return utils::Conversion::strToFloat64(text, success);
|
||||
}
|
||||
};
|
||||
|
||||
@ -544,7 +544,7 @@ template<>
|
||||
struct ApiController::TypeInterpretation <oatpp::Boolean> {
|
||||
static oatpp::Boolean fromString(const oatpp::String& typeName, const oatpp::String& text, bool& success) {
|
||||
(void) typeName;
|
||||
return utils::conversion::strToBool(text, success);
|
||||
return utils::Conversion::strToBool(text, success);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -25,8 +25,8 @@
|
||||
#include "BufferStreamTest.hpp"
|
||||
|
||||
#include "oatpp/core/data/stream/BufferStream.hpp"
|
||||
#include "oatpp/core/utils/ConversionUtils.hpp"
|
||||
#include "oatpp/core/utils/Binary.hpp"
|
||||
#include "oatpp/utils/Conversion.hpp"
|
||||
#include "oatpp/utils/Binary.hpp"
|
||||
|
||||
namespace oatpp { namespace test { namespace core { namespace data { namespace stream {
|
||||
|
||||
@ -44,15 +44,15 @@ void BufferStreamTest::onRun() {
|
||||
|
||||
stream.setCurrentPosition(0);
|
||||
stream << 101;
|
||||
OATPP_ASSERT(stream.toString() == oatpp::utils::conversion::int32ToStr(101))
|
||||
OATPP_ASSERT(stream.toString() == oatpp::utils::Conversion::int32ToStr(101))
|
||||
|
||||
stream.setCurrentPosition(0);
|
||||
stream << static_cast<v_float32>(101.5);
|
||||
OATPP_ASSERT(stream.toString() == oatpp::utils::conversion::float32ToStr(101.5f))
|
||||
OATPP_ASSERT(stream.toString() == oatpp::utils::Conversion::float32ToStr(101.5f))
|
||||
|
||||
stream.setCurrentPosition(0);
|
||||
stream << static_cast<v_float64>(101.5f);
|
||||
OATPP_ASSERT(stream.toString() == oatpp::utils::conversion::float64ToStr(101.5))
|
||||
OATPP_ASSERT(stream.toString() == oatpp::utils::Conversion::float64ToStr(101.5))
|
||||
|
||||
stream.setCurrentPosition(0);
|
||||
stream << true;
|
||||
@ -68,27 +68,27 @@ void BufferStreamTest::onRun() {
|
||||
|
||||
stream.setCurrentPosition(0);
|
||||
stream << oatpp::Int8(8);
|
||||
OATPP_ASSERT(stream.toString() == oatpp::utils::conversion::int32ToStr(8))
|
||||
OATPP_ASSERT(stream.toString() == oatpp::utils::Conversion::int32ToStr(8))
|
||||
|
||||
stream.setCurrentPosition(0);
|
||||
stream << oatpp::Int16(16);
|
||||
OATPP_ASSERT(stream.toString() == oatpp::utils::conversion::int32ToStr(16))
|
||||
OATPP_ASSERT(stream.toString() == oatpp::utils::Conversion::int32ToStr(16))
|
||||
|
||||
stream.setCurrentPosition(0);
|
||||
stream << oatpp::Int32(32);
|
||||
OATPP_ASSERT(stream.toString() == oatpp::utils::conversion::int32ToStr(32))
|
||||
OATPP_ASSERT(stream.toString() == oatpp::utils::Conversion::int32ToStr(32))
|
||||
|
||||
stream.setCurrentPosition(0);
|
||||
stream << oatpp::Int64(64);
|
||||
OATPP_ASSERT(stream.toString() == oatpp::utils::conversion::int32ToStr(64))
|
||||
OATPP_ASSERT(stream.toString() == oatpp::utils::Conversion::int32ToStr(64))
|
||||
|
||||
stream.setCurrentPosition(0);
|
||||
stream << oatpp::Float32(0.32f);
|
||||
OATPP_ASSERT(stream.toString() == oatpp::utils::conversion::float32ToStr(0.32f))
|
||||
OATPP_ASSERT(stream.toString() == oatpp::utils::Conversion::float32ToStr(0.32f))
|
||||
|
||||
stream.setCurrentPosition(0);
|
||||
stream << oatpp::Float64(0.64);
|
||||
OATPP_ASSERT(stream.toString() == oatpp::utils::conversion::float64ToStr(0.64))
|
||||
OATPP_ASSERT(stream.toString() == oatpp::utils::Conversion::float64ToStr(0.64))
|
||||
|
||||
stream.setCurrentPosition(0);
|
||||
stream << oatpp::Boolean(true);
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include "UrlTest.hpp"
|
||||
|
||||
#include "oatpp/core/utils/Random.hpp"
|
||||
#include "oatpp/utils/Random.hpp"
|
||||
#include "oatpp/encoding/Url.hpp"
|
||||
|
||||
namespace oatpp { namespace test { namespace encoding {
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "oatpp/core/data/mapping/type/List.hpp"
|
||||
#include "oatpp/core/data/mapping/type/Primitive.hpp"
|
||||
|
||||
#include "oatpp/core/utils/ConversionUtils.hpp"
|
||||
#include "oatpp/utils/Conversion.hpp"
|
||||
|
||||
#include "oatpp/core/macro/codegen.hpp"
|
||||
|
||||
@ -307,8 +307,8 @@ void DTOMapperTest::onRun(){
|
||||
auto c = obj1->field_fields;
|
||||
v_int32 i = 0;
|
||||
for(auto& pair : *c) {
|
||||
OATPP_ASSERT(pair.first == "key" + oatpp::utils::conversion::int32ToStr(i))
|
||||
OATPP_ASSERT(pair.second == "pair_item" + oatpp::utils::conversion::int32ToStr(i))
|
||||
OATPP_ASSERT(pair.first == "key" + oatpp::utils::Conversion::int32ToStr(i))
|
||||
OATPP_ASSERT(pair.second == "pair_item" + oatpp::utils::Conversion::int32ToStr(i))
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
@ -275,7 +275,7 @@ void FullAsyncTest::onRun() {
|
||||
auto value = response->readBodyToString();
|
||||
auto host = clientConnectionProvider->getProperty("host");
|
||||
OATPP_ASSERT(host)
|
||||
OATPP_ASSERT(value == host.toString() + ":" + oatpp::utils::conversion::int32ToStr(m_port))
|
||||
OATPP_ASSERT(value == host.toString() + ":" + oatpp::utils::Conversion::int32ToStr(m_port))
|
||||
}
|
||||
|
||||
if((i + 1) % iterationsStep == 0) {
|
||||
|
@ -284,7 +284,7 @@ void FullTest::onRun() {
|
||||
OATPP_ASSERT(dto->testMap->size() == 3)
|
||||
OATPP_ASSERT(dto->testMap["key1"] == "value1")
|
||||
OATPP_ASSERT(dto->testMap["key2"] == "32")
|
||||
OATPP_ASSERT(dto->testMap["key3"] == oatpp::utils::conversion::float32ToStr(0.32f))
|
||||
OATPP_ASSERT(dto->testMap["key3"] == oatpp::utils::Conversion::float32ToStr(0.32f))
|
||||
}
|
||||
|
||||
{ // test GET with header parameter
|
||||
@ -563,7 +563,7 @@ void FullTest::onRun() {
|
||||
auto value = response->readBodyToString();
|
||||
auto host = clientConnectionProvider->getProperty("host");
|
||||
OATPP_ASSERT(host)
|
||||
OATPP_ASSERT(value == host.toString() + ":" + oatpp::utils::conversion::int32ToStr(m_port))
|
||||
OATPP_ASSERT(value == host.toString() + ":" + oatpp::utils::Conversion::int32ToStr(m_port))
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
#include "oatpp/web/server/api/ApiController.hpp"
|
||||
#include "oatpp/json/ObjectMapper.hpp"
|
||||
#include "oatpp/core/utils/ConversionUtils.hpp"
|
||||
#include "oatpp/utils/Conversion.hpp"
|
||||
#include "oatpp/core/macro/codegen.hpp"
|
||||
#include "oatpp/core/macro/component.hpp"
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
#include "oatpp/web/server/api/ApiController.hpp"
|
||||
#include "oatpp/json/ObjectMapper.hpp"
|
||||
#include "oatpp/core/utils/ConversionUtils.hpp"
|
||||
#include "oatpp/utils/Conversion.hpp"
|
||||
#include "oatpp/core/macro/codegen.hpp"
|
||||
#include "oatpp/core/macro/component.hpp"
|
||||
|
||||
|
@ -40,7 +40,7 @@
|
||||
|
||||
#include "oatpp/core/data/resource/File.hpp"
|
||||
#include "oatpp/core/data/stream/FileStream.hpp"
|
||||
#include "oatpp/core/utils/ConversionUtils.hpp"
|
||||
#include "oatpp/utils/Conversion.hpp"
|
||||
#include "oatpp/core/macro/codegen.hpp"
|
||||
#include "oatpp/core/macro/component.hpp"
|
||||
|
||||
@ -114,14 +114,14 @@ public:
|
||||
ENDPOINT("GET", "queries", getWithQueries,
|
||||
QUERY(String, name), QUERY(Int32, age)) {
|
||||
auto dto = TestDto::createShared();
|
||||
dto->testValue = "name=" + name + "&age=" + oatpp::utils::conversion::int32ToStr(*age);
|
||||
dto->testValue = "name=" + name + "&age=" + oatpp::utils::Conversion::int32ToStr(*age);
|
||||
return createDtoResponse(Status::CODE_200, dto);
|
||||
}
|
||||
|
||||
ENDPOINT("GET", "queries/optional", getWithOptQueries,
|
||||
QUERY(String, name, "name", "Default"), QUERY(Int32, age, "age", 101)) {
|
||||
auto dto = TestDto::createShared();
|
||||
dto->testValue = "name=" + name + "&age=" + oatpp::utils::conversion::int32ToStr(*age);
|
||||
dto->testValue = "name=" + name + "&age=" + oatpp::utils::Conversion::int32ToStr(*age);
|
||||
return createDtoResponse(Status::CODE_200, dto);
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@
|
||||
#include "oatpp/core/data/resource/File.hpp"
|
||||
#include "oatpp/core/data/stream/FileStream.hpp"
|
||||
#include "oatpp/core/data/stream/Stream.hpp"
|
||||
#include "oatpp/core/utils/ConversionUtils.hpp"
|
||||
#include "oatpp/utils/Conversion.hpp"
|
||||
#include "oatpp/core/macro/codegen.hpp"
|
||||
#include "oatpp/core/macro/component.hpp"
|
||||
|
||||
@ -190,7 +190,7 @@ public:
|
||||
|
||||
Action act() override {
|
||||
oatpp::String text = request->getPathVariable("text-value");
|
||||
auto numIterations = oatpp::utils::conversion::strToInt32(request->getPathVariable("num-iterations")->c_str());
|
||||
auto numIterations = oatpp::utils::Conversion::strToInt32(request->getPathVariable("num-iterations")->c_str());
|
||||
|
||||
auto body = std::make_shared<oatpp::web::protocol::http::outgoing::StreamingBody>
|
||||
(std::make_shared<ReadCallback>(text, numIterations));
|
||||
@ -209,7 +209,7 @@ public:
|
||||
|
||||
Action act() override {
|
||||
|
||||
m_chunkSize = oatpp::utils::conversion::strToInt32(request->getPathVariable("chunk-size")->c_str());
|
||||
m_chunkSize = oatpp::utils::Conversion::strToInt32(request->getPathVariable("chunk-size")->c_str());
|
||||
|
||||
m_multipart = std::make_shared<oatpp::web::mime::multipart::PartList>(request->getHeaders());
|
||||
auto multipartReader = std::make_shared<oatpp::web::mime::multipart::AsyncReader>(m_multipart);
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
#include "oatpp/web/server/api/ApiController.hpp"
|
||||
#include "oatpp/json/ObjectMapper.hpp"
|
||||
#include "oatpp/core/utils/ConversionUtils.hpp"
|
||||
#include "oatpp/utils/Conversion.hpp"
|
||||
#include "oatpp/core/macro/codegen.hpp"
|
||||
#include "oatpp/core/macro/component.hpp"
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
#include "oatpp/web/server/api/ApiController.hpp"
|
||||
#include "oatpp/json/ObjectMapper.hpp"
|
||||
#include "oatpp/core/utils/ConversionUtils.hpp"
|
||||
#include "oatpp/utils/Conversion.hpp"
|
||||
#include "oatpp/core/macro/codegen.hpp"
|
||||
#include "oatpp/core/macro/component.hpp"
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
#include "oatpp/web/server/api/ApiController.hpp"
|
||||
#include "oatpp/json/ObjectMapper.hpp"
|
||||
#include "oatpp/core/utils/ConversionUtils.hpp"
|
||||
#include "oatpp/utils/Conversion.hpp"
|
||||
#include "oatpp/core/macro/codegen.hpp"
|
||||
#include "oatpp/core/macro/component.hpp"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user