Skip to content

Commit

Permalink
Error: move << operator from .hh to .cc file (#625)
Browse files Browse the repository at this point in the history
* Error: move << operator from .hh to .cc file

Signed-off-by: Steven Peters <scpeters@openrobotics.org>

* Fix visibility

Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>

Co-authored-by: Addisu Z. Taddese <addisu@openrobotics.org>
  • Loading branch information
scpeters and azeey authored Jul 14, 2021
1 parent 8a5cd48 commit 66a8c21
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
10 changes: 2 additions & 8 deletions include/sdf/Error.hh
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,8 @@ namespace sdf
/// \param[in,out] _out The output stream.
/// \param[in] _err The error to output.
/// \return Reference to the given output stream
public: friend std::ostream &operator<<(std::ostream &_out,
const sdf::Error &_err)
{
_out << "Error Code "
<< static_cast<std::underlying_type<sdf::ErrorCode>::type>(_err.Code())
<< " Msg: " << _err.Message();
return _out;
}
public: friend SDFORMAT_VISIBLE std::ostream &operator<<(
std::ostream &_out, const sdf::Error &_err);

/// \brief The error code value.
private: ErrorCode code = ErrorCode::NONE;
Expand Down
17 changes: 17 additions & 0 deletions src/Error.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,20 @@ bool Error::operator==(const bool _value) const
return ((this->code != ErrorCode::NONE) && _value) ||
((this->code == ErrorCode::NONE) && !_value);
}

namespace sdf
{
// Inline bracket to help doxygen filtering.
inline namespace SDF_VERSION_NAMESPACE {

/////////////////////////////////////////////////
// cppcheck-suppress unusedFunction
std::ostream &operator<<(std::ostream &_out, const sdf::Error &_err)
{
_out << "Error Code "
<< static_cast<std::underlying_type<sdf::ErrorCode>::type>(_err.Code())
<< " Msg: " << _err.Message();
return _out;
}
}
}

0 comments on commit 66a8c21

Please sign in to comment.