]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1211] Added copy assignment operator to LabelSequence
authorFrancis Dupont <fdupont@isc.org>
Fri, 8 May 2020 20:26:27 +0000 (22:26 +0200)
committerFrancis Dupont <fdupont@isc.org>
Mon, 15 Jun 2020 15:43:16 +0000 (15:43 +0000)
src/lib/dns/labelsequence.h

index 0b0b2bc4e8bbda1a241936340ba0f5f63fd013b8..63aec202cf986184a1d47902ed4bef1ff2cd9890 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2012-2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-2020 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -129,6 +129,26 @@ public:
         last_label_(ls.last_label_)
     {}
 
+    /// \brief Assignment operator.
+    ///
+    /// \note The associated data MUST remain in scope during the lifetime
+    /// of this LabelSequence, since only the pointers are copied.
+    ///
+    /// \note No validation is done on the given data upon construction;
+    ///       use with care.
+    ///
+    /// \param ls The LabelSequence to construct a LabelSequence from
+    LabelSequence& operator=(const LabelSequence& other) {
+        if (this != &other) {
+            // Not self-assignment.
+            data_ = other.data_;
+            offsets_ = other.offsets_;
+            first_label_ = other.first_label_;
+            last_label_ = other.last_label_;
+        }
+        return (*this);
+    }
+
     /// \brief Return the wire-format data for this LabelSequence
     ///
     /// The data is returned as a pointer to (the part of) the original