Go to the source code of this file.
|
#define | SizeOfRec() (gEmptyRec.data() - (const char*)&gEmptyRec) |
|
|
template<int SIZE> |
static StringBuffer | apply_format_string (const char *format, va_list args, char(&stackBuffer)[SIZE], SkString *heapBuffer) SK_PRINTF_LIKE(1 |
|
template<int SIZE> |
static StringBuffer static StringBuffer | apply_format_string (const char *format, va_list args, char(&stackBuffer)[SIZE], SkString *heapBuffer) |
|
bool | SkStrEndsWith (const char string[], const char suffixStr[]) |
|
bool | SkStrEndsWith (const char string[], const char suffixChar) |
|
int | SkStrStartsWithOneOf (const char string[], const char prefixes[]) |
|
char * | SkStrAppendU32 (char string[], uint32_t dec) |
|
char * | SkStrAppendS32 (char string[], int32_t dec) |
|
char * | SkStrAppendU64 (char string[], uint64_t dec, int minDigits) |
|
char * | SkStrAppendS64 (char string[], int64_t dec, int minDigits) |
|
char * | SkStrAppendScalar (char string[], SkScalar value) |
|
static uint32_t | trim_size_t_to_u32 (size_t value) |
|
static size_t | check_add32 (size_t base, size_t extra) |
|
SkString | SkStringPrintf (const char *format,...) |
|
◆ SizeOfRec
#define SizeOfRec |
( |
| ) |
(gEmptyRec.data() - (const char*)&gEmptyRec) |
◆ apply_format_string() [1/2]
Definition at line 39 of file SkString.cpp.
40 {
41
42 va_list argsCopy;
43 va_copy(argsCopy,
args);
45 if (outLength < 0) {
46 SkDebugf(
"SkString: vsnprintf reported error.");
48 return {stackBuffer, 0};
49 }
50 if (outLength <
SIZE) {
52 return {stackBuffer, outLength};
53 }
54
55
56
57
58 heapBuffer->
set(
nullptr, outLength);
59 char* heapBufferDest = heapBuffer->
data();
62 va_end(argsCopy);
63 return {heapBufferDest, outLength};
64}
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
const char * data() const
void set(const SkString &src)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
uint32_t uint32_t * format
◆ apply_format_string() [2/2]
static StringBuffer apply_format_string |
( |
const char * |
format, |
|
|
va_list |
args, |
|
|
char(&) |
stackBuffer[SIZE], |
|
|
SkString * |
heapBuffer |
|
) |
| |
|
static |
◆ check_add32()
static size_t check_add32 |
( |
size_t |
base, |
|
|
size_t |
extra |
|
) |
| |
|
static |
Definition at line 206 of file SkString.cpp.
206 {
208 if (sizeof(size_t) > sizeof(uint32_t)) {
209 if (
base + extra > UINT32_MAX) {
210 extra = UINT32_MAX -
base;
211 }
212 }
213 return extra;
214}
◆ SkStrAppendS32()
char * SkStrAppendS32 |
( |
char |
string[], |
|
|
int32_t |
dec |
|
) |
| |
Definition at line 120 of file SkString.cpp.
120 {
121 uint32_t udec = dec;
122 if (dec < 0) {
123 *string++ = '-';
124 udec = ~udec + 1;
125 }
127}
char * SkStrAppendU32(char string[], uint32_t dec)
◆ SkStrAppendS64()
char * SkStrAppendS64 |
( |
char |
string[], |
|
|
int64_t |
dec, |
|
|
int |
minDigits |
|
) |
| |
Definition at line 155 of file SkString.cpp.
155 {
156 uint64_t udec = dec;
157 if (dec < 0) {
158 *string++ = '-';
159 udec = ~udec + 1;
160 }
162}
char * SkStrAppendU64(char string[], uint64_t dec, int minDigits)
◆ SkStrAppendScalar()
char * SkStrAppendScalar |
( |
char |
buffer[], |
|
|
SkScalar |
value |
|
) |
| |
Write the scalar in decimal format into buffer, and return a pointer to the next char after the last one written. Note: a terminating 0 is not written into buffer, which must be at least kSkStrAppendScalar_MaxSize. Thus if the caller wants to add a 0 at the end, buffer must be at least kSkStrAppendScalar_MaxSize + 1 bytes large.
Definition at line 164 of file SkString.cpp.
164 {
165
166
168 strcpy(string, "nan");
169 return string + 3;
170 }
172 if (value > 0) {
173 strcpy(string, "inf");
174 return string + 3;
175 } else {
176 strcpy(string, "-inf");
177 return string + 4;
178 }
179 }
180
181
182 static const char gFormat[] = "%.8g";
183
186 memcpy(
string,
buffer, len);
189}
static bool SkIsFinite(T x, Pack... values)
static constexpr int kSkStrAppendScalar_MaxSize
static const uint8_t buffer[]
◆ SkStrAppendU32()
char * SkStrAppendU32 |
( |
char |
string[], |
|
|
uint32_t |
dec |
|
) |
| |
Definition at line 100 of file SkString.cpp.
100 {
102
105
106 do {
108 dec /= 10;
109 } while (dec != 0);
110
113 memcpy(string, p, cp_len);
114 string += cp_len;
115
117 return string;
118}
static constexpr int kSkStrAppendU32_MaxSize
constexpr uint8_t SkToU8(S x)
◆ SkStrAppendU64()
char * SkStrAppendU64 |
( |
char |
string[], |
|
|
uint64_t |
dec, |
|
|
int |
minDigits |
|
) |
| |
Definition at line 129 of file SkString.cpp.
129 {
131
134
135 do {
136 *--
p =
SkToU8(
'0' + (int32_t) (dec % 10));
137 dec /= 10;
138 minDigits--;
139 } while (dec != 0);
140
141 while (minDigits > 0) {
143 minDigits--;
144 }
145
148 memcpy(string, p, cp_len);
149 string += cp_len;
150
152 return string;
153}
static constexpr int kSkStrAppendU64_MaxSize
◆ SkStrEndsWith() [1/2]
bool SkStrEndsWith |
( |
const char |
string[], |
|
|
const char |
suffixChar |
|
) |
| |
Definition at line 77 of file SkString.cpp.
77 {
79 size_t strLen = strlen(string);
80 if (0 == strLen) {
81 return false;
82 } else {
83 return (suffixChar == string[strLen-1]);
84 }
85}
◆ SkStrEndsWith() [2/2]
bool SkStrEndsWith |
( |
const char |
string[], |
|
|
const char |
suffixStr[] |
|
) |
| |
Definition at line 68 of file SkString.cpp.
68 {
71 size_t strLen = strlen(string);
72 size_t suffixLen = strlen(suffixStr);
73 return strLen >= suffixLen &&
74 !strncmp(string + strLen - suffixLen, suffixStr, suffixLen);
75}
◆ SkStringPrintf()
SkString SkStringPrintf |
( |
const char * |
format, |
|
|
|
... |
|
) |
| |
Definition at line 629 of file SkString.cpp.
629 {
635 return formattedOutput;
636}
void void printVAList(const char format[], va_list) SK_PRINTF_LIKE(2
◆ SkStrStartsWithOneOf()
int SkStrStartsWithOneOf |
( |
const char |
string[], |
|
|
const char |
prefixes[] |
|
) |
| |
Definition at line 87 of file SkString.cpp.
87 {
88 int index = 0;
89 do {
90 const char* limit = strchr(prefixes, '\0');
91 if (!strncmp(string, prefixes, limit - prefixes)) {
92 return index;
93 }
94 prefixes = limit + 1;
95 index++;
96 } while (prefixes[0]);
97 return -1;
98}
◆ trim_size_t_to_u32()
static uint32_t trim_size_t_to_u32 |
( |
size_t |
value | ) |
|
|
static |
Definition at line 197 of file SkString.cpp.
197 {
198 if (sizeof(size_t) > sizeof(uint32_t)) {
199 if (value > UINT32_MAX) {
201 }
202 }
203 return (uint32_t)
value;
204}
◆ kBufferSize
const size_t kBufferSize = 1024 |
|
static |