Added match
diff --git a/ndn-cpp/name.cpp b/ndn-cpp/name.cpp
index 8f8a161..9e60ca9 100644
--- a/ndn-cpp/name.cpp
+++ b/ndn-cpp/name.cpp
@@ -277,4 +277,25 @@
return result.str();
}
+bool Name::match(const Name &name)
+{
+ // Imitate ndn_Name_match.
+
+ // This name is longer than the name we are checking it against.
+ if (components_.size() > name.components_.size())
+ return 0;
+
+ // Check if at least one of given components doesn't match.
+ unsigned int i;
+ for (i = 0; i < components_.size(); ++i) {
+ const Component &selfComponent = components_[i];
+ const Component &nameComponent = name.components_[i];
+
+ if (selfComponent.getValue() != nameComponent.getValue())
+ return false;
+ }
+
+ return true;
+}
+
}
diff --git a/ndn-cpp/name.hpp b/ndn-cpp/name.hpp
index 5c6754a..42269e4 100644
--- a/ndn-cpp/name.hpp
+++ b/ndn-cpp/name.hpp
@@ -174,6 +174,8 @@
components_.push_back(Component());
components_.back().setSegment(segment);
}
+
+ bool match(const Name &name);
private:
std::vector<Component> components_;