Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef String16WTF_h | 5 #ifndef String16WTF_h |
| 6 #define String16WTF_h | 6 #define String16WTF_h |
| 7 | 7 |
| 8 #include "platform/Decimal.h" | 8 #include "platform/Decimal.h" |
| 9 #include "public/platform/WebString.h" | 9 #include "public/platform/WebString.h" |
| 10 #include "wtf/text/StringBuilder.h" | 10 #include "wtf/text/StringBuilder.h" |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 String16(const WTF::String& impl); | 32 String16(const WTF::String& impl); |
| 33 String16(WTF::HashTableDeletedValueType) : m_impl(WTF::HashTableDeletedValue ) { } | 33 String16(WTF::HashTableDeletedValueType) : m_impl(WTF::HashTableDeletedValue ) { } |
| 34 bool isHashTableDeletedValue() const { return m_impl.isHashTableDeletedValue (); } | 34 bool isHashTableDeletedValue() const { return m_impl.isHashTableDeletedValue (); } |
| 35 operator WTF::String() const { return m_impl; } | 35 operator WTF::String() const { return m_impl; } |
| 36 operator WebString() { return m_impl; } | 36 operator WebString() { return m_impl; } |
| 37 const WTF::String& impl() const { return m_impl; } | 37 const WTF::String& impl() const { return m_impl; } |
| 38 | 38 |
| 39 ~String16() { } | 39 ~String16() { } |
| 40 | 40 |
| 41 static String16 number(int i) { return String::number(i); } | 41 static String16 number(int i) { return String::number(i); } |
| 42 static String16 fromDouble(double number) { return Decimal::fromDouble(numbe r).toString(); } | 42 static String16 fromDouble(double number, int precision = -1) { return preci sion == -1 ? Decimal::fromDouble(number).toString() : String::numberToStringFixe dWidth(number, precision); } |
|
dgozman
2016/04/08 18:18:46
Let's do a separate method fromDoubleFixedWidth.
kozy
2016/04/08 23:56:51
Done.
| |
| 43 | 43 |
| 44 size_t length() const { return m_impl.length(); } | 44 size_t length() const { return m_impl.length(); } |
| 45 bool isEmpty() const { return m_impl.isEmpty(); } | 45 bool isEmpty() const { return m_impl.isEmpty(); } |
| 46 UChar operator[](unsigned index) const { return m_impl[index]; } | 46 UChar operator[](unsigned index) const { return m_impl[index]; } |
| 47 | 47 |
| 48 unsigned sizeInBytes() const { return m_impl.sizeInBytes(); } | 48 unsigned sizeInBytes() const { return m_impl.sizeInBytes(); } |
| 49 const UChar* characters16() const { return m_impl.isEmpty() ? nullptr : m_im pl.characters16(); } | 49 const UChar* characters16() const { return m_impl.isEmpty() ? nullptr : m_im pl.characters16(); } |
| 50 | 50 |
| 51 static double charactersToDouble(const LChar* characters, size_t length, boo l* ok = 0) { return ::charactersToDouble(characters, length, ok); } | 51 static double charactersToDouble(const LChar* characters, size_t length, boo l* ok = 0) { return ::charactersToDouble(characters, length, ok); } |
| 52 static double charactersToDouble(const UChar* characters, size_t length, boo l* ok = 0) { return ::charactersToDouble(characters, length, ok); } | 52 static double charactersToDouble(const UChar* characters, size_t length, boo l* ok = 0) { return ::charactersToDouble(characters, length, ok); } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 | 129 |
| 130 template<> | 130 template<> |
| 131 struct HashTraits<String16> : SimpleClassHashTraits<String16> { | 131 struct HashTraits<String16> : SimpleClassHashTraits<String16> { |
| 132 static const bool hasIsEmptyValueFunction = true; | 132 static const bool hasIsEmptyValueFunction = true; |
| 133 static bool isEmptyValue(const String16& a) { return a.impl().isNull(); } | 133 static bool isEmptyValue(const String16& a) { return a.impl().isNull(); } |
| 134 }; | 134 }; |
| 135 | 135 |
| 136 } // namespace WTF | 136 } // namespace WTF |
| 137 | 137 |
| 138 #endif // !defined(String16WTF_h) | 138 #endif // !defined(String16WTF_h) |
| OLD | NEW |