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

Side by Side Diff: public/platform/WebString.h

Issue 15806014: Reduce usage of WebString::data (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 months 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 | Annotate | Revision Log
« no previous file with comments | « Tools/DumpRenderTree/chromium/TestRunner/src/SpellCheckClient.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 71
72 WEBKIT_EXPORT void reset(); 72 WEBKIT_EXPORT void reset();
73 WEBKIT_EXPORT void assign(const WebString&); 73 WEBKIT_EXPORT void assign(const WebString&);
74 WEBKIT_EXPORT void assign(const WebUChar* data, size_t len); 74 WEBKIT_EXPORT void assign(const WebUChar* data, size_t len);
75 75
76 WEBKIT_EXPORT bool equals(const WebString& s) const; 76 WEBKIT_EXPORT bool equals(const WebString& s) const;
77 77
78 WEBKIT_EXPORT size_t length() const; 78 WEBKIT_EXPORT size_t length() const;
79 WEBKIT_EXPORT const WebUChar* data() const; 79 WEBKIT_EXPORT const WebUChar* data() const;
80 80
81 // Caller must check bounds.
82 WEBKIT_EXPORT WebUChar at(unsigned) const;
83
81 bool isEmpty() const { return !length(); } 84 bool isEmpty() const { return !length(); }
82 bool isNull() const { return !m_private; } 85 bool isNull() const { return !m_private; }
83 86
84 WEBKIT_EXPORT WebCString utf8() const; 87 WEBKIT_EXPORT WebCString utf8() const;
85 88
86 WEBKIT_EXPORT static WebString fromUTF8(const char* data, size_t length); 89 WEBKIT_EXPORT static WebString fromUTF8(const char* data, size_t length);
87 WEBKIT_EXPORT static WebString fromUTF8(const char* data); 90 WEBKIT_EXPORT static WebString fromUTF8(const char* data);
88 91
89 template <int N> WebString(const char (&data)[N]) 92 template <int N> WebString(const char (&data)[N])
90 : m_private(0) 93 : m_private(0)
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 155
153 template <class UTF8String> 156 template <class UTF8String>
154 static WebString fromUTF8(const UTF8String& s) 157 static WebString fromUTF8(const UTF8String& s)
155 { 158 {
156 return fromUTF8(s.data(), s.length()); 159 return fromUTF8(s.data(), s.length());
157 } 160 }
158 #endif 161 #endif
159 162
160 private: 163 private:
161 void assign(WebStringPrivate*); 164 void assign(WebStringPrivate*);
165
162 WebStringPrivate* m_private; 166 WebStringPrivate* m_private;
163 }; 167 };
164 168
165 inline bool operator==(const WebString& a, const WebString& b) 169 inline bool operator==(const WebString& a, const WebString& b)
166 { 170 {
167 return a.equals(b); 171 return a.equals(b);
168 } 172 }
169 173
170 inline bool operator!=(const WebString& a, const WebString& b) 174 inline bool operator!=(const WebString& a, const WebString& b)
171 { 175 {
172 return !(a == b); 176 return !(a == b);
173 } 177 }
174 178
175 } // namespace WebKit 179 } // namespace WebKit
176 180
177 #endif 181 #endif
OLDNEW
« no previous file with comments | « Tools/DumpRenderTree/chromium/TestRunner/src/SpellCheckClient.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698