aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/utility
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2023-10-29 15:11:10 +0100
committer hop311 <hop3114@gmail.com>2023-10-29 21:08:08 +0100
commit1b5e43fa7750cc4025d32f18390593cbce3ba842 (patch)
treed37fcb69766ec029ea4e3e2816c419f9d7e05f7c /src/openvic-simulation/utility
parent164264b047921dbe1567d2af183e1cffb200a8cb (diff)
Clang-format formatting (with manual cleanup)
Diffstat (limited to 'src/openvic-simulation/utility')
-rw-r--r--src/openvic-simulation/utility/BMP.cpp19
-rw-r--r--src/openvic-simulation/utility/ConstexprIntToStr.hpp6
-rw-r--r--src/openvic-simulation/utility/Logger.hpp9
3 files changed, 20 insertions, 14 deletions
diff --git a/src/openvic-simulation/utility/BMP.cpp b/src/openvic-simulation/utility/BMP.cpp
index cdd8ead..d4e7cf7 100644
--- a/src/openvic-simulation/utility/BMP.cpp
+++ b/src/openvic-simulation/utility/BMP.cpp
@@ -69,8 +69,10 @@ bool BMP::read_header() {
// Validate sizes and dimensions
// TODO - image_size_bytes can be 0 for non-compressed BMPs
if (header.file_size != header.offset + header.image_size_bytes) {
- Logger::error("Invalid BMP memory sizes: file size = ", header.file_size, " != ", header.offset + header.image_size_bytes,
- " = ", header.offset, " + ", header.image_size_bytes, " = image data offset + image data size");
+ Logger::error(
+ "Invalid BMP memory sizes: file size = ", header.file_size, " != ", header.offset + header.image_size_bytes, " = ",
+ header.offset, " + ", header.image_size_bytes, " = image data offset + image data size"
+ );
header_validated = false;
}
// TODO - support negative widths (i.e. horizontal flip)
@@ -91,24 +93,25 @@ bool BMP::read_header() {
#define STR(x) #x
static const std::set<uint16_t> BITS_PER_PIXEL { VALID_BITS_PER_PIXEL };
if (!BITS_PER_PIXEL.contains(header.bits_per_pixel)) {
- Logger::error("Invalid BMP bits per pixel: ", header.bits_per_pixel,
- " (must be one of " STR(VALID_BITS_PER_PIXEL) ")");
+ Logger::error("Invalid BMP bits per pixel: ", header.bits_per_pixel, " (must be one of " STR(VALID_BITS_PER_PIXEL) ")");
header_validated = false;
}
#undef VALID_BITS_PER_PIXEL
#undef STR
static constexpr uint16_t PALETTE_BITS_PER_PIXEL_LIMIT = 8;
if (header.num_colours != 0 && header.bits_per_pixel > PALETTE_BITS_PER_PIXEL_LIMIT) {
- Logger::error("Invalid BMP palette size: ", header.num_colours,
- " (should be 0 as bits per pixel is ", header.bits_per_pixel, " > 8)");
+ Logger::error(
+ "Invalid BMP palette size: ", header.num_colours, " (should be 0 as bits per pixel is ", header.bits_per_pixel,
+ " > 8)"
+ );
header_validated = false;
}
// TODO - validate important_colours
palette_size = header.bits_per_pixel > PALETTE_BITS_PER_PIXEL_LIMIT ? 0
// Use header.num_colours if it's greater than 0 and at most 1 << header.bits_per_pixel
- : 0 < header.num_colours && header.num_colours - 1 >> header.bits_per_pixel == 0 ? header.num_colours
- : 1 << header.bits_per_pixel;
+ : (0 < header.num_colours && header.num_colours - 1 >> header.bits_per_pixel == 0
+ ? header.num_colours : 1 << header.bits_per_pixel);
const uint32_t expected_offset = palette_size * PALETTE_COLOUR_SIZE + sizeof(header);
if (header.offset != expected_offset) {
diff --git a/src/openvic-simulation/utility/ConstexprIntToStr.hpp b/src/openvic-simulation/utility/ConstexprIntToStr.hpp
index e383365..e346ebe 100644
--- a/src/openvic-simulation/utility/ConstexprIntToStr.hpp
+++ b/src/openvic-simulation/utility/ConstexprIntToStr.hpp
@@ -33,7 +33,9 @@ namespace OpenVic::ConstexprIntToStr {
constexpr std::size_t next_value = value / 10;
if constexpr (next_value != 0) {
- return append_sequence(integer_to_string_sequence<next_value>(), std::integer_sequence<char, digits()[remainder]> {});
+ return append_sequence(
+ integer_to_string_sequence<next_value>(), std::integer_sequence<char, digits()[remainder]> {}
+ );
} else {
return std::integer_sequence<char, digits()[remainder]> {};
}
@@ -53,4 +55,4 @@ namespace OpenVic::ConstexprIntToStr {
constexpr auto make_itosv_array() {
return generate_itosv_array(std::make_integer_sequence<std::size_t, N>());
}
-} \ No newline at end of file
+}
diff --git a/src/openvic-simulation/utility/Logger.hpp b/src/openvic-simulation/utility/Logger.hpp
index b2395ac..a1c599d 100644
--- a/src/openvic-simulation/utility/Logger.hpp
+++ b/src/openvic-simulation/utility/Logger.hpp
@@ -23,8 +23,9 @@ namespace OpenVic {
source_location(std::string f, int l, std::string n) : _file(f), _line(l), _function(n) {}
public:
- static source_location current(std::string f = __builtin_FILE(), int l = __builtin_LINE(),
- std::string n = __builtin_FUNCTION()) {
+ static source_location current(
+ std::string f = __builtin_FILE(), int l = __builtin_LINE(), std::string n = __builtin_FUNCTION()
+ ) {
return source_location(f, l, n);
}
@@ -83,7 +84,7 @@ namespace OpenVic {
#define LOG_FUNC(name) \
private: \
- static inline log_channel_t name##_channel{}; \
+ static inline log_channel_t name##_channel {}; \
public: \
static inline void set_##name##_func(log_func_t log_func) { \
name##_channel.func = log_func; \
@@ -91,7 +92,7 @@ namespace OpenVic {
template<typename... Ts> \
struct name { \
name(Ts&&... ts, source_location const& location = source_location::current()) { \
- log<Ts...>{ name##_channel, std::forward<Ts>(ts)..., location }; \
+ log<Ts...> { name##_channel, std::forward<Ts>(ts)..., location }; \
} \
}; \
template<typename... Ts> \