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

Side by Side Diff: Source/wtf/text/WTFString.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/wtf/text/AtomicString.h ('k') | Source/wtf/text/WTFString.cpp » ('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 * (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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 WTF_EXPORT float charactersToFloat(const LChar*, size_t, bool* ok = 0); 72 WTF_EXPORT float charactersToFloat(const LChar*, size_t, bool* ok = 0);
73 WTF_EXPORT float charactersToFloat(const UChar*, size_t, bool* ok = 0); 73 WTF_EXPORT float charactersToFloat(const UChar*, size_t, bool* ok = 0);
74 WTF_EXPORT float charactersToFloat(const LChar*, size_t, size_t& parsedLength); 74 WTF_EXPORT float charactersToFloat(const LChar*, size_t, size_t& parsedLength);
75 WTF_EXPORT float charactersToFloat(const UChar*, size_t, size_t& parsedLength); 75 WTF_EXPORT float charactersToFloat(const UChar*, size_t, size_t& parsedLength);
76 76
77 enum TrailingZerosTruncatingPolicy { 77 enum TrailingZerosTruncatingPolicy {
78 KeepTrailingZeros, 78 KeepTrailingZeros,
79 TruncateTrailingZeros 79 TruncateTrailingZeros
80 }; 80 };
81 81
82 enum UTF8ConversionMode {
83 LenientUTF8Conversion,
84 StrictUTF8Conversion,
85 StrictUTF8ConversionReplacingUnpairedSurrogatesWithFFFD
86 };
87
82 template<bool isSpecialCharacter(UChar), typename CharacterType> 88 template<bool isSpecialCharacter(UChar), typename CharacterType>
83 bool isAllSpecialCharacters(const CharacterType*, size_t); 89 bool isAllSpecialCharacters(const CharacterType*, size_t);
84 90
85 // You can find documentation about this class in this doc: 91 // You can find documentation about this class in this doc:
86 // https://docs.google.com/document/d/1kOCUlJdh2WJMJGDf-WoEQhmnjKLaOYRbiHz5TiGJl 14/edit?usp=sharing 92 // https://docs.google.com/document/d/1kOCUlJdh2WJMJGDf-WoEQhmnjKLaOYRbiHz5TiGJl 14/edit?usp=sharing
87 class WTF_EXPORT String { 93 class WTF_EXPORT String {
88 public: 94 public:
89 // Construct a null string, distinguishable from an empty string. 95 // Construct a null string, distinguishable from an empty string.
90 String() { } 96 String() { }
91 97
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 182
177 unsigned sizeInBytes() const 183 unsigned sizeInBytes() const
178 { 184 {
179 if (!m_impl) 185 if (!m_impl)
180 return 0; 186 return 0;
181 return m_impl->length() * (is8Bit() ? sizeof(LChar) : sizeof(UChar)); 187 return m_impl->length() * (is8Bit() ? sizeof(LChar) : sizeof(UChar));
182 } 188 }
183 189
184 CString ascii() const; 190 CString ascii() const;
185 CString latin1() const; 191 CString latin1() const;
186 192 CString utf8(UTF8ConversionMode = LenientUTF8Conversion) const;
187 typedef enum {
188 LenientConversion,
189 StrictConversion,
190 StrictConversionReplacingUnpairedSurrogatesWithFFFD,
191 } ConversionMode;
192
193 CString utf8(ConversionMode = LenientConversion) const;
194 193
195 UChar operator[](unsigned index) const 194 UChar operator[](unsigned index) const
196 { 195 {
197 if (!m_impl || index >= m_impl->length()) 196 if (!m_impl || index >= m_impl->length())
198 return 0; 197 return 0;
199 return (*m_impl)[index]; 198 return (*m_impl)[index];
200 } 199 }
201 200
202 static String number(int); 201 static String number(int);
203 static String number(unsigned); 202 static String number(unsigned);
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 static const bool canCompareWithMemcmp = false; 672 static const bool canCompareWithMemcmp = false;
674 }; 673 };
675 674
676 // Shared global empty string. 675 // Shared global empty string.
677 WTF_EXPORT const String& emptyString(); 676 WTF_EXPORT const String& emptyString();
678 677
679 } 678 }
680 679
681 using WTF::CString; 680 using WTF::CString;
682 using WTF::KeepTrailingZeros; 681 using WTF::KeepTrailingZeros;
682 using WTF::StrictUTF8Conversion;
683 using WTF::StrictUTF8ConversionReplacingUnpairedSurrogatesWithFFFD;
683 using WTF::String; 684 using WTF::String;
684 using WTF::emptyString; 685 using WTF::emptyString;
685 using WTF::append; 686 using WTF::append;
686 using WTF::appendNumber; 687 using WTF::appendNumber;
687 using WTF::charactersAreAllASCII; 688 using WTF::charactersAreAllASCII;
688 using WTF::charactersToIntStrict; 689 using WTF::charactersToIntStrict;
689 using WTF::charactersToUIntStrict; 690 using WTF::charactersToUIntStrict;
690 using WTF::charactersToInt64Strict; 691 using WTF::charactersToInt64Strict;
691 using WTF::charactersToUInt64Strict; 692 using WTF::charactersToUInt64Strict;
692 using WTF::charactersToIntPtrStrict; 693 using WTF::charactersToIntPtrStrict;
693 using WTF::charactersToInt; 694 using WTF::charactersToInt;
694 using WTF::charactersToUInt; 695 using WTF::charactersToUInt;
695 using WTF::charactersToInt64; 696 using WTF::charactersToInt64;
696 using WTF::charactersToUInt64; 697 using WTF::charactersToUInt64;
697 using WTF::charactersToIntPtr; 698 using WTF::charactersToIntPtr;
698 using WTF::charactersToDouble; 699 using WTF::charactersToDouble;
699 using WTF::charactersToFloat; 700 using WTF::charactersToFloat;
700 using WTF::equal; 701 using WTF::equal;
701 using WTF::equalIgnoringCase; 702 using WTF::equalIgnoringCase;
702 using WTF::find; 703 using WTF::find;
703 using WTF::isAllSpecialCharacters; 704 using WTF::isAllSpecialCharacters;
704 using WTF::isSpaceOrNewline; 705 using WTF::isSpaceOrNewline;
705 using WTF::reverseFind; 706 using WTF::reverseFind;
706 707
707 #include "wtf/text/AtomicString.h" 708 #include "wtf/text/AtomicString.h"
708 #endif 709 #endif
OLDNEW
« no previous file with comments | « Source/wtf/text/AtomicString.h ('k') | Source/wtf/text/WTFString.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698