Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Side by Side Diff: Source/wtf/text/AtomicString.h

Issue 124003003: Add ascii() / latin1() / utf8() methods to AtomicString to avoid having to call string() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/web/tests/TouchActionTest.cpp ('k') | Source/wtf/text/WTFString.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public License 14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to 15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA. 17 * Boston, MA 02110-1301, USA.
18 * 18 *
19 */ 19 */
20 20
21 #ifndef AtomicString_h 21 #ifndef AtomicString_h
22 #define AtomicString_h 22 #define AtomicString_h
23 23
24 #include "wtf/HashTableDeletedValueType.h" 24 #include "wtf/HashTableDeletedValueType.h"
25 #include "wtf/WTFExport.h" 25 #include "wtf/WTFExport.h"
26 #include "wtf/text/CString.h"
26 #include "wtf/text/WTFString.h" 27 #include "wtf/text/WTFString.h"
27 28
28 // Define 'NO_IMPLICIT_ATOMICSTRING' before including this header, 29 // Define 'NO_IMPLICIT_ATOMICSTRING' before including this header,
29 // to disallow (expensive) implicit String-->AtomicString conversions. 30 // to disallow (expensive) implicit String-->AtomicString conversions.
30 #ifdef NO_IMPLICIT_ATOMICSTRING 31 #ifdef NO_IMPLICIT_ATOMICSTRING
31 #define ATOMICSTRING_CONVERSION explicit 32 #define ATOMICSTRING_CONVERSION explicit
32 #else 33 #else
33 #define ATOMICSTRING_CONVERSION 34 #define ATOMICSTRING_CONVERSION
34 #endif 35 #endif
35 36
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 #endif 158 #endif
158 #ifdef __OBJC__ 159 #ifdef __OBJC__
159 AtomicString(NSString* s) : m_string(add((CFStringRef)s)) { } 160 AtomicString(NSString* s) : m_string(add((CFStringRef)s)) { }
160 operator NSString*() const { return m_string; } 161 operator NSString*() const { return m_string; }
161 #endif 162 #endif
162 // AtomicString::fromUTF8 will return a null string if 163 // AtomicString::fromUTF8 will return a null string if
163 // the input data contains invalid UTF-8 sequences. 164 // the input data contains invalid UTF-8 sequences.
164 static AtomicString fromUTF8(const char*, size_t); 165 static AtomicString fromUTF8(const char*, size_t);
165 static AtomicString fromUTF8(const char*); 166 static AtomicString fromUTF8(const char*);
166 167
168 CString ascii() const { return m_string.ascii(); }
169 CString latin1() const { return m_string.latin1(); }
170 CString utf8(UTF8ConversionMode mode = LenientUTF8Conversion) const { return m_string.utf8(mode); }
171
167 #ifndef NDEBUG 172 #ifndef NDEBUG
168 void show() const; 173 void show() const;
169 #endif 174 #endif
170 175
171 private: 176 private:
172 String m_string; 177 String m_string;
173 178
174 static PassRefPtr<StringImpl> add(const LChar*); 179 static PassRefPtr<StringImpl> add(const LChar*);
175 ALWAYS_INLINE static PassRefPtr<StringImpl> add(const char* s) { return add( reinterpret_cast<const LChar*>(s)); }; 180 ALWAYS_INLINE static PassRefPtr<StringImpl> add(const char* s) { return add( reinterpret_cast<const LChar*>(s)); };
176 static PassRefPtr<StringImpl> add(const LChar*, unsigned length); 181 static PassRefPtr<StringImpl> add(const LChar*, unsigned length);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 using WTF::nullAtom; 267 using WTF::nullAtom;
263 using WTF::emptyAtom; 268 using WTF::emptyAtom;
264 using WTF::starAtom; 269 using WTF::starAtom;
265 using WTF::xmlAtom; 270 using WTF::xmlAtom;
266 using WTF::xmlnsAtom; 271 using WTF::xmlnsAtom;
267 using WTF::xlinkAtom; 272 using WTF::xlinkAtom;
268 #endif 273 #endif
269 274
270 #include "wtf/text/StringConcatenate.h" 275 #include "wtf/text/StringConcatenate.h"
271 #endif // AtomicString_h 276 #endif // AtomicString_h
OLDNEW
« no previous file with comments | « Source/web/tests/TouchActionTest.cpp ('k') | Source/wtf/text/WTFString.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698