mirror of
https://gitee.com/zyjblog/oatpp.git
synced 2024-12-22 22:16:37 +08:00
Merge pull request #842 from fhuberts/fix-Wsign-conversion
Fix compiler warnings in compilation units (-Wsign-conversion)
This commit is contained in:
commit
cc09632a14
@ -128,7 +128,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
||||
add_compiler_flags(4.6 "-Wpointer-arith")
|
||||
add_compiler_flags(4.6 "-Wredundant-decls")
|
||||
add_compiler_flags(4.6 "-Wshadow")
|
||||
#add_compiler_flags(4.6 "-Wsign-conversion")
|
||||
add_compiler_flags(4.6 "-Wsign-conversion")
|
||||
#add_compiler_flags(4.6 "-Wsuggest-attribute=const")
|
||||
add_compiler_flags(4.6 "-Wsuggest-attribute=noreturn")
|
||||
#add_compiler_flags(4.6 "-Wsuggest-attribute=pure")
|
||||
|
@ -31,8 +31,8 @@ const p_uint32 CRC32::TABLE_04C11DB7 = generateTable(0x04C11DB7);
|
||||
v_uint32 CRC32::bitReverse(v_uint32 poly) {
|
||||
v_uint32 result = 0;
|
||||
for(v_int32 i = 0; i < 32; i ++) {
|
||||
if((poly & (1 << i)) > 0) {
|
||||
result |= 1 << (31 - i);
|
||||
if((poly & (1U << i)) > 0) {
|
||||
result |= (1U << (31 - i));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@ -44,7 +44,7 @@ p_uint32 CRC32::generateTable(v_uint32 poly) {
|
||||
v_uint32 polyReverse = bitReverse(poly);
|
||||
v_uint32 value;
|
||||
|
||||
for(v_int32 i = 0; i < 256; i++) {
|
||||
for(v_uint32 i = 0; i < 256; i++) {
|
||||
value = i;
|
||||
for (v_int32 bit = 0; bit < 8; bit++) {
|
||||
if (value & 1) {
|
||||
@ -64,7 +64,7 @@ p_uint32 CRC32::generateTable(v_uint32 poly) {
|
||||
|
||||
v_uint32 CRC32::calc(const void *buffer, v_buff_size size, v_uint32 crc, v_uint32 initValue, v_uint32 xorOut, p_uint32 table) {
|
||||
|
||||
auto data = reinterpret_cast<const char*>(buffer);
|
||||
auto data = reinterpret_cast<const unsigned char*>(buffer);
|
||||
crc = crc ^ initValue;
|
||||
|
||||
for(v_buff_size i = 0; i < size; i++) {
|
||||
|
@ -28,6 +28,10 @@
|
||||
#include "oatpp/core/async/Error.hpp"
|
||||
#include "oatpp/core/Types.hpp"
|
||||
|
||||
#if !defined(WIN32) && !defined(_WIN32)
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
namespace oatpp {
|
||||
|
||||
/**
|
||||
@ -39,9 +43,11 @@ namespace oatpp {
|
||||
#else
|
||||
typedef unsigned long v_io_handle;
|
||||
#endif
|
||||
typedef int v_sock_size;
|
||||
constexpr const v_io_handle INVALID_IO_HANDLE = v_io_handle (-1);
|
||||
#else
|
||||
typedef int v_io_handle;
|
||||
typedef socklen_t v_sock_size;
|
||||
constexpr const v_io_handle INVALID_IO_HANDLE = (-1);
|
||||
#endif
|
||||
|
||||
|
@ -94,7 +94,7 @@ Executor::Executor(v_int32 processorWorkersCount, v_int32 ioWorkersCount, v_int3
|
||||
m_allWorkers.insert(m_allWorkers.end(), m_processorWorkers.begin(), m_processorWorkers.end());
|
||||
|
||||
std::vector<std::shared_ptr<worker::Worker>> ioWorkers;
|
||||
ioWorkers.reserve(ioWorkersCount);
|
||||
ioWorkers.reserve(static_cast<size_t>(ioWorkersCount));
|
||||
switch(ioWorkerType) {
|
||||
|
||||
case IO_WORKER_TYPE_NAIVE: {
|
||||
@ -119,7 +119,7 @@ Executor::Executor(v_int32 processorWorkersCount, v_int32 ioWorkersCount, v_int3
|
||||
linkWorkers(ioWorkers);
|
||||
|
||||
std::vector<std::shared_ptr<worker::Worker>> timerWorkers;
|
||||
timerWorkers.reserve(timerWorkersCount);
|
||||
timerWorkers.reserve(static_cast<size_t>(timerWorkersCount));
|
||||
for(v_int32 i = 0; i < timerWorkersCount; i++) {
|
||||
timerWorkers.push_back(std::make_shared<worker::TimerWorker>());
|
||||
}
|
||||
|
@ -138,42 +138,42 @@ void DefaultLogger::enablePriority(v_uint32 priority) {
|
||||
if (priority > PRIORITY_E) {
|
||||
return;
|
||||
}
|
||||
m_config.logMask |= (1 << priority);
|
||||
m_config.logMask |= (1U << priority);
|
||||
}
|
||||
|
||||
void DefaultLogger::disablePriority(v_uint32 priority) {
|
||||
if (priority > PRIORITY_E) {
|
||||
return;
|
||||
}
|
||||
m_config.logMask &= ~(1 << priority);
|
||||
m_config.logMask &= ~(1U << priority);
|
||||
}
|
||||
|
||||
bool DefaultLogger::isLogPriorityEnabled(v_uint32 priority) {
|
||||
if (priority > PRIORITY_E) {
|
||||
return true;
|
||||
}
|
||||
return m_config.logMask & (1 << priority);
|
||||
return m_config.logMask & (1U << priority);
|
||||
}
|
||||
|
||||
void LogCategory::enablePriority(v_uint32 priority) {
|
||||
if (priority > Logger::PRIORITY_E) {
|
||||
return;
|
||||
}
|
||||
enabledPriorities |= (1 << priority);
|
||||
enabledPriorities |= (1U << priority);
|
||||
}
|
||||
|
||||
void LogCategory::disablePriority(v_uint32 priority) {
|
||||
if (priority > Logger::PRIORITY_E) {
|
||||
return;
|
||||
}
|
||||
enabledPriorities &= ~(1 << priority);
|
||||
enabledPriorities &= ~(1U << priority);
|
||||
}
|
||||
|
||||
bool LogCategory::isLogPriorityEnabled(v_uint32 priority) {
|
||||
if (priority > Logger::PRIORITY_E) {
|
||||
return true;
|
||||
}
|
||||
return enabledPriorities & (1 << priority);
|
||||
return enabledPriorities & (1U << priority);
|
||||
}
|
||||
|
||||
void Environment::init() {
|
||||
@ -333,7 +333,7 @@ void Environment::log(v_uint32 priority, const std::string& tag, const std::stri
|
||||
|
||||
|
||||
void Environment::logFormatted(v_uint32 priority, const LogCategory& category, const char* message, ...) {
|
||||
if (category.categoryEnabled && (category.enabledPriorities & (1 << priority))) {
|
||||
if (category.categoryEnabled && (category.enabledPriorities & (1U << priority))) {
|
||||
va_list args;
|
||||
va_start(args, message);
|
||||
vlogFormatted(priority, category.tag, message, args);
|
||||
@ -367,9 +367,9 @@ void Environment::vlogFormatted(v_uint32 priority, const std::string& tag, const
|
||||
allocsize = m_logger->getMaxFormattingBufferSize();
|
||||
}
|
||||
auto buffer = std::unique_ptr<char[]>(new char[allocsize]);
|
||||
memset(buffer.get(), 0, allocsize);
|
||||
memset(buffer.get(), 0, static_cast<size_t>(allocsize));
|
||||
// actually format
|
||||
vsnprintf(buffer.get(), allocsize, message, args);
|
||||
vsnprintf(buffer.get(), static_cast<size_t>(allocsize), message, args);
|
||||
// call (user) providen log function
|
||||
log(priority, tag, buffer.get());
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ v_int32 setThreadAffinityToCpuRange(std::thread::native_handle_type nativeHandle
|
||||
CPU_ZERO(&cpuset);
|
||||
|
||||
for(v_int32 i = firstCpuIndex; i <= lastCpuIndex; i++) {
|
||||
CPU_SET(i, &cpuset);
|
||||
CPU_SET(static_cast<size_t>(i), &cpuset);
|
||||
}
|
||||
|
||||
v_int32 result = pthread_setaffinity_np(nativeHandle, sizeof(cpu_set_t), &cpuset);
|
||||
@ -76,7 +76,7 @@ v_int32 setThreadAffinityToCpuRange(std::thread::native_handle_type nativeHandle
|
||||
|
||||
static v_int32 calcHardwareConcurrency() {
|
||||
#if !defined(OATPP_THREAD_HARDWARE_CONCURRENCY)
|
||||
v_int32 concurrency = std::thread::hardware_concurrency();
|
||||
v_int32 concurrency = static_cast<v_int32>(std::thread::hardware_concurrency());
|
||||
if(concurrency == 0) {
|
||||
OATPP_LOGD("[oatpp::concurrency:Thread::calcHardwareConcurrency()]", "Warning - failed to get hardware_concurrency. Setting hardware_concurrency=1");
|
||||
concurrency = 1;
|
||||
|
@ -102,7 +102,7 @@ v_int32 ProcessingPipeline::iterate(data::buffer::InlineReadData& dataIn,
|
||||
return Error::FLUSH_DATA_OUT;
|
||||
}
|
||||
|
||||
v_buff_size i = 0;
|
||||
size_t i = 0;
|
||||
v_int32 res = Error::OK;
|
||||
|
||||
while(res == Error::OK) {
|
||||
@ -115,7 +115,7 @@ v_int32 ProcessingPipeline::iterate(data::buffer::InlineReadData& dataIn,
|
||||
}
|
||||
|
||||
data::buffer::InlineReadData* currDataOut = &dataOut;
|
||||
if(i < static_cast<v_buff_size>(m_intermediateData.size())) {
|
||||
if(i < m_intermediateData.size()) {
|
||||
currDataOut = &m_intermediateData[i];
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ v_int32 ProcessingPipeline::iterate(data::buffer::InlineReadData& dataIn,
|
||||
res = p->iterate(*currDataIn, *currDataOut);
|
||||
}
|
||||
|
||||
const v_int32 numOfProcessors = v_int32(m_processors.size());
|
||||
const size_t numOfProcessors = m_processors.size();
|
||||
|
||||
switch (res) {
|
||||
case Error::PROVIDE_DATA_IN:
|
||||
|
@ -28,7 +28,7 @@ namespace oatpp { namespace data { namespace mapping {
|
||||
|
||||
TypeResolver::TypeResolver() {
|
||||
|
||||
m_knownClasses.resize(data::mapping::type::ClassId::getClassCount(), false);
|
||||
m_knownClasses.resize(static_cast<size_t>(data::mapping::type::ClassId::getClassCount()), false);
|
||||
|
||||
addKnownClasses({
|
||||
data::mapping::type::__class::String::CLASS_ID,
|
||||
@ -64,7 +64,7 @@ TypeResolver::TypeResolver() {
|
||||
}
|
||||
|
||||
void TypeResolver::setKnownClass(const type::ClassId& classId, bool isKnown) {
|
||||
const v_uint32 id = classId.id;
|
||||
const v_uint32 id = static_cast<v_uint32>(classId.id);
|
||||
if(id >= m_knownClasses.size()) {
|
||||
m_knownClasses.resize(id + 1, false);
|
||||
}
|
||||
@ -78,7 +78,7 @@ void TypeResolver::addKnownClasses(const std::vector<type::ClassId>& knownClasse
|
||||
}
|
||||
|
||||
bool TypeResolver::isKnownClass(const type::ClassId& classId) const {
|
||||
const v_uint32 id = classId.id;
|
||||
const v_uint32 id = static_cast<v_uint32>(classId.id);
|
||||
if(id < m_knownClasses.size()) {
|
||||
return m_knownClasses[id];
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ String String::loadFromFile(const char* filename) {
|
||||
if (file.is_open()) {
|
||||
auto result = data::mapping::type::String(file.tellg());
|
||||
file.seekg(0, std::ios::beg);
|
||||
file.read(const_cast<char*>(result->data()), result->size());
|
||||
file.read(const_cast<char*>(result->data()), static_cast<std::streamsize>(result->size()));
|
||||
file.close();
|
||||
return result;
|
||||
}
|
||||
@ -55,7 +55,7 @@ String String::loadFromFile(const char* filename) {
|
||||
void String::saveToFile(const char* filename) const {
|
||||
std::ofstream fs(filename, std::ios::out | std::ios::binary);
|
||||
if(m_ptr != nullptr) {
|
||||
fs.write(m_ptr->data(), m_ptr->size());
|
||||
fs.write(m_ptr->data(), static_cast<std::streamsize>(m_ptr->size()));
|
||||
}
|
||||
fs.close();
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ oatpp::String InMemoryData::getInMemoryData() {
|
||||
|
||||
v_int64 InMemoryData::getKnownSize() {
|
||||
if(m_handle && m_handle->data) {
|
||||
return m_handle->data->size();
|
||||
return static_cast<v_int64>(m_handle->data->size());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -39,11 +39,11 @@ StringKeyLabel::StringKeyLabel(const std::shared_ptr<std::string>& memHandle, co
|
||||
{}
|
||||
|
||||
StringKeyLabel::StringKeyLabel(const char* constText)
|
||||
: oatpp::data::share::MemoryLabel(nullptr, constText, std::strlen(constText))
|
||||
: oatpp::data::share::MemoryLabel(nullptr, constText, static_cast<v_buff_size>(std::strlen(constText)))
|
||||
{}
|
||||
|
||||
StringKeyLabel::StringKeyLabel(const String& str)
|
||||
: oatpp::data::share::MemoryLabel(str.getPtr(), str->data(), str->size())
|
||||
: oatpp::data::share::MemoryLabel(str.getPtr(), str->data(), static_cast<v_buff_size>(str->size()))
|
||||
{}
|
||||
|
||||
StringKeyLabelCI::StringKeyLabelCI(const std::shared_ptr<std::string>& memHandle, const char* data, v_buff_size size)
|
||||
@ -51,11 +51,11 @@ StringKeyLabelCI::StringKeyLabelCI(const std::shared_ptr<std::string>& memHandle
|
||||
{}
|
||||
|
||||
StringKeyLabelCI::StringKeyLabelCI(const char* constText)
|
||||
: oatpp::data::share::MemoryLabel(nullptr, constText, std::strlen(constText))
|
||||
: oatpp::data::share::MemoryLabel(nullptr, constText, static_cast<v_buff_size>(std::strlen(constText)))
|
||||
{}
|
||||
|
||||
StringKeyLabelCI::StringKeyLabelCI(const String& str)
|
||||
: oatpp::data::share::MemoryLabel(str.getPtr(), str->data(), str->size())
|
||||
: oatpp::data::share::MemoryLabel(str.getPtr(), str->data(), static_cast<v_buff_size>(str->size()))
|
||||
{}
|
||||
|
||||
}}}
|
||||
|
@ -99,14 +99,14 @@ void StringTemplate::format(stream::ConsistentOutputStream* stream, ValueProvide
|
||||
stream->writeSimple(m_text->data() + prevPos, var.posStart - prevPos);
|
||||
}
|
||||
|
||||
stream->writeSimple(value->data(), value->size());
|
||||
stream->writeSimple(value->data(), static_cast<v_buff_size>(value->size()));
|
||||
|
||||
prevPos = var.posEnd + 1;
|
||||
|
||||
}
|
||||
|
||||
if(static_cast<size_t>(prevPos) < m_text->size()) {
|
||||
stream->writeSimple(m_text->data() + prevPos, m_text->size() - prevPos);
|
||||
stream->writeSimple(m_text->data() + prevPos, static_cast<v_buff_size>(m_text->size()) - prevPos);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ v_io_size BufferOutputStream::write(const void *data, v_buff_size count, async::
|
||||
|
||||
reserveBytesUpfront(count);
|
||||
|
||||
std::memcpy(m_data + m_position, data, count);
|
||||
std::memcpy(m_data + m_position, data, static_cast<size_t>(count));
|
||||
m_position += count;
|
||||
|
||||
return count;
|
||||
@ -90,7 +90,7 @@ void BufferOutputStream::reserveBytesUpfront(v_buff_size count) {
|
||||
|
||||
p_char8 newData = new v_char8[newCapacity];
|
||||
|
||||
std::memcpy(newData, m_data, m_position);
|
||||
std::memcpy(newData, m_data, static_cast<size_t>(m_position));
|
||||
delete [] m_data;
|
||||
m_data = newData;
|
||||
m_capacity = newCapacity;
|
||||
@ -189,7 +189,7 @@ BufferInputStream::BufferInputStream(const std::shared_ptr<std::string>& memoryH
|
||||
{}
|
||||
|
||||
BufferInputStream::BufferInputStream(const oatpp::String& data, const std::shared_ptr<void>& captureData)
|
||||
: BufferInputStream(data.getPtr(), reinterpret_cast<p_char8>(const_cast<char*>(data->data())), data->size(), captureData)
|
||||
: BufferInputStream(data.getPtr(), reinterpret_cast<p_char8>(const_cast<char*>(data->data())), static_cast<v_buff_size>(data->size()), captureData)
|
||||
{}
|
||||
|
||||
void BufferInputStream::reset(const std::shared_ptr<std::string>& memoryHandle,
|
||||
@ -220,7 +220,7 @@ v_io_size BufferInputStream::read(void *data, v_buff_size count, async::Action&
|
||||
if(desiredAmount > m_size - m_position) {
|
||||
desiredAmount = m_size - m_position;
|
||||
}
|
||||
std::memcpy(data, &m_data[m_position], desiredAmount);
|
||||
std::memcpy(data, &m_data[m_position], static_cast<size_t>(desiredAmount));
|
||||
m_position += desiredAmount;
|
||||
return desiredAmount;
|
||||
}
|
||||
@ -264,7 +264,7 @@ v_io_size BufferInputStream::peek(void *data, v_buff_size count, async::Action &
|
||||
if(desiredAmount > m_size - m_position) {
|
||||
desiredAmount = m_size - m_position;
|
||||
}
|
||||
std::memcpy(data, &m_data[m_position], desiredAmount);
|
||||
std::memcpy(data, &m_data[m_position], static_cast<size_t>(desiredAmount));
|
||||
return desiredAmount;
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ std::FILE* FileInputStream::getFile() {
|
||||
v_io_size FileInputStream::read(void *data, v_buff_size count, async::Action& action) {
|
||||
(void) action;
|
||||
if(m_file != nullptr) {
|
||||
return std::fread(data, 1, count, m_file);
|
||||
return static_cast<v_io_size>(std::fread(data, 1, static_cast<size_t>(count), m_file));
|
||||
}
|
||||
return oatpp::IOError::BROKEN_PIPE;
|
||||
}
|
||||
@ -147,7 +147,7 @@ std::FILE* FileOutputStream::getFile() {
|
||||
|
||||
v_io_size FileOutputStream::write(const void *data, v_buff_size count, async::Action& action) {
|
||||
(void) action;
|
||||
return std::fwrite(data, 1, count, m_file);
|
||||
return static_cast<v_io_size>(std::fwrite(data, 1, static_cast<size_t>(count), m_file));
|
||||
}
|
||||
|
||||
void FileOutputStream::setOutputStreamIOMode(IOMode ioMode) {
|
||||
|
@ -86,7 +86,7 @@ namespace oatpp { namespace parser {
|
||||
if(end == -1){
|
||||
end = m_caret->m_pos;
|
||||
}
|
||||
return std::string(&m_caret->m_data[m_start], end - m_start);
|
||||
return std::string(&m_caret->m_data[m_start], static_cast<size_t>(end - m_start));
|
||||
}
|
||||
|
||||
Caret::Label::operator bool() const {
|
||||
@ -125,7 +125,7 @@ v_int64 Caret::StateSaveGuard::getSavedErrorCode() {
|
||||
// Caret
|
||||
|
||||
Caret::Caret(const char* text)
|
||||
: Caret(text, std::strlen(text))
|
||||
: Caret(text, static_cast<v_buff_size>(std::strlen(text)))
|
||||
{}
|
||||
|
||||
Caret::Caret(const char* parseData, v_buff_size dataSize)
|
||||
@ -137,7 +137,7 @@ v_int64 Caret::StateSaveGuard::getSavedErrorCode() {
|
||||
{}
|
||||
|
||||
Caret::Caret(const oatpp::String& str)
|
||||
: Caret(str->data(), str->size())
|
||||
: Caret(str->data(), static_cast<v_buff_size>(str->size()))
|
||||
{
|
||||
m_dataMemoryHandle = str.getPtr();
|
||||
}
|
||||
@ -248,7 +248,7 @@ v_int64 Caret::StateSaveGuard::getSavedErrorCode() {
|
||||
}
|
||||
|
||||
bool Caret::skipCharsFromSet(const char* set){
|
||||
return skipCharsFromSet(set, std::strlen(set));
|
||||
return skipCharsFromSet(set, static_cast<v_buff_size>(std::strlen(set)));
|
||||
}
|
||||
|
||||
bool Caret::skipCharsFromSet(const char* set, v_buff_size setSize){
|
||||
@ -265,7 +265,7 @@ v_int64 Caret::StateSaveGuard::getSavedErrorCode() {
|
||||
}
|
||||
|
||||
v_buff_size Caret::findCharFromSet(const char* set){
|
||||
return findCharFromSet(set, std::strlen(set));
|
||||
return findCharFromSet(set, static_cast<v_buff_size>(std::strlen(set)));
|
||||
}
|
||||
|
||||
v_buff_size Caret::findCharFromSet(const char* set, v_buff_size setSize){
|
||||
@ -395,7 +395,7 @@ v_int64 Caret::StateSaveGuard::getSavedErrorCode() {
|
||||
}
|
||||
|
||||
bool Caret::isAtText(const char* text, bool skipIfTrue){
|
||||
return isAtText(text, std::strlen(text), skipIfTrue);
|
||||
return isAtText(text, static_cast<v_buff_size>(std::strlen(text)), skipIfTrue);
|
||||
}
|
||||
|
||||
bool Caret::isAtText(const char* text, v_buff_size textSize, bool skipIfTrue){
|
||||
@ -423,7 +423,7 @@ v_int64 Caret::StateSaveGuard::getSavedErrorCode() {
|
||||
}
|
||||
|
||||
bool Caret::isAtTextNCS(const char* text, bool skipIfTrue){
|
||||
return isAtTextNCS(text, std::strlen(text), skipIfTrue);
|
||||
return isAtTextNCS(text, static_cast<v_buff_size>(std::strlen(text)), skipIfTrue);
|
||||
}
|
||||
|
||||
bool Caret::isAtTextNCS(const char* text, v_buff_size textSize, bool skipIfTrue){
|
||||
@ -492,7 +492,7 @@ v_int64 Caret::StateSaveGuard::getSavedErrorCode() {
|
||||
}
|
||||
|
||||
bool Caret::findText(const char* text) {
|
||||
return findText(text, std::strlen(text));
|
||||
return findText(text, static_cast<v_buff_size>(std::strlen(text)));
|
||||
}
|
||||
|
||||
bool Caret::findText(const char* text, v_buff_size textSize) {
|
||||
@ -501,7 +501,7 @@ v_int64 Caret::StateSaveGuard::getSavedErrorCode() {
|
||||
}
|
||||
|
||||
bool Caret::isAtCharFromSet(const char* set) const{
|
||||
return isAtCharFromSet(set, std::strlen(set));
|
||||
return isAtCharFromSet(set, static_cast<v_buff_size>(std::strlen(set)));
|
||||
}
|
||||
|
||||
bool Caret::isAtCharFromSet(const char* set, v_buff_size setSize) const{
|
||||
|
@ -77,19 +77,19 @@ namespace oatpp { namespace utils { namespace conversion {
|
||||
}
|
||||
|
||||
v_buff_size int32ToCharSequence(v_int32 value, p_char8 data, v_buff_size n) {
|
||||
return snprintf(reinterpret_cast<char*>(data), n, "%ld", static_cast<long>(value));
|
||||
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), n, "%lu", static_cast<unsigned long>(value));
|
||||
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), n, "%lld", static_cast<long long int>(value));
|
||||
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), n, "%llu", static_cast<long long unsigned int>(value));
|
||||
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){
|
||||
@ -132,7 +132,7 @@ namespace oatpp { namespace utils { namespace conversion {
|
||||
v_char8 buff [16];
|
||||
auto size = int32ToCharSequence(value, &buff[0], 16);
|
||||
if(size > 0){
|
||||
return std::string(reinterpret_cast<const char*>(buff), size);
|
||||
return std::string(reinterpret_cast<const char*>(buff), static_cast<size_t>(size));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@ -141,7 +141,7 @@ namespace oatpp { namespace utils { namespace conversion {
|
||||
v_char8 buff [16];
|
||||
auto size = uint32ToCharSequence(value, &buff[0], 16);
|
||||
if(size > 0){
|
||||
return std::string(reinterpret_cast<const char*>(buff), size);
|
||||
return std::string(reinterpret_cast<const char*>(buff), static_cast<size_t>(size));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@ -150,7 +150,7 @@ namespace oatpp { namespace utils { namespace conversion {
|
||||
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), size);
|
||||
return std::string(reinterpret_cast<const char*>(buff), static_cast<size_t>(size));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@ -159,7 +159,7 @@ namespace oatpp { namespace utils { namespace conversion {
|
||||
v_char8 buff [32];
|
||||
auto size = uint64ToCharSequence(value, &buff[0], 32);
|
||||
if(size > 0){
|
||||
return std::string(reinterpret_cast<const char*>(buff), size);
|
||||
return std::string(reinterpret_cast<const char*>(buff), static_cast<size_t>(size));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@ -189,11 +189,11 @@ namespace oatpp { namespace utils { namespace conversion {
|
||||
}
|
||||
|
||||
v_buff_size float32ToCharSequence(v_float32 value, p_char8 data, v_buff_size n, const char* format) {
|
||||
return snprintf(reinterpret_cast<char*>(data), n, format, static_cast<double>(value));
|
||||
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), n, format, value);
|
||||
return snprintf(reinterpret_cast<char*>(data), static_cast<size_t>(n), format, value);
|
||||
}
|
||||
|
||||
oatpp::String float32ToStr(v_float32 value, const char* format) {
|
||||
|
@ -34,18 +34,18 @@ v_buff_size String::compare(const void* data1, v_buff_size size1, const void* da
|
||||
if(data2 == nullptr) return 1;
|
||||
|
||||
if(size1 < size2) {
|
||||
auto res = std::memcmp(data1, data2, size1);
|
||||
auto res = std::memcmp(data1, data2, static_cast<size_t>(size1));
|
||||
if(res == 0) return -1;
|
||||
return res;
|
||||
}
|
||||
|
||||
if(size1 > size2) {
|
||||
auto res = std::memcmp(data1, data2, size2);
|
||||
auto res = std::memcmp(data1, data2, static_cast<size_t>(size2));
|
||||
if(res == 0) return 1;
|
||||
return res;
|
||||
}
|
||||
|
||||
return std::memcmp(data1, data2, size1);
|
||||
return std::memcmp(data1, data2, static_cast<size_t>(size1));
|
||||
|
||||
}
|
||||
|
||||
@ -63,8 +63,8 @@ v_buff_size String::compareCI_ASCII(const void* data1, v_buff_size size1, const
|
||||
|
||||
for(v_buff_size i = 0; i < size; i ++) {
|
||||
|
||||
v_char8 a = d1[i];
|
||||
v_char8 b = d2[i];
|
||||
v_char8 a = static_cast<v_char8>(d1[i]);
|
||||
v_char8 b = static_cast<v_char8>(d2[i]);
|
||||
|
||||
if(a >= 'A' && a <= 'Z') a |= 32;
|
||||
if(b >= 'A' && b <= 'Z') b |= 32;
|
||||
|
@ -66,14 +66,14 @@ v_buff_size Base64::calcDecodedStringSize(const char* data, v_buff_size size, v_
|
||||
|
||||
base64StrLength = size;
|
||||
|
||||
v_char8 auxChar1 = auxiliaryChars[0];
|
||||
v_char8 auxChar2 = auxiliaryChars[1];
|
||||
v_char8 paddingChar = auxiliaryChars[2];
|
||||
v_char8 auxChar1 = static_cast<v_char8>(auxiliaryChars[0]);
|
||||
v_char8 auxChar2 = static_cast<v_char8>(auxiliaryChars[1]);
|
||||
v_char8 paddingChar = static_cast<v_char8>(auxiliaryChars[2]);
|
||||
|
||||
v_buff_size i = 0;
|
||||
while (i < size) {
|
||||
|
||||
v_char8 a = data[i];
|
||||
v_char8 a = static_cast<v_char8>(data[i]);
|
||||
|
||||
bool isValidChar = (a >= 'A' && a <='Z') || (a >= 'a' && a <='z') || (a >= '0' && a <='9') || (a == auxChar1) || (a == auxChar2);
|
||||
if(!isValidChar) {
|
||||
@ -118,10 +118,10 @@ oatpp::String Base64::encode(const void* data, v_buff_size size, const char* alp
|
||||
v_char8 b0 = bdata[pos];
|
||||
v_char8 b1 = bdata[pos + 1];
|
||||
v_char8 b2 = bdata[pos + 2];
|
||||
resultData[0] = alphabet[(b0 & 252) >> 2];
|
||||
resultData[1] = alphabet[((b0 & 3) << 4) | ((b1 >> 4) & 15)];
|
||||
resultData[2] = alphabet[((b1 & 15) << 2) | ((b2 >> 6) & 3)];
|
||||
resultData[3] = alphabet[(b2 & 63)];
|
||||
resultData[0] = static_cast<v_char8>(alphabet[(b0 & 252) >> 2]);
|
||||
resultData[1] = static_cast<v_char8>(alphabet[((b0 & 3) << 4) | ((b1 >> 4) & 15)]);
|
||||
resultData[2] = static_cast<v_char8>(alphabet[((b1 & 15) << 2) | ((b2 >> 6) & 3)]);
|
||||
resultData[3] = static_cast<v_char8>(alphabet[(b2 & 63)]);
|
||||
resultData += 4;
|
||||
pos += 3;
|
||||
|
||||
@ -130,16 +130,16 @@ oatpp::String Base64::encode(const void* data, v_buff_size size, const char* alp
|
||||
if(pos + 1 < size) {
|
||||
v_char8 b0 = bdata[pos];
|
||||
v_char8 b1 = bdata[pos + 1];
|
||||
resultData[0] = alphabet[(b0 & 252) >> 2];
|
||||
resultData[1] = alphabet[((b0 & 3) << 4) | ((b1 >> 4) & 15)];
|
||||
resultData[2] = alphabet[((b1 & 15) << 2)];
|
||||
resultData[3] = alphabet[64];
|
||||
resultData[0] = static_cast<v_char8>(alphabet[(b0 & 252) >> 2]);
|
||||
resultData[1] = static_cast<v_char8>(alphabet[((b0 & 3) << 4) | ((b1 >> 4) & 15)]);
|
||||
resultData[2] = static_cast<v_char8>(alphabet[((b1 & 15) << 2)]);
|
||||
resultData[3] = static_cast<v_char8>(alphabet[64]);
|
||||
} else if(pos < size) {
|
||||
v_char8 b0 = bdata[pos];
|
||||
resultData[0] = alphabet[(b0 & 252) >> 2];
|
||||
resultData[1] = alphabet[(b0 & 3) << 4];
|
||||
resultData[2] = alphabet[64];
|
||||
resultData[3] = alphabet[64];
|
||||
resultData[0] = static_cast<v_char8>(alphabet[(b0 & 252) >> 2]);
|
||||
resultData[1] = static_cast<v_char8>(alphabet[(b0 & 3) << 4]);
|
||||
resultData[2] = static_cast<v_char8>(alphabet[64]);
|
||||
resultData[3] = static_cast<v_char8>(alphabet[64]);
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -147,7 +147,7 @@ oatpp::String Base64::encode(const void* data, v_buff_size size, const char* alp
|
||||
}
|
||||
|
||||
oatpp::String Base64::encode(const oatpp::String& data, const char* alphabet) {
|
||||
return encode(data->data(), data->size(), alphabet);
|
||||
return encode(data->data(), static_cast<v_buff_size>(data->size()), alphabet);
|
||||
}
|
||||
|
||||
oatpp::String Base64::decode(const char* data, v_buff_size size, const char* auxiliaryChars) {
|
||||
@ -162,10 +162,10 @@ oatpp::String Base64::decode(const char* data, v_buff_size size, const char* aux
|
||||
p_char8 resultData = reinterpret_cast<p_char8>(const_cast<char*>(result->data()));
|
||||
v_buff_size pos = 0;
|
||||
while (pos + 3 < base64StrLength) {
|
||||
v_char8 b0 = getAlphabetCharIndex(data[pos], auxiliaryChars);
|
||||
v_char8 b1 = getAlphabetCharIndex(data[pos + 1], auxiliaryChars);
|
||||
v_char8 b2 = getAlphabetCharIndex(data[pos + 2], auxiliaryChars);
|
||||
v_char8 b3 = getAlphabetCharIndex(data[pos + 3], auxiliaryChars);
|
||||
v_char8 b0 = getAlphabetCharIndex(static_cast<v_char8>(data[pos]), auxiliaryChars);
|
||||
v_char8 b1 = getAlphabetCharIndex(static_cast<v_char8>(data[pos + 1]), auxiliaryChars);
|
||||
v_char8 b2 = getAlphabetCharIndex(static_cast<v_char8>(data[pos + 2]), auxiliaryChars);
|
||||
v_char8 b3 = getAlphabetCharIndex(static_cast<v_char8>(data[pos + 3]), auxiliaryChars);
|
||||
|
||||
resultData[0] = static_cast<v_char8>((b0 << 2) | ((b1 >> 4) & 3));
|
||||
resultData[1] = static_cast<v_char8>(((b1 & 15) << 4) | ((b2 >> 2) & 15));
|
||||
@ -177,14 +177,14 @@ oatpp::String Base64::decode(const char* data, v_buff_size size, const char* aux
|
||||
|
||||
v_buff_size posDiff = base64StrLength - pos;
|
||||
if(posDiff == 3) {
|
||||
v_char8 b0 = getAlphabetCharIndex(data[pos], auxiliaryChars);
|
||||
v_char8 b1 = getAlphabetCharIndex(data[pos + 1], auxiliaryChars);
|
||||
v_char8 b2 = getAlphabetCharIndex(data[pos + 2], auxiliaryChars);
|
||||
v_char8 b0 = getAlphabetCharIndex(static_cast<v_char8>(data[pos]), auxiliaryChars);
|
||||
v_char8 b1 = getAlphabetCharIndex(static_cast<v_char8>(data[pos + 1]), auxiliaryChars);
|
||||
v_char8 b2 = getAlphabetCharIndex(static_cast<v_char8>(data[pos + 2]), auxiliaryChars);
|
||||
resultData[0] = static_cast<v_char8>((b0 << 2) | ((b1 >> 4) & 3));
|
||||
resultData[1] = static_cast<v_char8>(((b1 & 15) << 4) | ((b2 >> 2) & 15));
|
||||
} else if(posDiff == 2) {
|
||||
v_char8 b0 = getAlphabetCharIndex(data[pos], auxiliaryChars);
|
||||
v_char8 b1 = getAlphabetCharIndex(data[pos + 1], auxiliaryChars);
|
||||
v_char8 b0 = getAlphabetCharIndex(static_cast<v_char8>(data[pos]), auxiliaryChars);
|
||||
v_char8 b1 = getAlphabetCharIndex(static_cast<v_char8>(data[pos + 1]), auxiliaryChars);
|
||||
resultData[0] = static_cast<v_char8>((b0 << 2) | ((b1 >> 4) & 3));
|
||||
}
|
||||
|
||||
@ -193,7 +193,7 @@ oatpp::String Base64::decode(const char* data, v_buff_size size, const char* aux
|
||||
}
|
||||
|
||||
oatpp::String Base64::decode(const oatpp::String& data, const char* auxiliaryChars) {
|
||||
return decode(data->data(), data->size(), auxiliaryChars);
|
||||
return decode(data->data(), static_cast<v_buff_size>(data->size()), auxiliaryChars);
|
||||
}
|
||||
|
||||
}}
|
||||
|
@ -36,10 +36,10 @@ const char* Hex::ALPHABET_UPPER = "0123456789ABCDEF";
|
||||
const char* Hex::ALPHABET_LOWER = "0123456789abcdef";
|
||||
|
||||
void Hex::writeUInt16(v_uint16 value, p_char8 buffer){
|
||||
*(reinterpret_cast<p_uint32>(buffer)) = htonl((ALPHABET_UPPER[ value & 0x000F ] ) |
|
||||
(ALPHABET_UPPER[(value & 0x00F0) >> 4] << 8) |
|
||||
(ALPHABET_UPPER[(value & 0x0F00) >> 8] << 16) |
|
||||
(ALPHABET_UPPER[(value & 0xF000) >> 12] << 24));
|
||||
*(reinterpret_cast<p_uint32>(buffer)) = htonl((static_cast<v_uint32>(ALPHABET_UPPER[ value & 0x000F ]) ) |
|
||||
(static_cast<v_uint32>(ALPHABET_UPPER[(value & 0x00F0) >> 4]) << 8) |
|
||||
(static_cast<v_uint32>(ALPHABET_UPPER[(value & 0x0F00) >> 8]) << 16) |
|
||||
(static_cast<v_uint32>(ALPHABET_UPPER[(value & 0xF000) >> 12]) << 24));
|
||||
|
||||
}
|
||||
|
||||
@ -50,8 +50,8 @@ void Hex::writeUInt32(v_uint32 value, p_char8 buffer){
|
||||
|
||||
v_int32 Hex::readUInt16(const char* buffer, v_uint16& value) {
|
||||
value = 0;
|
||||
for(v_int32 i = 0; i < 4; i++){
|
||||
v_char8 a = buffer[i];
|
||||
for(v_uint32 i = 0; i < 4; i++){
|
||||
v_char8 a = static_cast<v_char8>(buffer[i]);
|
||||
if(a >= '0' && a <= '9') {
|
||||
value |= static_cast<v_uint16>((a - '0') << ((3 - i) << 2));
|
||||
} else if (a >= 'A' && a <= 'F') {
|
||||
@ -67,14 +67,14 @@ v_int32 Hex::readUInt16(const char* buffer, v_uint16& value) {
|
||||
|
||||
v_int32 Hex::readUInt32(const char* buffer, v_uint32& value) {
|
||||
value = 0;
|
||||
for(v_int32 i = 0; i < 8; i++){
|
||||
v_char8 a = buffer[i];
|
||||
for(v_uint32 i = 0; i < 8; i++){
|
||||
v_char8 a = static_cast<v_char8>(buffer[i]);
|
||||
if(a >= '0' && a <= '9') {
|
||||
value |= (a - '0') << ((7 - i) << 2);
|
||||
value |= static_cast<v_uint32>(a - '0') << ((7 - i) << 2);
|
||||
} else if (a >= 'A' && a <= 'F') {
|
||||
value |= (a - 'A' + 10) << ((7 - i) << 2);
|
||||
value |= static_cast<v_uint32>(a - 'A' + 10) << ((7 - i) << 2);
|
||||
} else if (a >= 'a' && a <= 'f') {
|
||||
value |= (a - 'a' + 10) << ((7 - i) << 2);
|
||||
value |= static_cast<v_uint32>(a - 'a' + 10) << ((7 - i) << 2);
|
||||
} else {
|
||||
return ERROR_UNKNOWN_SYMBOL;
|
||||
}
|
||||
@ -87,9 +87,9 @@ void Hex::encode(data::stream::ConsistentOutputStream* stream,
|
||||
const char* alphabet)
|
||||
{
|
||||
auto buffer = reinterpret_cast<const char*>(data);
|
||||
v_char8 oneByteBuffer[2];
|
||||
char oneByteBuffer[2];
|
||||
for(v_buff_size i = 0; i < size; i ++) {
|
||||
auto c = buffer[i];
|
||||
v_char8 c = static_cast<v_char8>(buffer[i]);
|
||||
v_char8 b1 = 0x0F & (c >> 4);
|
||||
v_char8 b2 = 0x0F & (c);
|
||||
oneByteBuffer[0] = alphabet[b1];
|
||||
|
@ -75,7 +75,7 @@ v_buff_size Unicode::getUtf8CharSequenceLengthForCode(v_uint32 code){
|
||||
}
|
||||
|
||||
v_int32 Unicode::encodeUtf8Char(const char* sequence, v_buff_size& length){
|
||||
v_char8 byte = sequence[0];
|
||||
v_char8 byte = static_cast<v_char8>(sequence[0]);
|
||||
if(byte > 127){
|
||||
v_int32 code;
|
||||
if((byte | 32) != byte){
|
||||
@ -115,34 +115,35 @@ v_int32 Unicode::encodeUtf8Char(const char* sequence, v_buff_size& length){
|
||||
}
|
||||
}
|
||||
|
||||
v_buff_size Unicode::decodeUtf8Char(v_int32 code, p_char8 buffer) {
|
||||
v_buff_size Unicode::decodeUtf8Char(v_int32 signed_code, p_char8 buffer) {
|
||||
v_uint32 code = static_cast<v_uint32>(signed_code);
|
||||
if(code >= 0x00000080 && code < 0x00000800){
|
||||
*(reinterpret_cast<p_int16>(buffer)) = htons(((((code >> 6) & 31) | 192) << 8) | ((code & 63) | 128));
|
||||
*(reinterpret_cast<p_int16>(buffer)) = static_cast<v_int16>(htons(((((code >> 6) & 31) | 192) << 8) | ((code & 63) | 128)));
|
||||
return 2;
|
||||
} else if(code >= 0x00000800 && code < 0x00010000){
|
||||
*(reinterpret_cast<p_int16>(buffer)) = htons((((( code >> 12 ) & 15) | 224) << 8) |
|
||||
(((code >> 6 ) & 63) | 128));
|
||||
*(reinterpret_cast<p_int16>(buffer)) = static_cast<v_int16>(htons((((( code >> 12 ) & 15) | 224) << 8) |
|
||||
(((code >> 6 ) & 63) | 128)));
|
||||
buffer[2] = (code & 63) | 128;
|
||||
return 3;
|
||||
} else if(code >= 0x00010000 && code < 0x00200000){
|
||||
*(reinterpret_cast<p_int32>(buffer)) = htonl(((((code >> 18 ) & 7) | 240) << 24) |
|
||||
*(reinterpret_cast<p_int32>(buffer)) = static_cast<v_int32>(htonl(((((code >> 18 ) & 7) | 240) << 24) |
|
||||
((((code >> 12 ) & 63) | 128) << 16) |
|
||||
((((code >> 6 ) & 63) | 128) << 8) |
|
||||
(( code & 63) | 128) );
|
||||
(( code & 63) | 128) ));
|
||||
return 4;
|
||||
} else if(code >= 0x00200000 && code < 0x04000000){
|
||||
*(reinterpret_cast<p_int32>(buffer)) = htonl(((((code >> 24 ) & 3) | 248) << 24) |
|
||||
*(reinterpret_cast<p_int32>(buffer)) = static_cast<v_int32>(htonl(((((code >> 24 ) & 3) | 248) << 24) |
|
||||
((((code >> 18 ) & 63) | 128) << 16) |
|
||||
((((code >> 12 ) & 63) | 128) << 8) |
|
||||
(((code >> 6 ) & 63) | 128));
|
||||
(((code >> 6 ) & 63) | 128)));
|
||||
buffer[4] = (code & 63) | 128;
|
||||
return 5;
|
||||
} else if(code >= 0x04000000){
|
||||
*(reinterpret_cast<p_int32>(buffer)) = htonl(((((code >> 30 ) & 1) | 252) << 24) |
|
||||
*(reinterpret_cast<p_int32>(buffer)) = static_cast<v_int32>(htonl(((((code >> 30 ) & 1) | 252) << 24) |
|
||||
((((code >> 24 ) & 63) | 128) << 16) |
|
||||
((((code >> 18 ) & 63) | 128) << 8) |
|
||||
(((code >> 12 ) & 63) | 128));
|
||||
*(reinterpret_cast<p_int16>(&buffer[4])) = htons(((((code >> 6 ) & 63) | 128) << 8) | (code & 63));
|
||||
(((code >> 12 ) & 63) | 128)));
|
||||
*(reinterpret_cast<p_int16>(&buffer[4])) = static_cast<v_int16>(htons(((((code >> 6 ) & 63) | 128) << 8) | (code & 63)));
|
||||
return 6;
|
||||
}
|
||||
buffer[0] = v_char8(code);
|
||||
|
@ -68,7 +68,7 @@ void Url::encode(data::stream::ConsistentOutputStream *stream, const void *data,
|
||||
auto pdata = reinterpret_cast<const char*>(data);
|
||||
|
||||
for(v_buff_size i = 0; i < size; i++) {
|
||||
v_char8 c = pdata[i];
|
||||
v_char8 c = static_cast<v_char8>(pdata[i]);
|
||||
if(config.allowedChars[c]) {
|
||||
stream->writeCharSimple(c);
|
||||
} else if(c == ' ' && config.spaceToPlus) {
|
||||
@ -88,7 +88,7 @@ void Url::decode(data::stream::ConsistentOutputStream* stream, const void* data,
|
||||
|
||||
while (i < size) {
|
||||
|
||||
v_char8 c = pdata[i];
|
||||
v_char8 c = static_cast<v_char8>(pdata[i]);
|
||||
if(c == '%') {
|
||||
if(size - i > 1) {
|
||||
Hex::decode(stream, pdata + i + 1, 2);
|
||||
@ -109,14 +109,14 @@ void Url::decode(data::stream::ConsistentOutputStream* stream, const void* data,
|
||||
}
|
||||
|
||||
oatpp::String Url::encode(const oatpp::String data, const Config& config) {
|
||||
data::stream::BufferOutputStream stream(data->size() * 3);
|
||||
encode(&stream, data->data(), data->size(), config);
|
||||
data::stream::BufferOutputStream stream(static_cast<v_buff_size>(data->size() * 3));
|
||||
encode(&stream, data->data(), static_cast<v_buff_size>(data->size()), config);
|
||||
return stream.toString();
|
||||
}
|
||||
|
||||
oatpp::String Url::decode(const oatpp::String data) {
|
||||
data::stream::BufferOutputStream stream(data->size());
|
||||
decode(&stream, data->data(), data->size());
|
||||
data::stream::BufferOutputStream stream(static_cast<v_buff_size>(data->size()));
|
||||
decode(&stream, data->data(), static_cast<v_buff_size>(data->size()));
|
||||
return stream.toString();
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ oatpp::String Url::Parser::parseScheme(oatpp::parser::Caret& caret) {
|
||||
v_buff_size size = caret.getPosition() - pos0;
|
||||
if(size > 0) {
|
||||
std::unique_ptr<v_char8[]> buff(new v_char8[size]);
|
||||
std::memcpy(buff.get(), &caret.getData()[pos0], size);
|
||||
std::memcpy(buff.get(), &caret.getData()[pos0], static_cast<size_t>(size));
|
||||
utils::String::lowerCase_ASCII(buff.get(), size);
|
||||
return oatpp::String(reinterpret_cast<const char*>(buff.get()), size);
|
||||
}
|
||||
@ -52,7 +52,7 @@ Url::Authority Url::Parser::parseAuthority(oatpp::parser::Caret& caret) {
|
||||
v_buff_size portPos = -1;
|
||||
|
||||
while (pos < caret.getDataSize()) {
|
||||
v_char8 a = data[pos];
|
||||
v_char8 a = static_cast<v_char8>(data[pos]);
|
||||
if(a == '@') {
|
||||
atPos = pos;
|
||||
pos ++;
|
||||
|
@ -123,7 +123,7 @@ provider::ResourceHandle<data::stream::IOStream> ConnectionProvider::get() {
|
||||
|
||||
if(clientHandle >= 0) {
|
||||
|
||||
if(connect(clientHandle, currResult->ai_addr, static_cast<int>(currResult->ai_addrlen)) == 0) {
|
||||
if(connect(clientHandle, currResult->ai_addr, static_cast<v_sock_size>(currResult->ai_addrlen)) == 0) {
|
||||
break;
|
||||
} else {
|
||||
err = errno;
|
||||
@ -282,7 +282,7 @@ oatpp::async::CoroutineStarterForResult<const provider::ResourceHandle<data::str
|
||||
Action doConnect() {
|
||||
errno = 0;
|
||||
|
||||
auto res = connect(m_clientHandle, m_currentResult->ai_addr, static_cast<int>(m_currentResult->ai_addrlen));
|
||||
auto res = connect(m_clientHandle, m_currentResult->ai_addr, static_cast<v_sock_size>(m_currentResult->ai_addrlen));
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
|
||||
|
@ -46,7 +46,7 @@
|
||||
|
||||
// Workaround for MinGW from: https://www.mail-archive.com/users@ipv6.org/msg02107.html
|
||||
#if defined(__MINGW32__) && _WIN32_WINNT < 0x0600
|
||||
const char * inet_ntop (int af, const void *src, char *dst, socklen_t cnt) {
|
||||
const char * inet_ntop (int af, const void *src, char *dst, oatpp::v_sock_size cnt) {
|
||||
if (af == AF_INET) {
|
||||
struct sockaddr_in in;
|
||||
|
||||
@ -228,7 +228,7 @@ oatpp::v_io_handle ConnectionProvider::instantiateServer(){
|
||||
// Update port after binding (typicaly in case of port = 0)
|
||||
struct ::sockaddr_in s_in;
|
||||
::memset(&s_in, 0, sizeof(s_in));
|
||||
::socklen_t s_in_len = 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)));
|
||||
|
||||
@ -280,7 +280,7 @@ oatpp::v_io_handle ConnectionProvider::instantiateServer(){
|
||||
"Warning. Failed to set %s for accepting socket: %s", "SO_REUSEADDR", strerror(errno));
|
||||
}
|
||||
|
||||
if (bind(serverHandle, currResult->ai_addr, static_cast<int>(currResult->ai_addrlen)) == 0 &&
|
||||
if (bind(serverHandle, currResult->ai_addr, static_cast<v_sock_size>(currResult->ai_addrlen)) == 0 &&
|
||||
listen(serverHandle, 10000) == 0)
|
||||
{
|
||||
break;
|
||||
@ -309,7 +309,7 @@ oatpp::v_io_handle ConnectionProvider::instantiateServer(){
|
||||
// Update port after binding (typicaly in case of port = 0)
|
||||
::sockaddr_in s_in;
|
||||
::memset(&s_in, 0, sizeof(s_in));
|
||||
::socklen_t s_in_len = 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)));
|
||||
|
||||
@ -351,7 +351,7 @@ provider::ResourceHandle<data::stream::IOStream> ConnectionProvider::getDefaultC
|
||||
provider::ResourceHandle<data::stream::IOStream> ConnectionProvider::getExtendedConnection() {
|
||||
|
||||
sockaddr_storage clientAddress;
|
||||
socklen_t clientAddressSize = sizeof(clientAddress);
|
||||
v_sock_size clientAddressSize = sizeof(clientAddress);
|
||||
|
||||
data::stream::Context::Properties properties;
|
||||
|
||||
|
@ -39,9 +39,9 @@ Beautifier::Beautifier(ConsistentOutputStream* outputStream, const oatpp::String
|
||||
{}
|
||||
|
||||
void Beautifier::writeIndent(ConsistentOutputStream* outputStream) {
|
||||
outputStream->writeSimple(m_newLine->data(), m_newLine->size());
|
||||
outputStream->writeSimple(m_newLine->data(), static_cast<v_buff_size>(m_newLine->size()));
|
||||
for(v_int32 i = 0; i < m_level; i ++ ) {
|
||||
outputStream->writeSimple(m_indent->data(), m_indent->size());
|
||||
outputStream->writeSimple(m_indent->data(), static_cast<v_buff_size>(m_indent->size()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ v_io_size Beautifier::write(const void *data, v_buff_size count, async::Action&
|
||||
|
||||
for(v_buff_size i = 0; i < count; i ++) {
|
||||
|
||||
v_char8 c = (reinterpret_cast<const char*>(data)) [i];
|
||||
v_char8 c = static_cast<v_char8>((reinterpret_cast<const char*>(data)) [i]);
|
||||
|
||||
if(m_isCharEscaped) {
|
||||
m_isCharEscaped = false;
|
||||
|
@ -34,7 +34,7 @@ v_buff_size Utils::calcEscapedStringSize(const char* data, v_buff_size size, v_b
|
||||
v_buff_size i = 0;
|
||||
safeSize = size;
|
||||
while (i < size) {
|
||||
v_char8 a = data[i];
|
||||
v_char8 a = static_cast<v_char8>(data[i]);
|
||||
if(a < 32) {
|
||||
i ++;
|
||||
|
||||
@ -102,7 +102,7 @@ v_buff_size Utils::calcUnescapedStringSize(const char* data, v_buff_size size, v
|
||||
v_buff_size i = 0;
|
||||
|
||||
while (i < size) {
|
||||
v_char8 a = data[i];
|
||||
v_char8 a = static_cast<v_char8>(data[i]);
|
||||
if(a == '\\'){
|
||||
|
||||
if(i + 1 == size){
|
||||
@ -111,7 +111,7 @@ v_buff_size Utils::calcUnescapedStringSize(const char* data, v_buff_size size, v
|
||||
return 0;
|
||||
}
|
||||
|
||||
v_char8 b = data[i + 1];
|
||||
v_char8 b = static_cast<v_char8>(data[i + 1]);
|
||||
|
||||
if(b == '"' || b == '\\' || b == '/' || b == 'b' || b == 'f' || b == 'n' || b == 'r' || b == 't'){
|
||||
result += 1;
|
||||
@ -160,7 +160,7 @@ v_buff_size Utils::calcUnescapedStringSize(const char* data, v_buff_size size, v
|
||||
}
|
||||
|
||||
if(low >= 0xDC00 && low <= 0xDFFF){
|
||||
v_uint32 bigCode = encoding::Unicode::utf16SurrogatePairToCode(code, low);
|
||||
v_uint32 bigCode = static_cast<v_uint32>(encoding::Unicode::utf16SurrogatePairToCode(static_cast<v_int16>(code), static_cast<v_int16>(low)));
|
||||
i += 12;
|
||||
result += encoding::Unicode::getUtf8CharSequenceLengthForCode(bigCode);
|
||||
} else {
|
||||
@ -205,16 +205,16 @@ v_buff_size Utils::escapeUtf8Char(const char* sequence, p_char8 buffer){
|
||||
oatpp::encoding::Unicode::codeToUtf16SurrogatePair(code, high, low);
|
||||
buffer[0] = '\\';
|
||||
buffer[1] = 'u';
|
||||
oatpp::encoding::Hex::writeUInt16(high, &buffer[2]);
|
||||
oatpp::encoding::Hex::writeUInt16(static_cast<v_uint16>(high), &buffer[2]);
|
||||
buffer[6] = '\\';
|
||||
buffer[7] = 'u';
|
||||
oatpp::encoding::Hex::writeUInt16(low, &buffer[8]);
|
||||
oatpp::encoding::Hex::writeUInt16(static_cast<v_uint16>(low), &buffer[8]);
|
||||
return 12;
|
||||
} else {
|
||||
buffer[0] = '\\';
|
||||
buffer[1] = 'u';
|
||||
buffer[2] = '+';
|
||||
oatpp::encoding::Hex::writeUInt32(code, &buffer[2]);
|
||||
oatpp::encoding::Hex::writeUInt32(static_cast<v_uint32>(code), &buffer[2]);
|
||||
return 11;
|
||||
}
|
||||
}
|
||||
@ -232,7 +232,7 @@ oatpp::String Utils::escapeString(const char* data, v_buff_size size, v_uint32 f
|
||||
{
|
||||
v_buff_size i = 0;
|
||||
while (i < safeSize) {
|
||||
v_char8 a = data[i];
|
||||
v_char8 a = static_cast<v_char8>(data[i]);
|
||||
if (a < 32) {
|
||||
|
||||
switch (a) {
|
||||
@ -267,13 +267,13 @@ oatpp::String Utils::escapeString(const char* data, v_buff_size size, v_uint32 f
|
||||
resultData[pos + 1] = '/';
|
||||
pos += 2;
|
||||
} else {
|
||||
resultData[pos] = data[i];
|
||||
resultData[pos] = static_cast<v_char8>(data[i]);
|
||||
pos++;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
resultData[pos] = data[i];
|
||||
resultData[pos] = static_cast<v_char8>(data[i]);
|
||||
pos++;
|
||||
break;
|
||||
|
||||
@ -285,7 +285,7 @@ oatpp::String Utils::escapeString(const char* data, v_buff_size size, v_uint32 f
|
||||
v_buff_size charSize = oatpp::encoding::Unicode::getUtf8CharSequenceLength(a);
|
||||
if (charSize != 0) {
|
||||
if (!(flags & FLAG_ESCAPE_UTF8CHAR)) {
|
||||
std::memcpy(reinterpret_cast<void*>(&resultData[pos]), reinterpret_cast<void*>(const_cast<char*>(&data[i])), charSize);
|
||||
std::memcpy(reinterpret_cast<void*>(&resultData[pos]), reinterpret_cast<void*>(const_cast<char*>(&data[i])), static_cast<size_t>(charSize));
|
||||
pos += charSize;
|
||||
}
|
||||
else {
|
||||
@ -295,7 +295,7 @@ oatpp::String Utils::escapeString(const char* data, v_buff_size size, v_uint32 f
|
||||
}
|
||||
else {
|
||||
// invalid char
|
||||
resultData[pos] = data[i];
|
||||
resultData[pos] = static_cast<v_char8>(data[i]);
|
||||
i++;
|
||||
pos++;
|
||||
}
|
||||
@ -318,10 +318,10 @@ void Utils::unescapeStringToBuffer(const char* data, v_buff_size size, p_char8 r
|
||||
v_buff_size pos = 0;
|
||||
|
||||
while (i < size) {
|
||||
v_char8 a = data[i];
|
||||
v_char8 a = static_cast<v_char8>(data[i]);
|
||||
|
||||
if(a == '\\'){
|
||||
v_char8 b = data[i + 1];
|
||||
v_char8 b = static_cast<v_char8>(data[i + 1]);
|
||||
if(b != 'u'){
|
||||
switch (b) {
|
||||
case '"': resultData[pos] = '"'; pos ++; break;
|
||||
@ -340,7 +340,7 @@ void Utils::unescapeStringToBuffer(const char* data, v_buff_size size, p_char8 r
|
||||
v_uint32 code;
|
||||
encoding::Hex::readUInt32(&data[i + 3], code);
|
||||
i += 11;
|
||||
pos += encoding::Unicode::decodeUtf8Char(code, &resultData[pos]);
|
||||
pos += encoding::Unicode::decodeUtf8Char(static_cast<v_int32>(code), &resultData[pos]);
|
||||
} else {
|
||||
|
||||
v_uint16 code;
|
||||
@ -349,8 +349,8 @@ void Utils::unescapeStringToBuffer(const char* data, v_buff_size size, p_char8 r
|
||||
if(code >= 0xD800 && code <= 0xDBFF){
|
||||
v_uint16 low;
|
||||
encoding::Hex::readUInt16(&data[i + 8], low);
|
||||
v_uint32 bigCode = encoding::Unicode::utf16SurrogatePairToCode(code, low);
|
||||
pos += encoding::Unicode::decodeUtf8Char(bigCode, &resultData[pos]);
|
||||
v_uint32 bigCode = static_cast<v_uint32>(encoding::Unicode::utf16SurrogatePairToCode(static_cast<v_int16>(code), static_cast<v_int16>(low)));
|
||||
pos += encoding::Unicode::decodeUtf8Char(static_cast<v_int32>(bigCode), &resultData[pos]);
|
||||
i += 12;
|
||||
} else {
|
||||
pos += encoding::Unicode::decodeUtf8Char(code, &resultData[pos]);
|
||||
@ -377,7 +377,7 @@ oatpp::String Utils::unescapeString(const char* data, v_buff_size size, v_int64&
|
||||
}
|
||||
auto result = String(unescapedSize);
|
||||
if(unescapedSize == size) {
|
||||
std::memcpy(reinterpret_cast<void*>(const_cast<char*>(result->data())), data, size);
|
||||
std::memcpy(reinterpret_cast<void*>(const_cast<char*>(result->data())), data, static_cast<size_t>(size));
|
||||
} else {
|
||||
unescapeStringToBuffer(data, size, reinterpret_cast<p_char8>(const_cast<char*>(result->data())));
|
||||
}
|
||||
@ -392,9 +392,9 @@ std::string Utils::unescapeStringToStdString(const char* data, v_buff_size size,
|
||||
return "";
|
||||
}
|
||||
std::string result;
|
||||
result.resize(unescapedSize);
|
||||
result.resize(static_cast<size_t>(unescapedSize));
|
||||
if(unescapedSize == size) {
|
||||
std::memcpy(reinterpret_cast<void*>(const_cast<char*>(result.data())), data, size);
|
||||
std::memcpy(reinterpret_cast<void*>(const_cast<char*>(result.data())), data, static_cast<size_t>(size));
|
||||
} else {
|
||||
unescapeStringToBuffer(data, size, reinterpret_cast<p_char8>(const_cast<char*>(result.data())));
|
||||
}
|
||||
@ -412,7 +412,7 @@ const char* Utils::preparseString(ParsingCaret& caret, v_buff_size& size){
|
||||
v_buff_size length = caret.getDataSize();
|
||||
|
||||
while (pos < length) {
|
||||
v_char8 a = data[pos];
|
||||
v_char8 a = static_cast<v_char8>(data[pos]);
|
||||
if(a == '"'){
|
||||
size = pos - pos0;
|
||||
return &data[pos0];
|
||||
|
@ -32,7 +32,7 @@ Deserializer::Deserializer(const std::shared_ptr<Config>& config)
|
||||
: m_config(config)
|
||||
{
|
||||
|
||||
m_methods.resize(data::mapping::type::ClassId::getClassCount(), nullptr);
|
||||
m_methods.resize(static_cast<size_t>(data::mapping::type::ClassId::getClassCount()), nullptr);
|
||||
|
||||
setDeserializerMethod(data::mapping::type::__class::String::CLASS_ID, &Deserializer::deserializeString);
|
||||
setDeserializerMethod(data::mapping::type::__class::Any::CLASS_ID, &Deserializer::deserializeAny);
|
||||
@ -66,7 +66,7 @@ Deserializer::Deserializer(const std::shared_ptr<Config>& config)
|
||||
}
|
||||
|
||||
void Deserializer::setDeserializerMethod(const data::mapping::type::ClassId& classId, DeserializerMethod method) {
|
||||
const v_uint32 id = classId.id;
|
||||
const v_uint32 id = static_cast<v_uint32>(classId.id);
|
||||
if(id >= m_methods.size()) {
|
||||
m_methods.resize(id + 1, nullptr);
|
||||
}
|
||||
@ -83,7 +83,7 @@ void Deserializer::skipScope(oatpp::parser::Caret& caret, v_char8 charOpen, v_ch
|
||||
bool isInString = false;
|
||||
|
||||
while(pos < size){
|
||||
v_char8 a = data[pos];
|
||||
v_char8 a = static_cast<v_char8>(data[pos]);
|
||||
if(a == charOpen){
|
||||
if(!isInString){
|
||||
scopeCounter ++;
|
||||
@ -113,7 +113,7 @@ void Deserializer::skipString(oatpp::parser::Caret& caret){
|
||||
v_buff_size pos = caret.getPosition();
|
||||
v_int32 scopeCounter = 0;
|
||||
while(pos < size){
|
||||
v_char8 a = data[pos];
|
||||
v_char8 a = static_cast<v_char8>(data[pos]);
|
||||
if(a == '"'){
|
||||
scopeCounter ++;
|
||||
if(scopeCounter == 2) {
|
||||
@ -132,7 +132,7 @@ void Deserializer::skipToken(oatpp::parser::Caret& caret){
|
||||
v_buff_size size = caret.getDataSize();
|
||||
v_buff_size pos = caret.getPosition();
|
||||
while(pos < size){
|
||||
v_char8 a = data[pos];
|
||||
v_char8 a = static_cast<v_char8>(data[pos]);
|
||||
if(a == ' ' || a == '\t' || a == '\n' || a == '\r' || a == '\b' || a == '\f' ||
|
||||
a == '}' || a == ',' || a == ']') {
|
||||
caret.setPosition(pos);
|
||||
@ -225,7 +225,7 @@ const data::mapping::type::Type* Deserializer::guessNumberType(oatpp::parser::Ca
|
||||
const data::mapping::type::Type* Deserializer::guessType(oatpp::parser::Caret& caret) {
|
||||
{
|
||||
parser::Caret::StateSaveGuard stateGuard(caret);
|
||||
v_char8 c = *caret.getCurrData();
|
||||
v_char8 c = static_cast<v_char8>(*caret.getCurrData());
|
||||
switch (c) {
|
||||
case '"':
|
||||
return String::Class::getType();
|
||||
@ -494,7 +494,7 @@ oatpp::Void Deserializer::deserializeObject(Deserializer* deserializer, parser::
|
||||
}
|
||||
|
||||
oatpp::Void Deserializer::deserialize(parser::Caret& caret, const Type* const type) {
|
||||
auto id = type->classId.id;
|
||||
auto id = static_cast<v_uint32>(type->classId.id);
|
||||
auto& method = m_methods[id];
|
||||
if(method) {
|
||||
return (*method)(this, caret, type);
|
||||
|
@ -33,7 +33,7 @@ Serializer::Serializer(const std::shared_ptr<Config>& config)
|
||||
: m_config(config)
|
||||
{
|
||||
|
||||
m_methods.resize(data::mapping::type::ClassId::getClassCount(), nullptr);
|
||||
m_methods.resize(static_cast<size_t>(data::mapping::type::ClassId::getClassCount()), nullptr);
|
||||
|
||||
setSerializerMethod(data::mapping::type::__class::String::CLASS_ID, &Serializer::serializeString);
|
||||
setSerializerMethod(data::mapping::type::__class::Any::CLASS_ID, &Serializer::serializeAny);
|
||||
@ -67,7 +67,7 @@ Serializer::Serializer(const std::shared_ptr<Config>& config)
|
||||
}
|
||||
|
||||
void Serializer::setSerializerMethod(const data::mapping::type::ClassId& classId, SerializerMethod method) {
|
||||
const v_uint32 id = classId.id;
|
||||
const v_uint32 id = static_cast<v_uint32>(classId.id);
|
||||
if(id >= m_methods.size()) {
|
||||
m_methods.resize(id + 1, nullptr);
|
||||
}
|
||||
@ -93,7 +93,7 @@ void Serializer::serializeString(Serializer* serializer,
|
||||
|
||||
auto str = static_cast<std::string*>(polymorph.get());
|
||||
|
||||
serializeString(stream, str->data(), str->size(), serializer->m_config->escapeFlags);
|
||||
serializeString(stream, str->data(), static_cast<v_buff_size>(str->size()), serializer->m_config->escapeFlags);
|
||||
|
||||
}
|
||||
|
||||
@ -202,7 +202,7 @@ void Serializer::serializeMap(Serializer* serializer,
|
||||
(first) ? first = false : stream->writeSimple(",", 1);
|
||||
const auto& untypedKey = iterator->getKey();
|
||||
const auto& key = oatpp::String(std::static_pointer_cast<std::string>(untypedKey.getPtr()));
|
||||
serializeString(stream, key->data(), key->size(), serializer->m_config->escapeFlags);
|
||||
serializeString(stream, key->data(), static_cast<v_buff_size>(key->size()), serializer->m_config->escapeFlags);
|
||||
stream->writeSimple(":", 1);
|
||||
serializer->serialize(stream, value);
|
||||
}
|
||||
@ -245,7 +245,7 @@ void Serializer::serializeObject(Serializer* serializer,
|
||||
|
||||
if (value || config->includeNullFields || (field->info.required && config->alwaysIncludeRequired)) {
|
||||
(first) ? first = false : stream->writeSimple(",", 1);
|
||||
serializeString(stream, field->name, std::strlen(field->name), serializer->m_config->escapeFlags);
|
||||
serializeString(stream, field->name, static_cast<v_buff_size>(std::strlen(field->name)), serializer->m_config->escapeFlags);
|
||||
stream->writeSimple(":", 1);
|
||||
serializer->serialize(stream, value);
|
||||
}
|
||||
@ -259,7 +259,7 @@ void Serializer::serializeObject(Serializer* serializer,
|
||||
void Serializer::serialize(data::stream::ConsistentOutputStream* stream,
|
||||
const oatpp::Void& polymorph)
|
||||
{
|
||||
auto id = polymorph.getValueType()->classId.id;
|
||||
auto id = static_cast<v_uint32>(polymorph.getValueType()->classId.id);
|
||||
auto& method = m_methods[id];
|
||||
if(method) {
|
||||
(*method)(this, stream, polymorph);
|
||||
|
@ -94,7 +94,7 @@ const std::list<std::shared_ptr<Part>>& PartList::getAllParts() {
|
||||
}
|
||||
|
||||
v_int64 PartList::count() {
|
||||
return m_parts.size();
|
||||
return static_cast<v_int64>(m_parts.size());
|
||||
}
|
||||
|
||||
}}}}
|
||||
|
@ -144,14 +144,14 @@ StatefulParser::ListenerCall StatefulParser::parseNext_Boundary(data::buffer::In
|
||||
auto size = inlineData.bytesLeft;
|
||||
|
||||
auto sampleData = m_nextBoundarySample->data();
|
||||
v_io_size sampleSize = m_nextBoundarySample->size();
|
||||
v_io_size sampleSize = static_cast<v_io_size>(m_nextBoundarySample->size());
|
||||
|
||||
if (m_currPartIndex == 0) {
|
||||
sampleData = m_firstBoundarySample->data();
|
||||
sampleSize = m_firstBoundarySample->size();
|
||||
sampleSize = static_cast<v_io_size>(m_firstBoundarySample->size());
|
||||
} else {
|
||||
sampleData = m_nextBoundarySample->data();
|
||||
sampleSize = m_nextBoundarySample->size();
|
||||
sampleSize = static_cast<v_io_size>(m_nextBoundarySample->size());
|
||||
}
|
||||
|
||||
v_io_size checkSize = sampleSize - m_currBoundaryCharIndex;
|
||||
|
@ -140,7 +140,7 @@ const char* const ContentRange::UNIT_BYTES = "bytes";
|
||||
|
||||
oatpp::String Range::toString() const {
|
||||
data::stream::BufferOutputStream stream(256);
|
||||
stream.writeSimple(units->data(), units->size());
|
||||
stream.writeSimple(units->data(), static_cast<v_buff_size>(units->size()));
|
||||
stream.writeSimple("=", 1);
|
||||
stream.writeAsString(start);
|
||||
stream.writeSimple("-", 1);
|
||||
@ -185,7 +185,7 @@ Range Range::parse(const oatpp::String& str) {
|
||||
|
||||
oatpp::String ContentRange::toString() const {
|
||||
data::stream::BufferOutputStream stream(256);
|
||||
stream.writeSimple(units->data(), units->size());
|
||||
stream.writeSimple(units->data(), static_cast<v_buff_size>(units->size()));
|
||||
stream.writeSimple(" ", 1);
|
||||
stream.writeAsString(start);
|
||||
stream.writeSimple("-", 1);
|
||||
@ -266,7 +266,7 @@ oatpp::data::share::StringKeyLabelCI Parser::parseHeaderNameLabel(const std::sha
|
||||
oatpp::parser::Caret& caret) {
|
||||
const char* data = caret.getData();
|
||||
for(v_buff_size i = caret.getPosition(); i < caret.getDataSize(); i++) {
|
||||
v_char8 a = data[i];
|
||||
v_char8 a = static_cast<v_char8>(data[i]);
|
||||
if(a == ':' || a == ' '){
|
||||
oatpp::data::share::StringKeyLabelCI label(headersText, &data[caret.getPosition()], i - caret.getPosition());
|
||||
caret.setPosition(i);
|
||||
|
@ -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<p_char8>(const_cast<char*>(m_chunkHeader->data())), m_chunkHeader->size());
|
||||
dataOut.set(reinterpret_cast<p_char8>(const_cast<char*>(m_chunkHeader->data())), static_cast<v_buff_size>(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<p_char8>(const_cast<char*>(m_chunkHeader->data())), m_chunkHeader->size());
|
||||
dataOut.set(reinterpret_cast<p_char8>(const_cast<char*>(m_chunkHeader->data())), static_cast<v_buff_size>(m_chunkHeader->size()));
|
||||
|
||||
m_firstChunk = false;
|
||||
m_writeChunkHeader = false;
|
||||
|
@ -83,7 +83,7 @@ void SimpleBodyDecoder::handleExpectHeader(const Headers& headers, data::stream:
|
||||
|
||||
auto expect = headers.getAsMemoryLabel<data::share::StringKeyLabelCI>(Header::EXPECT);
|
||||
if(expect == Header::Value::EXPECT_100_CONTINUE) {
|
||||
auto res = connection->writeExactSizeDataSimple(RESPONSE_100_CONTINUE.data(), RESPONSE_100_CONTINUE.size());
|
||||
auto res = connection->writeExactSizeDataSimple(RESPONSE_100_CONTINUE.data(), static_cast<v_buff_size>(RESPONSE_100_CONTINUE.size()));
|
||||
if(res != static_cast<v_io_size>(RESPONSE_100_CONTINUE.size())) {
|
||||
throw std::runtime_error("[oatpp::web::protocol::http::incoming::SimpleBodyDecoder::handleExpectHeader()]: "
|
||||
"Error. Unable to send 100-continue response.");
|
||||
@ -97,7 +97,7 @@ oatpp::async::CoroutineStarter SimpleBodyDecoder::handleExpectHeaderAsync(const
|
||||
{
|
||||
auto expect = headers.getAsMemoryLabel<data::share::StringKeyLabelCI>(Header::EXPECT);
|
||||
if(expect == Header::Value::EXPECT_100_CONTINUE) {
|
||||
return connection->writeExactSizeDataAsync(RESPONSE_100_CONTINUE.data(), RESPONSE_100_CONTINUE.size());
|
||||
return connection->writeExactSizeDataAsync(RESPONSE_100_CONTINUE.data(), static_cast<v_buff_size>(RESPONSE_100_CONTINUE.size()));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -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<void*>(const_cast<char*>(m_buffer->data())), m_buffer->size())
|
||||
, m_inlineData(reinterpret_cast<void*>(const_cast<char*>(m_buffer->data())), static_cast<v_buff_size>(m_buffer->size()))
|
||||
{}
|
||||
|
||||
std::shared_ptr<BufferBody> BufferBody::createShared(const oatpp::String &buffer,
|
||||
@ -49,7 +49,7 @@ v_io_size BufferBody::read(void *buffer, v_buff_size count, async::Action &actio
|
||||
desiredToRead = count;
|
||||
}
|
||||
|
||||
std::memcpy(buffer, m_inlineData.currBufferPtr, desiredToRead);
|
||||
std::memcpy(buffer, m_inlineData.currBufferPtr, static_cast<size_t>(desiredToRead));
|
||||
m_inlineData.inc(desiredToRead);
|
||||
|
||||
return desiredToRead;
|
||||
@ -71,7 +71,7 @@ p_char8 BufferBody::getKnownData() {
|
||||
}
|
||||
|
||||
v_int64 BufferBody::getKnownSize() {
|
||||
return m_buffer->size();
|
||||
return static_cast<v_int64>(m_buffer->size());
|
||||
}
|
||||
|
||||
}}}}}
|
||||
|
@ -134,7 +134,7 @@ v_io_size MultipartBody::readBoundary(const std::shared_ptr<Multipart>& multipar
|
||||
boundary = "\r\n--" + multipart->getBoundary() + "\r\n";
|
||||
}
|
||||
|
||||
readStream.reset(boundary.getPtr(), reinterpret_cast<p_char8>(const_cast<char*>(boundary->data())), boundary->size());
|
||||
readStream.reset(boundary.getPtr(), reinterpret_cast<p_char8>(const_cast<char*>(boundary->data())), static_cast<v_buff_size>(boundary->size()));
|
||||
|
||||
}
|
||||
|
||||
@ -161,7 +161,7 @@ v_io_size MultipartBody::readHeaders(const std::shared_ptr<Multipart>& multipart
|
||||
http::Utils::writeHeaders(part->getHeaders(), &stream);
|
||||
stream.writeSimple("\r\n", 2);
|
||||
auto str = stream.toString();
|
||||
readStream.reset(str.getPtr(), reinterpret_cast<p_char8>(const_cast<char*>(str->data())), str->size());
|
||||
readStream.reset(str.getPtr(), reinterpret_cast<p_char8>(const_cast<char*>(str->data())), static_cast<v_buff_size>(str->size()));
|
||||
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ std::shared_ptr<handler::AuthorizationObject> BasicAuthorizationHandler::handleA
|
||||
|
||||
if(header && header->size() > 6 && utils::String::compare(header->data(), 6, "Basic ", 6) == 0) {
|
||||
|
||||
oatpp::String auth = oatpp::encoding::Base64::decode(header->c_str() + 6, header->size() - 6);
|
||||
oatpp::String auth = oatpp::encoding::Base64::decode(header->c_str() + 6, static_cast<v_buff_size>(header->size() - 6));
|
||||
parser::Caret caret(auth);
|
||||
|
||||
if (caret.findChar(':')) {
|
||||
@ -110,7 +110,7 @@ std::shared_ptr<AuthorizationObject> BearerAuthorizationHandler::handleAuthoriza
|
||||
|
||||
if(header && header->size() > 7 && utils::String::compare(header->data(), 7, "Bearer ", 7) == 0) {
|
||||
|
||||
oatpp::String token = oatpp::String(header->c_str() + 7, header->size() - 7);
|
||||
oatpp::String token = oatpp::String(header->c_str() + 7, static_cast<v_buff_size>(header->size() - 7));
|
||||
|
||||
auto authResult = authorize(token);
|
||||
if(authResult) {
|
||||
@ -135,4 +135,4 @@ std::shared_ptr<AuthorizationObject> BearerAuthorizationHandler::authorize(const
|
||||
return authObject;
|
||||
}
|
||||
|
||||
}}}}
|
||||
}}}}
|
||||
|
@ -99,17 +99,17 @@ std::shared_ptr<Pattern> Pattern::parse(p_char8 data, v_buff_size size){
|
||||
}
|
||||
|
||||
std::shared_ptr<Pattern> Pattern::parse(const char* data){
|
||||
return parse(reinterpret_cast<p_char8>(const_cast<char*>(data)), std::strlen(data));
|
||||
return parse(reinterpret_cast<p_char8>(const_cast<char*>(data)), static_cast<v_buff_size>(std::strlen(data)));
|
||||
}
|
||||
|
||||
std::shared_ptr<Pattern> Pattern::parse(const oatpp::String& data){
|
||||
return parse(reinterpret_cast<p_char8>(const_cast<char*>(data->data())), data->size());
|
||||
return parse(reinterpret_cast<p_char8>(const_cast<char*>(data->data())), static_cast<v_buff_size>(data->size()));
|
||||
}
|
||||
|
||||
v_char8 Pattern::findSysChar(oatpp::parser::Caret& caret) {
|
||||
auto data = caret.getData();
|
||||
for (v_buff_size i = caret.getPosition(); i < caret.getDataSize(); i++) {
|
||||
v_char8 a = data[i];
|
||||
v_char8 a = static_cast<v_char8>(data[i]);
|
||||
if(a == '/' || a == '?') {
|
||||
caret.setPosition(i);
|
||||
return a;
|
||||
@ -136,7 +136,7 @@ bool Pattern::match(const StringKeyLabel& url, MatchMap& matchMap) {
|
||||
|
||||
if(part->function == Part::FUNCTION_CONST){
|
||||
|
||||
if(!caret.isAtText(part->text->data(), part->text->size(), true)) {
|
||||
if(!caret.isAtText(part->text->data(), static_cast<v_buff_size>(part->text->size()), true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
|
||||
void writeChar(char c) {
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
m_buffer->writeCharSimple(c);
|
||||
m_buffer->writeCharSimple(static_cast<v_char8>(c));
|
||||
}
|
||||
|
||||
};
|
||||
@ -159,7 +159,7 @@ bool checkSymbol(char symbol, const char* data, v_buff_size size) {
|
||||
}
|
||||
|
||||
bool checkSymbol(char symbol, const oatpp::String& str) {
|
||||
return checkSymbol(symbol, str->data(), str->size());
|
||||
return checkSymbol(symbol, str->data(), static_cast<v_buff_size>(str->size()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ void InMemoryDataTest::onRun() {
|
||||
|
||||
{
|
||||
auto s = data.openOutputStream();
|
||||
s->writeExactSizeDataSimple(testData->data(), testData->size());
|
||||
s->writeExactSizeDataSimple(testData->data(), static_cast<v_buff_size>(testData->size()));
|
||||
}
|
||||
|
||||
OATPP_ASSERT(data.getKnownSize() == static_cast<v_int64>(testData->size()))
|
||||
@ -59,10 +59,10 @@ void InMemoryDataTest::onRun() {
|
||||
|
||||
{
|
||||
auto s1 = data.openOutputStream();
|
||||
s1->writeExactSizeDataSimple(testData1->data(), testData1->size());
|
||||
s1->writeExactSizeDataSimple(testData1->data(), static_cast<v_buff_size>(testData1->size()));
|
||||
|
||||
auto s2 = data.openOutputStream();
|
||||
s2->writeExactSizeDataSimple(testData2->data(), testData2->size());
|
||||
s2->writeExactSizeDataSimple(testData2->data(), static_cast<v_buff_size>(testData2->size()));
|
||||
|
||||
s1.reset();
|
||||
OATPP_ASSERT(data.getInMemoryData() == "data=" + testData1)
|
||||
@ -79,7 +79,7 @@ void InMemoryDataTest::onRun() {
|
||||
|
||||
{
|
||||
auto s1 = data.openOutputStream();
|
||||
s1->writeExactSizeDataSimple(testData->data(), testData->size());
|
||||
s1->writeExactSizeDataSimple(testData->data(), static_cast<v_buff_size>(testData->size()));
|
||||
}
|
||||
|
||||
oatpp::data::stream::BufferOutputStream s;
|
||||
|
@ -37,7 +37,7 @@ void UrlTest::onRun(){
|
||||
|
||||
for(v_int32 i = 0; i < 100; i++) {
|
||||
oatpp::String buff(100);
|
||||
utils::random::Random::randomBytes(reinterpret_cast<p_char8>(const_cast<char*>(buff->data())), buff->size());
|
||||
utils::random::Random::randomBytes(reinterpret_cast<p_char8>(const_cast<char*>(buff->data())), static_cast<v_buff_size>(buff->size()));
|
||||
auto encoded = oatpp::encoding::Url::encode(buff, config);
|
||||
auto decoded = oatpp::encoding::Url::decode(encoded);
|
||||
OATPP_ASSERT(decoded == buff);
|
||||
@ -50,7 +50,7 @@ void UrlTest::onRun(){
|
||||
|
||||
for(v_int32 i = 0; i < 100; i++) {
|
||||
oatpp::String buff(100);
|
||||
utils::random::Random::randomBytes(reinterpret_cast<p_char8>(const_cast<char*>(buff->data())), buff->size());
|
||||
utils::random::Random::randomBytes(reinterpret_cast<p_char8>(const_cast<char*>(buff->data())), static_cast<v_buff_size>(buff->size()));
|
||||
auto encoded = oatpp::encoding::Url::encode(buff, config);
|
||||
auto decoded = oatpp::encoding::Url::decode(encoded);
|
||||
OATPP_ASSERT(decoded == buff);
|
||||
|
@ -55,7 +55,7 @@ namespace {
|
||||
auto submission = m_interface->connect();
|
||||
auto socket = submission->getSocket();
|
||||
|
||||
auto res = socket->writeExactSizeDataSimple(m_dataSample->data(), m_dataSample->size());
|
||||
auto res = socket->writeExactSizeDataSimple(m_dataSample->data(), static_cast<v_buff_size>(m_dataSample->size()));
|
||||
OATPP_ASSERT(res == static_cast<v_io_size>(m_dataSample->size()));
|
||||
|
||||
v_char8 buffer[100];
|
||||
@ -87,7 +87,7 @@ namespace {
|
||||
void run() {
|
||||
v_char8 buffer[100];
|
||||
oatpp::data::stream::BufferOutputStream stream;
|
||||
auto res = oatpp::data::stream::transfer(m_socket.get(), &stream, m_dataSample->size(), buffer, 100);
|
||||
auto res = oatpp::data::stream::transfer(m_socket.get(), &stream, static_cast<v_io_size>(m_dataSample->size()), buffer, 100);
|
||||
|
||||
OATPP_ASSERT(res == static_cast<v_io_size>(m_dataSample->size()));
|
||||
OATPP_ASSERT(stream.getCurrentPosition() == res);
|
||||
|
@ -40,7 +40,7 @@ namespace {
|
||||
typedef oatpp::network::virtual_::Pipe Pipe;
|
||||
|
||||
const char* DATA_CHUNK = "<0123456789/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ>";
|
||||
const v_buff_size CHUNK_SIZE = std::strlen(DATA_CHUNK);
|
||||
const v_buff_size CHUNK_SIZE = static_cast<v_buff_size>(std::strlen(DATA_CHUNK));
|
||||
|
||||
class WriterTask : public oatpp::base::Countable {
|
||||
private:
|
||||
|
@ -217,7 +217,7 @@ void FullAsyncTest::onRun() {
|
||||
v_int32 numIterations = 10;
|
||||
oatpp::data::stream::BufferOutputStream stream;
|
||||
for(v_int32 j = 0; j < numIterations; j++) {
|
||||
stream.writeSimple(sample->data(), sample->size());
|
||||
stream.writeSimple(sample->data(), static_cast<v_buff_size>(sample->size()));
|
||||
}
|
||||
auto data = stream.toString();
|
||||
auto response = client->getChunked(sample, numIterations, connection);
|
||||
|
@ -437,7 +437,7 @@ void FullTest::onRun() {
|
||||
v_int32 numIterations = 10;
|
||||
oatpp::data::stream::BufferOutputStream stream;
|
||||
for(v_int32 j = 0; j < numIterations; j++) {
|
||||
stream.writeSimple(sample->data(), sample->size());
|
||||
stream.writeSimple(sample->data(), static_cast<v_buff_size>(sample->size()));
|
||||
}
|
||||
auto data = stream.toString();
|
||||
auto response = client->getChunked(sample, numIterations, connection);
|
||||
|
@ -163,11 +163,11 @@ void PipelineAsyncTest::onRun() {
|
||||
oatpp::data::stream::BufferOutputStream receiveStream;
|
||||
oatpp::data::buffer::IOBuffer ioBuffer;
|
||||
|
||||
oatpp::data::stream::transfer(connection.object.get(), &receiveStream, sample->size() * m_pipelineSize, ioBuffer.getData(), ioBuffer.getSize());
|
||||
oatpp::data::stream::transfer(connection.object.get(), &receiveStream, static_cast<v_io_size>(sample->size() * static_cast<size_t>(m_pipelineSize)), ioBuffer.getData(), ioBuffer.getSize());
|
||||
|
||||
auto result = receiveStream.toString();
|
||||
|
||||
OATPP_ASSERT(result->size() == sample->size() * m_pipelineSize);
|
||||
OATPP_ASSERT(result->size() == sample->size() * static_cast<size_t>(m_pipelineSize));
|
||||
//OATPP_ASSERT(result == wantedResult); // headers may come in different order on different OSs
|
||||
|
||||
});
|
||||
|
@ -161,14 +161,14 @@ void PipelineTest::onRun() {
|
||||
oatpp::data::stream::BufferOutputStream receiveStream;
|
||||
oatpp::data::buffer::IOBuffer ioBuffer;
|
||||
|
||||
v_io_size transferSize = sample->size() * m_pipelineSize;
|
||||
v_io_size transferSize = static_cast<v_io_size>(sample->size() * static_cast<size_t>(m_pipelineSize));
|
||||
|
||||
OATPP_LOGD(TAG, "want to Receive %ld bytes", transferSize);
|
||||
oatpp::data::stream::transfer(connection.object.get(), &receiveStream, transferSize, ioBuffer.getData(), ioBuffer.getSize());
|
||||
|
||||
auto result = receiveStream.toString();
|
||||
|
||||
OATPP_ASSERT(result->size() == sample->size() * m_pipelineSize);
|
||||
OATPP_ASSERT(result->size() == sample->size() * static_cast<size_t>(m_pipelineSize));
|
||||
//OATPP_ASSERT(result == wantedResult); // headers may come in different order on different OSs
|
||||
|
||||
});
|
||||
|
@ -68,15 +68,15 @@ namespace {
|
||||
void parseStepByStep(const oatpp::String& text,
|
||||
const oatpp::String& boundary,
|
||||
const std::shared_ptr<oatpp::web::mime::multipart::StatefulParser::Listener>& listener,
|
||||
const v_int32 step)
|
||||
const size_t step)
|
||||
{
|
||||
|
||||
oatpp::web::mime::multipart::StatefulParser parser(boundary, listener, nullptr);
|
||||
|
||||
oatpp::data::stream::BufferInputStream stream(text.getPtr(), text->data(), text->size());
|
||||
oatpp::data::stream::BufferInputStream stream(text.getPtr(), text->data(), static_cast<v_buff_size>(text->size()));
|
||||
std::unique_ptr<v_char8[]> buffer(new v_char8[step]);
|
||||
v_io_size size;
|
||||
while((size = stream.readSimple(buffer.get(), step)) != 0) {
|
||||
while((size = stream.readSimple(buffer.get(), static_cast<v_buff_size>(step))) != 0) {
|
||||
oatpp::data::buffer::InlineWriteData inlineData(buffer.get(), size);
|
||||
while(inlineData.bytesLeft > 0 && !parser.finished()) {
|
||||
oatpp::async::Action action;
|
||||
@ -119,7 +119,7 @@ void StatefulParserTest::onRun() {
|
||||
auto listener = std::make_shared<oatpp::web::mime::multipart::PartsParser>(&multipart);
|
||||
listener->setDefaultPartReader(oatpp::web::mime::multipart::createInMemoryPartReader(128));
|
||||
|
||||
parseStepByStep(text, "12345", listener, static_cast<v_int32>(i));
|
||||
parseStepByStep(text, "12345", listener, i);
|
||||
|
||||
if(multipart.count() != 5) {
|
||||
OATPP_LOGD(TAG, "TEST_DATA_1 itearation %lu", i);
|
||||
|
Loading…
Reference in New Issue
Block a user