1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-06-16 14:20:56 +03:00

Reformat all code to coding standard

This commit is contained in:
Andrew Hutchings
2017-10-26 17:18:17 +01:00
parent 4985f3456e
commit 01446d1e22
1296 changed files with 403852 additions and 353747 deletions

View File

@ -40,7 +40,8 @@ using namespace config;
#include "installdir.h"
namespace {
namespace
{
mutex mx;
bool catalogLoaded = false;
@ -51,165 +52,181 @@ CatMap catmap;
void loadCatalog()
{
Config* cf = Config::makeConfig();
string configFile(cf->getConfig("MessageLog", "MessageLogFile"));
if (configFile.length() == 0)
configFile = startup::StartUp::installDir() + "/etc/MessageFile.txt";
ifstream msgFile(configFile.c_str());
while (msgFile.good())
{
stringbuf* sb = new stringbuf;
msgFile.get(*sb);
string m = sb->str();
delete sb;
if (m.length() > 0 && m[0] != '#')
{
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
boost::char_separator<char> sep("\t");
tokenizer tokens(m, sep);
tokenizer::iterator tok_iter = tokens.begin();
if (tok_iter != tokens.end())
{
int msgid = atoi(tok_iter->c_str());
++tok_iter;
if (tok_iter != tokens.end())
{
string msgtext = *tok_iter;
catmap[msgid] = msgtext;
}
}
}
ios_base::iostate st = msgFile.rdstate();
if ((st & ios_base::failbit) && !(st & ios_base::eofbit))
msgFile.clear();
(void)msgFile.get();
}
Config* cf = Config::makeConfig();
string configFile(cf->getConfig("MessageLog", "MessageLogFile"));
if (configFile.length() == 0)
configFile = startup::StartUp::installDir() + "/etc/MessageFile.txt";
ifstream msgFile(configFile.c_str());
while (msgFile.good())
{
stringbuf* sb = new stringbuf;
msgFile.get(*sb);
string m = sb->str();
delete sb;
if (m.length() > 0 && m[0] != '#')
{
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
boost::char_separator<char> sep("\t");
tokenizer tokens(m, sep);
tokenizer::iterator tok_iter = tokens.begin();
if (tok_iter != tokens.end())
{
int msgid = atoi(tok_iter->c_str());
++tok_iter;
if (tok_iter != tokens.end())
{
string msgtext = *tok_iter;
catmap[msgid] = msgtext;
}
}
}
ios_base::iostate st = msgFile.rdstate();
if ((st & ios_base::failbit) && !(st & ios_base::eofbit))
msgFile.clear();
(void)msgFile.get();
}
}
}
namespace logging {
namespace logging
{
Message::Message(const MessageID msgid) :
fMsgID(msgid), fMsg(lookupMessage(msgid)), fConfig(Config::makeConfig())
fMsgID(msgid), fMsg(lookupMessage(msgid)), fConfig(Config::makeConfig())
{
}
Message::Message(const string msg):
fMsgID(0), fMsg(msg), fConfig(Config::makeConfig())
fMsgID(0), fMsg(msg), fConfig(Config::makeConfig())
{
}
void Message::swap(Message& rhs)
{
std::swap(fMsgID, rhs.fMsgID);
std::swap(fMsg, rhs.fMsg);
std::swap(fConfig, rhs.fConfig);
std::swap(fMsgID, rhs.fMsgID);
std::swap(fMsg, rhs.fMsg);
std::swap(fConfig, rhs.fConfig);
}
void Message::Args::add(int i)
{
fArgs.push_back(long(i));
fArgs.push_back(long(i));
}
void Message::Args::add(uint64_t u64)
{
fArgs.push_back(u64);
fArgs.push_back(u64);
}
void Message::Args::add(const string& s)
{
fArgs.push_back(s);
fArgs.push_back(s);
}
void Message::Args::add(double d)
{
fArgs.push_back(d);
fArgs.push_back(d);
}
void Message::Args::reset()
{
fArgs.clear();
fArgs.clear();
}
void Message::format(const Args& args)
{
Args::AnyVec::const_iterator iter = args.args().begin();
Args::AnyVec::const_iterator end = args.args().end();
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);
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;
}
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");
}
fMsg = fmt.str();
++iter;
}
fMsg = fmt.str();
}
/* static */
const string Message::lookupMessage(const MessageID& msgid)
{
if (!catalogLoaded)
{
mutex::scoped_lock lock(mx);
if (!catalogLoaded)
{
loadCatalog();
catalogLoaded = true;
}
}
string msgstr;
CatMap::const_iterator iter = catmap.find(msgid);
if (iter == catmap.end())
{
iter = catmap.find(0);
if (iter == catmap.end())
{
msgstr = "%1% %2% %3% %4% %5%";
}
else
{
msgstr = iter->second;
}
}
else
{
msgstr = iter->second;
}
ostringstream oss;
oss << "CAL" << setw(4) << setfill('0') << msgid << ": " << msgstr;
return oss.str();
if (!catalogLoaded)
{
mutex::scoped_lock lock(mx);
if (!catalogLoaded)
{
loadCatalog();
catalogLoaded = true;
}
}
string msgstr;
CatMap::const_iterator iter = catmap.find(msgid);
if (iter == catmap.end())
{
iter = catmap.find(0);
if (iter == catmap.end())
{
msgstr = "%1% %2% %3% %4% %5%";
}
else
{
msgstr = iter->second;
}
}
else
{
msgstr = iter->second;
}
ostringstream oss;
oss << "CAL" << setw(4) << setfill('0') << msgid << ": " << msgstr;
return oss.str();
}
void Message::reset()
{
fMsg = lookupMessage(fMsgID);
fMsg = lookupMessage(fMsgID);
}
}