#include "include/core/SkRefCnt.h"
#include "include/core/SkScalar.h"
#include "include/core/SkTypes.h"
#include "include/private/base/SkTo.h"
#include "include/private/base/SkTypeTraits.h"
#include <atomic>
#include <cstdarg>
#include <cstdint>
#include <cstring>
#include <string>
#include <string_view>
#include <type_traits>
Go to the source code of this file.
|
static bool | SkStrStartsWith (const char string[], const char prefixStr[]) |
|
static bool | SkStrStartsWith (const char string[], const char prefixChar) |
|
bool | SkStrEndsWith (const char string[], const char suffixStr[]) |
|
bool | SkStrEndsWith (const char string[], const char suffixChar) |
|
int | SkStrStartsWithOneOf (const char string[], const char prefixes[]) |
|
static int | SkStrFind (const char string[], const char substring[]) |
|
static int | SkStrFindLastOf (const char string[], const char subchar) |
|
static bool | SkStrContains (const char string[], const char substring[]) |
|
static bool | SkStrContains (const char string[], const char subchar) |
|
char * | SkStrAppendU32 (char buffer[], uint32_t) |
|
char * | SkStrAppendU64 (char buffer[], uint64_t, int minDigits) |
|
char * | SkStrAppendS32 (char buffer[], int32_t) |
|
char * | SkStrAppendS64 (char buffer[], int64_t, int minDigits) |
|
char * | SkStrAppendScalar (char buffer[], SkScalar) |
|
SK_API SkString | SkStringPrintf (const char *format,...) SK_PRINTF_LIKE(1 |
| Creates a new string and writes into it using a printf()-style format. More...
|
|
SK_API SkString static SkString | SkStringPrintf () |
|
static void | swap (SkString &a, SkString &b) |
|
◆ SkStrAppendS32()
char * SkStrAppendS32 |
( |
char |
buffer[], |
|
|
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 |
buffer[], |
|
|
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 }
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
189}
static constexpr bool SkIsNaN(T x)
static bool SkIsFinite(T x, Pack... values)
static constexpr int kSkStrAppendScalar_MaxSize
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
◆ SkStrAppendU32()
char * SkStrAppendU32 |
( |
char |
buffer[], |
|
|
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
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
constexpr uint8_t SkToU8(S x)
◆ SkStrAppendU64()
char * SkStrAppendU64 |
( |
char |
buffer[], |
|
|
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
◆ SkStrContains() [1/2]
static bool SkStrContains |
( |
const char |
string[], |
|
|
const char |
subchar |
|
) |
| |
|
inlinestatic |
Definition at line 58 of file SkString.h.
58 {
60 char tmp[2];
61 tmp[0] = subchar;
62 tmp[1] = '\0';
64}
static int SkStrFind(const char string[], const char substring[])
◆ SkStrContains() [2/2]
static bool SkStrContains |
( |
const char |
string[], |
|
|
const char |
substring[] |
|
) |
| |
|
inlinestatic |
◆ 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}
◆ SkStrFind()
static int SkStrFind |
( |
const char |
string[], |
|
|
const char |
substring[] |
|
) |
| |
|
inlinestatic |
Definition at line 41 of file SkString.h.
41 {
42 const char *first = strstr(string, substring);
43 if (nullptr == first) return -1;
44 return SkToInt(first - &
string[0]);
45}
constexpr int SkToInt(S x)
◆ SkStrFindLastOf()
static int SkStrFindLastOf |
( |
const char |
string[], |
|
|
const char |
subchar |
|
) |
| |
|
inlinestatic |
Definition at line 47 of file SkString.h.
47 {
48 const char* last = strrchr(string, subchar);
49 if (nullptr == last) return -1;
50 return SkToInt(last - &
string[0]);
51}
◆ SkStringPrintf() [1/2]
This makes it easier to write a caller as a VAR_ARGS function where the format string is optional.
Definition at line 287 of file SkString.h.
◆ SkStringPrintf() [2/2]
Creates a new string and writes into it using a printf()-style format.
◆ SkStrStartsWith() [1/2]
static bool SkStrStartsWith |
( |
const char |
string[], |
|
|
const char |
prefixChar |
|
) |
| |
|
inlinestatic |
Definition at line 31 of file SkString.h.
31 {
33 return (prefixChar == *string);
34}
◆ SkStrStartsWith() [2/2]
static bool SkStrStartsWith |
( |
const char |
string[], |
|
|
const char |
prefixStr[] |
|
) |
| |
|
inlinestatic |
Definition at line 26 of file SkString.h.
26 {
29 return !strncmp(string, prefixStr, strlen(prefixStr));
30}
◆ 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}
◆ swap()
◆ kSkStrAppendS32_MaxSize
◆ kSkStrAppendS64_MaxSize
◆ kSkStrAppendScalar_MaxSize
constexpr int kSkStrAppendScalar_MaxSize = 15 |
|
staticconstexpr |
Floats have at most 8 significant digits, so we limit our g to that. However, the total string could be 15 characters: -1.2345678e-005
In theory we should only expect up to 2 digits for the exponent, but on some platforms we have seen 3 (as in the example above).
Definition at line 101 of file SkString.h.
◆ kSkStrAppendU32_MaxSize
constexpr int kSkStrAppendU32_MaxSize = 10 |
|
staticconstexpr |
◆ kSkStrAppendU64_MaxSize
constexpr int kSkStrAppendU64_MaxSize = 20 |
|
staticconstexpr |