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/. */
9 * nsTDependentString_CharT
11 * Stores a null-terminated, immutable sequence of characters.
13 * Subclass of nsTString that restricts string value to an immutable
14 * character sequence. This class does not own its data, so the creator
15 * of objects of this type must take care to ensure that a
16 * nsTDependentString continues to reference valid memory for the
17 * duration of its use.
19 class nsTDependentString_CharT
: public nsTString_CharT
23 typedef nsTDependentString_CharT self_type
;
31 nsTDependentString_CharT(const char_type
* aStart
, const char_type
* aEnd
)
32 : string_type(const_cast<char_type
*>(aStart
),
33 uint32_t(aEnd
- aStart
), F_TERMINATED
)
35 AssertValidDepedentString();
38 nsTDependentString_CharT(const char_type
* aData
, uint32_t aLength
)
39 : string_type(const_cast<char_type
*>(aData
), aLength
, F_TERMINATED
)
41 AssertValidDepedentString();
44 #if defined(CharT_is_PRUnichar) && defined(MOZ_USE_CHAR16_WRAPPER)
45 nsTDependentString_CharT(char16ptr_t aData
, uint32_t aLength
)
46 : nsTDependentString_CharT(static_cast<const char16_t
*>(aData
), aLength
)
52 nsTDependentString_CharT(const char_type
* aData
)
53 : string_type(const_cast<char_type
*>(aData
),
54 uint32_t(char_traits::length(aData
)), F_TERMINATED
)
56 AssertValidDepedentString();
59 #if defined(CharT_is_PRUnichar) && defined(MOZ_USE_CHAR16_WRAPPER)
61 nsTDependentString_CharT(char16ptr_t aData
)
62 : nsTDependentString_CharT(static_cast<const char16_t
*>(aData
))
67 nsTDependentString_CharT(const string_type
& aStr
, uint32_t aStartPos
)
70 Rebind(aStr
, aStartPos
);
73 // Create a nsTDependentSubstring to be bound later
74 nsTDependentString_CharT()
80 // auto-generated copy-constructor OK
81 // auto-generated copy-assignment operator OK
82 // auto-generated destructor OK
86 * allow this class to be bound to a different string...
89 using nsTString_CharT::Rebind
;
90 void Rebind(const char_type
* aData
)
92 Rebind(aData
, uint32_t(char_traits::length(aData
)));
95 void Rebind(const char_type
* aStart
, const char_type
* aEnd
)
97 Rebind(aStart
, uint32_t(aEnd
- aStart
));
100 void Rebind(const string_type
&, uint32_t aStartPos
);
105 nsTDependentString_CharT(const substring_tuple_type
&) MOZ_DELETE
;