Skip to content

Commit f22c655

Browse files
committed
Suggestions for #1294
Signed-off-by: Addisu Z. Taddese <[email protected]>
1 parent d1e1fe3 commit f22c655

File tree

3 files changed

+28
-41
lines changed

3 files changed

+28
-41
lines changed

include/sdf/parser.hh

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,6 @@ namespace sdf
4848
SDFORMAT_VISIBLE
4949
bool init(SDFPtr _sdf);
5050

51-
/// \brief Initialize the SDF interface from the embedded root spec file
52-
/// \param[out] _errors Vector of errors.
53-
/// \param[out] _sdf Pointer to an SDF object.
54-
/// \return True if successful.
55-
SDFORMAT_VISIBLE
56-
bool init(sdf::Errors &_errors, SDFPtr _sdf);
57-
5851
/// \brief Initialize the SDF interface from the embedded root spec file
5952
/// \param[out] _sdf Pointer to an SDF object.
6053
/// \param[in] _config Custom parser configuration
@@ -63,12 +56,12 @@ namespace sdf
6356
bool init(SDFPtr _sdf, const ParserConfig &_config);
6457

6558
/// \brief Initialize the SDF interface from the embedded root spec file
66-
/// \param[out] _sdf Pointer to an SDF object.
6759
/// \param[out] _errors Vector of errors.
60+
/// \param[out] _sdf Pointer to an SDF object.
6861
/// \param[in] _config Custom parser configuration
6962
/// \return True if successful.
7063
SDFORMAT_VISIBLE
71-
bool init(SDFPtr _sdf, sdf::Errors &_errors, const ParserConfig &_config);
64+
bool init(sdf::Errors &_errors, SDFPtr _sdf, const ParserConfig &_config);
7265

7366
/// \brief Initialize the SDF interface using a file
7467
/// \param[in] _filename Name of the SDF file
@@ -561,7 +554,7 @@ namespace sdf
561554
/// \param[in] _root SDF Root object to check recursively.
562555
/// \return True if all attached_to graphs are valid.
563556
SDFORMAT_VISIBLE
564-
bool checkPoseRelativeToGraph( sdf::Errors &_errors, const sdf::Root *_root);
557+
bool checkPoseRelativeToGraph(sdf::Errors &_errors, const sdf::Root *_root);
565558

566559
/// \brief Check that all sibling elements of the same type have unique names.
567560
/// This checks recursively and should check the files exhaustively

src/parser.cc

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ static inline bool _initFile(const std::string &_filename,
170170
return false;
171171
}
172172

173-
return initDoc(_sdf, _errors, &xmlDoc, _config);
173+
return initDoc(_errors, _sdf, &xmlDoc, _config);
174174
}
175175

176176
//////////////////////////////////////////////////
@@ -394,29 +394,23 @@ bool init(SDFPtr _sdf)
394394
return init(_sdf, ParserConfig::GlobalConfig());
395395
}
396396

397-
//////////////////////////////////////////////////
398-
bool init(sdf::Errors &_errors, SDFPtr _sdf)
399-
{
400-
return init(_sdf, _errors, ParserConfig::GlobalConfig());
401-
}
402-
403397
//////////////////////////////////////////////////
404398
bool init(SDFPtr _sdf, const ParserConfig &_config)
405399
{
406400
sdf::Errors errors;
407-
bool result = init(_sdf, errors, _config);
401+
bool result = init(errors, _sdf, _config);
408402
sdf::throwOrPrintErrors(errors);
409403
return result;
410404

411405
}
412406

413407
//////////////////////////////////////////////////
414-
bool init(SDFPtr _sdf, sdf::Errors &_errors, const ParserConfig &_config)
408+
bool init(sdf::Errors &_errors, SDFPtr _sdf, const ParserConfig &_config)
415409
{
416410
std::string xmldata = SDF::EmbeddedSpec("root.sdf", false);
417411
auto xmlDoc = makeSdfDoc();
418412
xmlDoc.Parse(xmldata.c_str());
419-
return initDoc(_sdf, _errors, &xmlDoc, _config);
413+
return initDoc(_errors, _sdf, &xmlDoc, _config);
420414
}
421415

