Skip to content

Commit 0f17982

Browse files
committed
Update formatting
1 parent 3aa20d8 commit 0f17982

30 files changed

Lines changed: 193 additions & 139 deletions

libs/common/include/s25util/MyTime.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ struct Time
3232
/// liefert die aktuellen Ticks.
3333
static time64_t CurrentTick();
3434
/// Format a time as a string
35-
/// @param format Format to use (%Y=4 year (4 digits), %m month, %D day, %H hour, %i minute, %s second (all 2 digits), %% -> %)
35+
/// @param format Format to use (%Y=4 year (4 digits), %m month, %D day, %H hour, %i minute, %s second (all 2
36+
/// digits), %% -> %)
3637
/// @param time Pointer to time to format or nullptr to use current time
3738
static std::string FormatTime(const std::string& format, time64_t time);
3839
/// Format the current time as a string

libs/common/include/s25util/enumUtils.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,15 @@
2020
#include <type_traits>
2121

2222
/// Makes a strongly typed enum usable as a bitset
23-
#define MAKE_BITSET_STRONG(Type) \
24-
inline auto operator&(Type lhs, Type rhs) { return Type(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs)); } \
25-
inline auto operator|(Type lhs, Type rhs) { return Type(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs)); } \
26-
/* NOLINTNEXTLINE(bugprone-macro-parentheses) */ \
27-
static_assert(std::is_unsigned<std::underlying_type_t<Type>>::value, #Type " must use unsigned type as the underlying type")
23+
#define MAKE_BITSET_STRONG(Type) \
24+
inline auto operator&(Type lhs, Type rhs) \
25+
{ \
26+
return Type(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs)); \
27+
} \
28+
inline auto operator|(Type lhs, Type rhs) \
29+
{ \
30+
return Type(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs)); \
31+
} \
32+
/* NOLINTNEXTLINE(bugprone-macro-parentheses) */ \
33+
static_assert(std::is_unsigned<std::underlying_type_t<Type>>::value, \
34+
#Type " must use unsigned type as the underlying type")

libs/common/include/s25util/warningSuppression.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,26 @@
2323
// Macro that can be used to suppress unused warnings. Required e.g. for const std::arrays defined in headers
2424
// Don't use this if not absolutely necessary!
2525
#ifdef __GNUC__
26-
#define SUPPRESS_UNUSED __attribute__((unused))
26+
# define SUPPRESS_UNUSED __attribute__((unused))
2727
#else
28-
#define SUPPRESS_UNUSED
28+
# define SUPPRESS_UNUSED
2929
#endif
3030

3131
// Use for functions which use "unfixable" undefined behavior, but which is safe
3232
#if defined(__clang__)
33-
#define RTTR_ATTRIBUTE_NO_UBSAN(what) __attribute__((no_sanitize(BOOST_PP_STRINGIZE(what))))
33+
# define RTTR_ATTRIBUTE_NO_UBSAN(what) __attribute__((no_sanitize(BOOST_PP_STRINGIZE(what))))
3434
#elif defined(__GNUC__)
35-
#define RTTR_ATTRIBUTE_NO_UBSAN(what) __attribute__((no_sanitize_undefined))
35+
# define RTTR_ATTRIBUTE_NO_UBSAN(what) __attribute__((no_sanitize_undefined))
3636
#else
37-
#define RTTR_ATTRIBUTE_NO_UBSAN(what)
37+
# define RTTR_ATTRIBUTE_NO_UBSAN(what)
3838
#endif
3939

4040
#if BOOST_COMP_CLANG
41-
#define RTTR_DIAGNOSTIC(what) _Pragma(BOOST_PP_STRINGIZE(clang diagnostic what))
41+
# define RTTR_DIAGNOSTIC(what) _Pragma(BOOST_PP_STRINGIZE(clang diagnostic what))
4242
#elif BOOST_COMP_MSVC || defined(__INTELLISENSE__)
43-
#define RTTR_DIAGNOSTIC(what)
43+
# define RTTR_DIAGNOSTIC(what)
4444
#else
45-
#define RTTR_DIAGNOSTIC(what) _Pragma(BOOST_PP_STRINGIZE(GCC diagnostic what))
45+
# define RTTR_DIAGNOSTIC(what) _Pragma(BOOST_PP_STRINGIZE(GCC diagnostic what))
4646
#endif
4747

4848
#define RTTR_PUSH_DIAGNOSTIC RTTR_DIAGNOSTIC(push)

libs/common/src/LocaleHelper.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
#include <boost/predef/os.h>
2222
#include <iostream>
2323
#if BOOST_OS_WINDOWS
24-
#include <boost/locale.hpp>
24+
# include <boost/locale.hpp>
2525
#elif !BOOST_OS_MACOS
26-
#include "utf8.h"
27-
#include <iomanip>
28-
#include <sstream>
26+
# include "utf8.h"
27+
# include <iomanip>
28+
# include <sstream>
2929
#endif
3030

3131
namespace bfs = boost::filesystem;
@@ -97,7 +97,8 @@ bool LocaleHelper::init()
9797
// Call first to correctly init static variable
9898
getBfsDefaultLocale();
9999
// Check for errors and use system locale.
100-
// So don't rely on string conversions to yield identical results on all systems as locale settings can be changed!
100+
// So don't rely on string conversions to yield identical results on all systems as locale settings can be
101+
// changed!
101102
std::locale newLocale = createUtf8Locale();
102103
std::locale::global(newLocale);
103104
// Use also the encoding (mostly UTF8) for bfs paths: http://stackoverflow.com/questions/23393870
@@ -108,10 +109,11 @@ bool LocaleHelper::init()
108109
#if BOOST_OS_WINDOWS
109110
std::cerr << "Check your system language configuration!";
110111
#else
111-
#if BOOST_OS_MACOS
112-
std::cerr << "OS X has known problems when using libstdc++. Try setting LC_ALL and LANG to \"C\" or compile with libc++"
113-
<< std::endl;
114-
#endif
112+
# if BOOST_OS_MACOS
113+
std::cerr
114+
<< "OS X has known problems when using libstdc++. Try setting LC_ALL and LANG to \"C\" or compile with libc++"
115+
<< std::endl;
116+
# endif
115117
std::string lcAll = System::getEnvVar("LC_ALL");
116118
std::string lang = System::getEnvVar("LANG");
117119
std::cerr << "Check your environment for invalid settings (e.g. LC_ALL";

libs/common/src/MyTime.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
#include <iomanip>
2121
#include <iostream>
2222
#ifdef _WIN32
23-
#include <windows.h>
23+
# include <windows.h>
2424
#else
25-
#include <sys/times.h>
25+
# include <sys/times.h>
2626
#endif // _WIN32
2727
#include "StringConversion.h"
2828

@@ -57,7 +57,8 @@ time64_t Time::CurrentTick()
5757
/**
5858
* formatiert einen Zeitstring.
5959
*
60-
* @param[in] format Formatstring (%Y=4 stelliges Jahr, %m 2 stelliges Monat, %D tag, %H Stunde, %i Minute, %s Sekunden)
60+
* @param[in] format Formatstring (%Y=4 stelliges Jahr, %m 2 stelliges Monat, %D tag, %H Stunde, %i Minute, %s
61+
* Sekunden)
6162
* @param[in] time zu benutzender Timestamp.
6263
*
6364
* @return Formatted string

libs/common/src/SingletonPolicies.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,13 @@ class LifetimeTracker : public Singleton<LifetimeTracker, SingletonPolicies::Def
3131
const unsigned longevity_;
3232
DestructionFunPtr destFunc_;
3333

34-
LifetimeTrackerItem(unsigned longevity, DestructionFunPtr destFunc) : longevity_(longevity), destFunc_(destFunc) {}
34+
LifetimeTrackerItem(unsigned longevity, DestructionFunPtr destFunc) : longevity_(longevity), destFunc_(destFunc)
35+
{}
3536

36-
friend bool operator<(const LifetimeTrackerItem& lhs, const LifetimeTrackerItem& rhs) { return lhs.longevity_ < rhs.longevity_; }
37+
friend bool operator<(const LifetimeTrackerItem& lhs, const LifetimeTrackerItem& rhs)
38+
{
39+
return lhs.longevity_ < rhs.longevity_;
40+
}
3741
};
3842

3943
// Queue that sorts items in ascending order (front() points to smallest element)
@@ -50,7 +54,8 @@ class LifetimeTracker : public Singleton<LifetimeTracker, SingletonPolicies::Def
5054
void add(unsigned longevity, DestructionFunPtr destFunc)
5155
{
5256
// Remove same entries first. Calling a dtor twice is not supported!
53-
const auto it = std::find_if(items_.begin(), items_.end(), [destFunc](const auto& x) { return x.destFunc_ == destFunc; });
57+
const auto it =
58+
std::find_if(items_.begin(), items_.end(), [destFunc](const auto& x) { return x.destFunc_ == destFunc; });
5459
if(it != items_.end())
5560
items_.erase(it);
5661
items_.insert(LifetimeTrackerItem(longevity, destFunc));

libs/common/src/System.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ bool System::execute(const bfs::path& command, const std::string& arguments)
9696
return result == 0; // Assume 0 == OK
9797
}
9898

99-
System::ScopedCurrentPathChange::ScopedCurrentPathChange(const boost::filesystem::path& newCurrentPath) : oldCurPath(bfs::current_path())
99+
System::ScopedCurrentPathChange::ScopedCurrentPathChange(const boost::filesystem::path& newCurrentPath)
100+
: oldCurPath(bfs::current_path())
100101
{
101102
if(!newCurrentPath.empty())
102103
bfs::current_path(newCurrentPath);

libs/common/src/System_Win32.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
#include <windows.h>
2121
#include <shellapi.h>
2222
#ifdef _MSC_VER
23-
#pragma warning(push)
24-
#pragma warning(disable : 4091) // "typedef ": Ignoriert auf der linken Seite von "tagGPFIDL_FLAGS"
23+
# pragma warning(push)
24+
# pragma warning(disable : 4091) // "typedef ": Ignoriert auf der linken Seite von "tagGPFIDL_FLAGS"
2525
#endif
2626
#include <shlobj.h>
2727
#ifdef _MSC_VER
28-
#pragma warning(push)
28+
# pragma warning(push)
2929
#endif
3030
#include <stdexcept>
3131

@@ -34,20 +34,20 @@ namespace bfs = boost::filesystem;
3434
#if defined(__MINGW32__) && !defined(REFKNOWNFOLDERID)
3535

3636
using KNOWNFOLDERID = GUID;
37-
#define REFKNOWNFOLDERID const KNOWNFOLDERID&
37+
# define REFKNOWNFOLDERID const KNOWNFOLDERID&
3838

39-
#define DEFINE_KNOWN_FOLDER(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
40-
EXTERN_C const GUID DECLSPEC_SELECTANY name = {l, w1, w2, {b1, b2, b3, b4, b5, b6, b7, b8}}
39+
# define DEFINE_KNOWN_FOLDER(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
40+
EXTERN_C const GUID DECLSPEC_SELECTANY name = {l, w1, w2, {b1, b2, b3, b4, b5, b6, b7, b8}}
4141

42-
#define KF_FLAG_CREATE 0x00008000
42+
# define KF_FLAG_CREATE 0x00008000
4343

4444
// {4C5C32FF-BB9D-43b0-B5B4-2D72E54EAAA4}
4545
DEFINE_KNOWN_FOLDER(FOLDERID_SavedGames, 0x4c5c32ff, 0xbb9d, 0x43b0, 0xb5, 0xb4, 0x2d, 0x72, 0xe5, 0x4e, 0xaa, 0xa4);
4646
// {FDD39AD0-238F-46AF-ADB4-6C85480369C7}
4747
DEFINE_KNOWN_FOLDER(FOLDERID_Documents, 0xFDD39AD0, 0x238F, 0x46AF, 0xAD, 0xB4, 0x6C, 0x85, 0x48, 0x03, 0x69, 0xC7);
4848

4949
#elif(NTDDI_VERSION < NTDDI_VISTA)
50-
#define KF_FLAG_CREATE 0x00008000
50+
# define KF_FLAG_CREATE 0x00008000
5151
#endif // __MINGW32__
5252

5353
typedef HRESULT(WINAPI* LPSHGetKnownFolderPath)(REFKNOWNFOLDERID rfid, DWORD dwFlags, HANDLE hToken, PWSTR* ppszPath);

libs/common/src/Tokenizer.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
#include "Tokenizer.h"
1919
#include <utility>
2020

21-
Tokenizer::Tokenizer(std::string data, std::string delimiter) : data(std::move(data)), delimiter(std::move(delimiter)), curPos(0) {}
21+
Tokenizer::Tokenizer(std::string data, std::string delimiter)
22+
: data(std::move(data)), delimiter(std::move(delimiter)), curPos(0)
23+
{}
2224

2325
Tokenizer::operator bool() const
2426
{

libs/common/src/fileFuncs.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ std::string makePortableName(const std::string& fileName)
2929
for(char c : fileName)
3030
{
3131
// Characters allowed by portable_posix_name. These are also allowed by windows_name
32-
if((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '.' || c == '_' || c == '-')
32+
if((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '.' || c == '_'
33+
|| c == '-')
3334
result += c;
3435
else
3536
result += '_';

0 commit comments

Comments
 (0)