Added to_uri
diff --git a/ndn-cpp/Name.cpp b/ndn-cpp/Name.cpp
index 8caa59d..995746c 100644
--- a/ndn-cpp/Name.cpp
+++ b/ndn-cpp/Name.cpp
@@ -4,6 +4,7 @@
* BSD license, See the LICENSE file for more information.
*/
+#include <sstream>
#include "Name.hpp"
using namespace std;
@@ -14,4 +15,17 @@
{
}
+std::string Name::to_uri()
+{
+ // TODO: implement fully.
+ ostringstream output;
+ for (int i = 0; i < components_.size(); ++i) {
+ output << "/";
+ for (int j = 0; j < components_[i].size(); ++j)
+ output << components_[i][j];
+ }
+
+ return output.str();
+}
+
}
diff --git a/ndn-cpp/Name.hpp b/ndn-cpp/Name.hpp
index 29e95cd..2d2744a 100644
--- a/ndn-cpp/Name.hpp
+++ b/ndn-cpp/Name.hpp
@@ -53,6 +53,12 @@
return components_.size();
}
+ /**
+ * Encode this name as a URI.
+ * @return the encoded URI.
+ */
+ std::string to_uri();
+
private:
std::vector<std::vector<unsigned char> > components_;
};