Bug 1339559 - Identify script that resulted in non-structured-clonable data r=kmag
[gecko.git] / xpcom / string / nsTDependentSubstring.h
blobf7125d8229c882f60e2d718a97fc96ef58222079
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 // IWYU pragma: private, include "nsString.h"
8 /**
9 * nsTDependentSubstring_CharT
11 * A string class which wraps an external array of string characters. It
12 * is the client code's responsibility to ensure that the external buffer
13 * remains valid for a long as the string is alive.
15 * NAMES:
16 * nsDependentSubstring for wide characters
17 * nsDependentCSubstring for narrow characters
19 class nsTDependentSubstring_CharT : public nsTSubstring_CharT
21 public:
23 typedef nsTDependentSubstring_CharT self_type;
25 public:
27 void Rebind(const substring_type&, uint32_t aStartPos,
28 uint32_t aLength = size_type(-1));
30 void Rebind(const char_type* aData, size_type aLength);
32 void Rebind(const char_type* aStart, const char_type* aEnd);
34 nsTDependentSubstring_CharT(const substring_type& aStr, uint32_t aStartPos,
35 uint32_t aLength = size_type(-1))
36 : substring_type()
38 Rebind(aStr, aStartPos, aLength);
41 nsTDependentSubstring_CharT(const char_type* aData, size_type aLength)
42 : substring_type(const_cast<char_type*>(aData), aLength, F_NONE)
46 nsTDependentSubstring_CharT(const char_type* aStart, const char_type* aEnd);
48 #if defined(CharT_is_PRUnichar) && defined(MOZ_USE_CHAR16_WRAPPER)
49 nsTDependentSubstring_CharT(char16ptr_t aData, size_type aLength)
50 : nsTDependentSubstring_CharT(static_cast<const char16_t*>(aData), aLength)
54 nsTDependentSubstring_CharT(char16ptr_t aStart, char16ptr_t aEnd);
55 #endif
57 nsTDependentSubstring_CharT(const const_iterator& aStart,
58 const const_iterator& aEnd);
60 // Create a nsTDependentSubstring to be bound later
61 nsTDependentSubstring_CharT()
62 : substring_type()
66 // auto-generated copy-constructor OK (XXX really?? what about base class copy-ctor?)
68 private:
69 // NOT USED
70 void operator=(const self_type&); // we're immutable, you can't assign into a substring
73 inline const nsTDependentSubstring_CharT
74 Substring(const nsTSubstring_CharT& aStr, uint32_t aStartPos,
75 uint32_t aLength = uint32_t(-1))
77 return nsTDependentSubstring_CharT(aStr, aStartPos, aLength);
80 inline const nsTDependentSubstring_CharT
81 Substring(const nsReadingIterator<CharT>& aStart,
82 const nsReadingIterator<CharT>& aEnd)
84 return nsTDependentSubstring_CharT(aStart.get(), aEnd.get());
87 inline const nsTDependentSubstring_CharT
88 Substring(const CharT* aData, uint32_t aLength)
90 return nsTDependentSubstring_CharT(aData, aLength);
93 const nsTDependentSubstring_CharT
94 Substring(const CharT* aStart, const CharT* aEnd);
96 inline const nsTDependentSubstring_CharT
97 StringHead(const nsTSubstring_CharT& aStr, uint32_t aCount)
99 return nsTDependentSubstring_CharT(aStr, 0, aCount);
102 inline const nsTDependentSubstring_CharT
103 StringTail(const nsTSubstring_CharT& aStr, uint32_t aCount)
105 return nsTDependentSubstring_CharT(aStr, aStr.Length() - aCount, aCount);