| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |