Name: Added toSegment and toVersion.
diff --git a/ndn-cpp/c/name.h b/ndn-cpp/c/name.h
index 12b024b..d6badc1 100644
--- a/ndn-cpp/c/name.h
+++ b/ndn-cpp/c/name.h
@@ -41,14 +41,6 @@
uint64_t ndn_NameComponent_toNumber(struct ndn_NameComponent *self);
/**
- * Convert binary blob name component (network-ordered number) to number, using appropriate marker from the naming convention
- * @param comp name component to be converted
- * @param marker required marker from the naming convention
- *
- * If the required marker does not exist, an exception will be thrown
- */
-
-/**
* Interpret the name component as a network-ordered number with a marker and return an integer.
* @param self A pointer to the ndn_NameComponent struct.
* @param marker The required first byte of the component.
diff --git a/ndn-cpp/name.hpp b/ndn-cpp/name.hpp
index 70defd1..3adf841 100644
--- a/ndn-cpp/name.hpp
+++ b/ndn-cpp/name.hpp
@@ -97,14 +97,60 @@
return Name::toEscapedString(*value_);
}
- uint64_t toNumber() const
+ /**
+ * Interpret this name component as a network-ordered number and return an integer.
+ * @return The integer number.
+ */
+ uint64_t
+ toNumber() const
{
struct ndn_NameComponent componentStruct;
get(componentStruct);
return ndn_NameComponent_toNumber(&componentStruct);
}
- uint64_t toNumberWithMarker(uint8_t marker) const;
+ /**
+ * Interpret this name component as a network-ordered number with a marker and return an integer.
+ * @param marker The required first byte of the component.
+ * @return The integer number.
+ * @throw runtime_error If the first byte of the component does not equal the marker.
+ */
+ uint64_t
+ toNumberWithMarker(uint8_t marker) const;
+
+ /**
+ * Interpret this name component as a segment number according to NDN name conventions (a network-ordered number
+ * where the first byte is the marker 0x00).
+ * @return The integer segment number.
+ * @throw runtime_error If the first byte of the component is not the expected marker.
+ */
+ uint64_t
+ toSegment() const
+ {
+ return toNumberWithMarker(0x00);
+ }
+
+ /**
+ * @deprecated Use toSegment.
+ */
+ uint64_t
+ toSeqNum() const
+ {
+ return toSegment();
+ }
+
+ /**
+ * Interpret this name component as a version number according to NDN name conventions (a network-ordered number
+ * where the first byte is the marker 0xFD). Note that this returns the exact number from the component
+ * without converting it to a time representation.
+ * @return The integer segment number.
+ * @throw runtime_error If the first byte of the component is not the expected marker.
+ */
+ uint64_t
+ toVersion() const
+ {
+ return toNumberWithMarker(0xFD);
+ }
/**
* Make a component value by decoding the escapedString between beginOffset and endOffset according to the NDN URI Scheme.