OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010 Apple Inc. All rights reserv
ed. | 3 * Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010 Apple Inc. All rights reserv
ed. |
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 unsigned length() const { return m_length; } | 74 unsigned length() const { return m_length; } |
75 | 75 |
76 UChar operator[](unsigned i) const | 76 UChar operator[](unsigned i) const |
77 { | 77 { |
78 ASSERT_WITH_SECURITY_IMPLICATION(i < m_length); | 78 ASSERT_WITH_SECURITY_IMPLICATION(i < m_length); |
79 if (is8Bit()) | 79 if (is8Bit()) |
80 return m_data.characters8[i]; | 80 return m_data.characters8[i]; |
81 return m_data.characters16[i]; | 81 return m_data.characters16[i]; |
82 } | 82 } |
83 | 83 |
84 bool equalIgnoringCase(const char* str) const | 84 template<unsigned matchLength> |
| 85 bool equalIgnoringASCIICase(const char (&match)[matchLength]) const |
85 { | 86 { |
86 bool match = is8Bit() ? WTF::equalIgnoringCase(str, characters8(), lengt
h()) : WTF::equalIgnoringCase(str, characters16(), length()); | 87 if (matchLength - 1 != length()) |
87 if (!match) | |
88 return false; | 88 return false; |
89 ASSERT(strlen(str) >= length()); | 89 return is8Bit() ? WTF::equalIgnoringASCIICase(characters8(), match, leng
th()) : WTF::equalIgnoringASCIICase(characters16(), match, length()); |
90 return str[length()] == '\0'; | |
91 } | 90 } |
92 | 91 |
93 operator String() const { return is8Bit() ? String(m_data.characters8, m_len
gth) : StringImpl::create8BitIfPossible(m_data.characters16, m_length); } | 92 operator String() const { return is8Bit() ? String(m_data.characters8, m_len
gth) : StringImpl::create8BitIfPossible(m_data.characters16, m_length); } |
94 operator AtomicString() const { return is8Bit() ? AtomicString(m_data.charac
ters8, m_length) : AtomicString(m_data.characters16, m_length); } | 93 operator AtomicString() const { return is8Bit() ? AtomicString(m_data.charac
ters8, m_length) : AtomicString(m_data.characters16, m_length); } |
95 | 94 |
96 union { | 95 union { |
97 const LChar* characters8; | 96 const LChar* characters8; |
98 const UChar* characters16; | 97 const UChar* characters16; |
99 const void* charactersRaw; | 98 const void* charactersRaw; |
100 } m_data; | 99 } m_data; |
101 unsigned m_length; | 100 unsigned m_length; |
102 bool m_is8Bit; | 101 bool m_is8Bit; |
103 }; | 102 }; |
104 | 103 |
105 } | 104 } |
106 | 105 |
107 #endif | 106 #endif |
OLD | NEW |