]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[1774] Define and use type for Name data
authorMukund Sivaraman <muks@isc.org>
Sun, 24 Jun 2012 16:41:30 +0000 (22:11 +0530)
committerMukund Sivaraman <muks@isc.org>
Sun, 24 Jun 2012 16:41:30 +0000 (22:11 +0530)
src/lib/dns/name.cc
src/lib/dns/name.h

index 00b9aeb8b3f68d0ce6a1be5478f3cbc3516380c6..aa0f85f1a46cbf7d2921d3aa5d11c2c949503129 100644 (file)
@@ -151,7 +151,7 @@ Name::Name(const std::string &namestring, bool downcase) {
     offsets.reserve(Name::MAX_LABELS);
     offsets.push_back(0);
 
-    std::basic_string<uint8_t> ndata;
+    NameString ndata;
     ndata.reserve(Name::MAX_WIRE);
 
     // should we refactor this code using, e.g, the state pattern?  Probably
@@ -436,8 +436,8 @@ Name::toText(bool omit_final_dot) const {
         return (".");
     }
 
-    std::basic_string<uint8_t>::const_iterator np = ndata_.begin();
-    std::basic_string<uint8_t>::const_iterator np_end = ndata_.end();
+    NameString::const_iterator np = ndata_.begin();
+    NameString::const_iterator np_end = ndata_.end();
     unsigned int labels = labelcount_; // use for integrity check
     // init with an impossible value to catch error cases in the end:
     unsigned int count = MAX_LABELLEN + 1;
@@ -665,7 +665,7 @@ Name::reverse() const {
     // Copy the original name, label by label, from tail to head.
     vector<unsigned char>::const_reverse_iterator rit0 = offsets_.rbegin();
     vector<unsigned char>::const_reverse_iterator rit1 = rit0 + 1;
-    basic_string<uint8_t>::const_iterator n0 = ndata_.begin();
+    NameString::const_iterator n0 = ndata_.begin();
     retname.offsets_.push_back(0);
     while (rit1 != offsets_.rend()) {
         retname.ndata_.append(n0 + *rit1, n0 + *rit0);
index 56e78164a418c1d4b6f0e137d76286a4c70a57d7..84c243a21cd2999b7d53a4a1dea19208cbdb2f4a 100644 (file)
@@ -229,6 +229,9 @@ class Name {
     ///
     //@{
 private:
+    /// \brief Name data string
+    typedef std::basic_string<uint8_t> NameString;
+
     /// The default constructor
     ///
     /// This is used internally in the class implementation, but at least at
@@ -679,7 +682,7 @@ public:
     //@}
 
 private:
-    std::basic_string<uint8_t> ndata_;
+    NameString ndata_;
     std::vector<unsigned char> offsets_;
     unsigned int length_;
     unsigned int labelcount_;