New 'cut' method in CcnxNameComponents (similar to java API cut method)
diff --git a/model/ccnx-name-components.cc b/model/ccnx-name-components.cc
index a0a12da..c852d33 100644
--- a/model/ccnx-name-components.cc
+++ b/model/ccnx-name-components.cc
@@ -90,6 +90,19 @@
return subComponents;
}
+CcnxNameComponents
+CcnxNameComponents::cut (size_t minusComponents) const
+{
+ CcnxNameComponents retval;
+ std::list<std::string>::const_iterator component = m_prefix.begin ();
+ for (uint32_t i = 0; i < m_prefix.size () - minusComponents; i++, component++)
+ {
+ retval.Add (*component);
+ }
+
+ return retval;
+}
+
void
CcnxNameComponents::Print (std::ostream &os) const
{
diff --git a/model/ccnx-name-components.h b/model/ccnx-name-components.h
index 622f51f..54f9998 100644
--- a/model/ccnx-name-components.h
+++ b/model/ccnx-name-components.h
@@ -112,6 +112,12 @@
*/
std::list<boost::reference_wrapper<const std::string> >
GetSubComponents (size_t num) const;
+
+ /**
+ * @brief Get prefix of the name, containing less minusComponents right components
+ */
+ CcnxNameComponents
+ cut (size_t minusComponents) const;
/**
* \brief Print name