422416
//////////////////////////////////////////////////
@@ -444,7 +438,7 @@ bool initFile(const std::string &_filename, const ParserConfig &_config,
444438
{
445439
auto xmlDoc = makeSdfDoc();
446440
xmlDoc.Parse(xmldata.c_str());
447-
return initDoc(_sdf, _errors, &xmlDoc, _config);
441+
return initDoc(_errors, _sdf, &xmlDoc, _config);
448442
}
449443
return _initFile(sdf::findFile(_filename, true, false, _config), _config,
450444
_sdf, _errors);
@@ -475,7 +469,7 @@ bool initFile(const std::string &_filename, const ParserConfig &_config,
475469
{
476470
auto xmlDoc = makeSdfDoc();
477471
xmlDoc.Parse(xmldata.c_str());
478-
return initDoc(_sdf, _errors, &xmlDoc, _config);
472+
return initDoc(_errors, _sdf, &xmlDoc, _config);
479473
}
480474
return _initFile(sdf::findFile(_filename, true, false, _config), _config,
481475
_sdf, _errors);
@@ -503,7 +497,7 @@ bool initString(const std::string &_xmlString, const ParserConfig &_config,
503497
return false;
504498
}
505499

506-
return initDoc(_sdf, _errors, &xmlDoc, _config);
500+
return initDoc(_errors, _sdf, &xmlDoc, _config);
507501
}
508502

509503
//////////////////////////////////////////////////
@@ -538,8 +532,8 @@ inline tinyxml2::XMLElement *_initDocGetElement(tinyxml2::XMLDocument *_xmlDoc,
538532
}
539533

540534
//////////////////////////////////////////////////
541-
bool initDoc(SDFPtr _sdf,
542-
sdf::Errors &_errors,
535+
bool initDoc(sdf::Errors &_errors,
536+
SDFPtr _sdf,
543537
tinyxml2::XMLDocument *_xmlDoc,
544538
const ParserConfig &_config)
545539
{
@@ -549,12 +543,12 @@ bool initDoc(SDFPtr _sdf,
549543
return false;
550544
}
551545

552-
return initXml(_sdf->Root(), _errors, element, _config);
546+
return initXml(_errors, _sdf->Root(), element, _config);
553547
}
554548

555549
//////////////////////////////////////////////////
556-
bool initDoc(ElementPtr _sdf,
557-
sdf::Errors &_errors,
550+
bool initDoc(sdf::Errors &_errors,
551+
ElementPtr _sdf,
558552
tinyxml2::XMLDocument *_xmlDoc,
559553
const ParserConfig &_config)
560554
{
@@ -564,12 +558,12 @@ bool initDoc(ElementPtr _sdf,
564558
return false;
565559
}
566560

567-
return initXml(_sdf, _errors, element, _config);
561+
return initXml(_errors, _sdf, element, _config);
568562
}
569563

570564
//////////////////////////////////////////////////
571-
bool initXml(ElementPtr _sdf,
572-
sdf::Errors &_errors,
565+
bool initXml(sdf::Errors &_errors,
566+
ElementPtr _sdf,
573567
tinyxml2::XMLElement *_xml,
574568
const ParserConfig &_config)
575569
{
@@ -696,7 +690,7 @@ bool initXml(ElementPtr _sdf,
696690
else
697691
{
698692
ElementPtr element(new Element);
699-
initXml(element, _errors, child, _config);
693+
initXml(_errors, element, child, _config);
700694
_sdf->AddElementDescription(element);
701695
}
702696
}

src/parser_private.hh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,43 +46,43 @@ namespace sdf
4646
/// \brief Initialize the SDF interface using a TinyXML2 document.
4747
///
4848
/// This actually forwards to initXml after converting the inputs
49-
/// \param[out] _sdf SDF interface to be initialized
5049
/// \param[out] _errors Vector of errors.
50+
/// \param[out] _sdf SDF interface to be initialized
5151
/// \param[in] _xmlDoc TinyXML2 document containing the SDFormat description
5252
/// file that corresponds with the input SDFPtr
5353
/// \param[in] _config Custom parser configuration
5454
/// \return True on success, false on error.
55-
bool initDoc(SDFPtr _sdf,
56-
sdf::Errors &_errors,
55+
bool initDoc(sdf::Errors &_errors,
56+
SDFPtr _sdf,
5757
tinyxml2::XMLDocument *_xmlDoc,
5858
const ParserConfig &_config);
5959

6060
/// \brief Initialize the SDF Element using a TinyXML2 document
6161
///
6262
/// This actually forwards to initXml after converting the inputs
63-
/// \param[out] _sdf SDF Element to be initialized
6463
/// \param[out] _errors Vector of errors.
64+
/// \param[out] _sdf SDF Element to be initialized
6565
/// \param[in] _xmlDoc TinyXML2 document containing the SDFormat description
6666
/// file that corresponds with the input ElementPtr
6767
/// \param[in] _config Custom parser configuration
6868
/// \return True on success, false on error.
69-
bool initDoc(ElementPtr _sdf,
70-
sdf::Errors &_errors,
69+
bool initDoc(sdf::Errors &_errors,
70+
ElementPtr _sdf,
7171
tinyxml2::XMLDocument *_xmlDoc,
7272
const ParserConfig &_config);
7373

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

0 commit comments

Comments
 (0)