Skip to content

Commit

Permalink
grouping in and out parameters
Browse files Browse the repository at this point in the history
Signed-off-by: Marco A. Gutierrez <marco@openrobotics.org>
  • Loading branch information
Marco A. Gutierrez committed Sep 9, 2022
1 parent dd4e25f commit 5612619
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 96 deletions.
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ if (BUILD_TESTING)
target_sources(UNIT_Converter_TEST PRIVATE
Converter.cc
EmbeddedSdf.cc
XmlUtils.cc
Utils.cc)
Utils.cc
XmlUtils.cc)
endif()

if (TARGET UNIT_FrameSemantics_TEST)
Expand Down
42 changes: 21 additions & 21 deletions src/Converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ void UpdatePose(tinyxml2::XMLElement *_elem,
}

/////////////////////////////////////////////////
bool Converter::Convert(tinyxml2::XMLDocument *_doc,
bool Converter::Convert(sdf::Errors &_errors,
tinyxml2::XMLDocument *_doc,
const std::string &_toVersion,
sdf::Errors &_errors,
const ParserConfig &_config,
bool _quiet)
{
Expand Down Expand Up @@ -168,7 +168,7 @@ bool Converter::Convert(tinyxml2::XMLDocument *_doc,
_errors.push_back({ErrorCode::CONVERSION_ERROR, ss.str()});
return false;
}
ConvertImpl(elem, xmlDoc.FirstChildElement("convert"), _errors, _config);
ConvertImpl(elem, xmlDoc.FirstChildElement("convert"), _config, _errors);
}

// Check that we actually converted to the desired final version.
Expand All @@ -187,9 +187,9 @@ bool Converter::Convert(tinyxml2::XMLDocument *_doc,
}

/////////////////////////////////////////////////
void Converter::Convert(tinyxml2::XMLDocument *_doc,
void Converter::Convert(sdf::Errors &_errors,
tinyxml2::XMLDocument *_doc,
tinyxml2::XMLDocument *_convertDoc,
sdf::Errors &_errors,
const ParserConfig &_config)
{
if (_doc == NULL)
Expand All @@ -204,14 +204,14 @@ void Converter::Convert(tinyxml2::XMLDocument *_doc,
}

ConvertImpl(_doc->FirstChildElement(), _convertDoc->FirstChildElement(),
_errors, _config);
_config, _errors);
}

/////////////////////////////////////////////////
void Converter::ConvertDescendantsImpl(tinyxml2::XMLElement *_e,
tinyxml2::XMLElement *_c,
sdf::Errors &_errors,
const ParserConfig &_config)
const ParserConfig &_config,
sdf::Errors &_errors)
{
if (!_c->Attribute("descendant_name"))
{
Expand All @@ -233,18 +233,18 @@ void Converter::ConvertDescendantsImpl(tinyxml2::XMLElement *_e,
{
if (strcmp(e->Name(), _c->Attribute("descendant_name")) == 0)
{
ConvertImpl(e, _c, _errors, _config);
ConvertImpl(e, _c, _config, _errors);
}
ConvertDescendantsImpl(e, _c, _errors, _config);
ConvertDescendantsImpl(e, _c, _config, _errors);
e = e->NextSiblingElement();
}
}

/////////////////////////////////////////////////
void Converter::ConvertImpl(tinyxml2::XMLElement *_elem,
tinyxml2::XMLElement *_convert,
sdf::Errors &_errors,
const ParserConfig &_config)
const ParserConfig &_config,
sdf::Errors &_errors)
{
if (_elem == NULL)
{
Expand All @@ -257,7 +257,7 @@ void Converter::ConvertImpl(tinyxml2::XMLElement *_elem,
return;
}

CheckDeprecation(_elem, _convert, _errors, _config);
CheckDeprecation(_elem, _convert, _config, _errors);

for (auto *convertElem = _convert->FirstChildElement("convert");
convertElem; convertElem = convertElem->NextSiblingElement("convert"))
Expand All @@ -268,13 +268,13 @@ void Converter::ConvertImpl(tinyxml2::XMLElement *_elem,
convertElem->Attribute("name"));
while (elem)
{
ConvertImpl(elem, convertElem, _errors, _config);
ConvertImpl(elem, convertElem, _config, _errors);
elem = elem->NextSiblingElement(convertElem->Attribute("name"));
}
}
if (convertElem->Attribute("descendant_name"))
{
ConvertDescendantsImpl(_elem, convertElem, _errors, _config);
ConvertDescendantsImpl(_elem, convertElem, _config, _errors);
}
}

Expand Down Expand Up @@ -305,11 +305,11 @@ void Converter::ConvertImpl(tinyxml2::XMLElement *_elem,
}
else if (name == "remove")
{
Remove(_elem, childElem, _errors);
Remove(_errors, _elem, childElem);
}
else if (name == "remove_empty")
{
Remove(_elem, childElem, _errors, true);
Remove(_errors, _elem, childElem, true);
}
else if (name == "unflatten")
{
Expand Down Expand Up @@ -747,9 +747,9 @@ void Converter::Add(tinyxml2::XMLElement *_elem,
}

/////////////////////////////////////////////////
void Converter::Remove(tinyxml2::XMLElement *_elem,
void Converter::Remove(sdf::Errors &_errors,
tinyxml2::XMLElement *_elem,
tinyxml2::XMLElement *_removeElem,
sdf::Errors &_errors,
bool _removeOnlyEmpty)
{
if (_elem == NULL)
Expand Down Expand Up @@ -1207,8 +1207,8 @@ const char *Converter::GetValue(const char *_valueElem, const char *_valueAttr,
/////////////////////////////////////////////////
void Converter::CheckDeprecation(tinyxml2::XMLElement *_elem,
tinyxml2::XMLElement *_convert,
sdf::Errors &_errors,
const ParserConfig &_config)
const ParserConfig &_config,
sdf::Errors &_errors)
{
// Process deprecated elements
for (auto *deprecatedElem = _convert->FirstChildElement("deprecated");
Expand Down
36 changes: 18 additions & 18 deletions src/Converter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -36,51 +36,51 @@ namespace sdf
class Converter
{
/// \brief Convert SDF to the specified version.
/// \param[out] _errors Vector of errors.
/// \param[in] _doc SDF xml doc
/// \param[in] _toVersion Version number in string format.
/// \param[out] _errors Vector of errors.
/// \param[in] _config Parser configuration.
/// \param[in] _quiet False to be more verbose.
public: static bool Convert(tinyxml2::XMLDocument *_doc,
public: static bool Convert(sdf::Errors &_errors,
tinyxml2::XMLDocument *_doc,
const std::string &_toVersion,
sdf::Errors &_errors,
const ParserConfig &_config,
bool _quiet = false);

/// \cond
/// This is an internal function.
/// \brief Generic convert function that converts the SDF based on the
/// given Convert file.
/// \param[out] _errors Vector of errors.
/// \param[in] _doc SDF xml doc
/// \param[in] _convertDoc Convert xml doc
/// \param[out] _errors Vector of errors.
/// \param[in] _config Parser configuration.
public: static void Convert(tinyxml2::XMLDocument *_doc,
public: static void Convert(sdf::Errors &_errors,
tinyxml2::XMLDocument *_doc,
tinyxml2::XMLDocument *_convertDoc,
sdf::Errors &_errors,
const ParserConfig &_config);
/// \endcond

/// \brief Implementation of Convert functionality.
/// \param[in] _elem SDF xml element tree to convert.
/// \param[in] _convert Convert xml element tree.
/// \param[out] _errors Vector of errors.
/// \param[in] _config Parser configuration.
/// \param[out] _errors Vector of errors.
private: static void ConvertImpl(tinyxml2::XMLElement *_elem,
tinyxml2::XMLElement *_convert,
sdf::Errors &_errors,
const ParserConfig &_config);
const ParserConfig &_config,
sdf::Errors &_errors);

/// \brief Recursive helper function for ConvertImpl that converts
/// elements named by the descendant_name attribute.
/// \param[in] _e SDF xml element tree to convert.
/// \param[in] _c Convert xml element tree.
/// \param[out] _errors Vector of errors.
/// \param[in] _config Parser configuration.
/// \param[out] _errors Vector of errors.
private: static void ConvertDescendantsImpl(tinyxml2::XMLElement *_e,
tinyxml2::XMLElement *_c,
sdf::Errors &_errors,
const ParserConfig &_config);
const ParserConfig &_config,
sdf::Errors &_errors);

/// \brief Rename an element or attribute.
/// \param[in] _elem The element to be renamed, or the element which
Expand All @@ -107,8 +107,8 @@ namespace sdf
/// be moved.
/// \param[in] _moveElem A 'convert' element that describes the move
/// operation.
/// \param[out] _errors Vector of errors.
/// \param[in] _copy True to copy the element
/// \param[out] _errors Vector of errors.
private: static void Move(tinyxml2::XMLElement *_elem,
tinyxml2::XMLElement *_moveElem,
const bool _copy,
Expand All @@ -124,15 +124,15 @@ namespace sdf
sdf::Errors &_errors);

/// \brief Remove an attribute or elements.
/// \param[out] _errors Vector of Errors.
/// \param[in] _elem The element from which data may be removed.
/// \param[in] _removeElem The metadata about what to remove.
/// \param[out] _errors Vector of Errors.
/// \param[in] _removeOnlyEmpty If true, only remove an attribute
/// containing an empty string or elements that contain neither value nor
/// child elements nor attributes.
private: static void Remove(tinyxml2::XMLElement *_elem,
private: static void Remove(sdf::Errors &_errors,
tinyxml2::XMLElement *_elem,
tinyxml2::XMLElement *_removeElem,
sdf::Errors &_errors,
bool _removeOnlyEmpty = false);

/// \brief Unflatten an element (conversion from SDFormat <= 1.7 to 1.8)
Expand All @@ -159,8 +159,8 @@ namespace sdf

private: static void CheckDeprecation(tinyxml2::XMLElement *_elem,
tinyxml2::XMLElement *_convert,
sdf::Errors &_errors,
const ParserConfig &_config);
const ParserConfig &_config,
sdf::Errors &_errors);
};
}
}
Expand Down
Loading

0 comments on commit 5612619

Please sign in to comment.