Skip to content

Commit 346a85c

Browse files
committed
Further reviewed formatting
1 parent 907a171 commit 346a85c

26 files changed

Lines changed: 129 additions & 156 deletions

File tree

libraries/application/src/morpheus/application/application.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "morpheus/application/application.hpp"
2-
#include "morpheus/application/version.hpp"
32
#include "morpheus/application/po/options.hpp"
3+
#include "morpheus/application/version.hpp"
44
#include "morpheus/core/base/debugging.hpp"
55
#include "morpheus/core/conformance/date.hpp"
66
#include "morpheus/core/conformance/format.hpp"
@@ -23,11 +23,12 @@ namespace
2323
/// \brief Override the default termination handler to print the call stack before exiting the program to aid debugging.
2424
void terminationHandler()
2525
{
26-
try{
26+
try
27+
{
2728
debugPrint(fmt_ns::format("{}", MORPHEUS_CURRENT_STACKTRACE));
2829
}
29-
catch(...){
30-
30+
catch (...)
31+
{
3132
}
3233
std::abort();
3334
}
@@ -48,14 +49,15 @@ void terminationHandler()
4849
} // namespace
4950

5051
Application::Application(int argc, char const* const* argv)
51-
: mConfig(
52-
[&]
53-
{
54-
po::Config config;
55-
if (auto invalid = parseProgramOptions(argc, argv, po::HelpDocumentation{}, config)) {
56-
}
57-
return config;
58-
}())
52+
: mConfig(
53+
[&]
54+
{
55+
po::Config config;
56+
if (auto invalid = parseProgramOptions(argc, argv, po::HelpDocumentation{}, config))
57+
{
58+
}
59+
return config;
60+
}())
5961
//`: mLogName(getDefaultApplicationLogName())
6062
{
6163
std::set_terminate(terminationHandler);

libraries/application/src/morpheus/application/application.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ class Application
2929
/// Path to application log file.
3030
std::filesystem::path getLogPath() const noexcept { return mLogPath; }
3131

32-
void run()
33-
{
34-
35-
}
32+
void run() {}
3633

3734
private:
3835
po::Config mConfig; /// Common application configuration

libraries/application/src/morpheus/application/try_catch.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void tryCatch(std::invocable auto f)
2020
{
2121
BOOST_LOG_TRIVIAL(error) << "Exception caught: " << ex.what() << std::endl << st_ns::stacktrace::current();
2222
}
23-
catch(...)
23+
catch (...)
2424
{
2525
BOOST_LOG_TRIVIAL(error) << "Unknown exception!\n" << st_ns::stacktrace::current();
2626
}

libraries/application/tests/po/adapters/boost/log.tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ TEST_CASE_METHOD(BoostLogFixture, "Test parsing of boost log types as program op
4646
auto getLogLevel = [](std::string_view param)
4747
{
4848
Logging logging{};
49-
std::array cliOptions = { "dummyProgram.exe", "--log-level", param.data() };
49+
std::array cliOptions = {"dummyProgram.exe", "--log-level", param.data()};
5050
auto const result = parseProgramOptions(static_cast<int>(cliOptions.size()), cliOptions.data(), HelpDocumentation{}, logging);
5151
REQUIRE(!result);
5252
return logging.logLevel;
@@ -73,7 +73,7 @@ TEST_CASE_METHOD(BoostLogFixture, "Test parsing of boost log types as program op
7373
}
7474
SECTION("Ensure invalid value parse correctly")
7575
{
76-
std::array cliOptions = { "dummyProgram.exe", "--log-level", "invalid"};
76+
std::array cliOptions = {"dummyProgram.exe", "--log-level", "invalid"};
7777
Logging logging;
7878
auto const result = parseProgramOptions(static_cast<int>(cliOptions.size()), cliOptions.data(), HelpDocumentation{}, logging);
7979
REQUIRE(result);

libraries/application/tests/po/adapters/std/filesystem.tests.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
#include <array>
1313
#include <filesystem>
1414
#include <optional>
15-
#include <string_view>
1615
#include <string>
16+
#include <string_view>
1717

1818
namespace morpheus::application::po
1919
{
@@ -39,13 +39,12 @@ TEST_CASE_METHOD(LoggingFixture, "Test parsing of std filesystem path as options
3939
auto getPath = [](std::string_view param)
4040
{
4141
Filesystem filesystem{};
42-
std::array cliOptions = { "dummyProgram.exe", "--path", param.data() };
42+
std::array cliOptions = {"dummyProgram.exe", "--path", param.data()};
4343
auto const result = parseProgramOptions(static_cast<int>(cliOptions.size()), cliOptions.data(), HelpDocumentation{}, filesystem);
4444
REQUIRE(!result);
4545
return filesystem.path;
4646
};
4747

48-
4948
auto const exeLocation = boost::dll::program_location().parent_path();
5049
REQUIRE(getPath(".") == std::filesystem::path("."));
5150
REQUIRE(getPath("..") == std::filesystem::path(".."));
@@ -57,7 +56,6 @@ TEST_CASE_METHOD(LoggingFixture, "Test parsing of std filesystem path as options
5756
// https://github.com/boostorg/program_options/issues/69
5857
REQUIRE(getPath("/home/user/path with spaces/.") == std::filesystem::path("/home/user/path with spaces/."));
5958
}
60-
6159
}
6260

6361
} // namespace morpheus::application::po

libraries/application/tests/po/options.tests.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
#include <cstdint>
1313
#include <iostream>
1414
#include <optional>
15-
#include <string_view>
1615
#include <string>
16+
#include <string_view>
1717
#include <utility>
1818

1919
namespace morpheus::application::po
@@ -87,7 +87,7 @@ TEST_CASE_METHOD(LoggingFixture, "Ensure options parsing of native types works",
8787
}
8888
WHEN("Parsing invalid parameters because the first parameter is not a program name")
8989
{
90-
std::array const cliOptions = { "--first-name", "John", "--surname", "Doe", "--age", "42", "--year-of-birth", "1980", "--alive", "true" };
90+
std::array const cliOptions = {"--first-name", "John", "--surname", "Doe", "--age", "42", "--year-of-birth", "1980", "--alive", "true"};
9191
// RedirectStream captureErrors(std::cerr); Capture error logging
9292
auto const result = parseProgramOptions(static_cast<int>(cliOptions.size()), cliOptions.data(), HelpDocumentation{}, person);
9393
THEN("Expect no error results and valid values extracted")
@@ -97,7 +97,7 @@ TEST_CASE_METHOD(LoggingFixture, "Ensure options parsing of native types works",
9797
}
9898
WHEN("Requesting the help text is displayed")
9999
{
100-
std::array const cliOptions = { "dummyProgram.exe", "-h" };
100+
std::array const cliOptions = {"dummyProgram.exe", "-h"};
101101
auto findOption = captureOutput(cliOptions, HelpDocumentation{}, person);
102102
THEN("Expect output to be successfully prints to screen")
103103
{
@@ -111,9 +111,9 @@ TEST_CASE_METHOD(LoggingFixture, "Ensure options parsing of native types works",
111111
}
112112
WHEN("Requesting the help text is displayed when providing a version")
113113
{
114-
std::array const cliOptions = { "dummyProgram.exe", "-h" };
114+
std::array const cliOptions = {"dummyProgram.exe", "-h"};
115115
HelpDocumentation helpWithVersion;
116-
helpWithVersion.version = Version{ 1, 0, 0 };
116+
helpWithVersion.version = Version{1, 0, 0};
117117
auto findOption = captureOutput(cliOptions, helpWithVersion, person);
118118
THEN("Expect output to be successfully prints to screen with version option")
119119
{
@@ -128,7 +128,7 @@ TEST_CASE_METHOD(LoggingFixture, "Ensure options parsing of native types works",
128128
}
129129
WHEN("Requesting the help text is displayed with multiple options objects")
130130
{
131-
std::array const cliOptions = { "dummyProgram.exe", "-h" };
131+
std::array const cliOptions = {"dummyProgram.exe", "-h"};
132132

133133
struct Extra
134134
{

libraries/core/src/morpheus/core/base/debugging.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ void breakpoint_if_debugging() noexcept
2424
breakpoint();
2525
}
2626

27-
bool is_debugger_present() noexcept { return boost::debug::under_debugger(); }
27+
bool is_debugger_present() noexcept
28+
{
29+
return boost::debug::under_debugger();
30+
}
2831

2932
void debugPrint(std::string_view const message)
3033
{

libraries/core/src/morpheus/core/base/scoped_action.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ class HoldReturnType;
2929
/// Specialisation for entry action with a void return type.
3030
template <>
3131
class HoldReturnType<void>
32-
{
33-
};
32+
{};
3433

3534
/// \class HoldReturnType
3635
/// Holding type to own the return value of an entry action to a scoped action.
@@ -76,7 +75,8 @@ template <std::invocable EntryAction, std::invocable ExitAction>
7675
class [[nodiscard, maybe_unused]] ScopedAction : public detail::HoldReturnType<std::invoke_result_t<EntryAction>>
7776
{
7877
public:
79-
constexpr ScopedAction(EntryAction onEntry, ExitAction onExit) : mAction(std::move(onExit))
78+
constexpr ScopedAction(EntryAction onEntry, ExitAction onExit)
79+
: mAction(std::move(onExit))
8080
{
8181
if constexpr (std::is_same_v<std::invoke_result_t<EntryAction>, void>)
8282
onEntry();

libraries/core/src/morpheus/core/functional/concepts/function.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace morpheus::functional::concepts
1111
/// <a href="https://eel.is/c++draft/func.require">[func.require]</a>, details at
1212
/// <a href="https://en.cppreference.com/w/cpp/named_req/FunctionObject">FunctionObject</a>.
1313
template <typename T, typename... Args>
14-
concept Function = requires(T t){
14+
concept Function = requires(T t) {
1515
requires std::is_object_v<T>;
1616
requires std::invocable<T, Args...>;
1717
};

libraries/core/src/morpheus/core/functional/function_ref.hpp

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -98,49 +98,49 @@ class function_ref<Return(Args...)>
9898
template <class F>
9999
function_ref(F* f) noexcept
100100
requires std::is_function_v<F> and isInvokableWith<F>
101-
: mInvoke([](Storage storage, Args... args) noexcept(isNoexcept) { return invoke(function_ref::get<F>(storage), std::forward<Args>(args)...); })
102-
, mStorage(f)
101+
: mInvoke([](Storage storage, Args... args) noexcept(isNoexcept) { return invoke(function_ref::get<F>(storage), std::forward<Args>(args)...); })
102+
, mStorage(f)
103103
{}
104104

105105
template <auto F>
106106
constexpr function_ref(nontype_t<F>) noexcept
107-
: mInvoke([](Storage, Args... args) noexcept(isNoexcept) { return invoke(F, std::forward<Args>(args)...); })
107+
: mInvoke([](Storage, Args... args) noexcept(isNoexcept) { return invoke(F, std::forward<Args>(args)...); })
108108
{}
109109

110110
template <auto F, class T>
111111
constexpr function_ref(nontype_t<F>, T& object) noexcept
112-
requires isInvokableWith<decltype(F), T&>
113-
: mInvoke(
114-
[](Storage storage, Args... args) noexcept(isNoexcept) -> Return
115-
{
116-
auto& objectStorage = *function_ref::get<constness<T>>(storage);
117-
return invoke(F, objectStorage, std::forward<Args>(args)...);
118-
})
119-
, mStorage(std::addressof(object))
112+
requires isInvokableWith<decltype(F), T&>
113+
: mInvoke(
114+
[](Storage storage, Args... args) noexcept(isNoexcept) -> Return
115+
{
116+
auto& objectStorage = *function_ref::get<constness<T>>(storage);
117+
return invoke(F, objectStorage, std::forward<Args>(args)...);
118+
})
119+
, mStorage(std::addressof(object))
120120
{}
121121

122122
template <auto F, class T>
123123
constexpr function_ref(nontype_t<F>, constness<T> const* object) noexcept
124-
requires isInvokableWith<decltype(F), constness<T> const*>
125-
: mInvoke(
126-
[](Storage storage, Args... args) noexcept(isNoexcept) -> Return
127-
{
128-
constness<T>& objectStorage = *function_ref::get<T>(storage);
129-
return invoke(F, objectStorage, std::forward<Args>(args)...);
130-
})
131-
, mStorage(std::addressof(object))
124+
requires isInvokableWith<decltype(F), constness<T> const*>
125+
: mInvoke(
126+
[](Storage storage, Args... args) noexcept(isNoexcept) -> Return
127+
{
128+
constness<T>& objectStorage = *function_ref::get<T>(storage);
129+
return invoke(F, objectStorage, std::forward<Args>(args)...);
130+
})
131+
, mStorage(std::addressof(object))
132132
{}
133133

134134
template <class F, class T = std::remove_reference_t<F>>
135135
constexpr function_ref(F&& f) noexcept
136-
requires(not std::is_same_v<F, function_ref> and not std::is_member_pointer_v<F> and isInvokableWith<F, constness<T>>)
137-
: mInvoke(
138-
[](Storage storage, Args... args) noexcept(isNoexcept) -> Return
139-
{
140-
constness<T>& objectStorage = *function_ref::get<T>(storage);
141-
return invoke(objectStorage, std::forward<Args>(args)...);
142-
})
143-
, mStorage(std::addressof(f))
136+
requires(not std::is_same_v<F, function_ref> and not std::is_member_pointer_v<F> and isInvokableWith<F, constness<T>>)
137+
: mInvoke(
138+
[](Storage storage, Args... args) noexcept(isNoexcept) -> Return
139+
{
140+
constness<T>& objectStorage = *function_ref::get<T>(storage);
141+
return invoke(objectStorage, std::forward<Args>(args)...);
142+
})
143+
, mStorage(std::addressof(f))
144144
{}
145145

146146
template <typename F, class T = std::remove_reference_t<F>>
@@ -167,17 +167,20 @@ class function_ref<Return(Args...)>
167167

168168
template <class T>
169169
requires std::is_object_v<T>
170-
constexpr explicit Storage(T* t) noexcept : p(t)
170+
constexpr explicit Storage(T* t) noexcept
171+
: p(t)
171172
{}
172173

173174
template <class T>
174175
requires std::is_object_v<T>
175-
constexpr explicit Storage(T const* t) noexcept : cp(t)
176+
constexpr explicit Storage(T const* t) noexcept
177+
: cp(t)
176178
{}
177179

178180
template <class F>
179181
requires std::is_function_v<F>
180-
constexpr explicit Storage(F* f) noexcept : fp(f)
182+
constexpr explicit Storage(F* f) noexcept
183+
: fp(f)
181184
{}
182185
};
183186

0 commit comments

Comments
 (0)