1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

C++20 fixes

This commit is contained in:
Leonid Fedorov
2022-02-01 15:54:05 +00:00
parent 0ee5203262
commit 65252df4f6
36 changed files with 22433 additions and 310 deletions

View File

@ -20,13 +20,8 @@
#include "logger.h"
#include <fstream>
#include <iostream>
#include <boost/regex.hpp>
#ifdef _MSC_VER
#include "unistd.h"
#include "sysinfo.h"
#else
#include <sys/sysinfo.h>
#endif
using namespace boost;
using namespace std;

View File

@ -72,7 +72,7 @@ class STLPoolAllocator
void usePoolAllocator(boost::shared_ptr<PoolAllocator> b);
boost::shared_ptr<utils::PoolAllocator> getPoolAllocator();
pointer allocate(size_type, const void* hint = 0);
pointer allocate(size_type, typename STLPoolAllocator<T>::const_pointer hint = 0);
void deallocate(pointer p, size_type n);
size_type max_size() const throw();
inline uint64_t getMemUsage() const
@ -131,7 +131,7 @@ boost::shared_ptr<utils::PoolAllocator> STLPoolAllocator<T>::getPoolAllocator()
template <class T>
typename STLPoolAllocator<T>::pointer STLPoolAllocator<T>::allocate(
typename STLPoolAllocator<T>::size_type s, typename std::allocator<void>::const_pointer hint)
typename STLPoolAllocator<T>::size_type s, typename STLPoolAllocator<T>::const_pointer hint)
{
return (pointer)pa->allocate(s * sizeof(T));
}

View File

@ -28,13 +28,8 @@
#include <string>
#include <boost/any.hpp>
#include <vector>
#ifdef _MSC_VER
#include <winsock2.h>
#include <ws2tcpip.h>
#include <stdio.h>
#else
#include <netinet/in.h>
#endif
#ifdef __linux__
#define POSIX_REGEX
@ -43,7 +38,7 @@
#ifdef POSIX_REGEX
#include <regex.h>
#else
#include <boost/regex.hpp>
#include <regex>
#endif
#include "mcs_datatype.h"

View File

@ -28,7 +28,7 @@ using namespace std;
#ifdef __linux__
#include <regex.h>
#else
#include <boost/regex.hpp>
#include <regex>
using namespace boost;
#endif
@ -226,8 +226,8 @@ inline bool getBool(rowgroup::Row& row, funcexp::FunctionParm& pm, bool& isNull,
return false;
#else
regex pat(pattern.c_str());
return regex_search(expr.c_str(), pat);
std::regex pat(pattern.c_str());
return std::regex_search(expr.c_str(), pat);
#endif
}

View File

@ -32,7 +32,6 @@
#include <inttypes.h>
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/regex.hpp>
#include <boost/tokenizer.hpp>
#include "dataconvert.h"

22109
utils/json/json.hpp Normal file

File diff suppressed because it is too large Load Diff

92
utils/loggingcpp/format.h Normal file
View File

@ -0,0 +1,92 @@
/*
Copyright (c) 2021 MariaDB Corporation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
*/
#pragma once
#include <boost/any.hpp>
#include <cstdint>
#include <regex>
#include <stdexcept>
#include <string>
namespace logging
{
template <class T, class Iter>
void formatOne(std::string& errMsg, Iter iter, uint32_t position)
{
T arg = boost::any_cast<T>(*iter);
std::string token = std::string("%") + std::to_string(position) + std::string("%");
size_t index = 0;
while (true)
{
index = errMsg.find(token, index);
if (index == std::string::npos)
break;
if constexpr (std::is_same_v<T, std::string>)
{
errMsg.replace(index, token.length(), arg);
}
else
{
errMsg.replace(index, token.length(), std::to_string(arg));
}
index += token.length();
}
}
template <class T>
void formatMany(std::string& errMsg, const T& args)
{
auto iter = args.begin();
auto end = args.end();
uint32_t position = 1;
while (iter != end)
{
if (iter->type() == typeid(long))
{
formatOne<long>(errMsg, iter, position);
}
else if (iter->type() == typeid(uint64_t))
{
formatOne<uint64_t>(errMsg, iter, position);
}
else if (iter->type() == typeid(double))
{
formatOne<double>(errMsg, iter, position);
}
else if (iter->type() == typeid(std::string))
{
formatOne<std::string>(errMsg, iter, position);
}
else
{
throw std::logic_error("logggin::format: unexpected type in argslist");
}
++iter;
++position;
}
static std::regex restToken("%[0-9]%");
errMsg = std::regex_replace(errMsg, restToken, "");
}
} // namespace logging

