diff options
author | Ben Murdoch <benm@google.com> | 2011-05-24 11:24:40 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-06-02 09:53:15 +0100 |
commit | 81bc750723a18f21cd17d1b173cd2a4dda9cea6e (patch) | |
tree | 7a9e5ed86ff429fd347a25153107221543909b19 /Source/JavaScriptCore/wtf/text/WTFString.h | |
parent | 94088a6d336c1dd80a1e734af51e96abcbb689a7 (diff) | |
download | external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.zip external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.gz external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.bz2 |
Merge WebKit at r80534: Intial merge by Git
Change-Id: Ia7a83357124c9e1cdb1debf55d9661ec0bd09a61
Diffstat (limited to 'Source/JavaScriptCore/wtf/text/WTFString.h')
-rw-r--r-- | Source/JavaScriptCore/wtf/text/WTFString.h | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/Source/JavaScriptCore/wtf/text/WTFString.h b/Source/JavaScriptCore/wtf/text/WTFString.h index 0aee2ef..713a6c3 100644 --- a/Source/JavaScriptCore/wtf/text/WTFString.h +++ b/Source/JavaScriptCore/wtf/text/WTFString.h @@ -31,7 +31,7 @@ #include <objc/objc.h> #endif -#if PLATFORM(CF) +#if USE(CF) typedef const struct __CFString * CFStringRef; #endif @@ -79,8 +79,8 @@ int64_t charactersToInt64(const UChar*, size_t, bool* ok = 0); // ignores traili uint64_t charactersToUInt64(const UChar*, size_t, bool* ok = 0); // ignores trailing garbage intptr_t charactersToIntPtr(const UChar*, size_t, bool* ok = 0); // ignores trailing garbage -double charactersToDouble(const UChar*, size_t, bool* ok = 0); -float charactersToFloat(const UChar*, size_t, bool* ok = 0); +double charactersToDouble(const UChar*, size_t, bool* ok = 0, bool* didReadNumber = 0); +float charactersToFloat(const UChar*, size_t, bool* ok = 0, bool* didReadNumber = 0); template<bool isSpecialCharacter(UChar)> bool isAllSpecialCharacters(const UChar*, size_t); @@ -92,6 +92,11 @@ public: // Construct a string with UTF-16 data. String(const UChar* characters, unsigned length); + // Construct a string by copying the contents of a vector. To avoid + // copying, consider using String::adopt instead. + template<size_t inlineCapacity> + explicit String(const Vector<UChar, inlineCapacity>&); + // Construct a string with UTF-16 data, from a null-terminated source. String(const UChar*); @@ -264,8 +269,8 @@ public: int64_t toInt64(bool* ok = 0) const; uint64_t toUInt64(bool* ok = 0) const; intptr_t toIntPtr(bool* ok = 0) const; - double toDouble(bool* ok = 0) const; - float toFloat(bool* ok = 0) const; + double toDouble(bool* ok = 0, bool* didReadNumber = 0) const; + float toFloat(bool* ok = 0, bool* didReadNumber = 0) const; bool percentage(int& percentage) const; @@ -284,7 +289,7 @@ public: operator UnspecifiedBoolTypeA() const; operator UnspecifiedBoolTypeB() const; -#if PLATFORM(CF) +#if USE(CF) String(CFStringRef); CFStringRef createCFString() const; #endif @@ -326,7 +331,14 @@ public: static String fromUTF8WithLatin1Fallback(const char*, size_t); // Determines the writing direction using the Unicode Bidi Algorithm rules P2 and P3. - WTF::Unicode::Direction defaultWritingDirection() const { return m_impl ? m_impl->defaultWritingDirection() : WTF::Unicode::LeftToRight; } + WTF::Unicode::Direction defaultWritingDirection(bool* hasStrongDirectionality = 0) const + { + if (m_impl) + return m_impl->defaultWritingDirection(hasStrongDirectionality); + if (hasStrongDirectionality) + *hasStrongDirectionality = false; + return WTF::Unicode::LeftToRight; + } bool containsOnlyASCII() const { return charactersAreAllASCII(characters(), length()); } bool containsOnlyLatin1() const { return charactersAreAllLatin1(characters(), length()); } @@ -378,6 +390,12 @@ inline void swap(String& a, String& b) { a.swap(b); } // Definitions of string operations +template<size_t inlineCapacity> +String::String(const Vector<UChar, inlineCapacity>& vector) + : m_impl(vector.size() ? StringImpl::create(vector.data(), vector.size()) : 0) +{ +} + #ifdef __OBJC__ // This is for situations in WebKit where the long standing behavior has been // "nil if empty", so we try to maintain longstanding behavior for the sake of |