OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
reserved. |
3 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 3 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 96 |
97 template<typename StringType1, typename StringType2> | 97 template<typename StringType1, typename StringType2> |
98 unsigned StringAppend<StringType1, StringType2>::length() | 98 unsigned StringAppend<StringType1, StringType2>::length() |
99 { | 99 { |
100 StringTypeAdapter<StringType1> adapter1(m_string1); | 100 StringTypeAdapter<StringType1> adapter1(m_string1); |
101 StringTypeAdapter<StringType2> adapter2(m_string2); | 101 StringTypeAdapter<StringType2> adapter2(m_string2); |
102 return adapter1.length() + adapter2.length(); | 102 return adapter1.length() + adapter2.length(); |
103 } | 103 } |
104 | 104 |
105 template<typename StringType1, typename StringType2> | 105 template<typename StringType1, typename StringType2> |
106 class StringTypeAdapter<StringAppend<StringType1, StringType2> > { | 106 class StringTypeAdapter<StringAppend<StringType1, StringType2>> { |
107 public: | 107 public: |
108 StringTypeAdapter<StringAppend<StringType1, StringType2> >(StringAppend<Stri
ngType1, StringType2>& buffer) | 108 StringTypeAdapter<StringAppend<StringType1, StringType2>>(StringAppend<Strin
gType1, StringType2>& buffer) |
109 : m_buffer(buffer) | 109 : m_buffer(buffer) |
110 { | 110 { |
111 } | 111 } |
112 | 112 |
113 unsigned length() { return m_buffer.length(); } | 113 unsigned length() { return m_buffer.length(); } |
114 | 114 |
115 bool is8Bit() { return m_buffer.is8Bit(); } | 115 bool is8Bit() { return m_buffer.is8Bit(); } |
116 | 116 |
117 void writeTo(LChar* destination) { m_buffer.writeTo(destination); } | 117 void writeTo(LChar* destination) { m_buffer.writeTo(destination); } |
118 void writeTo(UChar* destination) { m_buffer.writeTo(destination); } | 118 void writeTo(UChar* destination) { m_buffer.writeTo(destination); } |
119 | 119 |
120 private: | 120 private: |
121 StringAppend<StringType1, StringType2>& m_buffer; | 121 StringAppend<StringType1, StringType2>& m_buffer; |
122 }; | 122 }; |
123 | 123 |
124 inline StringAppend<const char*, String> operator+(const char* string1, const St
ring& string2) | 124 inline StringAppend<const char*, String> operator+(const char* string1, const St
ring& string2) |
125 { | 125 { |
126 return StringAppend<const char*, String>(string1, string2); | 126 return StringAppend<const char*, String>(string1, string2); |
127 } | 127 } |
128 | 128 |
129 inline StringAppend<const char*, AtomicString> operator+(const char* string1, co
nst AtomicString& string2) | 129 inline StringAppend<const char*, AtomicString> operator+(const char* string1, co
nst AtomicString& string2) |
130 { | 130 { |
131 return StringAppend<const char*, AtomicString>(string1, string2); | 131 return StringAppend<const char*, AtomicString>(string1, string2); |
132 } | 132 } |
133 | 133 |
134 template<typename U, typename V> | 134 template<typename U, typename V> |
135 inline StringAppend<const char*, StringAppend<U, V> > operator+(const char* stri
ng1, const StringAppend<U, V>& string2) | 135 inline StringAppend<const char*, StringAppend<U, V>> operator+(const char* strin
g1, const StringAppend<U, V>& string2) |
136 { | 136 { |
137 return StringAppend<const char*, StringAppend<U, V> >(string1, string2); | 137 return StringAppend<const char*, StringAppend<U, V>>(string1, string2); |
138 } | 138 } |
139 | 139 |
140 inline StringAppend<const UChar*, String> operator+(const UChar* string1, const
String& string2) | 140 inline StringAppend<const UChar*, String> operator+(const UChar* string1, const
String& string2) |
141 { | 141 { |
142 return StringAppend<const UChar*, String>(string1, string2); | 142 return StringAppend<const UChar*, String>(string1, string2); |
143 } | 143 } |
144 | 144 |
145 inline StringAppend<const UChar*, AtomicString> operator+(const UChar* string1,
const AtomicString& string2) | 145 inline StringAppend<const UChar*, AtomicString> operator+(const UChar* string1,
const AtomicString& string2) |
146 { | 146 { |
147 return StringAppend<const UChar*, AtomicString>(string1, string2); | 147 return StringAppend<const UChar*, AtomicString>(string1, string2); |
148 } | 148 } |
149 | 149 |
150 template<typename U, typename V> | 150 template<typename U, typename V> |
151 inline StringAppend<const UChar*, StringAppend<U, V> > operator+(const UChar* st
ring1, const StringAppend<U, V>& string2) | 151 inline StringAppend<const UChar*, StringAppend<U, V>> operator+(const UChar* str
ing1, const StringAppend<U, V>& string2) |
152 { | 152 { |
153 return StringAppend<const UChar*, StringAppend<U, V> >(string1, string2); | 153 return StringAppend<const UChar*, StringAppend<U, V>>(string1, string2); |
154 } | 154 } |
155 | 155 |
156 template<typename T> | 156 template<typename T> |
157 StringAppend<String, T> operator+(const String& string1, T string2) | 157 StringAppend<String, T> operator+(const String& string1, T string2) |
158 { | 158 { |
159 return StringAppend<String, T>(string1, string2); | 159 return StringAppend<String, T>(string1, string2); |
160 } | 160 } |
161 | 161 |
162 template<typename U, typename V, typename W> | 162 template<typename U, typename V, typename W> |
163 StringAppend<StringAppend<U, V>, W> operator+(const StringAppend<U, V>& string1,
W string2) | 163 StringAppend<StringAppend<U, V>, W> operator+(const StringAppend<U, V>& string1,
W string2) |
164 { | 164 { |
165 return StringAppend<StringAppend<U, V>, W>(string1, string2); | 165 return StringAppend<StringAppend<U, V>, W>(string1, string2); |
166 } | 166 } |
167 | 167 |
168 } // namespace WTF | 168 } // namespace WTF |
169 | 169 |
170 #endif // StringOperators_h | 170 #endif // StringOperators_h |
OLD | NEW |