View File

@ -29,7 +29,6 @@
#include <fstream>
using namespace std;
#include <boost/format.hpp>
#include <boost/tokenizer.hpp>
#include <boost/thread.hpp>
using namespace boost;
@ -43,6 +42,8 @@ using namespace config;
#include "installdir.h"
#include "format.h"
namespace logging
{
IDBErrorInfo* IDBErrorInfo::fInstance = 0;
@ -156,43 +157,7 @@ string IDBErrorInfo::logError(const logging::LOG_TYPE logLevel, const logging::L
void IDBErrorInfo::format(string& errMsg, const Message::Args& args)
{
Message::Args::AnyVec::const_iterator iter = args.args().begin();
Message::Args::AnyVec::const_iterator end = args.args().end();
boost::format fmt(errMsg);
fmt.exceptions(boost::io::no_error_bits);
while (iter != end)
{
if (iter->type() == typeid(long))
{
long l = any_cast<long>(*iter);
fmt % l;
}
else if (iter->type() == typeid(uint64_t))
{
uint64_t u64 = any_cast<uint64_t>(*iter);
fmt % u64;
}
else if (iter->type() == typeid(double))
{
double d = any_cast<double>(*iter);
fmt % d;
}
else if (iter->type() == typeid(string))
{
string s = any_cast<string>(*iter);
fmt % s;
}
else
{
throw logic_error("IDBErrorInfo::format: unexpected type in argslist");
}
++iter;
}
errMsg = fmt.str();
formatMany(errMsg, args.args());
}
/* static */

View File

@ -29,7 +29,7 @@
#include <fstream>
using namespace std;
#include <boost/format.hpp>
#include <boost/tokenizer.hpp>
#include <boost/thread.hpp>
using namespace boost;
@ -41,6 +41,7 @@ using namespace config;
#include "installdir.h"
#include "format.h"
namespace
{
boost::mutex mx;
@ -143,43 +144,7 @@ void Message::Args::reset()
void Message::format(const Args& args)
{
Args::AnyVec::const_iterator iter = args.args().begin();
Args::AnyVec::const_iterator end = args.args().end();
boost::format fmt(fMsg);
fmt.exceptions(boost::io::no_error_bits);
while (iter != end)
{
if (iter->type() == typeid(long))
{
long l = any_cast<long>(*iter);
fmt % l;
}
else if (iter->type() == typeid(uint64_t))
{
uint64_t u64 = any_cast<uint64_t>(*iter);
fmt % u64;
}
else if (iter->type() == typeid(double))
{
double d = any_cast<double>(*iter);
fmt % d;
}
else if (iter->type() == typeid(string))
{
string s = any_cast<string>(*iter);
fmt % s;
}
else
{
throw logic_error("Message::format: unexpected type in argslist");
}
++iter;
}
fMsg = fmt.str();
formatMany(fMsg, args.args());
}
/* static */

View File

@ -45,17 +45,10 @@ namespace rwlock
/// the layout of the shmseg
struct State
{
#ifdef _MSC_VER
volatile LONG writerswaiting;
volatile LONG writing;
volatile LONG readerswaiting;
volatile LONG reading;
#else
volatile int writerswaiting;
volatile int writing;
volatile int readerswaiting;
volatile int reading;
#endif
int writerswaiting;
int writing;
int readerswaiting;
int reading;
boost::interprocess::interprocess_semaphore sems[3];
};

View File

@ -19,7 +19,7 @@
#include <string>
using namespace std;
#include <boost/regex.hpp>
#include <regex.hpp>
#include "grepit.h"
@ -32,13 +32,13 @@ namespace winport
{
bool grepit(istream& is, const string& pattern)
{
boost::regex pat(pattern);
std::regex pat(pattern);
string cInput;
getline(is, cInput);
while (is.good())
{
if (boost::regex_match(cInput, pat))
if (std::regex_match(cInput, pat))
return true;
getline(is, cInput);