1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 nsTAdoptingString_CharT
&
8 nsTAdoptingString_CharT::operator=(const self_type
& str
)
10 // This'll violate the constness of this argument, that's just
11 // the nature of this class...
12 self_type
* mutable_str
= const_cast<self_type
*>(&str
);
14 if (str
.mFlags
& F_OWNED
) {
15 // We want to do what Adopt() does, but without actually incrementing
16 // the Adopt count. Note that we can be a little more straightforward
17 // about this than Adopt() is, because we know that str.mData is
18 // non-null. Should we be able to assert that str is not void here?
19 NS_ASSERTION(str
.mData
, "String with null mData?");
22 mLength
= str
.mLength
;
23 SetDataFlags(F_TERMINATED
| F_OWNED
);
25 // Make str forget the buffer we just took ownership of.
26 new (mutable_str
) self_type();
30 mutable_str
->Truncate();
37 nsTString_CharT::Rebind(const char_type
* data
, size_type length
)
39 // If we currently own a buffer, release it.
42 mData
= const_cast<char_type
*>(data
);
44 SetDataFlags(F_TERMINATED
);
45 AssertValidDepedentString();