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

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

Issue 17448012: Add SkString::appendU32() and SkString::appendU64() (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: add_cornercase_test_that_works_now 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 | « 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 } 52 }
53 53
54 static inline char *SkStrDup(const char string[]) { 54 static inline char *SkStrDup(const char string[]) {
55 char *ret = (char *) sk_malloc_throw(strlen(string)+1); 55 char *ret = (char *) sk_malloc_throw(strlen(string)+1);
56 memcpy(ret,string,strlen(string)+1); 56 memcpy(ret,string,strlen(string)+1);
57 return ret; 57 return ret;
58 } 58 }
59 59
60 60
61 61
62 #define SkStrAppendS32_MaxSize 11 62 #define SkStrAppendU32_MaxSize 10
63 char* SkStrAppendU32(char buffer[], int32_t);
64 #define SkStrAppendU64_MaxSize 20
65 char* SkStrAppendU64(char buffer[], int64_t, int minDigits);
66
67 #define SkStrAppendS32_MaxSize (SkStrAppendU32_MaxSize + 1)
63 char* SkStrAppendS32(char buffer[], int32_t); 68 char* SkStrAppendS32(char buffer[], int32_t);
64 #define SkStrAppendS64_MaxSize 20 69 #define SkStrAppendS64_MaxSize (SkStrAppendU64_MaxSize + 1)
65 char* SkStrAppendS64(char buffer[], int64_t, int minDigits); 70 char* SkStrAppendS64(char buffer[], int64_t, int minDigits);
66 71
67 /** 72 /**
68 * Floats have at most 8 significant digits, so we limit our %g to that. 73 * Floats have at most 8 significant digits, so we limit our %g to that.
69 * However, the total string could be 15 characters: -1.2345678e-005 74 * However, the total string could be 15 characters: -1.2345678e-005
70 * 75 *
71 * In theory we should only expect up to 2 digits for the exponent, but on 76 * In theory we should only expect up to 2 digits for the exponent, but on
72 * some platforms we have seen 3 (as in the example above). 77 * some platforms we have seen 3 (as in the example above).
73 */ 78 */
74 #define SkStrAppendScalar_MaxSize 15 79 #define SkStrAppendScalar_MaxSize 15
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 void set(const char text[], size_t len); 162 void set(const char text[], size_t len);
158 void setUTF16(const uint16_t[]); 163 void setUTF16(const uint16_t[]);
159 void setUTF16(const uint16_t[], size_t len); 164 void setUTF16(const uint16_t[], size_t len);
160 165
161 void insert(size_t offset, const SkString& src) { this->insert(offset, src.c _str(), src.size()); } 166 void insert(size_t offset, const SkString& src) { this->insert(offset, src.c _str(), src.size()); }
162 void insert(size_t offset, const char text[]); 167 void insert(size_t offset, const char text[]);
163 void insert(size_t offset, const char text[], size_t len); 168 void insert(size_t offset, const char text[], size_t len);
164 void insertUnichar(size_t offset, SkUnichar); 169 void insertUnichar(size_t offset, SkUnichar);
165 void insertS32(size_t offset, int32_t value); 170 void insertS32(size_t offset, int32_t value);
166 void insertS64(size_t offset, int64_t value, int minDigits = 0); 171 void insertS64(size_t offset, int64_t value, int minDigits = 0);
172 void insertU32(size_t offset, uint32_t value);
173 void insertU64(size_t offset, uint64_t value, int minDigits = 0);
167 void insertHex(size_t offset, uint32_t value, int minDigits = 0); 174 void insertHex(size_t offset, uint32_t value, int minDigits = 0);
168 void insertScalar(size_t offset, SkScalar); 175 void insertScalar(size_t offset, SkScalar);
169 176
170 void append(const SkString& str) { this->insert((size_t)-1, str); } 177 void append(const SkString& str) { this->insert((size_t)-1, str); }
171 void append(const char text[]) { this->insert((size_t)-1, text); } 178 void append(const char text[]) { this->insert((size_t)-1, text); }
172 void append(const char text[], size_t len) { this->insert((size_t)-1, text, len); } 179 void append(const char text[], size_t len) { this->insert((size_t)-1, text, len); }
173 void appendUnichar(SkUnichar uni) { this->insertUnichar((size_t)-1, uni); } 180 void appendUnichar(SkUnichar uni) { this->insertUnichar((size_t)-1, uni); }
174 void appendS32(int32_t value) { this->insertS32((size_t)-1, value); } 181 void appendS32(int32_t value) { this->insertS32((size_t)-1, value); }
175 void appendS64(int64_t value, int minDigits = 0) { this->insertS64((size_t)- 1, value, minDigits); } 182 void appendS64(int64_t value, int minDigits = 0) { this->insertS64((size_t)- 1, value, minDigits); }
183 void appendU32(uint32_t value) { this->insertU32((size_t)-1, value); }
184 void appendU64(uint64_t value, int minDigits = 0) { this->insertU64((size_t) -1, value, minDigits); }
176 void appendHex(uint32_t value, int minDigits = 0) { this->insertHex((size_t) -1, value, minDigits); } 185 void appendHex(uint32_t value, int minDigits = 0) { this->insertHex((size_t) -1, value, minDigits); }
177 void appendScalar(SkScalar value) { this->insertScalar((size_t)-1, value); } 186 void appendScalar(SkScalar value) { this->insertScalar((size_t)-1, value); }
178 187
179 void prepend(const SkString& str) { this->insert(0, str); } 188 void prepend(const SkString& str) { this->insert(0, str); }
180 void prepend(const char text[]) { this->insert(0, text); } 189 void prepend(const char text[]) { this->insert(0, text); }
181 void prepend(const char text[], size_t len) { this->insert(0, text, len); } 190 void prepend(const char text[], size_t len) { this->insert(0, text, len); }
182 void prependUnichar(SkUnichar uni) { this->insertUnichar(0, uni); } 191 void prependUnichar(SkUnichar uni) { this->insertUnichar(0, uni); }
183 void prependS32(int32_t value) { this->insertS32(0, value); } 192 void prependS32(int32_t value) { this->insertS32(0, value); }
184 void prependS64(int32_t value, int minDigits = 0) { this->insertS64(0, value , minDigits); } 193 void prependS64(int32_t value, int minDigits = 0) { this->insertS64(0, value , minDigits); }
185 void prependHex(uint32_t value, int minDigits = 0) { this->insertHex(0, valu e, minDigits); } 194 void prependHex(uint32_t value, int minDigits = 0) { this->insertHex(0, valu e, minDigits); }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 /// Creates a new string and writes into it using a printf()-style format. 256 /// Creates a new string and writes into it using a printf()-style format.
248 SkString SkStringPrintf(const char* format, ...); 257 SkString SkStringPrintf(const char* format, ...);
249 258
250 // Specialized to take advantage of SkString's fast swap path. The unspecialized function is 259 // Specialized to take advantage of SkString's fast swap path. The unspecialized function is
251 // declared in SkTypes.h and called by SkTSort. 260 // declared in SkTypes.h and called by SkTSort.
252 template <> inline void SkTSwap(SkString& a, SkString& b) { 261 template <> inline void SkTSwap(SkString& a, SkString& b) {
253 a.swap(b); 262 a.swap(b);
254 } 263 }
255 264
256 #endif 265 #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