From: Mukund Sivaraman Date: Sun, 24 Jun 2012 16:41:30 +0000 (+0530) Subject: [1774] Define and use type for Name data X-Git-Tag: trac2351_base~220 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=31ee75a034bad0d43d30368fa1ed7a3643aea402;p=thirdparty%2Fkea.git [1774] Define and use type for Name data --- diff --git a/src/lib/dns/name.cc b/src/lib/dns/name.cc index 00b9aeb8b3..aa0f85f1a4 100644 --- a/src/lib/dns/name.cc +++ b/src/lib/dns/name.cc @@ -151,7 +151,7 @@ Name::Name(const std::string &namestring, bool downcase) { offsets.reserve(Name::MAX_LABELS); offsets.push_back(0); - std::basic_string 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::const_iterator np = ndata_.begin(); - std::basic_string::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::const_reverse_iterator rit0 = offsets_.rbegin(); vector::const_reverse_iterator rit1 = rit0 + 1; - basic_string::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); diff --git a/src/lib/dns/name.h b/src/lib/dns/name.h index 56e78164a4..84c243a21c 100644 --- a/src/lib/dns/name.h +++ b/src/lib/dns/name.h @@ -229,6 +229,9 @@ class Name { /// //@{ private: + /// \brief Name data string + typedef std::basic_string 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 ndata_; + NameString ndata_; std::vector offsets_; unsigned int length_; unsigned int labelcount_;