Added set(struct ndn_Name &)
diff --git a/ndn-cpp/Name.cpp b/ndn-cpp/Name.cpp
index 995746c..5a62801 100644
--- a/ndn-cpp/Name.cpp
+++ b/ndn-cpp/Name.cpp
@@ -5,6 +5,7 @@
*/
#include <sstream>
+#include "c/Name.h"
#include "Name.hpp"
using namespace std;
@@ -15,6 +16,13 @@
{
}
+void Name::set(struct ndn_Name &nameStruct)
+{
+ clear();
+ for (int i = 0; i < nameStruct.nComponents; ++i)
+ addComponent(nameStruct.components[i].value, nameStruct.components[i].valueLength);
+}
+
std::string Name::to_uri()
{
// TODO: implement fully.
diff --git a/ndn-cpp/Name.hpp b/ndn-cpp/Name.hpp
index 2d2744a..eacd420 100644
--- a/ndn-cpp/Name.hpp
+++ b/ndn-cpp/Name.hpp
@@ -11,6 +11,8 @@
#include "common.h"
#include "encoding/BinaryXMLWireFormat.hpp"
+extern "C" { struct ndn_Name; }
+
namespace ndn {
class Name {
@@ -32,6 +34,12 @@
}
/**
+ * Clear the name, and set the components by copying from the name struct.
+ * @param name a C ndn_Name struct
+ */
+ void set(struct ndn_Name &nameStruct);
+
+ /**
* Add a new component, copying from value of length valueLength.
*/
void addComponent(unsigned char *value, unsigned int valueLength) {