Skip to content

Commit 94080d3

Browse files
committed
clang-format all files
1 parent 226a22b commit 94080d3

File tree

332 files changed

+10279
-10994
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

332 files changed

+10279
-10994
lines changed

base/24bits.h

+14-12
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,23 @@ namespace base {
1515

1616
#ifdef LAF_LITTLE_ENDIAN
1717

18-
template<typename PTR, typename VALUE>
19-
inline void write24bits(PTR* ptr, VALUE value) {
20-
((uint8_t*)ptr)[0] = value;
21-
((uint8_t*)ptr)[1] = value >> 8;
22-
((uint8_t*)ptr)[2] = value >> 16;
23-
}
18+
template<typename PTR, typename VALUE>
19+
inline void write24bits(PTR* ptr, VALUE value)
20+
{
21+
((uint8_t*)ptr)[0] = value;
22+
((uint8_t*)ptr)[1] = value >> 8;
23+
((uint8_t*)ptr)[2] = value >> 16;
24+
}
2425

2526
#elif defined(LAF_BIG_ENDIAN)
2627

27-
template<typename PTR, typename VALUE>
28-
inline void write24bits(PTR* ptr, VALUE value) {
29-
((uint8_t*)ptr)[0] = value >> 16;
30-
((uint8_t*)ptr)[1] = value >> 8;
31-
((uint8_t*)ptr)[2] = value;
32-
}
28+
template<typename PTR, typename VALUE>
29+
inline void write24bits(PTR* ptr, VALUE value)
30+
{
31+
((uint8_t*)ptr)[0] = value >> 16;
32+
((uint8_t*)ptr)[1] = value >> 8;
33+
((uint8_t*)ptr)[2] = value;
34+
}
3335

3436
#endif
3537

base/base.h

+8-10
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,21 @@
3636

3737
#undef ABS
3838
#undef SGN
39-
#define ABS(x) (((x) >= 0) ? (x) : (-(x)))
40-
#define SGN(x) (((x) >= 0) ? 1 : -1)
41-
42-
39+
#define ABS(x) (((x) >= 0) ? (x) : (-(x)))
40+
#define SGN(x) (((x) >= 0) ? 1 : -1)
4341

4442
//////////////////////////////////////////////////////////////////////
4543
// Overloaded new/delete operators to detect memory-leaks
4644

4745
#if defined __cplusplus && defined LAF_MEMLEAK
4846

49-
#include <new>
47+
#include <new>
5048

51-
#ifdef _NOEXCEPT
52-
#define LAF_NOEXCEPT _NOEXCEPT
53-
#else
54-
#define LAF_NOEXCEPT
55-
#endif
49+
#ifdef _NOEXCEPT
50+
#define LAF_NOEXCEPT _NOEXCEPT
51+
#else
52+
#define LAF_NOEXCEPT
53+
#endif
5654

5755
void* operator new(std::size_t size);
5856
void* operator new[](std::size_t size);

base/base64.cpp

+10-13
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Read LICENSE.txt for more information.
77

88
#ifdef HAVE_CONFIG_H
9-
#include "config.h"
9+
#include "config.h"
1010
#endif
1111

1212
#include "base/base64.h"
@@ -56,15 +56,15 @@ static inline int base64Inv(int asciiChar)
5656

5757
void encode_base64(const char* input, size_t n, std::string& output)
5858
{
59-
const size_t size = 4*int(std::ceil(n/3.0)); // Estimate encoded string size
59+
const size_t size = 4 * int(std::ceil(n / 3.0)); // Estimate encoded string size
6060
output.resize(size);
6161

6262
auto outIt = output.begin();
6363
auto outEnd = output.end();
6464
uint8_t next = 0;
6565
size_t i = 0;
6666
size_t j = 0;
67-
for (; i<n; ++i, ++input) {
67+
for (; i < n; ++i, ++input) {
6868
auto inputValue = *input;
6969
switch (j) {
7070
case 0:
@@ -95,39 +95,36 @@ void encode_base64(const char* input, size_t n, std::string& output)
9595
*outIt = base64Char(next);
9696
++outIt;
9797
}
98-
for (; outIt!=outEnd; ++outIt)
99-
*outIt = '='; // Padding
98+
for (; outIt != outEnd; ++outIt)
99+
*outIt = '='; // Padding
100100
}
101101
}
102102

103103
void decode_base64(const char* input, size_t n, buffer& output)
104104
{
105-
size_t size = 3*int(std::ceil(n/4.0)); // Estimate decoded buffer size
105+
size_t size = 3 * int(std::ceil(n / 4.0)); // Estimate decoded buffer size
106106
output.resize(size);
107107

108108
auto outIt = output.begin();
109109
size_t i = 0;
110-
for (; i+3<n; i+=4, input+=4) {
111-
*outIt = (((base64Inv(input[0]) ) << 2) |
112-
((base64Inv(input[1]) & 0b110000) >> 4));
110+
for (; i + 3 < n; i += 4, input += 4) {
111+
*outIt = (((base64Inv(input[0])) << 2) | ((base64Inv(input[1]) & 0b110000) >> 4));
113112
++outIt;
114113

115114
if (input[2] == '=') {
116115
size -= 2;
117116
break;
118117
}
119118

120-
*outIt = (((base64Inv(input[1]) & 0b001111) << 4) |
121-
((base64Inv(input[2]) & 0b111100) >> 2));
119+
*outIt = (((base64Inv(input[1]) & 0b001111) << 4) | ((base64Inv(input[2]) & 0b111100) >> 2));
122120
++outIt;
123121

124122
if (input[3] == '=') {
125123
--size;
126124
break;
127125
}
128126

129-
*outIt = (((base64Inv(input[2]) & 0b000011) << 6) |
130-
((base64Inv(input[3]) )));
127+
*outIt = (((base64Inv(input[2]) & 0b000011) << 6) | ((base64Inv(input[3]))));
131128
++outIt;
132129
}
133130

base/base64.h

+14-7
Original file line numberDiff line numberDiff line change
@@ -18,46 +18,53 @@ namespace base {
1818
void encode_base64(const char* input, size_t n, std::string& output);
1919
void decode_base64(const char* input, size_t n, buffer& output);
2020

21-
inline void encode_base64(const buffer& input, std::string& output) {
21+
inline void encode_base64(const buffer& input, std::string& output)
22+
{
2223
if (!input.empty())
2324
encode_base64((const char*)&input[0], input.size(), output);
2425
}
2526

26-
inline std::string encode_base64(const buffer& input) {
27+
inline std::string encode_base64(const buffer& input)
28+
{
2729
std::string output;
2830
if (!input.empty())
2931
encode_base64((const char*)&input[0], input.size(), output);
3032
return output;
3133
}
3234

33-
inline std::string encode_base64(const std::string& input) {
35+
inline std::string encode_base64(const std::string& input)
36+
{
3437
std::string output;
3538
if (!input.empty())
3639
encode_base64((const char*)input.c_str(), input.size(), output);
3740
return output;
3841
}
3942

40-
inline void decode_base64(const std::string& input, buffer& output) {
43+
inline void decode_base64(const std::string& input, buffer& output)
44+
{
4145
if (!input.empty())
4246
decode_base64(input.c_str(), input.size(), output);
4347
}
4448

45-
inline buffer decode_base64(const std::string& input) {
49+
inline buffer decode_base64(const std::string& input)
50+
{
4651
buffer output;
4752
if (!input.empty())
4853
decode_base64(input.c_str(), input.size(), output);
4954
return output;
5055
}
5156

52-
inline std::string decode_base64s(const std::string& input) {
57+
inline std::string decode_base64s(const std::string& input)
58+
{
5359
if (input.empty())
5460
return std::string();
5561
buffer tmp;
5662
decode_base64(input.c_str(), input.size(), tmp);
5763
return std::string((const char*)&tmp[0], tmp.size());
5864
}
5965

60-
inline buffer decode_base64(const buffer& input) {
66+
inline buffer decode_base64(const buffer& input)
67+
{
6168
buffer output;
6269
if (!input.empty())
6370
decode_base64((const char*)&input[0], input.size(), output);

base/base64_tests.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ using namespace base;
1515
TEST(Base64, Encode)
1616
{
1717
EXPECT_EQ("", encode_base64(buffer()));
18-
EXPECT_EQ("Cg==", encode_base64(buffer{'\n'}));
19-
EXPECT_EQ("YQ==", encode_base64(buffer{'a'}));
20-
EXPECT_EQ("YWJjZGU=", encode_base64(buffer{'a', 'b', 'c', 'd', 'e'}));
18+
EXPECT_EQ("Cg==", encode_base64(buffer{ '\n' }));
19+
EXPECT_EQ("YQ==", encode_base64(buffer{ 'a' }));
20+
EXPECT_EQ("YWJjZGU=", encode_base64(buffer{ 'a', 'b', 'c', 'd', 'e' }));
2121
EXPECT_EQ("YWJjZGU=", encode_base64("abcde"));
2222
EXPECT_EQ("YWJj", encode_base64("abc"));
2323
EXPECT_EQ("5pel5pys6Kqe", encode_base64("\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E")); // "日本語"
@@ -26,9 +26,9 @@ TEST(Base64, Encode)
2626
TEST(Base64, Decode)
2727
{
2828
EXPECT_EQ(buffer(), decode_base64(""));
29-
EXPECT_EQ(buffer{'\n'}, decode_base64("Cg=="));
30-
EXPECT_EQ(buffer{'a'}, decode_base64("YQ=="));
31-
EXPECT_EQ(buffer({'a', 'b', 'c', 'd', 'e'}), decode_base64("YWJjZGU="));
29+
EXPECT_EQ(buffer{ '\n' }, decode_base64("Cg=="));
30+
EXPECT_EQ(buffer{ 'a' }, decode_base64("YQ=="));
31+
EXPECT_EQ(buffer({ 'a', 'b', 'c', 'd', 'e' }), decode_base64("YWJjZGU="));
3232
EXPECT_EQ("abcde", decode_base64s("YWJjZGU="));
3333
EXPECT_EQ("abc", decode_base64s("YWJj"));
3434
EXPECT_EQ("\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E", decode_base64s("5pel5pys6Kqe")); // "日本語"

base/cfile.cpp

+7-17
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Read LICENSE.txt for more information.
66

77
#ifdef HAVE_CONFIG_H
8-
#include "config.h"
8+
#include "config.h"
99
#endif
1010

1111
#include <cstdio>
@@ -84,14 +84,9 @@ long long fgetq(FILE* file)
8484
return EOF;
8585

8686
// Little endian.
87-
return (((long long)b8 << 56) |
88-
((long long)b7 << 48) |
89-
((long long)b6 << 40) |
90-
((long long)b5 << 32) |
91-
((long long)b4 << 24) |
92-
((long long)b3 << 16) |
93-
((long long)b2 << 8) |
94-
(long long)b1);
87+
return (((long long)b8 << 56) | ((long long)b7 << 48) | ((long long)b6 << 40) |
88+
((long long)b5 << 32) | ((long long)b4 << 24) | ((long long)b3 << 16) |
89+
((long long)b2 << 8) | (long long)b1);
9590
}
9691

9792
// Reads a 32-bit single-precision floating point number using
@@ -148,14 +143,9 @@ double fgetd(FILE* file)
148143
return EOF;
149144

150145
// Little endian.
151-
long long v = (((long long)b8 << 56) |
152-
((long long)b7 << 48) |
153-
((long long)b6 << 40) |
154-
((long long)b5 << 32) |
155-
((long long)b4 << 24) |
156-
((long long)b3 << 16) |
157-
((long long)b2 << 8) |
158-
(long long)b1);
146+
long long v = (((long long)b8 << 56) | ((long long)b7 << 48) | ((long long)b6 << 40) |
147+
((long long)b5 << 32) | ((long long)b4 << 24) | ((long long)b3 << 16) |
148+
((long long)b2 << 8) | (long long)b1);
159149
return *reinterpret_cast<double*>(&v);
160150
}
161151

base/cfile.h

+10-10
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212

1313
namespace base {
1414

15-
int fgetw(FILE* file);
16-
long fgetl(FILE* file);
17-
long long fgetq(FILE* file);
18-
float fgetf(FILE* file);
19-
double fgetd(FILE* file);
20-
int fputw(int w, FILE* file);
21-
int fputl(long l, FILE* file);
22-
int fputq(long long l, FILE* file);
23-
int fputf(float l, FILE* file);
24-
int fputd(double l, FILE* file);
15+
int fgetw(FILE* file);
16+
long fgetl(FILE* file);
17+
long long fgetq(FILE* file);
18+
float fgetf(FILE* file);
19+
double fgetd(FILE* file);
20+
int fputw(int w, FILE* file);
21+
int fputl(long l, FILE* file);
22+
int fputq(long long l, FILE* file);
23+
int fputf(float l, FILE* file);
24+
int fputd(double l, FILE* file);
2525

2626
} // namespace base
2727

base/chrono.cpp

+41-37
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,41 @@
1-
// LAF Base Library
2-
// Copyright (c) 2021 Igara Studio S.A.
3-
// Copyright (c) 2001-2016 David Capello
4-
//
5-
// This file is released under the terms of the MIT license.
6-
// Read LICENSE.txt for more information.
7-
8-
#ifdef HAVE_CONFIG_H
9-
#include "config.h"
10-
#endif
11-
12-
#include "base/chrono.h"
13-
14-
#if LAF_WINDOWS
15-
#include "base/chrono_win32.h"
16-
#else
17-
#include "base/chrono_unix.h"
18-
#endif
19-
20-
namespace base {
21-
22-
Chrono::Chrono() : m_impl(new ChronoImpl) {
23-
}
24-
25-
Chrono::~Chrono() {
26-
delete m_impl;
27-
}
28-
29-
void Chrono::reset() {
30-
m_impl->reset();
31-
}
32-
33-
double Chrono::elapsed() const {
34-
return m_impl->elapsed();
35-
}
36-
37-
} // namespace base
1+
// LAF Base Library
2+
// Copyright (c) 2021 Igara Studio S.A.
3+
// Copyright (c) 2001-2016 David Capello
4+
//
5+
// This file is released under the terms of the MIT license.
6+
// Read LICENSE.txt for more information.
7+
8+
#ifdef HAVE_CONFIG_H
9+
#include "config.h"
10+
#endif
11+
12+
#include "base/chrono.h"
13+
14+
#if LAF_WINDOWS
15+
#include "base/chrono_win32.h"
16+
#else
17+
#include "base/chrono_unix.h"
18+
#endif
19+
20+
namespace base {
21+
22+
Chrono::Chrono() : m_impl(new ChronoImpl)
23+
{
24+
}
25+
26+
Chrono::~Chrono()
27+
{
28+
delete m_impl;
29+
}
30+
31+
void Chrono::reset()
32+
{
33+
m_impl->reset();
34+
}
35+
36+
double Chrono::elapsed() const
37+
{
38+
return m_impl->elapsed();
39+
}
40+
41+
} // namespace base

0 commit comments

Comments
 (0)