| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 tmp[1] = '\0'; | 51 tmp[1] = '\0'; |
| 52 return (-1 != SkStrFind(string, tmp)); | 52 return (-1 != SkStrFind(string, tmp)); |
| 53 } | 53 } |
| 54 | 54 |
| 55 static inline char *SkStrDup(const char string[]) { | 55 static inline char *SkStrDup(const char string[]) { |
| 56 char *ret = (char *) sk_malloc_throw(strlen(string)+1); | 56 char *ret = (char *) sk_malloc_throw(strlen(string)+1); |
| 57 memcpy(ret,string,strlen(string)+1); | 57 memcpy(ret,string,strlen(string)+1); |
| 58 return ret; | 58 return ret; |
| 59 } | 59 } |
| 60 | 60 |
| 61 | 61 /* |
| 62 * The SkStrAppend... methods will write into the provided buffer, assuming it
is large enough. |
| 63 * Each method has an associated const (e.g. SkStrAppendU32_MaxSize) which will
be the largest |
| 64 * value needed for that method's buffer. |
| 65 * |
| 66 * char storage[SkStrAppendU32_MaxSize]; |
| 67 * SkStrAppendU32(storage, value); |
| 68 * |
| 69 * Note : none of the SkStrAppend... methods write a terminating 0 to their buf
fers. Instead, |
| 70 * the methods return the ptr to the end of the written part of the buffer. Thi
s can be used |
| 71 * to compute the length, and/or know where to write a 0 if that is desired. |
| 72 * |
| 73 * char storage[SkStrAppendU32_MaxSize + 1]; |
| 74 * char* stop = SkStrAppendU32(storage, value); |
| 75 * size_t len = stop - storage; |
| 76 * *stop = 0; // valid, since storage was 1 byte larger than the max. |
| 77 */ |
| 62 | 78 |
| 63 #define SkStrAppendU32_MaxSize 10 | 79 #define SkStrAppendU32_MaxSize 10 |
| 64 char* SkStrAppendU32(char buffer[], uint32_t); | 80 char* SkStrAppendU32(char buffer[], uint32_t); |
| 65 #define SkStrAppendU64_MaxSize 20 | 81 #define SkStrAppendU64_MaxSize 20 |
| 66 char* SkStrAppendU64(char buffer[], uint64_t, int minDigits); | 82 char* SkStrAppendU64(char buffer[], uint64_t, int minDigits); |
| 67 | 83 |
| 68 #define SkStrAppendS32_MaxSize (SkStrAppendU32_MaxSize + 1) | 84 #define SkStrAppendS32_MaxSize (SkStrAppendU32_MaxSize + 1) |
| 69 char* SkStrAppendS32(char buffer[], int32_t); | 85 char* SkStrAppendS32(char buffer[], int32_t); |
| 70 #define SkStrAppendS64_MaxSize (SkStrAppendU64_MaxSize + 1) | 86 #define SkStrAppendS64_MaxSize (SkStrAppendU64_MaxSize + 1) |
| 71 char* SkStrAppendS64(char buffer[], int64_t, int minDigits); | 87 char* SkStrAppendS64(char buffer[], int64_t, int minDigits); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 // Specialized to take advantage of SkString's fast swap path. The unspecialized
function is | 255 // Specialized to take advantage of SkString's fast swap path. The unspecialized
function is |
| 240 // declared in SkTypes.h and called by SkTSort. | 256 // declared in SkTypes.h and called by SkTSort. |
| 241 template <> inline void SkTSwap(SkString& a, SkString& b) { | 257 template <> inline void SkTSwap(SkString& a, SkString& b) { |
| 242 a.swap(b); | 258 a.swap(b); |
| 243 } | 259 } |
| 244 | 260 |
| 245 // Split str on any characters in delimiters into out. (Think, strtok with a sa
ne API.) | 261 // Split str on any characters in delimiters into out. (Think, strtok with a sa
ne API.) |
| 246 void SkStrSplit(const char* str, const char* delimiters, SkTArray<SkString>* out
); | 262 void SkStrSplit(const char* str, const char* delimiters, SkTArray<SkString>* out
); |
| 247 | 263 |
| 248 #endif | 264 #endif |
| OLD | NEW |