summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/dns/labelsequence.cc27
-rw-r--r--src/lib/dns/labelsequence.h2
2 files changed, 25 insertions, 4 deletions
diff --git a/src/lib/dns/labelsequence.cc b/src/lib/dns/labelsequence.cc
index 21da769e31..b43d8e4d61 100644
--- a/src/lib/dns/labelsequence.cc
+++ b/src/lib/dns/labelsequence.cc
@@ -15,13 +15,34 @@
#include <dns/labelsequence.h>
#include <exceptions/exceptions.h>
-// TODO: REMOVE
-#include <iostream>
+/// Light-weight Accessor to Name object
+///
+/// The purpose of this class is to easily match Names and parts of Names,
+/// without needing to copy the underlying data on each split.
+///
+/// It can only work on existing Name objects, and the Name object MUST
+/// remain in scope during the entire lifetime of its associated
+/// LabelSequence(s)
+///
+/// Upon creation of a LabelSequence, it records the offsets of the
+/// labels in the wireformat data of the Name. When split() is called on
+/// the LabelSequence, no changes in the Name's data occur, but the
+/// internal pointers of the LabelSequence are modified.
+///
+/// LabelSequences can be compared to other LabelSequences, and their
+/// data can be requested (which then points to part of the original
+/// data of the associated Name object).
+///
namespace isc {
namespace dns {
-
+/// \brief Constructs a LabelSequence for the given name
+///
+/// The associated Name MUST remain in scope during the lifetime of
+/// this LabelSequence, since getData() refers to data from the
+/// Name object (the only data the LabelSequence stores are pointers
+/// to the labels in the Name object).
LabelSequence::LabelSequence(const Name& name) : name_(name),
first_label_(0) {
size_t label_count_ = name.getLabelCount();
diff --git a/src/lib/dns/labelsequence.h b/src/lib/dns/labelsequence.h
index 87704f6093..686442f146 100644
--- a/src/lib/dns/labelsequence.h
+++ b/src/lib/dns/labelsequence.h
@@ -32,7 +32,7 @@ public:
void split(int i);
- size_t getLabelCount() { return last_label_ - first_label_; }
+ size_t getLabelCount() const { return last_label_ - first_label_; }
const Name& getName() const { return name_; }