Skip to content

Commit

Permalink
Address reviewer feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carroll <[email protected]>
  • Loading branch information
mjcarroll committed Jun 11, 2020
1 parent 6331828 commit 8086293
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 50 deletions.
4 changes: 0 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ if (NOT USE_INTERNAL_URDF)
link_directories(${URDF_LIBRARY_DIRS})
endif()

# TODO(mjcarroll) These should probably actually be target_* variants
link_directories(${tinyxml2_LIBRARY_DIRS})
include_directories(${tinyxml2_INCLUDE_DIRS})

set (sources
Actor.cc
AirPressure.cc
Expand Down
34 changes: 1 addition & 33 deletions src/XmlUtils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,38 +56,6 @@ tinyxml2::XMLNode* DeepClone(tinyxml2::XMLDocument *_doc,
return copy;
}

/////////////////////////////////////////////////
std::string &TrimStringLeft(std::string &_s)
{
_s.erase(
_s.begin(),
find_if_not(_s.begin(), _s.end(),
[](int c)
{
return isspace(c);
}));
return _s;
}

/////////////////////////////////////////////////
std::string &TrimStringRight(std::string &_s)
{
_s.erase(
find_if_not(_s.rbegin(), _s.rend(),
[](int c)
{
return isspace(c);
}).base(),
_s.end());
return _s;
}

/////////////////////////////////////////////////
std::string TrimString(const std::string &_s)
{
std::string t = _s;
return TrimStringLeft(TrimStringRight(t));
}
}
}
} // namespace sdf

5 changes: 0 additions & 5 deletions src/XmlUtils.hh
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ namespace sdf
/// \returns The newly copied node
tinyxml2::XMLNode* DeepClone(tinyxml2::XMLDocument *_doc,
const tinyxml2::XMLNode *_src);

/// \brief Trim whitespace from a string
/// \param[in] _s String to trim
/// \returns String _s with whitespace trimmed from both ends
std::string TrimString(const std::string &_s);
}
}
#endif
4 changes: 2 additions & 2 deletions src/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ template <typename TPtr>
static inline bool _initFile(const std::string &_filename, TPtr _sdf)
{
tinyxml2::XMLDocument xmlDoc;
if (xmlDoc.LoadFile(_filename.c_str()))
if (tinyxml2::XML_SUCCESS != xmlDoc.LoadFile(_filename.c_str()))
{
sdferr << "Unable to load file["
<< _filename << "]: " << xmlDoc.ErrorStr() << "\n";
Expand Down Expand Up @@ -756,7 +756,7 @@ std::string getModelFilePath(const std::string &_modelDirPath)
}

tinyxml2::XMLDocument configFileDoc;
if (!configFileDoc.LoadFile(configFilePath.c_str()))
if (tinyxml2::XML_SUCCESS != configFileDoc.LoadFile(configFilePath.c_str()))
{
sdferr << "Error parsing XML in file ["
<< configFilePath << "]: "
Expand Down
6 changes: 3 additions & 3 deletions src/parser_urdf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ bool URDF2SDF::IsURDF(const std::string &_filename)
{
tinyxml2::XMLDocument xmlDoc;

if (!xmlDoc.LoadFile(_filename.c_str()))
if (tinyxml2::XML_SUCCESS == xmlDoc.LoadFile(_filename.c_str()))
{
tinyxml2::XMLPrinter printer;
xmlDoc.Print(&printer);
Expand Down Expand Up @@ -1157,7 +1157,7 @@ void AddKeyValue(tinyxml2::XMLElement *_elem, const std::string &_key,
_elem->DeleteChild(childElem); // remove old _elem
}

auto* doc = _elem->GetDocument();
auto *doc = _elem->GetDocument();
tinyxml2::XMLElement *ekey = doc->NewElement(_key.c_str());
tinyxml2::XMLText *textEkey = doc->NewText(_value.c_str());
ekey->LinkEndChild(textEkey);
Expand Down Expand Up @@ -1196,7 +1196,7 @@ std::string GetKeyValueAsString(tinyxml2::XMLElement* _elem)
sdfwarn << "Attribute value string not set\n";
}
}
return TrimString(valueStr);
return trim(valueStr.c_str());
}

/////////////////////////////////////////////////
Expand Down
2 changes: 0 additions & 2 deletions src/parser_urdf.hh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ namespace sdf
/// \brief convert urdf file to sdf xml document
/// \param[in] _urdfStr a string containing filename of the urdf model.
/// \param[inout] _sdfXmlDoc document to populate with the sdf model.
/// \return a tinyxml document containing sdf of the model
public: void InitModelFile(const std::string &_filename,
tinyxml2::XMLDocument *_sdfXmlDoc);

Expand All @@ -63,7 +62,6 @@ namespace sdf
/// \param[in] _urdfStr a string containing model urdf
/// \param[inout] _sdfXmlDoc document to populate with the sdf model.
/// \param[in] _enforceLimits option to enforce joint limits
/// \return a tinyxml document containing sdf of the model
public: void InitModelString(const std::string &_urdfStr,
tinyxml2::XMLDocument *_sdfXmlDoc,
bool _enforceLimits = true);
Expand Down
1 change: 0 additions & 1 deletion src/parser_urdf_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ std::string getMinimalUrdfTxt()
std::string convertUrdfStrToSdfStr(const std::string &_urdf)
{
sdf::URDF2SDF parser_;
SDF_SUPPRESS_DEPRECATED_END
tinyxml2::XMLDocument sdf_result;
parser_.InitModelString(_urdf, &sdf_result);
tinyxml2::XMLPrinter printer;
Expand Down

0 comments on commit 8086293

Please sign in to comment.