OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. All rights
reserved. | 3 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. All rights
reserved. |
4 * Copyright (C) 2009 Google Inc. All rights reserved. | 4 * Copyright (C) 2009 Google Inc. All rights reserved. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 #ifndef StringImpl_h | 23 #ifndef StringImpl_h |
24 #define StringImpl_h | 24 #define StringImpl_h |
25 | 25 |
26 #include "wtf/ASCIICType.h" | 26 #include "wtf/ASCIICType.h" |
27 #include "wtf/Forward.h" | 27 #include "wtf/Forward.h" |
28 #include "wtf/HashMap.h" | 28 #include "wtf/HashMap.h" |
29 #include "wtf/StringHasher.h" | 29 #include "wtf/StringHasher.h" |
30 #include "wtf/Vector.h" | 30 #include "wtf/Vector.h" |
31 #include "wtf/WTFExport.h" | 31 #include "wtf/WTFExport.h" |
| 32 #include "wtf/text/StringView.h" |
32 #include "wtf/text/Unicode.h" | 33 #include "wtf/text/Unicode.h" |
33 #include <limits.h> | 34 #include <limits.h> |
34 | 35 |
35 #if OS(MACOSX) | 36 #if OS(MACOSX) |
36 typedef const struct __CFString * CFStringRef; | 37 typedef const struct __CFString * CFStringRef; |
37 #endif | 38 #endif |
38 | 39 |
39 #ifdef __OBJC__ | 40 #ifdef __OBJC__ |
40 @class NSString; | 41 @class NSString; |
41 #endif | 42 #endif |
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 return c <= 0x7F ? WTF::isASCIISpace(c) : WTF::Unicode::direction(c) == WTF:
:Unicode::WhiteSpaceNeutral; | 737 return c <= 0x7F ? WTF::isASCIISpace(c) : WTF::Unicode::direction(c) == WTF:
:Unicode::WhiteSpaceNeutral; |
737 } | 738 } |
738 | 739 |
739 inline PassRefPtr<StringImpl> StringImpl::isolatedCopy() const | 740 inline PassRefPtr<StringImpl> StringImpl::isolatedCopy() const |
740 { | 741 { |
741 if (is8Bit()) | 742 if (is8Bit()) |
742 return create(characters8(), m_length); | 743 return create(characters8(), m_length); |
743 return create(characters16(), m_length); | 744 return create(characters16(), m_length); |
744 } | 745 } |
745 | 746 |
| 747 inline void StringView::set(StringImpl& impl, unsigned offset, unsigned length) |
| 748 { |
| 749 SECURITY_DCHECK(offset + length <= impl.length()); |
| 750 m_length = length; |
| 751 m_is8Bit = impl.is8Bit(); |
| 752 if (m_is8Bit) |
| 753 m_data.characters8 = impl.characters8() + offset; |
| 754 else |
| 755 m_data.characters16 = impl.characters16() + offset; |
| 756 } |
| 757 |
| 758 inline StringView::StringView(StringImpl* impl) |
| 759 { |
| 760 impl ? set(*impl, 0, impl->length()) : clear(); |
| 761 } |
| 762 |
| 763 inline StringView::StringView(StringImpl* impl, unsigned offset) |
| 764 { |
| 765 impl ? set(*impl, offset, impl->length()) : clear(); |
| 766 } |
| 767 |
| 768 inline StringView::StringView(StringImpl* impl, unsigned offset, unsigned length
) |
| 769 { |
| 770 impl ? set(*impl, offset, length) : clear(); |
| 771 } |
| 772 |
746 // TODO(rob.buis) possibly find a better place for this method. | 773 // TODO(rob.buis) possibly find a better place for this method. |
747 // Turns a UChar32 to uppercase based on localeIdentifier. | 774 // Turns a UChar32 to uppercase based on localeIdentifier. |
748 WTF_EXPORT UChar32 toUpper(UChar32, const AtomicString& localeIdentifier); | 775 WTF_EXPORT UChar32 toUpper(UChar32, const AtomicString& localeIdentifier); |
749 | 776 |
750 struct StringHash; | 777 struct StringHash; |
751 | 778 |
752 // StringHash is the default hash for StringImpl* and RefPtr<StringImpl> | 779 // StringHash is the default hash for StringImpl* and RefPtr<StringImpl> |
753 template<typename T> struct DefaultHash; | 780 template<typename T> struct DefaultHash; |
754 template<> struct DefaultHash<StringImpl*> { | 781 template<> struct DefaultHash<StringImpl*> { |
755 typedef StringHash Hash; | 782 typedef StringHash Hash; |
756 }; | 783 }; |
757 template<> struct DefaultHash<RefPtr<StringImpl>> { | 784 template<> struct DefaultHash<RefPtr<StringImpl>> { |
758 typedef StringHash Hash; | 785 typedef StringHash Hash; |
759 }; | 786 }; |
760 | 787 |
761 } // namespace WTF | 788 } // namespace WTF |
762 | 789 |
763 using WTF::StringImpl; | 790 using WTF::StringImpl; |
764 using WTF::equal; | 791 using WTF::equal; |
765 using WTF::equalNonNull; | 792 using WTF::equalNonNull; |
766 using WTF::TextCaseSensitivity; | 793 using WTF::TextCaseSensitivity; |
767 using WTF::TextCaseSensitive; | 794 using WTF::TextCaseSensitive; |
768 using WTF::TextCaseASCIIInsensitive; | 795 using WTF::TextCaseASCIIInsensitive; |
769 using WTF::TextCaseInsensitive; | 796 using WTF::TextCaseInsensitive; |
770 | 797 |
771 #endif | 798 #endif |
OLD | NEW |