-
Notifications
You must be signed in to change notification settings - Fork 391
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2022 from elBoberido/iox-1755-distinct-overloads-…
…for-arithmetic-types-for-logstream iox-#1755 Distinct overloads for arithmetic types for logstream
- Loading branch information
Showing
5 changed files
with
348 additions
and
43 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
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,132 @@ 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 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 signed char val) noexcept | ||
{ | ||
m_logger.logDec(val); | ||
m_isFlushed = false; | ||
return *this; | ||
} | ||
|
||
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 +244,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 +252,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 +268,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 +292,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
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,84 @@ 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 | ||
/// @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 | ||
// 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 'char' | ||
/// @param[in] val is the 'char' to log | ||
/// @return a reference to the LogStream instance | ||
LogStream& operator<<(const char val) noexcept; | ||
|
||
/// @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 | ||
template <typename T, typename std::enable_if_t<std::is_arithmetic<T>::value, bool> = 0> | ||
LogStream& operator<<(const T val) noexcept; | ||
LogStream& operator<<(const short val) noexcept; | ||
|
||
/// @brief Logging support for 'unsigned short' | ||
/// @param[in] val is the 'unsigned short' 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 | ||
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.