model: Small extension of Name class
Now name can be also constructed from a list of strings (previously, there
were a constructor version accepting list of references to strings).
diff --git a/model/ndn-name.cc b/model/ndn-name.cc
index a1624fb..1a3da80 100644
--- a/model/ndn-name.cc
+++ b/model/ndn-name.cc
@@ -46,6 +46,14 @@
}
}
+Name::Name (const std::list<std::string> &components)
+{
+ BOOST_FOREACH (const std::string &component, components)
+ {
+ Add (component);
+ }
+}
+
Name::Name (const std::string &prefix)
{
istringstream is (prefix);
diff --git a/model/ndn-name.h b/model/ndn-name.h
index 2f01f36..db39ccf 100644
--- a/model/ndn-name.h
+++ b/model/ndn-name.h
@@ -66,6 +66,13 @@
Name (const std::list<boost::reference_wrapper<const std::string> > &components);
/**
+ * \brief Constructor
+ * Creates a prefix from a list of strings where every string represents a prefix component
+ * @param[in] components A list of strings
+ */
+ Name (const std::list<std::string> &components);
+
+ /**
* @brief Constructor
* Creates a prefix from the string (string is parsed using operator>>)
* @param[in] prefix A string representation of a prefix
@@ -85,7 +92,7 @@
* @param[in] value The object to be appended
*/
template<class T>
- inline void
+ inline Name&
Add (const T &value);
/**
@@ -260,8 +267,7 @@
Name&
Name::operator () (const T &value)
{
- Add (value);
- return *this;
+ return Add (value);
}
/**
@@ -270,12 +276,14 @@
* @param[in] value The object to be appended
*/
template<class T>
-void
+Name&
Name::Add (const T &value)
{
std::ostringstream os;
os << value;
m_prefix.push_back (os.str ());
+
+ return *this;
}
/**