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/. */
8 nsTDependentString
<T
>::nsTDependentString(const char_type
* aStart
,
10 : string_type(const_cast<char_type
*>(aStart
), uint32_t(aEnd
- aStart
),
11 DataFlags::TERMINATED
, ClassFlags(0)) {
12 MOZ_RELEASE_ASSERT(aStart
<= aEnd
, "Overflow!");
13 this->AssertValidDependentString();
17 void nsTDependentString
<T
>::Rebind(const string_type
& str
, uint32_t startPos
) {
18 MOZ_ASSERT(str
.GetDataFlags() & DataFlags::TERMINATED
,
19 "Unterminated flat string");
21 // If we currently own a buffer, release it.
24 size_type strLength
= str
.Length();
26 if (startPos
> strLength
) {
31 const_cast<char_type
*>(static_cast<const char_type
*>(str
.Data())) +
33 size_type newLen
= strLength
- startPos
;
34 DataFlags newDataFlags
=
35 str
.GetDataFlags() & (DataFlags::TERMINATED
| DataFlags::LITERAL
);
36 this->SetData(newData
, newLen
, newDataFlags
);
40 void nsTDependentString
<T
>::Rebind(const char_type
* aStart
,
41 const char_type
* aEnd
) {
42 MOZ_RELEASE_ASSERT(aStart
<= aEnd
, "Overflow!");
43 this->Rebind(aStart
, uint32_t(aEnd
- aStart
));