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

Side by Side Diff: include/core/SkString.h

Issue 1672123002: Make SkString movable. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Don't need 'this' on 'f' fields. Created 4 years, 10 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
« no previous file with comments | « no previous file | src/core/SkString.cpp » ('j') | 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 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #ifndef SkString_DEFINED 10 #ifndef SkString_DEFINED
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 counting to make string assignments and copies very fast 119 counting to make string assignments and copies very fast
120 with no extra RAM cost. Assumes UTF8 encoding. 120 with no extra RAM cost. Assumes UTF8 encoding.
121 */ 121 */
122 class SK_API SkString { 122 class SK_API SkString {
123 public: 123 public:
124 SkString(); 124 SkString();
125 explicit SkString(size_t len); 125 explicit SkString(size_t len);
126 explicit SkString(const char text[]); 126 explicit SkString(const char text[]);
127 SkString(const char text[], size_t len); 127 SkString(const char text[], size_t len);
128 SkString(const SkString&); 128 SkString(const SkString&);
129 SkString(SkString&&);
129 ~SkString(); 130 ~SkString();
130 131
131 bool isEmpty() const { return 0 == fRec->fLength; } 132 bool isEmpty() const { return 0 == fRec->fLength; }
132 size_t size() const { return (size_t) fRec->fLength; } 133 size_t size() const { return (size_t) fRec->fLength; }
133 const char* c_str() const { return fRec->data(); } 134 const char* c_str() const { return fRec->data(); }
134 char operator[](size_t n) const { return this->c_str()[n]; } 135 char operator[](size_t n) const { return this->c_str()[n]; }
135 136
136 bool equals(const SkString&) const; 137 bool equals(const SkString&) const;
137 bool equals(const char text[]) const; 138 bool equals(const char text[]) const;
138 bool equals(const char text[], size_t len) const; 139 bool equals(const char text[], size_t len) const;
(...skipping 26 matching lines...) Expand all
165 friend bool operator==(const SkString& a, const SkString& b) { 166 friend bool operator==(const SkString& a, const SkString& b) {
166 return a.equals(b); 167 return a.equals(b);
167 } 168 }
168 friend bool operator!=(const SkString& a, const SkString& b) { 169 friend bool operator!=(const SkString& a, const SkString& b) {
169 return !a.equals(b); 170 return !a.equals(b);
170 } 171 }
171 172
172 // these methods edit the string 173 // these methods edit the string
173 174
174 SkString& operator=(const SkString&); 175 SkString& operator=(const SkString&);
176 SkString& operator=(SkString&&);
175 SkString& operator=(const char text[]); 177 SkString& operator=(const char text[]);
176 178
177 char* writable_str(); 179 char* writable_str();
178 char& operator[](size_t n) { return this->writable_str()[n]; } 180 char& operator[](size_t n) { return this->writable_str()[n]; }
179 181
180 void reset(); 182 void reset();
181 /** Destructive resize, does not preserve contents. */ 183 /** Destructive resize, does not preserve contents. */
182 void resize(size_t len) { this->set(NULL, len); } 184 void resize(size_t len) { this->set(NULL, len); }
183 void set(const SkString& src) { *this = src; } 185 void set(const SkString& src) { *this = src; }
184 void set(const char text[]); 186 void set(const char text[]);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 }; 281 };
280 282
281 // Split str on any characters in delimiters into out. (Think, strtok with a sa ne API.) 283 // Split str on any characters in delimiters into out. (Think, strtok with a sa ne API.)
282 void SkStrSplit(const char* str, const char* delimiters, SkStrSplitMode splitMod e, 284 void SkStrSplit(const char* str, const char* delimiters, SkStrSplitMode splitMod e,
283 SkTArray<SkString>* out); 285 SkTArray<SkString>* out);
284 inline void SkStrSplit(const char* str, const char* delimiters, SkTArray<SkStrin g>* out) { 286 inline void SkStrSplit(const char* str, const char* delimiters, SkTArray<SkStrin g>* out) {
285 SkStrSplit(str, delimiters, kCoalesce_SkStrSplitMode, out); 287 SkStrSplit(str, delimiters, kCoalesce_SkStrSplitMode, out);
286 } 288 }
287 289
288 #endif 290 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkString.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698