| OLD | NEW |
| 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, 2010, 2012 Apple Inc. All rights | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010, 2012 Apple Inc. All rights |
| 4 * reserved. | 4 * reserved. |
| 5 * Copyright (C) 2007-2009 Torch Mobile, Inc. | 5 * Copyright (C) 2007-2009 Torch Mobile, Inc. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 | 244 |
| 245 void String::ensure16Bit() { | 245 void String::ensure16Bit() { |
| 246 if (isNull()) | 246 if (isNull()) |
| 247 return; | 247 return; |
| 248 if (!is8Bit()) | 248 if (!is8Bit()) |
| 249 return; | 249 return; |
| 250 if (unsigned length = this->length()) | 250 if (unsigned length = this->length()) |
| 251 m_impl = | 251 m_impl = |
| 252 make16BitFrom8BitSource(m_impl->characters8(), length).releaseImpl(); | 252 make16BitFrom8BitSource(m_impl->characters8(), length).releaseImpl(); |
| 253 else | 253 else |
| 254 m_impl = StringImpl::empty16Bit(); | 254 m_impl = StringImpl::empty16Bit; |
| 255 } | 255 } |
| 256 | 256 |
| 257 void String::truncate(unsigned length) { | 257 void String::truncate(unsigned length) { |
| 258 if (m_impl) | 258 if (m_impl) |
| 259 m_impl = m_impl->truncate(length); | 259 m_impl = m_impl->truncate(length); |
| 260 } | 260 } |
| 261 | 261 |
| 262 void String::remove(unsigned start, unsigned lengthToRemove) { | 262 void String::remove(unsigned start, unsigned lengthToRemove) { |
| 263 if (m_impl) | 263 if (m_impl) |
| 264 m_impl = m_impl->remove(start, lengthToRemove); | 264 m_impl = m_impl->remove(start, lengthToRemove); |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 } | 769 } |
| 770 | 770 |
| 771 String String::fromUTF8WithLatin1Fallback(const LChar* string, size_t size) { | 771 String String::fromUTF8WithLatin1Fallback(const LChar* string, size_t size) { |
| 772 String utf8 = fromUTF8(string, size); | 772 String utf8 = fromUTF8(string, size); |
| 773 if (!utf8) | 773 if (!utf8) |
| 774 return String(string, size); | 774 return String(string, size); |
| 775 return utf8; | 775 return utf8; |
| 776 } | 776 } |
| 777 | 777 |
| 778 const String& emptyString() { | 778 const String& emptyString() { |
| 779 DEFINE_STATIC_LOCAL(String, emptyString, (StringImpl::empty())); | 779 DEFINE_STATIC_LOCAL(String, emptyString, (StringImpl::empty)); |
| 780 return emptyString; | 780 return emptyString; |
| 781 } | 781 } |
| 782 | 782 |
| 783 const String& emptyString16Bit() { | 783 const String& emptyString16Bit() { |
| 784 DEFINE_STATIC_LOCAL(String, emptyString, (StringImpl::empty16Bit())); | 784 DEFINE_STATIC_LOCAL(String, emptyString, (StringImpl::empty16Bit)); |
| 785 return emptyString; | 785 return emptyString; |
| 786 } | 786 } |
| 787 | 787 |
| 788 std::ostream& operator<<(std::ostream& out, const String& string) { | 788 std::ostream& operator<<(std::ostream& out, const String& string) { |
| 789 if (string.isNull()) | 789 if (string.isNull()) |
| 790 return out << "<null>"; | 790 return out << "<null>"; |
| 791 | 791 |
| 792 out << '"'; | 792 out << '"'; |
| 793 for (unsigned index = 0; index < string.length(); ++index) { | 793 for (unsigned index = 0; index < string.length(); ++index) { |
| 794 // Print shorthands for select cases. | 794 // Print shorthands for select cases. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 return out << '"'; | 827 return out << '"'; |
| 828 } | 828 } |
| 829 | 829 |
| 830 #ifndef NDEBUG | 830 #ifndef NDEBUG |
| 831 void String::show() const { | 831 void String::show() const { |
| 832 dataLogF("%s\n", asciiDebug(impl()).data()); | 832 dataLogF("%s\n", asciiDebug(impl()).data()); |
| 833 } | 833 } |
| 834 #endif | 834 #endif |
| 835 | 835 |
| 836 } // namespace WTF | 836 } // namespace WTF |
| OLD | NEW |