Fix warnings on Windows (#368)
This commit is contained in:
parent
4bd19773b5
commit
810896c94c
|
@ -116,7 +116,7 @@ void create_model::createModelClassFromPG(
|
|||
<< std::endl;
|
||||
return;
|
||||
}
|
||||
for (size_t i = 0; i < r.size(); ++i)
|
||||
for (Result::SizeType i = 0; i < r.size(); ++i)
|
||||
{
|
||||
auto row = r[i];
|
||||
ColumnInfo info;
|
||||
|
@ -977,13 +977,17 @@ void create_model::createModel(const std::string &path,
|
|||
closedir(dp);
|
||||
#endif
|
||||
auto configFile = path + "/model.json";
|
||||
#ifdef _WIN32
|
||||
if (_access(configFile.c_str(), 0) != 0)
|
||||
#else
|
||||
if (access(configFile.c_str(), 0) != 0)
|
||||
#endif
|
||||
{
|
||||
std::cerr << "Config file " << configFile << " not found!" << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
#ifdef _WIN32
|
||||
if (access(configFile.c_str(), 04) != 0)
|
||||
if (_access(configFile.c_str(), 04) != 0)
|
||||
#else
|
||||
if (access(configFile.c_str(), R_OK) != 0)
|
||||
#endif
|
||||
|
|
|
@ -150,7 +150,10 @@ class Relationship
|
|||
else
|
||||
{
|
||||
char message[128];
|
||||
sprintf(message, "Invalid relationship type: %s", type.data());
|
||||
snprintf(message,
|
||||
sizeof(message),
|
||||
"Invalid relationship type: %s",
|
||||
type.data());
|
||||
throw std::runtime_error(message);
|
||||
}
|
||||
originalTableName_ =
|
||||
|
|
|
@ -69,7 +69,11 @@ static void newModelConfigFile(std::ofstream &configFile)
|
|||
}
|
||||
void create_project::createProject(const std::string &projectName)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (_access(projectName.data(), 0) == 0)
|
||||
#else
|
||||
if (access(projectName.data(), 0) == 0)
|
||||
#endif
|
||||
{
|
||||
std::cerr
|
||||
<< "The directory already exists, please use another project name!"
|
||||
|
@ -79,8 +83,12 @@ void create_project::createProject(const std::string &projectName)
|
|||
std::cout << "create a project named " << projectName << std::endl;
|
||||
|
||||
drogon::utils::createPath(projectName);
|
||||
// 1.create CMakeLists.txt
|
||||
// 1.create CMakeLists.txt
|
||||
#ifdef _WIN32
|
||||
auto r = _chdir(projectName.data());
|
||||
#else
|
||||
auto r = chdir(projectName.data());
|
||||
#endif
|
||||
(void)(r);
|
||||
std::ofstream cmakeFile("CMakeLists.txt", std::ofstream::out);
|
||||
newCmakeFile(cmakeFile, projectName);
|
||||
|
|
|
@ -294,7 +294,7 @@ void press::outputResults()
|
|||
auto microSecs = now.microSecondsSinceEpoch() -
|
||||
statistics_.startDate_.microSecondsSinceEpoch();
|
||||
double seconds = (double)microSecs / 1000000.0;
|
||||
size_t rps = statistics_.numOfGoodResponse_ / seconds;
|
||||
size_t rps = static_cast<size_t>(statistics_.numOfGoodResponse_ / seconds);
|
||||
std::cout << std::endl;
|
||||
std::cout << "TOTALS: " << numOfConnections_ << " connect, "
|
||||
<< numOfRequests_ << " requests, "
|
||||
|
|
|
@ -133,9 +133,9 @@ class CacheMap
|
|||
}
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(bucketMutex_);
|
||||
for (int i = wheels_.size() - 1; i >= 0; --i)
|
||||
for (auto iter = wheels_.rbegin(); iter != wheels_.rend(); ++iter)
|
||||
{
|
||||
wheels_[i].clear();
|
||||
iter->clear();
|
||||
}
|
||||
}
|
||||
LOG_TRACE << "CacheMap destruct!";
|
||||
|
@ -265,7 +265,7 @@ class CacheMap
|
|||
*/
|
||||
bool findAndFetch(const T1 &key, T2 &value)
|
||||
{
|
||||
int timeout = 0;
|
||||
size_t timeout = 0;
|
||||
bool flag = false;
|
||||
std::lock_guard<std::mutex> lock(mtx_);
|
||||
auto iter = map_.find(key);
|
||||
|
@ -326,7 +326,7 @@ class CacheMap
|
|||
// protected by bucketMutex;
|
||||
if (delay <= 0)
|
||||
return;
|
||||
delay = delay / tickInterval_ + 1;
|
||||
delay = static_cast<size_t>(delay / tickInterval_ + 1);
|
||||
size_t t = ticksCounter_;
|
||||
for (size_t i = 0; i < wheelsNumber_; ++i)
|
||||
{
|
||||
|
|
|
@ -19,6 +19,10 @@
|
|||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable : 4250)
|
||||
#endif
|
||||
|
||||
namespace drogon
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -26,7 +26,14 @@ using namespace drogon;
|
|||
CacheFile::CacheFile(const std::string &path, bool autoDelete)
|
||||
: autoDelete_(autoDelete), path_(path)
|
||||
{
|
||||
#ifndef _MSC_VER
|
||||
file_ = fopen(path_.data(), "wb+");
|
||||
#else
|
||||
if (fopen_s(&file_, path_.data(), "wb+") != 0)
|
||||
{
|
||||
file_ = nullptr;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
CacheFile::~CacheFile()
|
||||
|
@ -38,7 +45,11 @@ CacheFile::~CacheFile()
|
|||
if (autoDelete_ && file_)
|
||||
{
|
||||
fclose(file_);
|
||||
#ifdef _WIN32
|
||||
_unlink(path_.data());
|
||||
#else
|
||||
unlink(path_.data());
|
||||
#endif
|
||||
}
|
||||
else if (file_)
|
||||
{
|
||||
|
@ -66,7 +77,11 @@ char *CacheFile::data()
|
|||
if (!data_)
|
||||
{
|
||||
fflush(file_);
|
||||
#ifdef _WIN32
|
||||
auto fd = _fileno(file_);
|
||||
#else
|
||||
auto fd = fileno(file_);
|
||||
#endif
|
||||
dataLength_ = length();
|
||||
data_ = static_cast<char *>(
|
||||
mmap(nullptr, dataLength_, PROT_READ, MAP_SHARED, fd, 0));
|
||||
|
|
|
@ -94,13 +94,17 @@ static bool bytesSize(std::string &sizeStr, size_t &size)
|
|||
}
|
||||
ConfigLoader::ConfigLoader(const std::string &configFile)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (_access(configFile.c_str(), 0) != 0)
|
||||
#else
|
||||
if (access(configFile.c_str(), 0) != 0)
|
||||
#endif
|
||||
{
|
||||
std::cerr << "Config file " << configFile << " not found!" << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
#ifdef _WIN32
|
||||
if (access(configFile.c_str(), 04) != 0)
|
||||
if (_access(configFile.c_str(), 04) != 0)
|
||||
#else
|
||||
if (access(configFile.c_str(), R_OK) != 0)
|
||||
#endif
|
||||
|
|
|
@ -320,13 +320,17 @@ HttpAppFramework &HttpAppFrameworkImpl::setLogPath(
|
|||
{
|
||||
if (logPath == "")
|
||||
return *this;
|
||||
#ifdef _WIN32
|
||||
if (_access(logPath.c_str(), 0) != 0)
|
||||
#else
|
||||
if (access(logPath.c_str(), 0) != 0)
|
||||
#endif
|
||||
{
|
||||
std::cerr << "Log path dose not exist!\n";
|
||||
exit(1);
|
||||
}
|
||||
#ifdef _WIN32
|
||||
if (access(logPath.c_str(), 06) != 0)
|
||||
if (_access(logPath.c_str(), 06) != 0)
|
||||
#else
|
||||
if (access(logPath.c_str(), R_OK | W_OK) != 0)
|
||||
#endif
|
||||
|
@ -362,7 +366,7 @@ void HttpAppFrameworkImpl::run()
|
|||
for (int i = 0; i < 256; ++i)
|
||||
{
|
||||
char dirName[4];
|
||||
sprintf(dirName, "%02x", i);
|
||||
snprintf(dirName, sizeof(dirName), "%02x", i);
|
||||
std::transform(dirName, dirName + 2, dirName, toupper);
|
||||
utils::createPath(getUploadPath() + "/tmp/" + dirName);
|
||||
}
|
||||
|
@ -405,7 +409,7 @@ void HttpAppFrameworkImpl::run()
|
|||
if (!logPath_.empty())
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (access(logPath_.c_str(), 06) != 0)
|
||||
if (_access(logPath_.c_str(), 06) != 0)
|
||||
#else
|
||||
if (access(logPath_.c_str(), R_OK | W_OK) != 0)
|
||||
#endif
|
||||
|
|
|
@ -540,7 +540,8 @@ void HttpControllersRouter::doControllerHandler(
|
|||
{
|
||||
if (responsePtr->expiredTime() == 0 ||
|
||||
(trantor::Date::now() <
|
||||
responsePtr->creationDate().after(responsePtr->expiredTime())))
|
||||
responsePtr->creationDate().after(
|
||||
static_cast<double>(responsePtr->expiredTime()))))
|
||||
{
|
||||
// use cached response!
|
||||
LOG_TRACE << "Use cached response";
|
||||
|
|
|
@ -225,13 +225,13 @@ void HttpResponseImpl::makeHeaderString(
|
|||
{
|
||||
if (sendfileName_.empty())
|
||||
{
|
||||
long unsigned int bodyLength =
|
||||
size_t bodyLength =
|
||||
bodyPtr_ ? bodyPtr_->length()
|
||||
: (bodyViewPtr_ ? bodyViewPtr_->length() : 0);
|
||||
len = snprintf(buf,
|
||||
sizeof buf,
|
||||
"Content-Length: %lu\r\n",
|
||||
bodyLength);
|
||||
static_cast<unsigned long>(bodyLength));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -311,13 +311,13 @@ void HttpResponseImpl::renderToBuffer(trantor::MsgBuffer &buffer)
|
|||
{
|
||||
if (sendfileName_.empty())
|
||||
{
|
||||
long unsigned int bodyLength =
|
||||
auto bodyLength =
|
||||
bodyPtr_ ? bodyPtr_->length()
|
||||
: (bodyViewPtr_ ? bodyViewPtr_->length() : 0);
|
||||
len = snprintf(buf,
|
||||
sizeof buf,
|
||||
"Content-Length: %lu\r\n",
|
||||
bodyLength);
|
||||
static_cast<unsigned long>(bodyLength));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -329,9 +329,8 @@ void HttpResponseImpl::renderToBuffer(trantor::MsgBuffer &buffer)
|
|||
}
|
||||
len = snprintf(buf,
|
||||
sizeof buf,
|
||||
"Content-Length: %llu\r\n",
|
||||
static_cast<long long unsigned int>(
|
||||
filestat.st_size));
|
||||
"Content-Length: %lu\r\n",
|
||||
static_cast<unsigned long>(filestat.st_size));
|
||||
}
|
||||
|
||||
buffer.append(buf, len);
|
||||
|
|
|
@ -340,7 +340,7 @@ void HttpServer::onRequests(
|
|||
{
|
||||
/*
|
||||
* A client that supports persistent connections MAY
|
||||
* “pipeline” its requests (i.e., send multiple requests
|
||||
* "pipeline" its requests (i.e., send multiple requests
|
||||
* without waiting for each response). A server MUST send
|
||||
* its responses to those requests in the same order that
|
||||
* the requests were received. rfc2616-8.1.1.2
|
||||
|
@ -524,4 +524,4 @@ void HttpServer::sendResponses(
|
|||
conn->send(buffer);
|
||||
}
|
||||
buffer.retrieveAll();
|
||||
}
|
||||
}
|
|
@ -203,7 +203,8 @@ void HttpSimpleControllersRouter::doControllerHandler(
|
|||
{
|
||||
if (responsePtr->expiredTime() == 0 ||
|
||||
(trantor::Date::now() <
|
||||
responsePtr->creationDate().after(responsePtr->expiredTime())))
|
||||
responsePtr->creationDate().after(
|
||||
static_cast<double>(responsePtr->expiredTime()))))
|
||||
{
|
||||
// use cached response!
|
||||
LOG_TRACE << "Use cached response";
|
||||
|
|
|
@ -69,9 +69,11 @@ std::string genRandomString(int length)
|
|||
static const char char_space[] =
|
||||
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
static std::once_flag once;
|
||||
static const int len = strlen(char_space);
|
||||
static const int randMax = RAND_MAX - (RAND_MAX % len);
|
||||
std::call_once(once, []() { std::srand(time(nullptr)); });
|
||||
static const size_t len = strlen(char_space);
|
||||
static const size_t randMax = RAND_MAX - (RAND_MAX % len);
|
||||
std::call_once(once, []() {
|
||||
std::srand(static_cast<unsigned int>(time(nullptr)));
|
||||
});
|
||||
|
||||
int i;
|
||||
std::string str;
|
||||
|
@ -381,7 +383,7 @@ std::string base64Encode(const unsigned char *bytes_to_encode,
|
|||
|
||||
std::vector<char> base64DecodeToVector(const std::string &encoded_string)
|
||||
{
|
||||
int in_len = encoded_string.size();
|
||||
auto in_len = encoded_string.size();
|
||||
int i = 0;
|
||||
int in_{0};
|
||||
char char_array_4[4], char_array_3[3];
|
||||
|
@ -396,7 +398,8 @@ std::vector<char> base64DecodeToVector(const std::string &encoded_string)
|
|||
if (i == 4)
|
||||
{
|
||||
for (i = 0; i < 4; ++i)
|
||||
char_array_4[i] = base64Chars.find(char_array_4[i]);
|
||||
char_array_4[i] =
|
||||
static_cast<char>(base64Chars.find(char_array_4[i]));
|
||||
|
||||
char_array_3[0] =
|
||||
(char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
|
||||
|
@ -416,7 +419,8 @@ std::vector<char> base64DecodeToVector(const std::string &encoded_string)
|
|||
char_array_4[j] = 0;
|
||||
|
||||
for (int j = 0; j < 4; ++j)
|
||||
char_array_4[j] = base64Chars.find(char_array_4[j]);
|
||||
char_array_4[j] =
|
||||
static_cast<char>(base64Chars.find(char_array_4[j]));
|
||||
|
||||
char_array_3[0] =
|
||||
(char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
|
||||
|
@ -433,7 +437,7 @@ std::vector<char> base64DecodeToVector(const std::string &encoded_string)
|
|||
|
||||
std::string base64Decode(const std::string &encoded_string)
|
||||
{
|
||||
int in_len = encoded_string.size();
|
||||
auto in_len = encoded_string.size();
|
||||
int i = 0;
|
||||
int in_{0};
|
||||
unsigned char char_array_4[4], char_array_3[3];
|
||||
|
@ -447,7 +451,8 @@ std::string base64Decode(const std::string &encoded_string)
|
|||
if (i == 4)
|
||||
{
|
||||
for (i = 0; i < 4; ++i)
|
||||
char_array_4[i] = base64Chars.find(char_array_4[i]);
|
||||
char_array_4[i] = static_cast<unsigned char>(
|
||||
base64Chars.find(char_array_4[i]));
|
||||
|
||||
char_array_3[0] =
|
||||
(char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
|
||||
|
@ -467,7 +472,8 @@ std::string base64Decode(const std::string &encoded_string)
|
|||
char_array_4[j] = 0;
|
||||
|
||||
for (int j = 0; j < 4; ++j)
|
||||
char_array_4[j] = base64Chars.find(char_array_4[j]);
|
||||
char_array_4[j] =
|
||||
static_cast<unsigned char>(base64Chars.find(char_array_4[j]));
|
||||
|
||||
char_array_3[0] =
|
||||
(char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
|
||||
|
@ -778,9 +784,9 @@ std::string gzipCompress(const char *data, const size_t ndata)
|
|||
return std::string{};
|
||||
}
|
||||
std::string outstr;
|
||||
outstr.resize(compressBound(ndata));
|
||||
outstr.resize(compressBound(static_cast<uLong>(ndata)));
|
||||
strm.next_in = (Bytef *)data;
|
||||
strm.avail_in = ndata;
|
||||
strm.avail_in = static_cast<uInt>(ndata);
|
||||
int ret;
|
||||
do
|
||||
{
|
||||
|
@ -789,7 +795,7 @@ std::string gzipCompress(const char *data, const size_t ndata)
|
|||
outstr.resize(strm.total_out * 2);
|
||||
}
|
||||
assert(outstr.size() >= strm.total_out);
|
||||
strm.avail_out = outstr.size() - strm.total_out;
|
||||
strm.avail_out = static_cast<uInt>(outstr.size() - strm.total_out);
|
||||
strm.next_out = (Bytef *)outstr.data() + strm.total_out;
|
||||
ret = deflate(&strm, Z_FINISH); /* no bad return value */
|
||||
if (ret == Z_STREAM_ERROR)
|
||||
|
@ -820,7 +826,7 @@ std::string gzipDecompress(const char *data, const size_t ndata)
|
|||
|
||||
z_stream strm = {0};
|
||||
strm.next_in = (Bytef *)data;
|
||||
strm.avail_in = ndata;
|
||||
strm.avail_in = static_cast<uInt>(ndata);
|
||||
strm.total_out = 0;
|
||||
strm.zalloc = Z_NULL;
|
||||
strm.zfree = Z_NULL;
|
||||
|
@ -837,7 +843,8 @@ std::string gzipDecompress(const char *data, const size_t ndata)
|
|||
decompressed.resize(decompressed.length() * 2);
|
||||
}
|
||||
strm.next_out = (Bytef *)decompressed.data() + strm.total_out;
|
||||
strm.avail_out = decompressed.length() - strm.total_out;
|
||||
strm.avail_out =
|
||||
static_cast<uInt>(decompressed.length() - strm.total_out);
|
||||
// Inflate another chunk.
|
||||
int status = inflate(&strm, Z_SYNC_FLUSH);
|
||||
if (status == Z_STREAM_END)
|
||||
|
@ -938,7 +945,7 @@ int createPath(const std::string &path)
|
|||
auto tmpPath = path;
|
||||
std::stack<std::string> pathStack;
|
||||
#ifdef _WIN32
|
||||
while (access(tmpPath.c_str(), 06) != 0)
|
||||
while (_access(tmpPath.c_str(), 06) != 0)
|
||||
#else
|
||||
while (access(tmpPath.c_str(), F_OK) != 0)
|
||||
#endif
|
||||
|
@ -980,7 +987,7 @@ int createPath(const std::string &path)
|
|||
pathStack.pop();
|
||||
|
||||
#ifdef _WIN32
|
||||
if (mkdir(tmpPath.c_str()) == -1)
|
||||
if (_mkdir(tmpPath.c_str()) == -1)
|
||||
#else
|
||||
if (mkdir(tmpPath.c_str(), 0755) == -1)
|
||||
#endif
|
||||
|
|
|
@ -75,7 +75,7 @@ void WebSocketConnectionImpl::sendWsData(const char *msg,
|
|||
|
||||
if (len <= 125)
|
||||
{
|
||||
bytesFormatted[1] = len;
|
||||
bytesFormatted[1] = static_cast<char>(len);
|
||||
indexStartRawData = 2;
|
||||
}
|
||||
else if (len <= 65535)
|
||||
|
@ -105,7 +105,9 @@ void WebSocketConnectionImpl::sendWsData(const char *msg,
|
|||
{
|
||||
// Add masking key;
|
||||
static std::once_flag once;
|
||||
std::call_once(once, []() { std::srand(time(nullptr)); });
|
||||
std::call_once(once, []() {
|
||||
std::srand(static_cast<unsigned int>(time(nullptr)));
|
||||
});
|
||||
int random = std::rand();
|
||||
|
||||
bytesFormatted[1] = (bytesFormatted[1] | 0x80);
|
||||
|
@ -278,7 +280,7 @@ bool WebSocketMessageParser::parse(trantor::MsgBuffer *buffer)
|
|||
if (buffer->readableBytes() >= (indexFirstMask + 4 + length))
|
||||
{
|
||||
auto masks = buffer->peek() + indexFirstMask;
|
||||
int indexFirstDataByte = indexFirstMask + 4;
|
||||
auto indexFirstDataByte = indexFirstMask + 4;
|
||||
auto rawData = buffer->peek() + indexFirstDataByte;
|
||||
auto oldLen = message_.length();
|
||||
message_.resize(oldLen + length);
|
||||
|
|
|
@ -30,29 +30,6 @@
|
|||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#if (defined __linux__) | (defined __MINGW32__)
|
||||
inline uint64_t ntohll(const uint64_t &input)
|
||||
{
|
||||
uint64_t rval;
|
||||
uint8_t *data = (uint8_t *)&rval;
|
||||
|
||||
data[0] = input >> 56;
|
||||
data[1] = input >> 48;
|
||||
data[2] = input >> 40;
|
||||
data[3] = input >> 32;
|
||||
data[4] = input >> 24;
|
||||
data[5] = input >> 16;
|
||||
data[6] = input >> 8;
|
||||
data[7] = input >> 0;
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
inline uint64_t htonll(const uint64_t &input)
|
||||
{
|
||||
return (ntohll(input));
|
||||
}
|
||||
#endif
|
||||
namespace drogon
|
||||
{
|
||||
namespace orm
|
||||
|
@ -202,7 +179,7 @@ inline float Field::as<float>() const
|
|||
{
|
||||
if (isNull())
|
||||
return 0.0;
|
||||
return atof(result_.getValue(row_, column_));
|
||||
return std::stof(result_.getValue(row_, column_));
|
||||
}
|
||||
|
||||
template <>
|
||||
|
|
|
@ -84,7 +84,7 @@ class Row
|
|||
* are related to regular iterators, it must be allowed to underflow to -1.
|
||||
*/
|
||||
long index_{0};
|
||||
size_t end_{0};
|
||||
Row::SizeType end_{0};
|
||||
friend class Result;
|
||||
Row(const Result &r, SizeType index) noexcept;
|
||||
};
|
||||
|
|
|
@ -33,6 +33,29 @@
|
|||
#include <winsock2.h>
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
#include <endian.h> // __BYTE_ORDER __LITTLE_ENDIAN
|
||||
#include <algorithm> // std::reverse()
|
||||
|
||||
template <typename T>
|
||||
constexpr T htonT(T value) noexcept
|
||||
{
|
||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
char *ptr = reinterpret_cast<char *>(&value);
|
||||
std::reverse(ptr, ptr + sizeof(T));
|
||||
#endif
|
||||
return value;
|
||||
}
|
||||
inline uint64_t htonll(uint64_t value)
|
||||
{
|
||||
return htonT<uint64_t>(value);
|
||||
}
|
||||
inline uint64_t ntohll(uint64_t value)
|
||||
{
|
||||
return htonll(value);
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace drogon
|
||||
{
|
||||
namespace orm
|
||||
|
@ -307,13 +330,13 @@ class SqlBinder
|
|||
switch (sizeof(T))
|
||||
{
|
||||
case 2:
|
||||
*std::static_pointer_cast<short>(obj) = ntohs(parameter);
|
||||
*std::static_pointer_cast<uint16_t>(obj) = htons(parameter);
|
||||
break;
|
||||
case 4:
|
||||
*std::static_pointer_cast<int>(obj) = ntohl(parameter);
|
||||
*std::static_pointer_cast<uint32_t>(obj) = htonl(parameter);
|
||||
break;
|
||||
case 8:
|
||||
*std::static_pointer_cast<long>(obj) = ntohll(parameter);
|
||||
*std::static_pointer_cast<uint64_t>(obj) = htonll(parameter);
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
|
|
|
@ -137,7 +137,7 @@ SqlBinder &SqlBinder::operator<<(const std::string &str)
|
|||
objs_.push_back(obj);
|
||||
++parametersNumber_;
|
||||
parameters_.push_back((char *)obj->c_str());
|
||||
lengths_.push_back(obj->length());
|
||||
lengths_.push_back(static_cast<int>(obj->length()));
|
||||
if (type_ == ClientType::PostgreSQL)
|
||||
{
|
||||
formats_.push_back(0);
|
||||
|
@ -162,7 +162,7 @@ SqlBinder &SqlBinder::operator<<(std::string &&str)
|
|||
objs_.push_back(obj);
|
||||
++parametersNumber_;
|
||||
parameters_.push_back((char *)obj->c_str());
|
||||
lengths_.push_back(obj->length());
|
||||
lengths_.push_back(static_cast<int>(obj->length()));
|
||||
if (type_ == ClientType::PostgreSQL)
|
||||
{
|
||||
formats_.push_back(0);
|
||||
|
@ -187,7 +187,7 @@ SqlBinder &SqlBinder::operator<<(const std::vector<char> &v)
|
|||
objs_.push_back(obj);
|
||||
++parametersNumber_;
|
||||
parameters_.push_back((char *)obj->data());
|
||||
lengths_.push_back(obj->size());
|
||||
lengths_.push_back(static_cast<int>(obj->size()));
|
||||
if (type_ == ClientType::PostgreSQL)
|
||||
{
|
||||
formats_.push_back(1);
|
||||
|
@ -211,7 +211,7 @@ SqlBinder &SqlBinder::operator<<(std::vector<char> &&v)
|
|||
objs_.push_back(obj);
|
||||
++parametersNumber_;
|
||||
parameters_.push_back((char *)obj->data());
|
||||
lengths_.push_back(obj->size());
|
||||
lengths_.push_back(static_cast<int>(obj->size()));
|
||||
if (type_ == ClientType::PostgreSQL)
|
||||
{
|
||||
formats_.push_back(1);
|
||||
|
|
|
@ -232,7 +232,7 @@ void PgConnection::execSqlInLoop(
|
|||
isRreparingStatement_ = false;
|
||||
if (PQsendQueryPrepared(connectionPtr_.get(),
|
||||
iter->second.c_str(),
|
||||
paraNum,
|
||||
static_cast<int>(paraNum),
|
||||
parameters.data(),
|
||||
length.data(),
|
||||
format.data(),
|
||||
|
@ -258,8 +258,8 @@ void PgConnection::execSqlInLoop(
|
|||
if (PQsendPrepare(connectionPtr_.get(),
|
||||
statementName_.c_str(),
|
||||
sql_.data(),
|
||||
paraNum,
|
||||
NULL) == 0)
|
||||
static_cast<int>(paraNum),
|
||||
nullptr) == 0)
|
||||
{
|
||||
LOG_ERROR << "send query error: "
|
||||
<< PQerrorMessage(connectionPtr_.get());
|
||||
|
@ -272,7 +272,7 @@ void PgConnection::execSqlInLoop(
|
|||
}
|
||||
return;
|
||||
}
|
||||
parametersNumber_ = paraNum;
|
||||
parametersNumber_ = static_cast<int>(paraNum);
|
||||
parameters_ = std::move(parameters);
|
||||
lengths_ = std::move(length);
|
||||
formats_ = std::move(format);
|
||||
|
|
2
trantor
2
trantor
|
@ -1 +1 @@
|
|||
Subproject commit f9a4de585fc996cb94c5edcadbec0d7d874a1aa1
|
||||
Subproject commit b46138e0cd281bc42f061bf9c51755e96ad9f3f6
|
Loading…
Reference in New Issue