forked from eclipse-iceoryx/iceoryx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
iox-eclipse-iceoryx#1755 Distinct overloads for arithmetic types for …
…'LogStream'
- Loading branch information
1 parent
c5d1340
commit cc844be
Showing
3 changed files
with
278 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
// Copyright (c) 2019 - 2021 by Robert Bosch GmbH. All rights reserved. | ||
// Copyright (c) 2021 - 2022 by Apex.AI Inc. All rights reserved. | ||
// Copyright (c) 2023 by Mathias Kraus <[email protected]>. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
|
@@ -108,45 +109,125 @@ inline LogStream& LogStream::self() noexcept | |
return *this; | ||
} | ||
|
||
// AXIVION Next Construct AutosarC++19_03-A3.9.1 : See at declaration in header | ||
// AXIVION Next Construct AutosarC++19_03-M5.17.1 : This is not used as shift operator but as stream operator and does | ||
// AXIVION DISABLE STYLE AutosarC++19_03-M5.17.1 : This is not used as shift operator but as stream operator and does | ||
// not require to implement '<<=' | ||
|
||
// AXIVION Next Construct AutosarC++19_03-A3.9.1 : See at declaration in header | ||
inline LogStream& LogStream::operator<<(const char* cstr) noexcept | ||
{ | ||
m_logger.logString(cstr); | ||
m_isFlushed = false; | ||
return *this; | ||
} | ||
|
||
// AXIVION Next Construct AutosarC++19_03-M5.17.1 : This is not used as shift operator but as stream operator and does | ||
// not require to implement '<<=' | ||
inline LogStream& LogStream::operator<<(const std::string& str) noexcept | ||
{ | ||
m_logger.logString(str.c_str()); | ||
m_isFlushed = false; | ||
return *this; | ||
} | ||
|
||
// AXIVION Next Construct AutosarC++19_03-M5.17.1 : This is not used as shift operator but as stream operator and does | ||
// not require to implement '<<=' | ||
inline LogStream& LogStream::operator<<(const bool val) noexcept | ||
{ | ||
m_logger.logBool(val); | ||
return *this; | ||
} | ||
|
||
// AXIVION Next Construct AutosarC++19_03-M5.17.1 : This is not used as shift operator but as stream operator and does | ||
// not require to implement '<<=' | ||
template <typename T, typename std::enable_if_t<std::is_arithmetic<T>::value, bool>> | ||
inline LogStream& LogStream::operator<<(const T val) noexcept | ||
// AXIVION DISABLE STYLE AutosarC++19_03-A3.9.1 : See at declaration in header | ||
|
||
inline LogStream& LogStream::operator<<(const signed char val) noexcept | ||
{ | ||
m_logger.logDec(val); | ||
m_isFlushed = false; | ||
return *this; | ||
} | ||
|
||
// AXIVION Next Construct AutosarC++19_03-M5.17.1 : This is not used as shift operator but as stream operator and does | ||
// not require to implement '<<=' | ||
inline LogStream& LogStream::operator<<(const unsigned char val) noexcept | ||
{ | ||
m_logger.logDec(val); | ||
m_isFlushed = false; | ||
return *this; | ||
} | ||
|
||
inline LogStream& LogStream::operator<<(const short val) noexcept | ||
{ | ||
m_logger.logDec(val); | ||
m_isFlushed = false; | ||
return *this; | ||
} | ||
|
||
inline LogStream& LogStream::operator<<(const unsigned short val) noexcept | ||
{ | ||
m_logger.logDec(val); | ||
m_isFlushed = false; | ||
return *this; | ||
} | ||
|
||
inline LogStream& LogStream::operator<<(const int val) noexcept | ||
{ | ||
m_logger.logDec(val); | ||
m_isFlushed = false; | ||
return *this; | ||
} | ||
|
||
inline LogStream& LogStream::operator<<(const unsigned int val) noexcept | ||
{ | ||
m_logger.logDec(val); | ||
m_isFlushed = false; | ||
return *this; | ||
} | ||
|
||
inline LogStream& LogStream::operator<<(const long val) noexcept | ||
{ | ||
m_logger.logDec(val); | ||
m_isFlushed = false; | ||
return *this; | ||
} | ||
|
||
inline LogStream& LogStream::operator<<(const unsigned long val) noexcept | ||
{ | ||
m_logger.logDec(val); | ||
m_isFlushed = false; | ||
return *this; | ||
} | ||
|
||
inline LogStream& LogStream::operator<<(const long long val) noexcept | ||
{ | ||
m_logger.logDec(val); | ||
m_isFlushed = false; | ||
return *this; | ||
} | ||
|
||
inline LogStream& LogStream::operator<<(const unsigned long long val) noexcept | ||
{ | ||
m_logger.logDec(val); | ||
m_isFlushed = false; | ||
return *this; | ||
} | ||
|
||
inline LogStream& LogStream::operator<<(const float val) noexcept | ||
{ | ||
m_logger.logDec(val); | ||
m_isFlushed = false; | ||
return *this; | ||
} | ||
|
||
inline LogStream& LogStream::operator<<(const double val) noexcept | ||
{ | ||
m_logger.logDec(val); | ||
m_isFlushed = false; | ||
return *this; | ||
} | ||
|
||
inline LogStream& LogStream::operator<<(const long double val) noexcept | ||
{ | ||
m_logger.logDec(val); | ||
m_isFlushed = false; | ||
return *this; | ||
} | ||
|
||
// AXIVION ENABLE STYLE AutosarC++19_03-A3.9.1 | ||
|
||
template <typename T, typename std::enable_if_t<std::is_integral<T>::value, bool>> | ||
inline LogStream& LogStream::operator<<(const LogHex<T> val) noexcept | ||
{ | ||
|
@@ -156,8 +237,6 @@ inline LogStream& LogStream::operator<<(const LogHex<T> val) noexcept | |
return *this; | ||
} | ||
|
||
// AXIVION Next Construct AutosarC++19_03-M5.17.1 : This is not used as shift operator but as stream operator and does | ||
// not require to implement '<<=' | ||
template <typename T, typename std::enable_if_t<std::is_floating_point<T>::value, bool>> | ||
inline LogStream& LogStream::operator<<(const LogHex<T> val) noexcept | ||
{ | ||
|
@@ -166,17 +245,13 @@ inline LogStream& LogStream::operator<<(const LogHex<T> val) noexcept | |
return *this; | ||
} | ||
|
||
// AXIVION Next Construct AutosarC++19_03-M5.17.1 : This is not used as shift operator but as stream operator and does | ||
// not require to implement '<<=' | ||
inline LogStream& LogStream::operator<<(const LogHex<const void* const> val) noexcept | ||
{ | ||
m_logger.logHex(val.m_value); | ||
m_isFlushed = false; | ||
return *this; | ||
} | ||
|
||
// AXIVION Next Construct AutosarC++19_03-M5.17.1 : This is not used as shift operator but as stream operator and does | ||
// not require to implement '<<=' | ||
template <typename T, typename std::enable_if_t<std::is_integral<T>::value, bool>> | ||
inline LogStream& LogStream::operator<<(const LogOct<T> val) noexcept | ||
{ | ||
|
@@ -186,16 +261,12 @@ inline LogStream& LogStream::operator<<(const LogOct<T> val) noexcept | |
return *this; | ||
} | ||
|
||
// AXIVION Next Construct AutosarC++19_03-M5.17.1 : This is not used as shift operator but as stream operator and does | ||
// not require to implement '<<=' | ||
template <typename Callable, typename> | ||
inline LogStream& LogStream::operator<<(const Callable& c) noexcept | ||
{ | ||
return c(*this); | ||
} | ||
|
||
// AXIVION Next Construct AutosarC++19_03-M5.17.1 : This is not used as shift operator but as stream operator and does | ||
// not require to implement '<<=' | ||
inline LogStream& LogStream::operator<<(const LogLevel value) noexcept | ||
{ | ||
m_logger.logString(asStringLiteral(value)); | ||
|
@@ -214,15 +285,15 @@ inline LogStreamOff& LogStreamOff::self() noexcept | |
return *this; | ||
} | ||
|
||
// AXIVION Next Construct AutosarC++19_03-M5.17.1 : This is not used as shift operator but as stream operator and does | ||
// not require to implement '<<=' | ||
template <typename T> | ||
inline LogStreamOff& LogStreamOff::operator<<(T&&) noexcept | ||
{ | ||
return *this; | ||
} | ||
} // namespace internal | ||
|
||
// AXIVION ENABLE STYLE AutosarC++19_03-M5.17.1 | ||
|
||
} // namespace log | ||
} // namespace iox | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
// Copyright (c) 2019 - 2021 by Robert Bosch GmbH. All rights reserved. | ||
// Copyright (c) 2021 - 2022 by Apex.AI Inc. All rights reserved. | ||
// Copyright (c) 2023 by Mathias Kraus <[email protected]>. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
|
@@ -156,17 +157,79 @@ class LogStream | |
/// and avoid the std::string dependency; alternatively this could be implemented as free function | ||
LogStream& operator<<(const std::string& str) noexcept; | ||
|
||
/// @brief Logging support for boolean | ||
/// @param[in] val is the boolean to log | ||
// AXIVION DISABLE STYLE AutosarC++19_03-A3.9.1 : Basic numeric types are used in order to cover als basic numeric types, independent of the type alias | ||
|
||
/// @brief Logging support for 'boolean' | ||
/// @param[in] val is the 'boolean' to log | ||
/// @return a reference to the LogStream instance | ||
LogStream& operator<<(const bool val) noexcept; | ||
|
||
/// @brief Logging support for arithmetic numbers in decimal format | ||
/// @tparam[in] T is the arithmetic data type of the value to log | ||
/// @param[in] val is the number to log | ||
/// @brief Logging support for 'signed char' | ||
/// @param[in] val is the 'signed char' to log | ||
/// @return a reference to the LogStream instance | ||
LogStream& operator<<(const signed char val) noexcept; | ||
|
||
/// @brief Logging support for 'unsigned char' | ||
/// @param[in] val is the 'unsigned char' to log | ||
/// @return a reference to the LogStream instance | ||
LogStream& operator<<(const unsigned char val) noexcept; | ||
|
||
/// @brief Logging support for 'short' | ||
/// @param[in] val is the 'short' to log | ||
/// @return a reference to the LogStream instance | ||
LogStream& operator<<(const short val) noexcept; | ||
|
||
/// @brief Logging support for 'unsigned shor' | ||
/// @param[in] val is the 'unsigned shor' to log | ||
/// @return a reference to the LogStream instance | ||
LogStream& operator<<(const unsigned short val) noexcept; | ||
|
||
/// @brief Logging support for 'int' | ||
/// @param[in] val is the 'int' to log | ||
/// @return a reference to the LogStream instance | ||
LogStream& operator<<(const int val) noexcept; | ||
|
||
/// @brief Logging support for 'unsigned int' | ||
/// @param[in] val is the 'unsigned int' to log | ||
/// @return a reference to the LogStream instance | ||
LogStream& operator<<(const unsigned int val) noexcept; | ||
|
||
/// @brief Logging support for 'long' | ||
/// @param[in] val is the 'long' to log | ||
/// @return a reference to the LogStream instance | ||
template <typename T, typename std::enable_if_t<std::is_arithmetic<T>::value, bool> = 0> | ||
LogStream& operator<<(const T val) noexcept; | ||
LogStream& operator<<(const long val) noexcept; | ||
|
||
/// @brief Logging support for 'unsigned long' | ||
/// @param[in] val is the 'unsigned long' to log | ||
/// @return a reference to the LogStream instance | ||
LogStream& operator<<(const unsigned long val) noexcept; | ||
|
||
/// @brief Logging support for 'long long' | ||
/// @param[in] val is the 'long long' to log | ||
/// @return a reference to the LogStream instance | ||
LogStream& operator<<(const long long val) noexcept; | ||
|
||
/// @brief Logging support for 'unsigned long long' | ||
/// @param[in] val is the 'unsigned long long' to log | ||
/// @return a reference to the LogStream instance | ||
LogStream& operator<<(const unsigned long long val) noexcept; | ||
|
||
/// @brief Logging support for 'float' | ||
/// @param[in] val is the 'float' to log | ||
/// @return a reference to the LogStream instance | ||
LogStream& operator<<(const float val) noexcept; | ||
|
||
/// @brief Logging support for 'double' | ||
/// @param[in] val is the 'double' to log | ||
/// @return a reference to the LogStream instance | ||
LogStream& operator<<(const double val) noexcept; | ||
|
||
/// @brief Logging support for 'long double' | ||
/// @param[in] val is the 'long double' to log | ||
/// @return a reference to the LogStream instance | ||
LogStream& operator<<(const long double val) noexcept; | ||
|
||
// AXIVION ENABLE STYLE AutosarC++19_03-A3.9.1 | ||
|
||
/// @brief Logging support for integral numbers in hexadecimal format | ||
/// @tparam[in] T is the integral data type of the value to log | ||
|
Oops, something went wrong.