|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* vim:set ts=2 sw=2 sts=2 et cindent: */ |
|
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 |
|
8 /** |
|
9 * nsTDependentString_CharT |
|
10 * |
|
11 * Stores a null-terminated, immutable sequence of characters. |
|
12 * |
|
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. |
|
18 */ |
|
19 class nsTDependentString_CharT : public nsTString_CharT |
|
20 { |
|
21 public: |
|
22 |
|
23 typedef nsTDependentString_CharT self_type; |
|
24 |
|
25 public: |
|
26 |
|
27 /** |
|
28 * constructors |
|
29 */ |
|
30 |
|
31 nsTDependentString_CharT( const char_type* start, const char_type* end ) |
|
32 : string_type(const_cast<char_type*>(start), uint32_t(end - start), F_TERMINATED) |
|
33 { |
|
34 AssertValidDepedentString(); |
|
35 } |
|
36 |
|
37 nsTDependentString_CharT( const char_type* data, uint32_t length ) |
|
38 : string_type(const_cast<char_type*>(data), length, F_TERMINATED) |
|
39 { |
|
40 AssertValidDepedentString(); |
|
41 } |
|
42 |
|
43 #if defined(CharT_is_PRUnichar) && defined(MOZ_USE_CHAR16_WRAPPER) |
|
44 nsTDependentString_CharT( char16ptr_t data, uint32_t length ) |
|
45 : nsTDependentString_CharT(static_cast<const char16_t*>(data), length) {} |
|
46 #endif |
|
47 |
|
48 explicit |
|
49 nsTDependentString_CharT( const char_type* data ) |
|
50 : string_type(const_cast<char_type*>(data), uint32_t(char_traits::length(data)), F_TERMINATED) |
|
51 { |
|
52 AssertValidDepedentString(); |
|
53 } |
|
54 |
|
55 #if defined(CharT_is_PRUnichar) && defined(MOZ_USE_CHAR16_WRAPPER) |
|
56 explicit |
|
57 nsTDependentString_CharT( char16ptr_t data ) |
|
58 : nsTDependentString_CharT( static_cast<const char16_t*>(data)) {} |
|
59 #endif |
|
60 |
|
61 nsTDependentString_CharT( const string_type& str, uint32_t startPos ) |
|
62 : string_type() |
|
63 { |
|
64 Rebind(str, startPos); |
|
65 } |
|
66 |
|
67 // Create a nsTDependentSubstring to be bound later |
|
68 nsTDependentString_CharT() |
|
69 : string_type() {} |
|
70 |
|
71 // XXX are you sure?? |
|
72 // auto-generated copy-constructor OK |
|
73 // auto-generated copy-assignment operator OK |
|
74 // auto-generated destructor OK |
|
75 |
|
76 |
|
77 /** |
|
78 * allow this class to be bound to a different string... |
|
79 */ |
|
80 |
|
81 using nsTString_CharT::Rebind; |
|
82 void Rebind( const char_type* data ) |
|
83 { |
|
84 Rebind(data, uint32_t(char_traits::length(data))); |
|
85 } |
|
86 |
|
87 void Rebind( const char_type* start, const char_type* end ) |
|
88 { |
|
89 Rebind(start, uint32_t(end - start)); |
|
90 } |
|
91 |
|
92 void Rebind( const string_type&, uint32_t startPos ); |
|
93 |
|
94 private: |
|
95 |
|
96 // NOT USED |
|
97 nsTDependentString_CharT( const substring_tuple_type& ); |
|
98 }; |