From bdac8bda586f373f9ab18eaf928ccb0aad7aef33 Mon Sep 17 00:00:00 2001 From: Martin Stump <martin.stump@mercedes-benz.com> Date: Wed, 15 Mar 2023 14:01:49 +0100 Subject: [PATCH] Replace pragma once with include guards Signed-off-by: Martin Stump <martin.stump@mercedes-benz.com> --- include/MantleAPI/Common/i_logger.h | 5 ++++- include/MantleAPI/Common/log_utils.h | 10 +++++++--- test/MantleAPI/Common/mock_logger.h | 7 +++++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/include/MantleAPI/Common/i_logger.h b/include/MantleAPI/Common/i_logger.h index 37d8efa..7aac562 100644 --- a/include/MantleAPI/Common/i_logger.h +++ b/include/MantleAPI/Common/i_logger.h @@ -8,7 +8,8 @@ * SPDX-License-Identifier: EPL-2.0 *******************************************************************************/ -#pragma once +#ifndef MANTLEAPI_COMMON_I_LOGGER_H +#define MANTLEAPI_COMMON_I_LOGGER_H #include <string_view> @@ -64,3 +65,5 @@ public: }; } // namespace mantle_api + +#endif // MANTLEAPI_COMMON_I_LOGGER_H diff --git a/include/MantleAPI/Common/log_utils.h b/include/MantleAPI/Common/log_utils.h index 7d00569..8431423 100644 --- a/include/MantleAPI/Common/log_utils.h +++ b/include/MantleAPI/Common/log_utils.h @@ -8,11 +8,13 @@ * SPDX-License-Identifier: EPL-2.0 *******************************************************************************/ -#pragma once +#ifndef MANTLEAPI_COMMON_LOG_UTILS_H +#define MANTLEAPI_COMMON_LOG_UTILS_H #include <MantleAPI/Common/i_logger.h> #include <array> +#include <ostream> #include <string_view> namespace mantle_api @@ -23,13 +25,13 @@ namespace log_utils static inline constexpr auto kLogLevelNames = std::array<std::string_view, 6>{"Trace", "Debug", "Info", "Warning", "Error", "Critical"}; -[[nodiscard]] inline constexpr auto ToStringView(LogLevel level) noexcept -> std::string_view +[[nodiscard]] constexpr auto ToStringView(LogLevel level) noexcept -> std::string_view { return (level >= LogLevel::kTrace && level <= LogLevel::kCritical) ? kLogLevelNames.at(static_cast<size_t>(level)) : "Log level out of range"; } template <LogLevel Level> -[[nodiscard]] inline constexpr auto ToStringView() noexcept -> std::string_view +[[nodiscard]] constexpr auto ToStringView() noexcept -> std::string_view { static_assert(Level >= LogLevel::kTrace && Level <= LogLevel::kCritical, "Log level out of range"); return ToStringView(Level); @@ -44,3 +46,5 @@ inline auto operator<<(std::ostream& os, mantle_api::LogLevel level) noexcept -> } } // namespace mantle_api + +#endif // MANTLEAPI_COMMON_LOG_UTILS_H diff --git a/test/MantleAPI/Common/mock_logger.h b/test/MantleAPI/Common/mock_logger.h index 546489e..958a31f 100644 --- a/test/MantleAPI/Common/mock_logger.h +++ b/test/MantleAPI/Common/mock_logger.h @@ -8,12 +8,13 @@ * SPDX-License-Identifier: EPL-2.0 *******************************************************************************/ -#pragma once +#ifndef MANTLEAPI_COMMON_MOCK_LOGGER_H +#define MANTLEAPI_COMMON_MOCK_LOGGER_H #include <gmock/gmock.h> #include <iomanip> -#include <iostream> +#include <ostream> #include "MantleAPI/Common/i_logger.h" #include "MantleAPI/Common/log_utils.h" @@ -41,3 +42,5 @@ public: }; } // namespace mantle_api + +#endif // MANTLEAPI_COMMON_MOCK_LOGGER_H -- GitLab