Skip to content

Commit

Permalink
moving output params first
Browse files Browse the repository at this point in the history
Signed-off-by: Marco A. Gutierrez <[email protected]>
  • Loading branch information
Marco A. Gutierrez committed Aug 16, 2023
1 parent 30671a5 commit 973e91c
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 47 deletions.
48 changes: 24 additions & 24 deletions src/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ static inline bool _initFile(const std::string &_filename,
return false;
}

return initDoc(&xmlDoc, _config, _sdf, _errors);
return initDoc(_sdf, _errors, &xmlDoc, _config);
}

//////////////////////////////////////////////////
Expand Down Expand Up @@ -416,7 +416,7 @@ bool init(SDFPtr _sdf, sdf::Errors &_errors, const ParserConfig &_config)
std::string xmldata = SDF::EmbeddedSpec("root.sdf", false);
auto xmlDoc = makeSdfDoc();
xmlDoc.Parse(xmldata.c_str());
return initDoc(&xmlDoc, _config, _sdf, _errors);
return initDoc(_sdf, _errors, &xmlDoc, _config);
}

//////////////////////////////////////////////////
Expand Down Expand Up @@ -444,7 +444,7 @@ bool initFile(const std::string &_filename, const ParserConfig &_config,
{
auto xmlDoc = makeSdfDoc();
xmlDoc.Parse(xmldata.c_str());
return initDoc(&xmlDoc, _config, _sdf, _errors);
return initDoc(_sdf, _errors, &xmlDoc, _config);

Check warning on line 447 in src/parser.cc

View check run for this annotation

Codecov / codecov/patch

src/parser.cc#L447

Added line #L447 was not covered by tests
}
return _initFile(sdf::findFile(_filename, true, false, _config), _config,
_sdf, _errors);
Expand Down Expand Up @@ -475,7 +475,7 @@ bool initFile(const std::string &_filename, const ParserConfig &_config,
{
auto xmlDoc = makeSdfDoc();
xmlDoc.Parse(xmldata.c_str());
return initDoc(&xmlDoc, _config, _sdf, _errors);
return initDoc(_sdf, _errors, &xmlDoc, _config);
}
return _initFile(sdf::findFile(_filename, true, false, _config), _config,
_sdf, _errors);
Expand Down Expand Up @@ -503,7 +503,7 @@ bool initString(const std::string &_xmlString, const ParserConfig &_config,
return false;
}

return initDoc(&xmlDoc, _config, _sdf, _errors);
return initDoc(_sdf, _errors, &xmlDoc, _config);
}

//////////////////////////////////////////////////
Expand Down Expand Up @@ -538,40 +538,40 @@ inline tinyxml2::XMLElement *_initDocGetElement(tinyxml2::XMLDocument *_xmlDoc,
}

//////////////////////////////////////////////////
bool initDoc(tinyxml2::XMLDocument *_xmlDoc,
const ParserConfig &_config,
SDFPtr _sdf,
sdf::Errors &_errors)
bool initDoc(SDFPtr _sdf,
sdf::Errors &_errors,
tinyxml2::XMLDocument *_xmlDoc,
const ParserConfig &_config)
{
auto element = _initDocGetElement(_xmlDoc, _errors);
if (!element)
{
return false;
}

return initXml(element, _config, _sdf->Root(), _errors);
return initXml(_sdf->Root(), _errors, element, _config);
}

//////////////////////////////////////////////////
bool initDoc(tinyxml2::XMLDocument *_xmlDoc,
const ParserConfig &_config,
ElementPtr _sdf,
sdf::Errors &_errors)
bool initDoc(ElementPtr _sdf,
sdf::Errors &_errors,
tinyxml2::XMLDocument *_xmlDoc,
const ParserConfig &_config)
{
auto element = _initDocGetElement(_xmlDoc, _errors);
if (!element)
{
return false;
}

return initXml(element, _config, _sdf, _errors);
return initXml(_sdf, _errors, element, _config);
}

//////////////////////////////////////////////////
bool initXml(tinyxml2::XMLElement *_xml,
const ParserConfig &_config,
ElementPtr _sdf,
sdf::Errors &_errors)
bool initXml(ElementPtr _sdf,
sdf::Errors &_errors,
tinyxml2::XMLElement *_xml,
const ParserConfig &_config)
{
const char *refString = _xml->Attribute("ref");
if (refString)
Expand Down Expand Up @@ -696,7 +696,7 @@ bool initXml(tinyxml2::XMLElement *_xml,
else
{
ElementPtr element(new Element);
initXml(child, _config, element, _errors);
initXml(element, _errors, child, _config);
_sdf->AddElementDescription(element);
}
}
Expand Down Expand Up @@ -1254,9 +1254,9 @@ bool checkXmlFromRoot(tinyxml2::XMLElement *_xmlRoot,
}

//////////////////////////////////////////////////
std::string getBestSupportedModelVersion(tinyxml2::XMLElement *_modelXML,
std::string &_modelFileName,
sdf::Errors &_errors)
std::string getBestSupportedModelVersion(std::string &_modelFileName,
sdf::Errors &_errors,
tinyxml2::XMLElement *_modelXML)
{
tinyxml2::XMLElement *sdfXML = _modelXML->FirstChildElement("sdf");
tinyxml2::XMLElement *nameSearch = _modelXML->FirstChildElement("name");
Expand Down Expand Up @@ -1380,7 +1380,7 @@ std::string getModelFilePath(sdf::Errors &_errors,
}

std::string modelFileName;
if (getBestSupportedModelVersion(modelXML, modelFileName, _errors).empty())
if (getBestSupportedModelVersion(modelFileName, _errors, modelXML).empty())
{
return std::string();
}
Expand Down
46 changes: 23 additions & 23 deletions src/parser_private.hh
Original file line number Diff line number Diff line change
Expand Up @@ -34,57 +34,57 @@ namespace sdf
//

/// \brief Get the best SDF version from models supported by this sdformat
/// \param[in] _modelXML XML element from config file pointing to the
/// model XML tag
/// \param[out] _modelFileName file name of the best model file
/// \param[out] _errors Vector of errors.
/// \param[in] _modelXML XML element from config file pointing to the
/// model XML tag
/// \return string with the best SDF version supported
std::string getBestSupportedModelVersion(tinyxml2::XMLElement *_modelXML,
std::string &_modelFileName,
sdf::Errors &_errors);
std::string getBestSupportedModelVersion(std::string &_modelFileName,
sdf::Errors &_errors,
tinyxml2::XMLElement *_modelXML);

/// \brief Initialize the SDF interface using a TinyXML2 document.
///
/// This actually forwards to initXml after converting the inputs
/// \param[out] _sdf SDF interface to be initialized
/// \param[out] _errors Vector of errors.
/// \param[in] _xmlDoc TinyXML2 document containing the SDFormat description
/// file that corresponds with the input SDFPtr
/// \param[in] _config Custom parser configuration
/// \param[out] _sdf SDF interface to be initialized
/// \param[out] _errors Vector of errors.
/// \return True on success, false on error.
bool initDoc(tinyxml2::XMLDocument *_xmlDoc,
const ParserConfig &_config,
SDFPtr _sdf,
sdf::Errors &_errors);
bool initDoc(SDFPtr _sdf,
sdf::Errors &_errors,
tinyxml2::XMLDocument *_xmlDoc,
const ParserConfig &_config);

/// \brief Initialize the SDF Element using a TinyXML2 document
///
/// This actually forwards to initXml after converting the inputs
/// \param[out] _sdf SDF Element to be initialized
/// \param[out] _errors Vector of errors.
/// \param[in] _xmlDoc TinyXML2 document containing the SDFormat description
/// file that corresponds with the input ElementPtr
/// \param[in] _config Custom parser configuration
/// \param[out] _sdf SDF Element to be initialized
/// \param[out] _errors Vector of errors.
/// \return True on success, false on error.
bool initDoc(tinyxml2::XMLDocument *_xmlDoc,
const ParserConfig &_config,
ElementPtr _sdf,
sdf::Errors &_errors);
bool initDoc(ElementPtr _sdf,
sdf::Errors &_errors,
tinyxml2::XMLDocument *_xmlDoc,
const ParserConfig &_config);

/// \brief Initialize the SDF Element by parsing the SDFormat description in
/// the input TinyXML2 element. This is where SDFormat spec/description files
/// are parsed
/// \remark For internal use only. Do not use this function.
/// \param[out] _sdf SDF ElementPtr to be initialized
/// \param[out] _errors Vector of errors.
/// \param[in] _xml TinyXML2 element containing the SDFormat description
/// file that corresponds with the input ElementPtr
/// \param[in] _config Custom parser configuration
/// \param[out] _sdf SDF ElementPtr to be initialized
/// \param[out] _errors Vector of errors.
/// \return True on success, false on error.
bool initXml(tinyxml2::XMLElement *_xml,
const ParserConfig &_config,
ElementPtr _sdf,
sdf::Errors &_errors);
bool initXml(ElementPtr _sdf,
sdf::Errors &_errors,
tinyxml2::XMLElement *_xml,
const ParserConfig &_config);

/// \brief Populate the SDF values from a TinyXML document
bool readDoc(tinyxml2::XMLDocument *_xmlDoc, SDFPtr _sdf,
Expand Down

0 comments on commit 973e91c

Please sign in to comment.