tolerate addresses that don't begin with a '/'

This commit is contained in:
Kevin Matz 2023-05-16 10:27:56 -04:00
parent d5bd61c35b
commit 7029286883
2 changed files with 15 additions and 11 deletions

View File

@ -131,20 +131,24 @@ void Receiver::dispatch(const std::shared_ptr<Message> msg) const
/** /**
* @brief Receiver::findMethods * @brief Receiver::findMethods
* @param pattern * @param address
* @return * @return
*/ */
std::vector<const Method *> Receiver::findMethods(std::string pattern) const std::vector<const Method *> Receiver::findMethods(std::string address) const
{ {
std::istringstream stream(pattern);
stream.seekg(1); // skip leading '/'
std::list<std::string> tokens;
for (std::string name; std::getline(stream, name, '/');)
tokens.push_back(name);
std::vector<const Method *> hits; std::vector<const Method *> hits;
address_space_->matchAddress(hits, tokens); if (address.empty())
return hits;
std::istringstream stream(address);
if (address[0] == '/') // skip leading '/'
stream.seekg(1);
std::list<std::string> pattern;
for (std::string name; std::getline(stream, name, '/');)
pattern.push_back(name);
address_space_->matchAddress(hits, pattern);
return hits; return hits;
} }

View File

@ -53,7 +53,7 @@ public:
* @return * @return
*/ */
Method *rootMethod() const { return address_space_; } Method *rootMethod() const { return address_space_; }
std::vector<const Method *> findMethods(std::string pattern) const; std::vector<const Method *> findMethods(std::string address) const;
protected: protected:
void scheduleBundle(const std::shared_ptr<Bundle> bundle) const; void scheduleBundle(const std::shared_ptr<Bundle> bundle) const;