[svn] commit: r379 - in /branches/jinmei-dnsmessageapi/src/lib/dns/cpp: name.cc name.h name_unittest.cc
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Dec 18 03:26:42 UTC 2009
Author: jinmei
Date: Fri Dec 18 03:26:42 2009
New Revision: 379
Log:
on second thought, it doesn't seem to be a good idea to have two downcase()
versions as the notation looks too similar and can be confusing.
revised the API and noted the restriction.
Modified:
branches/jinmei-dnsmessageapi/src/lib/dns/cpp/name.cc
branches/jinmei-dnsmessageapi/src/lib/dns/cpp/name.h
branches/jinmei-dnsmessageapi/src/lib/dns/cpp/name_unittest.cc
Modified: branches/jinmei-dnsmessageapi/src/lib/dns/cpp/name.cc
==============================================================================
--- branches/jinmei-dnsmessageapi/src/lib/dns/cpp/name.cc (original)
+++ branches/jinmei-dnsmessageapi/src/lib/dns/cpp/name.cc Fri Dec 18 03:26:42 2009
@@ -642,15 +642,6 @@
return (*this);
}
-
-Name
-Name::downcase() const
-{
- Name newname = *this;
-
- return (newname.downcase());
-}
-
}
}
Modified: branches/jinmei-dnsmessageapi/src/lib/dns/cpp/name.h
==============================================================================
--- branches/jinmei-dnsmessageapi/src/lib/dns/cpp/name.h (original)
+++ branches/jinmei-dnsmessageapi/src/lib/dns/cpp/name.h Fri Dec 18 03:26:42 2009
@@ -405,29 +405,26 @@
/// \brief Downcase all upper case alphabet characters in the name.
///
- /// We have two different versions of the \c downcase() method. This
- /// version modifies \this name class object. Since this method doesn't
- /// create a new object, it should be faster than the other version, and
- /// it's exception free. If the caller can allow the original object to be
- /// modified, this version would therefore be preferred.
+ /// This method modifies the calling object so that it can perform the
+ /// conversion as fast as possible and can be exception free.
+ ///
+ /// The return value of this version of \c downcase() is a reference to
+ /// the calling object (i.e., \c *this) so that the caller can use the
+ /// result of downcasing in a single line. For example, if variable
+ /// \c n is a \c Name class object possibly containing upper case
+ /// characters, and \c b is an \c OutpubBuffer class object, then the
+ /// following code will dump the name in wire format to \c b with
+ /// downcasing upper case characters:
+ ///
+ /// \code n.downcase().toWire(b); \endcode
+ ///
+ /// Since this method modifies the calling object, a \c const name object
+ /// cannot call it. If \c n is a \c const Name class object, it must first
+ /// be copied to a different object and the latter must be used for the
+ /// downcase modification.
///
/// \return A reference to the calling object with being downcased.
Name& downcase();
-
- /// \brief Downcase all upper case alphabet characters in a newly created
- /// copy of the name.
- ///
- /// We have two different versions of the \c downcase() method. This
- /// version makes a copy of the calling object and downcase the upper case
- /// characters of the copy. The calling object will be intact. This
- /// version will be slower than the other version due to the additional
- /// overhead, and may throw an exception if memory allocation fails.
- /// However, if the original object cannot be modified this version must be
- /// the choice.
- ///
- /// \return A new \c Name class object where upper case characters of the
- /// calling object are downcased.
- Name downcase() const;
//@}
///
Modified: branches/jinmei-dnsmessageapi/src/lib/dns/cpp/name_unittest.cc
==============================================================================
--- branches/jinmei-dnsmessageapi/src/lib/dns/cpp/name_unittest.cc (original)
+++ branches/jinmei-dnsmessageapi/src/lib/dns/cpp/name_unittest.cc Fri Dec 18 03:26:42 2009
@@ -396,13 +396,4 @@
compareInWireFormat(nameFactoryLowerCase().downcase(),
nameFactoryLowerCase());
}
-
-TEST_F(NameTest, copyAndDowncase)
-{
- Name name_lowercased = example_name_upper.downcase();
- compareInWireFormat(name_lowercased, example_name);
-
- name_lowercased = nameFactoryLowerCase().downcase();
- compareInWireFormat(name_lowercased, nameFactoryLowerCase());
-}
-}
+}
More information about the bind10-changes
mailing list