mirror of
https://gitee.com/zyjblog/oatpp.git
synced 2024-12-22 22:16:37 +08:00
Fix compiler warnings in headers (-Wsign-conversion)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
This commit is contained in:
parent
104c4eb011
commit
9e88481674
@ -166,7 +166,7 @@ public:
|
||||
|
||||
v_int64 getCollectionSize(const type::Void& object) const override {
|
||||
ContainerType* collection = static_cast<ContainerType*>(object.get());
|
||||
return collection->size();
|
||||
return static_cast<v_int64>(collection->size());
|
||||
}
|
||||
|
||||
void addItem(const type::Void& object, const type::Void& item) const override {
|
||||
|
@ -188,7 +188,7 @@ public:
|
||||
|
||||
v_int64 getMapSize(const type::Void& object) const override {
|
||||
ContainerType* map = static_cast<ContainerType*>(object.get());
|
||||
return map->size();
|
||||
return static_cast<v_int64>(map->size());
|
||||
}
|
||||
|
||||
void addItem(const type::Void& object, const type::Void& key, const type::Void& value) const override {
|
||||
|
@ -629,7 +629,7 @@ struct hash<oatpp::data::mapping::type::ClassId> {
|
||||
typedef v_uint64 result_type;
|
||||
|
||||
result_type operator()(argument_type const& v) const noexcept {
|
||||
return v.id;
|
||||
return static_cast<result_type>(v.id);
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -126,7 +126,7 @@ public:
|
||||
* @return - `true` if equals.
|
||||
*/
|
||||
bool equals(const char* data) const {
|
||||
auto len = data != nullptr ? std::strlen(data) : 0;
|
||||
auto len = data != nullptr ? static_cast<v_buff_size>(std::strlen(data)) : 0;
|
||||
return utils::String::compare(m_data, m_size, data, len) == 0;
|
||||
}
|
||||
|
||||
@ -154,7 +154,7 @@ public:
|
||||
* @return std::string(data, size)
|
||||
*/
|
||||
std::string std_str() const {
|
||||
return std::string(reinterpret_cast<const char*>(m_data), m_size);
|
||||
return std::string(reinterpret_cast<const char*>(m_data), static_cast<size_t>(m_size));
|
||||
}
|
||||
|
||||
inline bool operator==(std::nullptr_t) const {
|
||||
@ -210,7 +210,7 @@ public:
|
||||
inline bool operator==(const String& str) const {
|
||||
if(m_data == nullptr) return str == nullptr;
|
||||
if(str == nullptr) return false;
|
||||
return equals(str->data(), str->size());
|
||||
return equals(str->data(), static_cast<v_buff_size>(str->size()));
|
||||
}
|
||||
|
||||
inline bool operator!=(const String& str) const {
|
||||
@ -260,7 +260,7 @@ public:
|
||||
}
|
||||
|
||||
inline bool operator==(const char* str) const {
|
||||
auto len = str != nullptr ? std::strlen(str) : 0;
|
||||
auto len = str != nullptr ? static_cast<v_buff_size>(std::strlen(str)) : 0;
|
||||
return utils::String::compareCI_ASCII(m_data, m_size, str, len) == 0;
|
||||
}
|
||||
|
||||
@ -271,7 +271,7 @@ public:
|
||||
inline bool operator==(const String& str) const {
|
||||
if(m_data == nullptr) return str == nullptr;
|
||||
if(str == nullptr) return false;
|
||||
return utils::String::compareCI_ASCII(m_data, m_size, str->data(), str->size()) == 0;
|
||||
return utils::String::compareCI_ASCII(m_data, m_size, str->data(), static_cast<v_buff_size>(str->size())) == 0;
|
||||
}
|
||||
|
||||
inline bool operator!=(const String& str) const {
|
||||
@ -311,8 +311,8 @@ namespace std {
|
||||
auto data = reinterpret_cast<const char*>(s.getData());
|
||||
result_type result = 0;
|
||||
for(v_buff_size i = 0; i < s.getSize(); i++) {
|
||||
v_char8 c = data[i];
|
||||
result = (31 * result) + c;
|
||||
auto c = data[i];
|
||||
result = (31 * result) + static_cast<result_type>(c);
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -331,8 +331,8 @@ namespace std {
|
||||
auto data = reinterpret_cast<const char*>(s.getData());
|
||||
result_type result = 0;
|
||||
for(v_buff_size i = 0; i < s.getSize(); i++) {
|
||||
v_char8 c = data[i] | 32;
|
||||
result = (31 * result) + c;
|
||||
auto c = data[i] | 32;
|
||||
result = (31 * result) + static_cast<result_type>(c);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -230,7 +230,7 @@ public:
|
||||
* @return - actual number of bytes written. &id:oatpp::v_io_size;.
|
||||
*/
|
||||
v_io_size writeSimple(const char* data){
|
||||
return writeSimple(data, std::strlen(data));
|
||||
return writeSimple(data, static_cast<v_buff_size>(std::strlen(data)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -239,7 +239,7 @@ public:
|
||||
* @return - actual number of bytes written. &id:oatpp::v_io_size;.
|
||||
*/
|
||||
v_io_size writeSimple(const oatpp::String& str){
|
||||
return writeSimple(str->data(), str->size());
|
||||
return writeSimple(str->data(), static_cast<v_buff_size>(str->size()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -379,7 +379,7 @@ public:
|
||||
}
|
||||
|
||||
m_running = false;
|
||||
m_counter -= m_bench.size();
|
||||
m_counter -= static_cast<v_int64>(m_bench.size());
|
||||
m_bench.clear();
|
||||
}
|
||||
|
||||
|
@ -199,7 +199,7 @@ namespace oatpp { namespace utils { namespace conversion {
|
||||
*/
|
||||
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), n, pattern, value);
|
||||
return snprintf(reinterpret_cast<char*>(data), static_cast<size_t>(n), pattern, value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -745,7 +745,7 @@ namespace std {
|
||||
typedef v_uint64 result_type;
|
||||
|
||||
result_type operator()(oatpp::web::protocol::http::Status const& s) const noexcept {
|
||||
return s.code;
|
||||
return static_cast<result_type>(s.code);
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -187,7 +187,7 @@ public:
|
||||
: m_text(text)
|
||||
, m_counter(0)
|
||||
, m_iterations(iterations)
|
||||
, m_inlineData(text->data(), text->size())
|
||||
, m_inlineData(text->data(), static_cast<v_buff_size>(text->size()))
|
||||
{}
|
||||
|
||||
v_io_size read(void *buffer, v_buff_size count, async::Action& action) override {
|
||||
@ -202,11 +202,11 @@ public:
|
||||
desiredToRead = count;
|
||||
}
|
||||
|
||||
std::memcpy(buffer, m_inlineData.currBufferPtr, desiredToRead);
|
||||
std::memcpy(buffer, m_inlineData.currBufferPtr, static_cast<size_t>(desiredToRead));
|
||||
m_inlineData.inc(desiredToRead);
|
||||
|
||||
if (m_inlineData.bytesLeft == 0) {
|
||||
m_inlineData.set(m_text->data(), m_text->size());
|
||||
m_inlineData.set(m_text->data(), static_cast<v_buff_size>(m_text->size()));
|
||||
m_counter++;
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ public:
|
||||
: m_text(text)
|
||||
, m_counter(0)
|
||||
, m_iterations(iterations)
|
||||
, m_inlineData(text->data(), text->size())
|
||||
, m_inlineData(text->data(), static_cast<v_buff_size>(text->size()))
|
||||
{}
|
||||
|
||||
v_io_size read(void *buffer, v_buff_size count, async::Action& action) override {
|
||||
@ -168,11 +168,11 @@ public:
|
||||
desiredToRead = count;
|
||||
}
|
||||
|
||||
std::memcpy(buffer, m_inlineData.currBufferPtr, desiredToRead);
|
||||
std::memcpy(buffer, m_inlineData.currBufferPtr, static_cast<size_t>(desiredToRead));
|
||||
m_inlineData.inc(desiredToRead);
|
||||
|
||||
if (m_inlineData.bytesLeft == 0) {
|
||||
m_inlineData.set(m_text->data(), m_text->size());
|
||||
m_inlineData.set(m_text->data(), static_cast<v_buff_size>(m_text->size()));
|
||||
m_counter++;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user