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

Side by Side Diff: third_party/WebKit/Source/wtf/text/WTFString.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 * (C) 1999 Lars Knoll (knoll@kde.org) 2 * (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. 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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 225
226 template<size_t inlineCapacity> 226 template<size_t inlineCapacity>
227 void prependTo(Vector<UChar, inlineCapacity>&, unsigned pos = 0, unsigned le n = UINT_MAX) const; 227 void prependTo(Vector<UChar, inlineCapacity>&, unsigned pos = 0, unsigned le n = UINT_MAX) const;
228 228
229 UChar32 characterStartingAt(unsigned) const; 229 UChar32 characterStartingAt(unsigned) const;
230 template<typename CharacterType> 230 template<typename CharacterType>
231 bool contains(CharacterType c) const { return find(c) != kNotFound; } 231 bool contains(CharacterType c) const { return find(c) != kNotFound; }
232 bool contains(const LChar* str, TextCaseSensitivity caseSensitivity = TextCa seSensitive) const { return find(str, 0, caseSensitivity) != kNotFound; } 232 bool contains(const LChar* str, TextCaseSensitivity caseSensitivity = TextCa seSensitive) const { return find(str, 0, caseSensitivity) != kNotFound; }
233 bool contains(const String& str, TextCaseSensitivity caseSensitivity = TextC aseSensitive) const { return find(str, 0, caseSensitivity) != kNotFound; } 233 bool contains(const String& str, TextCaseSensitivity caseSensitivity = TextC aseSensitive) const { return find(str, 0, caseSensitivity) != kNotFound; }
234 234
235 bool startsWith(const String& s, TextCaseSensitivity caseSensitivity = TextC aseSensitive) const 235 bool startsWith(const StringView& prefix, TextCaseSensitivity caseSensitivit y = TextCaseSensitive) const
236 { return m_impl ? DISPATCH_CASE_OP(caseSensitivity, m_impl->startsWith, (s.impl())) : s.isEmpty(); } 236 { return m_impl ? DISPATCH_CASE_OP(caseSensitivity, m_impl->startsWith, (prefix)) : prefix.isEmpty(); }
237 bool startsWith(UChar character) const 237 bool startsWith(UChar character) const
238 { return m_impl ? m_impl->startsWith(character) : false; } 238 { return m_impl ? m_impl->startsWith(character) : false; }
239 template<unsigned matchLength>
240 bool startsWith(const char (&prefix)[matchLength], TextCaseSensitivity caseS ensitivity = TextCaseSensitive) const
241 { return m_impl ? DISPATCH_CASE_OP(caseSensitivity, m_impl->startsWith, (prefix, matchLength - 1)) : !matchLength; }
242 239
243 bool endsWith(const String& s, TextCaseSensitivity caseSensitivity = TextCas eSensitive) const 240 bool endsWith(const StringView& suffix, TextCaseSensitivity caseSensitivity = TextCaseSensitive) const
244 { return m_impl ? DISPATCH_CASE_OP(caseSensitivity, m_impl->endsWith, (s .impl())) : s.isEmpty(); } 241 { return m_impl ? DISPATCH_CASE_OP(caseSensitivity, m_impl->endsWith, (s uffix)) : suffix.isEmpty(); }
245 bool endsWith(UChar character) const 242 bool endsWith(UChar character) const
246 { return m_impl ? m_impl->endsWith(character) : false; } 243 { return m_impl ? m_impl->endsWith(character) : false; }
247 template<unsigned matchLength>
248 bool endsWith(const char (&prefix)[matchLength], TextCaseSensitivity caseSen sitivity = TextCaseSensitive) const
249 { return m_impl ? DISPATCH_CASE_OP(caseSensitivity, m_impl->endsWith, (p refix, matchLength - 1)) : !matchLength; }
250 244
251 void append(const String&); 245 void append(const String&);
252 void append(LChar); 246 void append(LChar);
253 void append(char c) { append(static_cast<LChar>(c)); } 247 void append(char c) { append(static_cast<LChar>(c)); }
254 void append(UChar); 248 void append(UChar);
255 void append(const LChar*, unsigned length); 249 void append(const LChar*, unsigned length);
256 void append(const char* charactersToAppend, unsigned length) { append(reinte rpret_cast<const LChar*>(charactersToAppend), length); } 250 void append(const char* charactersToAppend, unsigned length) { append(reinte rpret_cast<const LChar*>(charactersToAppend), length); }
257 void append(const UChar*, unsigned length); 251 void append(const UChar*, unsigned length);
258 void insert(const String&, unsigned pos); 252 void insert(const String&, unsigned pos);
259 void insert(const LChar*, unsigned length, unsigned pos); 253 void insert(const LChar*, unsigned length, unsigned pos);
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 inline bool operator!=(const Vector<char, inlineCapacity>& a, const String& b) { return !(a == b); } 442 inline bool operator!=(const Vector<char, inlineCapacity>& a, const String& b) { return !(a == b); }
449 template<size_t inlineCapacity> 443 template<size_t inlineCapacity>
450 inline bool operator!=(const String& a, const Vector<char, inlineCapacity>& b) { return b != a; } 444 inline bool operator!=(const String& a, const Vector<char, inlineCapacity>& b) { return b != a; }
451 445
452 inline bool equalIgnoringCase(const String& a, const String& b) { return equalIg noringCase(a.impl(), b.impl()); } 446 inline bool equalIgnoringCase(const String& a, const String& b) { return equalIg noringCase(a.impl(), b.impl()); }
453 inline bool equalIgnoringCase(const String& a, const LChar* b) { return equalIgn oringCase(a.impl(), b); } 447 inline bool equalIgnoringCase(const String& a, const LChar* b) { return equalIgn oringCase(a.impl(), b); }
454 inline bool equalIgnoringCase(const String& a, const char* b) { return equalIgno ringCase(a.impl(), reinterpret_cast<const LChar*>(b)); } 448 inline bool equalIgnoringCase(const String& a, const char* b) { return equalIgno ringCase(a.impl(), reinterpret_cast<const LChar*>(b)); }
455 inline bool equalIgnoringCase(const LChar* a, const String& b) { return equalIgn oringCase(a, b.impl()); } 449 inline bool equalIgnoringCase(const LChar* a, const String& b) { return equalIgn oringCase(a, b.impl()); }
456 inline bool equalIgnoringCase(const char* a, const String& b) { return equalIgno ringCase(reinterpret_cast<const LChar*>(a), b.impl()); } 450 inline bool equalIgnoringCase(const char* a, const String& b) { return equalIgno ringCase(reinterpret_cast<const LChar*>(a), b.impl()); }
457 451
458 inline bool equalIgnoringASCIICase(const String& a, const String& b) { return eq ualIgnoringASCIICase(a.impl(), b.impl()); }
459 inline bool equalIgnoringASCIICase(const String& a, const LChar* b) { return equ alIgnoringASCIICase(a.impl(), b); }
460 inline bool equalIgnoringASCIICase(const String& a, const char* b) { return equa lIgnoringASCIICase(a.impl(), b); }
461
462 inline bool equalPossiblyIgnoringCase(const String& a, const String& b, bool ign oreCase) 452 inline bool equalPossiblyIgnoringCase(const String& a, const String& b, bool ign oreCase)
463 { 453 {
464 return ignoreCase ? equalIgnoringCase(a, b) : (a == b); 454 return ignoreCase ? equalIgnoringCase(a, b) : (a == b);
465 } 455 }
466 456
467 inline bool equalIgnoringNullity(const String& a, const String& b) { return equa lIgnoringNullity(a.impl(), b.impl()); } 457 inline bool equalIgnoringNullity(const String& a, const String& b) { return equa lIgnoringNullity(a.impl(), b.impl()); }
468 458
469 template<size_t inlineCapacity> 459 template<size_t inlineCapacity>
470 inline bool equalIgnoringNullity(const Vector<UChar, inlineCapacity>& a, const S tring& b) { return equalIgnoringNullity(a, b.impl()); } 460 inline bool equalIgnoringNullity(const Vector<UChar, inlineCapacity>& a, const S tring& b) { return equalIgnoringNullity(a, b.impl()); }
471 461
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 using WTF::charactersAreAllASCII; 649 using WTF::charactersAreAllASCII;
660 using WTF::equal; 650 using WTF::equal;
661 using WTF::equalIgnoringCase; 651 using WTF::equalIgnoringCase;
662 using WTF::find; 652 using WTF::find;
663 using WTF::isAllSpecialCharacters; 653 using WTF::isAllSpecialCharacters;
664 using WTF::isSpaceOrNewline; 654 using WTF::isSpaceOrNewline;
665 using WTF::reverseFind; 655 using WTF::reverseFind;
666 656
667 #include "wtf/text/AtomicString.h" 657 #include "wtf/text/AtomicString.h"
668 #endif // WTFString_h 658 #endif // WTFString_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698