Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1228)

Side by Side Diff: third_party/WebKit/Source/wtf/text/StringView.h

Issue 2500723002: Add UTF-16 string literal constructors to String classes (Closed)
Patch Set: esprehn nit (cstr -> chars) Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 WTF_StringView_h 5 #ifndef WTF_StringView_h
6 #define WTF_StringView_h 6 #define WTF_StringView_h
7 7
8 #include "wtf/Allocator.h" 8 #include "wtf/Allocator.h"
9 #include "wtf/GetPtr.h" 9 #include "wtf/GetPtr.h"
10 #if DCHECK_IS_ON() 10 #if DCHECK_IS_ON()
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 chars ? strlen(reinterpret_cast<const char*>(chars)) : 0) {} 76 chars ? strlen(reinterpret_cast<const char*>(chars)) : 0) {}
77 StringView(const char* chars) 77 StringView(const char* chars)
78 : StringView(reinterpret_cast<const LChar*>(chars)) {} 78 : StringView(reinterpret_cast<const LChar*>(chars)) {}
79 79
80 // From a wide literal string or UChar buffer. 80 // From a wide literal string or UChar buffer.
81 StringView(const UChar* chars, unsigned length) 81 StringView(const UChar* chars, unsigned length)
82 : m_impl(StringImpl::empty16Bit()), 82 : m_impl(StringImpl::empty16Bit()),
83 m_characters16(chars), 83 m_characters16(chars),
84 m_length(length) {} 84 m_length(length) {}
85 StringView(const UChar* chars); 85 StringView(const UChar* chars);
86 StringView(const char16_t* chars)
87 : StringView(reinterpret_cast<const UChar*>(chars)) {}
86 88
87 #if DCHECK_IS_ON() 89 #if DCHECK_IS_ON()
88 ~StringView(); 90 ~StringView();
89 #endif 91 #endif
90 92
91 bool isNull() const { return !m_bytes; } 93 bool isNull() const { return !m_bytes; }
92 bool isEmpty() const { return !m_length; } 94 bool isEmpty() const { return !m_length; }
93 95
94 unsigned length() const { return m_length; } 96 unsigned length() const { return m_length; }
95 97
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 return !(a == b); 234 return !(a == b);
233 } 235 }
234 236
235 } // namespace WTF 237 } // namespace WTF
236 238
237 using WTF::StringView; 239 using WTF::StringView;
238 using WTF::equalIgnoringASCIICase; 240 using WTF::equalIgnoringASCIICase;
239 using WTF::equalIgnoringCase; 241 using WTF::equalIgnoringCase;
240 242
241 #endif 243 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698