Line data Source code
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/. */
6 :
7 0 : nsTDependentString_CharT::nsTDependentString_CharT(const char_type* aStart,
8 0 : const char_type* aEnd)
9 0 : : string_type(const_cast<char_type*>(aStart), uint32_t(aEnd - aStart),
10 0 : DataFlags::TERMINATED, ClassFlags(0))
11 : {
12 0 : MOZ_RELEASE_ASSERT(aStart <= aEnd, "Overflow!");
13 0 : AssertValidDependentString();
14 0 : }
15 :
16 : void
17 1298 : nsTDependentString_CharT::Rebind(const string_type& str, uint32_t startPos)
18 : {
19 1298 : MOZ_ASSERT(str.GetDataFlags() & DataFlags::TERMINATED, "Unterminated flat string");
20 :
21 : // If we currently own a buffer, release it.
22 1298 : Finalize();
23 :
24 1298 : size_type strLength = str.Length();
25 :
26 1298 : if (startPos > strLength) {
27 0 : startPos = strLength;
28 : }
29 :
30 1298 : mData = const_cast<char_type*>(static_cast<const char_type*>(str.Data())) + startPos;
31 1298 : mLength = strLength - startPos;
32 1298 : mDataFlags = str.GetDataFlags() & (DataFlags::TERMINATED | DataFlags::LITERAL);
33 1298 : }
34 :
35 : void
36 0 : nsTDependentString_CharT::Rebind(const char_type* aStart, const char_type* aEnd)
37 : {
38 0 : MOZ_RELEASE_ASSERT(aStart <= aEnd, "Overflow!");
39 0 : Rebind(aStart, uint32_t(aEnd - aStart));
40 0 : }
|