/src/mozilla-central/xpcom/string/nsTDependentSubstring.cpp
Line | Count | Source (jump to first uncovered line) |
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 | | #include "nsTDependentSubstring.h" |
8 | | |
9 | | template <typename T> |
10 | | void |
11 | | nsTDependentSubstring<T>::Rebind(const substring_type& str, |
12 | | uint32_t startPos, uint32_t length) |
13 | 8.87M | { |
14 | 8.87M | // If we currently own a buffer, release it. |
15 | 8.87M | this->Finalize(); |
16 | 8.87M | |
17 | 8.87M | size_type strLength = str.Length(); |
18 | 8.87M | |
19 | 8.87M | if (startPos > strLength) { |
20 | 0 | startPos = strLength; |
21 | 0 | } |
22 | 8.87M | |
23 | 8.87M | char_type* newData = |
24 | 8.87M | const_cast<char_type*>(static_cast<const char_type*>(str.Data())) + startPos; |
25 | 8.87M | size_type newLength = XPCOM_MIN(length, strLength - startPos); |
26 | 8.87M | DataFlags newDataFlags = DataFlags(0); |
27 | 8.87M | this->SetData(newData, newLength, newDataFlags); |
28 | 8.87M | } nsTDependentSubstring<char>::Rebind(nsTSubstring<char> const&, unsigned int, unsigned int) Line | Count | Source | 13 | 8.74M | { | 14 | 8.74M | // If we currently own a buffer, release it. | 15 | 8.74M | this->Finalize(); | 16 | 8.74M | | 17 | 8.74M | size_type strLength = str.Length(); | 18 | 8.74M | | 19 | 8.74M | if (startPos > strLength) { | 20 | 0 | startPos = strLength; | 21 | 0 | } | 22 | 8.74M | | 23 | 8.74M | char_type* newData = | 24 | 8.74M | const_cast<char_type*>(static_cast<const char_type*>(str.Data())) + startPos; | 25 | 8.74M | size_type newLength = XPCOM_MIN(length, strLength - startPos); | 26 | 8.74M | DataFlags newDataFlags = DataFlags(0); | 27 | 8.74M | this->SetData(newData, newLength, newDataFlags); | 28 | 8.74M | } |
nsTDependentSubstring<char16_t>::Rebind(nsTSubstring<char16_t> const&, unsigned int, unsigned int) Line | Count | Source | 13 | 124k | { | 14 | 124k | // If we currently own a buffer, release it. | 15 | 124k | this->Finalize(); | 16 | 124k | | 17 | 124k | size_type strLength = str.Length(); | 18 | 124k | | 19 | 124k | if (startPos > strLength) { | 20 | 0 | startPos = strLength; | 21 | 0 | } | 22 | 124k | | 23 | 124k | char_type* newData = | 24 | 124k | const_cast<char_type*>(static_cast<const char_type*>(str.Data())) + startPos; | 25 | 124k | size_type newLength = XPCOM_MIN(length, strLength - startPos); | 26 | 124k | DataFlags newDataFlags = DataFlags(0); | 27 | 124k | this->SetData(newData, newLength, newDataFlags); | 28 | 124k | } |
|
29 | | |
30 | | template <typename T> |
31 | | void |
32 | | nsTDependentSubstring<T>::Rebind(const char_type* data, size_type length) |
33 | 9.38M | { |
34 | 9.38M | NS_ASSERTION(data, "nsTDependentSubstring must wrap a non-NULL buffer"); |
35 | 9.38M | |
36 | 9.38M | // If we currently own a buffer, release it. |
37 | 9.38M | this->Finalize(); |
38 | 9.38M | |
39 | 9.38M | char_type* newData = |
40 | 9.38M | const_cast<char_type*>(static_cast<const char_type*>(data)); |
41 | 9.38M | size_type newLength = length; |
42 | 9.38M | DataFlags newDataFlags = DataFlags(0); |
43 | 9.38M | this->SetData(newData, newLength, newDataFlags); |
44 | 9.38M | } nsTDependentSubstring<char>::Rebind(char const*, unsigned int) Line | Count | Source | 33 | 9.38M | { | 34 | 9.38M | NS_ASSERTION(data, "nsTDependentSubstring must wrap a non-NULL buffer"); | 35 | 9.38M | | 36 | 9.38M | // If we currently own a buffer, release it. | 37 | 9.38M | this->Finalize(); | 38 | 9.38M | | 39 | 9.38M | char_type* newData = | 40 | 9.38M | const_cast<char_type*>(static_cast<const char_type*>(data)); | 41 | 9.38M | size_type newLength = length; | 42 | 9.38M | DataFlags newDataFlags = DataFlags(0); | 43 | 9.38M | this->SetData(newData, newLength, newDataFlags); | 44 | 9.38M | } |
Unexecuted instantiation: nsTDependentSubstring<char16_t>::Rebind(char16_t const*, unsigned int) |
45 | | |
46 | | template <typename T> |
47 | | void |
48 | | nsTDependentSubstring<T>::Rebind(const char_type* aStart, const char_type* aEnd) |
49 | 0 | { |
50 | 0 | MOZ_RELEASE_ASSERT(aStart <= aEnd, "Overflow!"); |
51 | 0 | this->Rebind(aStart, size_type(aEnd - aStart)); |
52 | 0 | } Unexecuted instantiation: nsTDependentSubstring<char>::Rebind(char const*, char const*) Unexecuted instantiation: nsTDependentSubstring<char16_t>::Rebind(char16_t const*, char16_t const*) |
53 | | |
54 | | template <typename T> |
55 | | nsTDependentSubstring<T>::nsTDependentSubstring(const char_type* aStart, |
56 | | const char_type* aEnd) |
57 | | : substring_type(const_cast<char_type*>(aStart), uint32_t(aEnd - aStart), |
58 | | DataFlags(0), ClassFlags(0)) |
59 | 15.8M | { |
60 | 15.8M | MOZ_RELEASE_ASSERT(aStart <= aEnd, "Overflow!"); |
61 | 15.8M | } nsTDependentSubstring<char>::nsTDependentSubstring(char const*, char const*) Line | Count | Source | 59 | 15.8M | { | 60 | 15.8M | MOZ_RELEASE_ASSERT(aStart <= aEnd, "Overflow!"); | 61 | 15.8M | } |
Unexecuted instantiation: nsTDependentSubstring<char16_t>::nsTDependentSubstring(char16_t const*, char16_t const*) |
62 | | |
63 | | #if defined(MOZ_USE_CHAR16_WRAPPER) |
64 | | template <typename T> |
65 | | template <typename Q, typename EnableIfChar16> |
66 | | nsTDependentSubstring<T>::nsTDependentSubstring(char16ptr_t aStart, |
67 | | char16ptr_t aEnd) |
68 | | : substring_type(static_cast<const char16_t*>(aStart), |
69 | | static_cast<const char16_t*>(aEnd)) |
70 | | { |
71 | | MOZ_RELEASE_ASSERT(static_cast<const char16_t*>(aStart) <= |
72 | | static_cast<const char16_t*>(aEnd), |
73 | | "Overflow!"); |
74 | | } |
75 | | #endif |
76 | | |
77 | | template <typename T> |
78 | | nsTDependentSubstring<T>::nsTDependentSubstring(const const_iterator& aStart, |
79 | | const const_iterator& aEnd) |
80 | | : substring_type(const_cast<char_type*>(aStart.get()), |
81 | | uint32_t(aEnd.get() - aStart.get()), |
82 | | DataFlags(0), ClassFlags(0)) |
83 | 0 | { |
84 | 0 | MOZ_RELEASE_ASSERT(aStart.get() <= aEnd.get(), "Overflow!"); |
85 | 0 | } Unexecuted instantiation: nsTDependentSubstring<char>::nsTDependentSubstring(nsReadingIterator<char> const&, nsReadingIterator<char> const&) Unexecuted instantiation: nsTDependentSubstring<char16_t>::nsTDependentSubstring(nsReadingIterator<char16_t> const&, nsReadingIterator<char16_t> const&) |
86 | | |
87 | | template <typename T> |
88 | | const nsTDependentSubstring<T> |
89 | | Substring(const T* aStart, const T* aEnd) |
90 | 5.90M | { |
91 | 5.90M | MOZ_RELEASE_ASSERT(aStart <= aEnd, "Overflow!"); |
92 | 5.90M | return nsTDependentSubstring<T>(aStart, aEnd); |
93 | 5.90M | } nsTDependentSubstring<char> const Substring<char>(char const*, char const*) Line | Count | Source | 90 | 5.90M | { | 91 | 5.90M | MOZ_RELEASE_ASSERT(aStart <= aEnd, "Overflow!"); | 92 | 5.90M | return nsTDependentSubstring<T>(aStart, aEnd); | 93 | 5.90M | } |
Unexecuted instantiation: nsTDependentSubstring<char16_t> const Substring<char16_t>(char16_t const*, char16_t const*) |
94 | | |
95 | | #if defined(MOZ_USE_CHAR16_WRAPPER) |
96 | | const nsTDependentSubstring<char16_t> |
97 | | Substring(char16ptr_t aData, uint32_t aLength) |
98 | | { |
99 | | return nsTDependentSubstring<char16_t>(aData, aLength); |
100 | | } |
101 | | |
102 | | const nsTDependentSubstring<char16_t> |
103 | | Substring(char16ptr_t aStart, char16ptr_t aEnd) |
104 | | { |
105 | | return Substring(static_cast<const char16_t*>(aStart), |
106 | | static_cast<const char16_t*>(aEnd)); |
107 | | } |
108 | | #endif |