Skip to content

Commit

Permalink
Merge branch 'sdf11' into jennuine/10_to_11
Browse files Browse the repository at this point in the history
Signed-off-by: Jenn Nguyen <[email protected]>
  • Loading branch information
jennuine committed Jul 13, 2021
2 parents 935543c + cb6cd03 commit c8ee0ab
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 24 deletions.
26 changes: 2 additions & 24 deletions include/sdf/Error.hh
Original file line number Diff line number Diff line change
Expand Up @@ -221,30 +221,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)
{
std::string pathInfo = "";

if (_err.XmlPath().has_value())
pathInfo += _err.XmlPath().value();

if (_err.FilePath().has_value())
pathInfo += ":" + _err.FilePath().value();

if (_err.LineNumber().has_value())
pathInfo += ":L" + std::to_string(_err.LineNumber().value());

if (!pathInfo.empty())
pathInfo = "[" + pathInfo + "]: ";

_out << "Error Code "
<< static_cast<std::underlying_type<sdf::ErrorCode>::type>(
_err.Code()) << ": "
<< pathInfo
<< "Msg: " << _err.Message();
return _out;
}
public: friend SDFORMAT_VISIBLE std::ostream &operator<<(
std::ostream &_out, const sdf::Error &_err);

/// \brief Private data pointer.
IGN_UTILS_IMPL_PTR(dataPtr)
Expand Down
33 changes: 33 additions & 0 deletions src/Error.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,36 @@ bool Error::operator==(const bool _value) const
return ((this->dataPtr->code != ErrorCode::NONE) && _value) ||
((this->dataPtr->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)
{
std::string pathInfo = "";

if (_err.XmlPath().has_value())
pathInfo += _err.XmlPath().value();

if (_err.FilePath().has_value())
pathInfo += ":" + _err.FilePath().value();

if (_err.LineNumber().has_value())
pathInfo += ":L" + std::to_string(_err.LineNumber().value());

if (!pathInfo.empty())
pathInfo = "[" + pathInfo + "]: ";

_out << "Error Code "
<< static_cast<std::underlying_type<sdf::ErrorCode>::type>(
_err.Code()) << ": "
<< pathInfo
<< "Msg: " << _err.Message();
return _out;
}
}
}

0 comments on commit c8ee0ab

Please sign in to comment.