Skip to content

Commit 9f5eef1

Browse files
restyled-commitsrobinlinden
authored andcommitted
style: Format the code the way restyled wants
1 parent 612b156 commit 9f5eef1

File tree

1 file changed

+30
-49
lines changed

1 file changed

+30
-49
lines changed

cpp/src/util/logging.h

Lines changed: 30 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -5,80 +5,61 @@
55
#include <ostream>
66
#include <vector>
77

8-
9-
struct scope_counter
10-
{
8+
struct scope_counter {
119
static std::size_t scope;
1210

13-
scope_counter ()
14-
{ scope++; }
11+
scope_counter() { scope++; }
1512

16-
~scope_counter ()
17-
{ scope--; }
13+
~scope_counter() { scope--; }
1814

19-
scope_counter (scope_counter const &rhs) = delete;
15+
scope_counter(scope_counter const &rhs) = delete;
2016
};
2117

22-
std::ostream &scope_indent (std::ostream &os, int line);
18+
std::ostream &scope_indent(std::ostream &os, int line);
2319

2420
#define SCOPE scope_counter const _scope
2521

26-
2722
#ifdef HAVE_GLOG
28-
# include <glog/logging.h>
29-
# undef LOG
30-
# define LOG(KIND) scope_indent (COMPACT_GOOGLE_LOG_##KIND.stream(), __LINE__)
23+
#include <glog/logging.h>
24+
#undef LOG
25+
#define LOG(KIND) scope_indent(COMPACT_GOOGLE_LOG_##KIND.stream(), __LINE__)
3126
#else
32-
namespace google
33-
{
34-
inline void InitGoogleLogging (char const *) { }
35-
inline void ShutdownGoogleLogging () { }
36-
inline void LogToStderr () { }
37-
}
27+
namespace google {
28+
inline void InitGoogleLogging(char const *) {}
29+
inline void ShutdownGoogleLogging() {}
30+
inline void LogToStderr() {}
31+
} // namespace google
3832

39-
struct null_ostream
40-
: std::ostream
41-
{
42-
};
33+
struct null_ostream : std::ostream {};
4334

44-
# define LOG(LEVEL) (null_ostream ())
45-
# define LOG_ASSERT(cond) assert (cond)
35+
#define LOG(LEVEL) (null_ostream())
36+
#define LOG_ASSERT(cond) assert(cond)
4637
#endif
4738

48-
void output_hex (std::ostream &os, uint8_t const *data, size_t length);
49-
39+
void output_hex(std::ostream &os, uint8_t const *data, size_t length);
5040

51-
struct formatter
52-
{
53-
formatter (formatter &&fmt)
54-
: text_ (std::move (fmt.text_))
55-
{ }
41+
struct formatter {
42+
formatter(formatter &&fmt) : text_(std::move(fmt.text_)) {}
5643

57-
explicit formatter (std::vector<char> text)
58-
: text_ (std::move (text))
59-
{ }
44+
explicit formatter(std::vector<char> text) : text_(std::move(text)) {}
6045

61-
friend std::ostream &operator << (std::ostream &os, formatter const &fmt);
46+
friend std::ostream &operator<<(std::ostream &os, formatter const &fmt);
6247

6348
private:
6449
std::vector<char> const text_;
6550
};
6651

52+
template <size_t N, typename... Args>
53+
formatter format(char const (&fmt)[N], Args const &...args) {
54+
std::vector<char> text(snprintf(nullptr, 0, fmt, args...) + 1);
55+
snprintf(text.data(), text.size(), fmt, args...);
6756

68-
template<size_t N, typename ...Args>
69-
formatter
70-
format (char const (&fmt)[N], Args const &...args)
71-
{
72-
std::vector<char> text (snprintf (nullptr, 0, fmt, args...) + 1);
73-
snprintf (text.data (), text.size (), fmt, args...);
74-
75-
return formatter (std::move (text));
57+
return formatter(std::move(text));
7658
}
7759

78-
template<std::size_t N>
79-
std::ostream &
80-
operator << (std::ostream &os, std::array<uint8_t, N> const &array)
81-
{
82-
output_hex (os, array.data (), array.size ());
60+
template <std::size_t N>
61+
std::ostream &operator<<(std::ostream &os,
62+
std::array<uint8_t, N> const &array) {
63+
output_hex(os, array.data(), array.size());
8364
return os;
8465
}

0 commit comments

Comments
 (0)