Skip to content

Commit d95dd8f

Browse files
committed
formatting for constructors
1 parent fe32120 commit d95dd8f

18 files changed

+93
-93
lines changed

.clang-format

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ BraceWrapping:
3939
SplitEmptyNamespace: false
4040
BreakBeforeBinaryOperators: None
4141
BreakBeforeTernaryOperators: true
42-
BreakConstructorInitializers: BeforeColon
42+
BreakConstructorInitializers: AfterColon
4343
BreakInheritanceList: BeforeColon
4444
ColumnLimit: 0
4545
CompactNamespaces: false

src/filesink.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
namespace g3 {
1515
using namespace internal;
1616

17-
FileSink::FileSink(const std::string& log_prefix, const std::string& log_directory, const std::string& logger_id, size_t write_to_log_every_x_message)
18-
: _log_details_func(&LogMessage::DefaultLogDetailsToString), _log_file_with_path(log_directory), _log_prefix_backup(log_prefix), _outptr(new std::ofstream), _header("\t\tLOG format: [YYYY/MM/DD hh:mm:ss uuu* LEVEL FILE->FUNCTION:LINE] message\n\n\t\t(uuu*: microseconds fractions of the seconds value)\n\n"), _firstEntry(true), _write_counter(0), _write_to_log_every_x_message(write_to_log_every_x_message) {
17+
FileSink::FileSink(const std::string& log_prefix, const std::string& log_directory, const std::string& logger_id, size_t write_to_log_every_x_message) :
18+
_log_details_func(&LogMessage::DefaultLogDetailsToString), _log_file_with_path(log_directory), _log_prefix_backup(log_prefix), _outptr(new std::ofstream), _header("\t\tLOG format: [YYYY/MM/DD hh:mm:ss uuu* LEVEL FILE->FUNCTION:LINE] message\n\n\t\t(uuu*: microseconds fractions of the seconds value)\n\n"), _firstEntry(true), _write_counter(0), _write_to_log_every_x_message(write_to_log_every_x_message) {
1919
_log_prefix_backup = prefixSanityFix(log_prefix);
2020
if (!isValidFilename(_log_prefix_backup)) {
2121
std::cerr << "g3log: forced abort due to illegal log prefix [" << log_prefix << "]" << std::endl;

src/g3log/active.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ namespace kjellkod {
2929

3030
class Active {
3131
private:
32-
Active()
33-
: done_(false) {} // Construction ONLY through factory createActive();
32+
Active() :
33+
done_(false) {} // Construction ONLY through factory createActive();
3434
Active(const Active&) = delete;
3535
Active& operator=(const Active&) = delete;
3636

src/g3log/atomicbool.hpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ namespace g3 {
1717
std::atomic<bool> value_;
1818

1919
public:
20-
atomicbool()
21-
: value_{false} {}
22-
atomicbool(bool value)
23-
: value_{value} {}
24-
atomicbool(const std::atomic<bool>& value)
25-
: value_{value.load(std::memory_order_acquire)} {}
26-
atomicbool(const atomicbool& other)
27-
: value_{other.value_.load(std::memory_order_acquire)} {}
20+
atomicbool() :
21+
value_{false} {}
22+
atomicbool(bool value) :
23+
value_{value} {}
24+
atomicbool(const std::atomic<bool>& value) :
25+
value_{value.load(std::memory_order_acquire)} {}
26+
atomicbool(const atomicbool& other) :
27+
value_{other.value_.load(std::memory_order_acquire)} {}
2828

2929
atomicbool& operator=(const atomicbool& other) {
3030
value_.store(other.value_.load(std::memory_order_acquire), std::memory_order_release);

src/g3log/loglevels.hpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ struct LEVELS {
3333
// force internal copy of the const char*. This is a simple safeguard for when g3log is used in a
3434
// "dynamic, runtime loading of shared libraries"
3535

36-
LEVELS(const LEVELS& other)
37-
: value(other.value), text(other.text.c_str()) {}
36+
LEVELS(const LEVELS& other) :
37+
value(other.value), text(other.text.c_str()) {}
3838

39-
LEVELS(int id, const std::string& idtext)
40-
: value(id), text(idtext) {}
39+
LEVELS(int id, const std::string& idtext) :
40+
value(id), text(idtext) {}
4141

4242
bool operator==(const LEVELS& rhs) const {
4343
return (value == rhs.value && text == rhs.text);
@@ -103,14 +103,14 @@ namespace g3 {
103103
LEVELS level;
104104

105105
// default operator needed for std::map compliance
106-
LoggingLevel()
107-
: status(false), level(INFO){};
108-
LoggingLevel(const LoggingLevel& lvl)
109-
: status(lvl.status), level(lvl.level) {}
110-
LoggingLevel(const LEVELS& lvl)
111-
: status(true), level(lvl){};
112-
LoggingLevel(const LEVELS& lvl, bool enabled)
113-
: status(enabled), level(lvl){};
106+
LoggingLevel() :
107+
status(false), level(INFO){};
108+
LoggingLevel(const LoggingLevel& lvl) :
109+
status(lvl.status), level(lvl.level) {}
110+
LoggingLevel(const LEVELS& lvl) :
111+
status(true), level(lvl){};
112+
LoggingLevel(const LEVELS& lvl, bool enabled) :
113+
status(enabled), level(lvl){};
114114
~LoggingLevel() = default;
115115

116116
LoggingLevel& operator=(const LoggingLevel& other) {

src/g3log/moveoncopy.hpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ namespace g3 {
1818
struct MoveOnCopy {
1919
mutable Moveable _move_only;
2020

21-
explicit MoveOnCopy(Moveable&& m)
22-
: _move_only(std::move(m)) {}
23-
MoveOnCopy(MoveOnCopy const& t)
24-
: _move_only(std::move(t._move_only)) {}
25-
MoveOnCopy(MoveOnCopy&& t)
26-
: _move_only(std::move(t._move_only)) {}
21+
explicit MoveOnCopy(Moveable&& m) :
22+
_move_only(std::move(m)) {}
23+
MoveOnCopy(MoveOnCopy const& t) :
24+
_move_only(std::move(t._move_only)) {}
25+
MoveOnCopy(MoveOnCopy&& t) :
26+
_move_only(std::move(t._move_only)) {}
2727

2828
MoveOnCopy& operator=(MoveOnCopy const& other) {
2929
_move_only = std::move(other._move_only);

src/g3log/sink.hpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@ namespace g3 {
4040
AsyncMessageCall _default_log_call;
4141

4242
template <typename DefaultLogCall>
43-
Sink(std::unique_ptr<T> sink, DefaultLogCall call)
44-
: SinkWrapper(),
45-
_real_sink{std::move(sink)},
46-
_bg(kjellkod::Active::createActive()),
47-
_default_log_call(std::bind(call, _real_sink.get(), std::placeholders::_1)) {
43+
Sink(std::unique_ptr<T> sink, DefaultLogCall call) :
44+
SinkWrapper(),
45+
_real_sink{std::move(sink)},
46+
_bg(kjellkod::Active::createActive()),
47+
_default_log_call(std::bind(call, _real_sink.get(), std::placeholders::_1)) {
4848
}
4949

50-
Sink(std::unique_ptr<T> sink, void (T::*Call)(std::string))
51-
: SinkWrapper(),
52-
_real_sink{std::move(sink)},
53-
_bg(kjellkod::Active::createActive()) {
50+
Sink(std::unique_ptr<T> sink, void (T::*Call)(std::string)) :
51+
SinkWrapper(),
52+
_real_sink{std::move(sink)},
53+
_bg(kjellkod::Active::createActive()) {
5454
std::function<void(std::string)> adapter = std::bind(Call, _real_sink.get(), std::placeholders::_1);
5555
_default_log_call = [=](LogMessageMover m) {
5656
adapter(m.get().toString());

src/g3log/sinkhandle.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ namespace g3 {
2727
std::weak_ptr<internal::Sink<T>> _sink;
2828

2929
public:
30-
SinkHandle(std::shared_ptr<internal::Sink<T>> sink)
31-
: _sink(sink) {}
30+
SinkHandle(std::shared_ptr<internal::Sink<T>> sink) :
31+
_sink(sink) {}
3232

3333
~SinkHandle() = default;
3434

src/g3log/stlpatch_future.hpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ namespace std {
2525
}
2626

2727
template <class _Fty2>
28-
explicit packaged_task(_Fty2&& _Fnarg)
29-
: _my_func(_Fnarg) {
28+
explicit packaged_task(_Fty2&& _Fnarg) :
29+
_my_func(_Fnarg) {
3030
}
3131

32-
packaged_task(packaged_task&& _Other)
33-
: _my_promise(move(_Other._my_promise)),
34-
_my_func(move(_Other._my_func)) {
32+
packaged_task(packaged_task&& _Other) :
33+
_my_promise(move(_Other._my_promise)),
34+
_my_func(move(_Other._my_func)) {
3535
}
3636

3737
packaged_task& operator=(packaged_task&& _Other) {

src/logcapture.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ LogCapture::~LogCapture() noexcept(false) {
4747
}
4848

4949
/// Called from crash handler when a fatal signal has occurred (SIGSEGV etc)
50-
LogCapture::LogCapture(const LEVELS& level, g3::SignalType fatal_signal, const char* dump)
51-
: LogCapture("", 0, "", level, "", fatal_signal, dump) {
50+
LogCapture::LogCapture(const LEVELS& level, g3::SignalType fatal_signal, const char* dump) :
51+
LogCapture("", 0, "", level, "", fatal_signal, dump) {
5252
}
5353

5454
/**
@@ -58,8 +58,8 @@ LogCapture::LogCapture(const LEVELS& level, g3::SignalType fatal_signal, const c
5858
* @fatal_signal for failed CHECK:SIGABRT or fatal signal caught in the signal handler
5959
*/
6060
LogCapture::LogCapture(const char* file, const int line, const char* function, const LEVELS& level,
61-
const char* expression, g3::SignalType fatal_signal, const char* dump)
62-
: _file(file), _line(line), _function(function), _level(level), _expression(expression), _fatal_signal(fatal_signal) {
61+
const char* expression, g3::SignalType fatal_signal, const char* dump) :
62+
_file(file), _line(line), _function(function), _level(level), _expression(expression), _fatal_signal(fatal_signal) {
6363

6464
if (g3::internal::wasFatal(level)) {
6565
_stack_trace = std::string{"\n*******\tSTACKDUMP *******\n"};

src/logmessage.cpp

+21-21
Original file line numberDiff line numberDiff line change
@@ -119,33 +119,33 @@ namespace g3 {
119119
}
120120

121121
LogMessage::LogMessage(std::string file, const int line,
122-
std::string function, const LEVELS level)
123-
: _logDetailsToStringFunc(LogMessage::DefaultLogDetailsToString), _timestamp(std::chrono::high_resolution_clock::now()), _call_thread_id(std::this_thread::get_id())
122+
std::string function, const LEVELS level) :
123+
_logDetailsToStringFunc(LogMessage::DefaultLogDetailsToString), _timestamp(std::chrono::high_resolution_clock::now()), _call_thread_id(std::this_thread::get_id())
124124
#if defined(G3_LOG_FULL_FILENAME)
125-
,
126-
_file(file)
125+
,
126+
_file(file)
127127
#else
128-
,
129-
_file(LogMessage::splitFileName(file))
128+
,
129+
_file(LogMessage::splitFileName(file))
130130
#endif
131-
,
132-
_file_path(file),
133-
_line(line),
134-
_function(std::move(function)),
135-
_level(level) {
131+
,
132+
_file_path(file),
133+
_line(line),
134+
_function(std::move(function)),
135+
_level(level) {
136136
}
137137

138-
LogMessage::LogMessage(const std::string& fatalOsSignalCrashMessage)
139-
: LogMessage({""}, 0, {""}, internal::FATAL_SIGNAL) {
138+
LogMessage::LogMessage(const std::string& fatalOsSignalCrashMessage) :
139+
LogMessage({""}, 0, {""}, internal::FATAL_SIGNAL) {
140140
_message.append(fatalOsSignalCrashMessage);
141141
}
142142

143-
LogMessage::LogMessage(const LogMessage& other)
144-
: _logDetailsToStringFunc(other._logDetailsToStringFunc), _timestamp(other._timestamp), _call_thread_id(other._call_thread_id), _file(other._file), _file_path(other._file_path), _line(other._line), _function(other._function), _level(other._level), _expression(other._expression), _message(other._message) {
143+
LogMessage::LogMessage(const LogMessage& other) :
144+
_logDetailsToStringFunc(other._logDetailsToStringFunc), _timestamp(other._timestamp), _call_thread_id(other._call_thread_id), _file(other._file), _file_path(other._file_path), _line(other._line), _function(other._function), _level(other._level), _expression(other._expression), _message(other._message) {
145145
}
146146

147-
LogMessage::LogMessage(LogMessage&& other)
148-
: _logDetailsToStringFunc(other._logDetailsToStringFunc), _timestamp(other._timestamp), _call_thread_id(other._call_thread_id), _file(std::move(other._file)), _file_path(std::move(other._file_path)), _line(other._line), _function(std::move(other._function)), _level(other._level), _expression(std::move(other._expression)), _message(std::move(other._message)) {
147+
LogMessage::LogMessage(LogMessage&& other) :
148+
_logDetailsToStringFunc(other._logDetailsToStringFunc), _timestamp(other._timestamp), _call_thread_id(other._call_thread_id), _file(std::move(other._file)), _file_path(std::move(other._file_path)), _line(other._line), _function(std::move(other._function)), _level(other._level), _expression(std::move(other._expression)), _message(std::move(other._message)) {
149149
}
150150

151151
std::string LogMessage::threadID() const {
@@ -154,11 +154,11 @@ namespace g3 {
154154
return oss.str();
155155
}
156156

157-
FatalMessage::FatalMessage(const LogMessage& details, g3::SignalType signal_id)
158-
: LogMessage(details), _signal_id(signal_id) {}
157+
FatalMessage::FatalMessage(const LogMessage& details, g3::SignalType signal_id) :
158+
LogMessage(details), _signal_id(signal_id) {}
159159

160-
FatalMessage::FatalMessage(const FatalMessage& other)
161-
: LogMessage(other), _signal_id(other._signal_id) {}
160+
FatalMessage::FatalMessage(const FatalMessage& other) :
161+
LogMessage(other), _signal_id(other._signal_id) {}
162162

163163
LogMessage FatalMessage::copyToLogMessage() const {
164164
return LogMessage(*this);

src/logworker.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
namespace g3 {
1919

20-
LogWorkerImpl::LogWorkerImpl()
21-
: _bg(kjellkod::Active::createActive()) {}
20+
LogWorkerImpl::LogWorkerImpl() :
21+
_bg(kjellkod::Active::createActive()) {}
2222

2323
void LogWorkerImpl::bgSave(g3::LogMessagePtr msgPtr) {
2424
std::unique_ptr<LogMessage> uniqueMsg(std::move(msgPtr.get()));

test_unit/test_concept_sink.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ class CoutSink {
2929
stringstream buffer;
3030
unique_ptr<ScopedOut> scope_ptr;
3131

32-
CoutSink()
33-
: scope_ptr(std::make_unique<ScopedOut>(std::cout, &buffer)) {}
32+
CoutSink() :
33+
scope_ptr(std::make_unique<ScopedOut>(std::cout, &buffer)) {}
3434

3535
public:
3636
void clear() { buffer.str(""); }
@@ -67,9 +67,9 @@ namespace g3 {
6767
}
6868

6969
public:
70-
Worker()
71-
: _bg{
72-
kjellkod::Active::createActive()} {
70+
Worker() :
71+
_bg{
72+
kjellkod::Active::createActive()} {
7373
}
7474

7575
~Worker() {

test_unit/test_cpp_future_concepts.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ TEST(Configuration, FutureSilly) {
3434

3535
struct MsgType {
3636
std::string msg_;
37-
MsgType(std::string m)
38-
: msg_(m){};
37+
MsgType(std::string m) :
38+
msg_(m){};
3939
std::string msg() { return msg_; }
4040
};
4141

test_unit/test_io.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -593,8 +593,8 @@ TEST(CHECK, CHECK_runtimeError) {
593593
const int size_;
594594

595595
public:
596-
explicit dynamic_int_array(int size)
597-
: data_{std::make_unique<int[]>(size)}, size_(size) {}
596+
explicit dynamic_int_array(int size) :
597+
data_{std::make_unique<int[]>(size)}, size_(size) {}
598598

599599
int& at(int i) {
600600
CHECK(i < size_);

test_unit/test_linux_dynamic_loaded_sharedlib.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020

2121
struct LogMessageCounter {
2222
std::vector<std::string>& bank;
23-
LogMessageCounter(std::vector<std::string>& storeMessages)
24-
: bank(storeMessages) {
23+
LogMessageCounter(std::vector<std::string>& storeMessages) :
24+
bank(storeMessages) {
2525
}
2626

2727
void countMessages(std::string msg) {

test_unit/test_sink.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ TEST(ConceptSink, OneHundredRemoveAllSinks) {
227227

228228
struct VoidReceiver {
229229
std::atomic<int>* _atomicCounter;
230-
explicit VoidReceiver(std::atomic<int>* counter)
231-
: _atomicCounter(counter) {}
230+
explicit VoidReceiver(std::atomic<int>* counter) :
231+
_atomicCounter(counter) {}
232232

233233
void receiveMsg(std::string msg) { /*ignored*/
234234
}
@@ -271,8 +271,8 @@ TEST(ConceptSink, VoidCall__TwoCalls_ExpectingTwoAdd) {
271271

272272
struct IntReceiver {
273273
std::atomic<int>* _atomicCounter;
274-
explicit IntReceiver(std::atomic<int>* counter)
275-
: _atomicCounter(counter) {}
274+
explicit IntReceiver(std::atomic<int>* counter) :
275+
_atomicCounter(counter) {}
276276

277277
void receiveMsgDoNothing(std::string msg) { /*ignored*/
278278
}

test_unit/testing_helpers.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,16 @@ namespace testing_helpers {
9898
}
9999
}
100100

101-
ScopedLogger::ScopedLogger()
102-
: _currentWorker(g3::LogWorker::createLogWorker()) {}
101+
ScopedLogger::ScopedLogger() :
102+
_currentWorker(g3::LogWorker::createLogWorker()) {}
103103
ScopedLogger::~ScopedLogger() {}
104104

105105
g3::LogWorker* ScopedLogger::get() {
106106
return _currentWorker.get();
107107
}
108108

109-
RestoreFileLogger::RestoreFileLogger(std::string directory)
110-
: _scope(new ScopedLogger), _handle(_scope->get()->addSink(std::make_unique<g3::FileSink>("UNIT_TEST_LOGGER", directory, "g3log", kFlushToDiskWithThisInterval), &g3::FileSink::fileWrite)) {
109+
RestoreFileLogger::RestoreFileLogger(std::string directory) :
110+
_scope(new ScopedLogger), _handle(_scope->get()->addSink(std::make_unique<g3::FileSink>("UNIT_TEST_LOGGER", directory, "g3log", kFlushToDiskWithThisInterval), &g3::FileSink::fileWrite)) {
111111
using namespace g3;
112112
g3::initializeLogging(_scope->_currentWorker.get());
113113
clearMockFatal();

0 commit comments

Comments
 (0)