Skip to content

Commit

Permalink
PR Fixup
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Brawner <brawner@gmail.com>
  • Loading branch information
brawner committed Jan 26, 2021
1 parent dc2fb5b commit 15dd27b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 9 additions & 0 deletions include/sdf/Types.hh
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,19 @@ namespace sdf
/// \return Lowercase equilvalent of _in.
std::string SDFORMAT_VISIBLE lowercase(const std::string &_in);

/// \brief Split a name into a two strings based on the '::' delimeter
/// \param[in] _absoluteName The fully qualified absolute name
/// \return A pair with the absolute name minus the leaf node name, and the
/// leaf name
SDFORMAT_VISIBLE
std::pair<std::string, std::string> SplitName(
const std::string &_absoluteName);

/// \brief Join two strings with the '::' delimiter.
/// This checks for edge cases and is safe to use with any valid names
/// \param[in] _scopeName the left-hand-side component
/// \param[in] _localName the right-hand-side component
/// \return A full string with the names joined by the '::' delimeter.
SDFORMAT_VISIBLE
std::string JoinName(
const std::string &_scopeName, const std::string &_localName);
Expand Down
7 changes: 4 additions & 3 deletions src/Types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,17 @@ static bool EndsWithDelimiter(const std::string &_s)
if (_s.size() < kSdfScopeDelimiter.size())
return false;

const size_t findStartPosition = _s.size() - kSdfScopeDelimiter.size();
return _s.substr(findStartPosition) == kSdfScopeDelimiter;
const size_t startPosition = _s.size() - kSdfScopeDelimiter.size();
return _s.compare(
startPosition, kSdfScopeDelimiter.size(), kSdfScopeDelimiter) == 0;
}

static bool StartsWithDelimiter(const std::string &_s)
{
if (_s.size() < kSdfScopeDelimiter.size())
return false;

return _s.substr(0, kSdfScopeDelimiter.size()) == kSdfScopeDelimiter;
return _s.compare(0, kSdfScopeDelimiter.size(), kSdfScopeDelimiter) == 0;
}

// Join an scope name prefix with a local name using the scope delimeter
Expand Down

0 comments on commit 15dd27b

Please sign in to comment.