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

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

Issue 2146163003: Use StringView for startsWith and endsWith. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
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
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 { return m_string.contains(s, caseSensitivity); } 80 { return m_string.contains(s, caseSensitivity); }
81 81
82 size_t find(UChar c, size_t start = 0) const { return m_string.find(c, start ); } 82 size_t find(UChar c, size_t start = 0) const { return m_string.find(c, start ); }
83 size_t find(CharacterMatchFunctionPtr matchFunction, unsigned start = 0) con st 83 size_t find(CharacterMatchFunctionPtr matchFunction, unsigned start = 0) con st
84 { return m_string.find(matchFunction, start); } 84 { return m_string.find(matchFunction, start); }
85 size_t find(const LChar* s, size_t start = 0, TextCaseSensitivity caseSensit ivity = TextCaseSensitive) const 85 size_t find(const LChar* s, size_t start = 0, TextCaseSensitivity caseSensit ivity = TextCaseSensitive) const
86 { return m_string.find(s, start, caseSensitivity); } 86 { return m_string.find(s, start, caseSensitivity); }
87 size_t find(const String& s, size_t start = 0, TextCaseSensitivity caseSensi tivity = TextCaseSensitive) const 87 size_t find(const String& s, size_t start = 0, TextCaseSensitivity caseSensi tivity = TextCaseSensitive) const
88 { return m_string.find(s, start, caseSensitivity); } 88 { return m_string.find(s, start, caseSensitivity); }
89 89
90 bool startsWith(const String& s, TextCaseSensitivity caseSensitivity = TextC aseSensitive) const 90 bool startsWith(const StringView& prefix, TextCaseSensitivity caseSensitivit y = TextCaseSensitive) const
91 { return m_string.startsWith(s, caseSensitivity); } 91 { return m_string.startsWith(prefix, caseSensitivity); }
92 bool startsWith(UChar character) const 92 bool startsWith(UChar character) const
93 { return m_string.startsWith(character); } 93 { return m_string.startsWith(character); }
94 template<unsigned matchLength>
95 bool startsWith(const char (&prefix)[matchLength], TextCaseSensitivity caseS ensitivity = TextCaseSensitive) const
96 { return m_string.startsWith<matchLength>(prefix, caseSensitivity); }
97 94
98 bool endsWith(const String& s, TextCaseSensitivity caseSensitivity = TextCas eSensitive) const 95 bool endsWith(const StringView& suffix, TextCaseSensitivity caseSensitivity = TextCaseSensitive) const
99 { return m_string.endsWith(s, caseSensitivity); } 96 { return m_string.endsWith(suffix, caseSensitivity); }
100 bool endsWith(UChar character) const 97 bool endsWith(UChar character) const
101 { return m_string.endsWith(character); } 98 { return m_string.endsWith(character); }
102 template<unsigned matchLength>
103 bool endsWith(const char (&prefix)[matchLength], TextCaseSensitivity caseSen sitivity = TextCaseSensitive) const
104 { return m_string.endsWith<matchLength>(prefix, caseSensitivity); }
105 99
106 AtomicString lower() const; 100 AtomicString lower() const;
107 AtomicString lowerASCII() const; 101 AtomicString lowerASCII() const;
108 AtomicString upper() const { return AtomicString(impl()->upper()); } 102 AtomicString upper() const { return AtomicString(impl()->upper()); }
109 103
110 int toInt(bool* ok = 0) const { return m_string.toInt(ok); } 104 int toInt(bool* ok = 0) const { return m_string.toInt(ok); }
111 double toDouble(bool* ok = 0) const { return m_string.toDouble(ok); } 105 double toDouble(bool* ok = 0) const { return m_string.toDouble(ok); }
112 float toFloat(bool* ok = 0) const { return m_string.toFloat(ok); } 106 float toFloat(bool* ok = 0) const { return m_string.toFloat(ok); }
113 107
114 static AtomicString number(int); 108 static AtomicString number(int);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 inline bool operator!=(const Vector<UChar>& a, const AtomicString& b) { return ! (a == b); } 171 inline bool operator!=(const Vector<UChar>& a, const AtomicString& b) { return ! (a == b); }
178 172
179 inline bool equalIgnoringCase(const AtomicString& a, const AtomicString& b) { re turn equalIgnoringCase(a.impl(), b.impl()); } 173 inline bool equalIgnoringCase(const AtomicString& a, const AtomicString& b) { re turn equalIgnoringCase(a.impl(), b.impl()); }
180 inline bool equalIgnoringCase(const AtomicString& a, const LChar* b) { return eq ualIgnoringCase(a.impl(), b); } 174 inline bool equalIgnoringCase(const AtomicString& a, const LChar* b) { return eq ualIgnoringCase(a.impl(), b); }
181 inline bool equalIgnoringCase(const AtomicString& a, const char* b) { return equ alIgnoringCase(a.impl(), reinterpret_cast<const LChar*>(b)); } 175 inline bool equalIgnoringCase(const AtomicString& a, const char* b) { return equ alIgnoringCase(a.impl(), reinterpret_cast<const LChar*>(b)); }
182 inline bool equalIgnoringCase(const AtomicString& a, const String& b) { return e qualIgnoringCase(a.impl(), b.impl()); } 176 inline bool equalIgnoringCase(const AtomicString& a, const String& b) { return e qualIgnoringCase(a.impl(), b.impl()); }
183 inline bool equalIgnoringCase(const LChar* a, const AtomicString& b) { return eq ualIgnoringCase(a, b.impl()); } 177 inline bool equalIgnoringCase(const LChar* a, const AtomicString& b) { return eq ualIgnoringCase(a, b.impl()); }
184 inline bool equalIgnoringCase(const char* a, const AtomicString& b) { return equ alIgnoringCase(reinterpret_cast<const LChar*>(a), b.impl()); } 178 inline bool equalIgnoringCase(const char* a, const AtomicString& b) { return equ alIgnoringCase(reinterpret_cast<const LChar*>(a), b.impl()); }
185 inline bool equalIgnoringCase(const String& a, const AtomicString& b) { return e qualIgnoringCase(a.impl(), b.impl()); } 179 inline bool equalIgnoringCase(const String& a, const AtomicString& b) { return e qualIgnoringCase(a.impl(), b.impl()); }
186 180
187 inline bool equalIgnoringASCIICase(const AtomicString& a, const AtomicString& b) { return equalIgnoringASCIICase(a.impl(), b.impl()); }
188 inline bool equalIgnoringASCIICase(const AtomicString& a, const char* b) { retur n equalIgnoringASCIICase(a.impl(), reinterpret_cast<const LChar*>(b)); }
189
190 // Define external global variables for the commonly used atomic strings. 181 // Define external global variables for the commonly used atomic strings.
191 // These are only usable from the main thread. 182 // These are only usable from the main thread.
192 WTF_EXPORT extern const AtomicString& nullAtom; 183 WTF_EXPORT extern const AtomicString& nullAtom;
193 WTF_EXPORT extern const AtomicString& emptyAtom; 184 WTF_EXPORT extern const AtomicString& emptyAtom;
194 WTF_EXPORT extern const AtomicString& starAtom; 185 WTF_EXPORT extern const AtomicString& starAtom;
195 WTF_EXPORT extern const AtomicString& xmlAtom; 186 WTF_EXPORT extern const AtomicString& xmlAtom;
196 WTF_EXPORT extern const AtomicString& xmlnsAtom; 187 WTF_EXPORT extern const AtomicString& xmlnsAtom;
197 WTF_EXPORT extern const AtomicString& xlinkAtom; 188 WTF_EXPORT extern const AtomicString& xlinkAtom;
198 189
199 190
(...skipping 21 matching lines...) Expand all
221 using WTF::AtomicString; 212 using WTF::AtomicString;
222 using WTF::nullAtom; 213 using WTF::nullAtom;
223 using WTF::emptyAtom; 214 using WTF::emptyAtom;
224 using WTF::starAtom; 215 using WTF::starAtom;
225 using WTF::xmlAtom; 216 using WTF::xmlAtom;
226 using WTF::xmlnsAtom; 217 using WTF::xmlnsAtom;
227 using WTF::xlinkAtom; 218 using WTF::xlinkAtom;
228 219
229 #include "wtf/text/StringConcatenate.h" 220 #include "wtf/text/StringConcatenate.h"
230 #endif // AtomicString_h 221 #endif // AtomicString_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698