name: Two more append methods
- append component represented as a string
- append timestamp-based version (automatically takes current timestamp)
Change-Id: I2917538c9b686b7ab9011f4c8e47c222dd33aaed
diff --git a/include/ndn-cpp/name.hpp b/include/ndn-cpp/name.hpp
index d2c1afe..b6b2e01 100644
--- a/include/ndn-cpp/name.hpp
+++ b/include/ndn-cpp/name.hpp
@@ -351,6 +351,20 @@
return *this;
}
+ /**
+ * @brief Append name component that represented as a string
+ *
+ * Note that this method is necessary to ensure correctness and unambiguity of
+ * ``append("string")`` operations (both Component and Name can be implicitly
+ * converted from string, each having different outcomes
+ */
+ Name&
+ append(const char *value)
+ {
+ components_.push_back(Component(value));
+ return *this;
+ }
+
Name&
append(const Block &value)
{
@@ -503,6 +517,15 @@
components_.push_back(Component::fromNumberWithMarker(version, 0xFD));
return *this;
}
+
+ /**
+ * @brief Append a component with the encoded version number.
+ *
+ * This version of the method creates version number based on the current timestamp
+ * @return This name so that you can chain calls to append.
+ */
+ Name&
+ appendVersion();
/**
* Check if this name has the same component count and components as the given name.
diff --git a/src/name.cpp b/src/name.cpp
index 44e6039..0a0b0e3 100644
--- a/src/name.cpp
+++ b/src/name.cpp
@@ -11,6 +11,7 @@
#include <string.h>
#include <ndn-cpp/name.hpp>
#include "c/util/ndn_memory.h"
+#include "c/util/time.h"
#include "util/string-helper.hpp"
@@ -169,6 +170,13 @@
return *this;
}
+Name&
+Name::appendVersion()
+{
+ appendVersion(ndn_getNowMilliseconds());
+ return *this;
+}
+
Name
Name::getSubName(size_t iStartComponent, size_t nComponents) const
{