Go to the documentation of this file.
31 #include "absl/strings/str_cat.h"
47 len = strlen(src) + 1;
58 struct tm* tm_info = localtime(
reinterpret_cast<time_t*
>(&
tm.tv_sec));
59 strftime(time_buffer,
sizeof(time_buffer),
"%Y-%m-%dT%H:%M:%S", tm_info);
60 snprintf(ns_buffer, 11,
".%09d",
tm.tv_nsec);
64 for (
int i = 7;
i >= 1;
i -= 3) {
65 if (ns_buffer[
i] ==
'0' && ns_buffer[
i + 1] ==
'0' &&
66 ns_buffer[
i + 2] ==
'0') {
91 if (
out->length ==
out->capacity) {
99 static const char* hex =
"0123456789abcdef";
116 int out_was_empty = (
out->length == 0);
117 if (!out_was_empty) {
125 if (!out_was_empty) {
140 *out_len =
out.length;
154 if (
len == 0)
return 0;
156 for (
i = 0;
i <
len;
i++) {
157 if (
buf[
i] <
'0' ||
buf[
i] >
'9')
return 0;
159 if (new_val <
out)
return 0;
169 for (p1 =
str, p2 =
str +
len - 1; p2 > p1; ++p1, --p2) {
186 sign =
value < 0 ? -1 : 1;
188 output[
i++] =
static_cast<char>(
'0' + sign * (
value % 10));
191 if (sign < 0)
output[
i++] =
'-';
207 sign =
value < 0 ? -1 : 1;
209 output[
i++] =
static_cast<char>(
'0' + sign * (
value % 10));
212 if (sign < 0)
output[
i++] =
'-';
221 if (*
end !=
'\0' || result < 0 || result > INT_MAX)
return -1;
222 return static_cast<int>(
result);
226 const size_t str_length = strlen(
str);
227 const size_t out_length = str_length >
length ? str_length :
length;
235 char*
gpr_strjoin(
const char** strs,
size_t nstrs,
size_t* final_length) {
240 size_t* final_length) {
241 const size_t sep_len = strlen(
sep);
242 size_t out_length = 0;
245 for (
i = 0;
i < nstrs;
i++) {
246 out_length += strlen(strs[
i]);
250 out_length += sep_len * (nstrs - 1);
254 for (
i = 0;
i < nstrs;
i++) {
255 const size_t slen = strlen(strs[
i]);
258 out_length += sep_len;
264 if (final_length !=
nullptr) {
265 *final_length = out_length;
278 }
while (ca ==
cb && ca != 0 &&
cb != 0 &&
n != 0);
287 size_t* nstrs,
size_t* capstrs) {
289 static_cast<char*
>(
gpr_malloc(
static_cast<size_t>(
end - beg) + 1));
292 if (*nstrs == *capstrs) {
293 *capstrs =
std::max(
size_t(8), 2 * *capstrs);
294 *strs =
static_cast<char**
>(
gpr_realloc(*strs,
sizeof(*strs) * *capstrs));
296 (*strs)[*nstrs] =
out;
314 if (s ==
nullptr)
return nullptr;
315 char*
b =
const_cast<char*
>(
reinterpret_cast<const char*
>(s));
317 for (
i = 0;
i <
n;
i++) {
318 if (
b[
n -
i - 1] ==
c) {
319 return &
b[
n -
i - 1];
326 const char* kTrue[] = {
"1",
"t",
"true",
"y",
"yes"};
327 const char* kFalse[] = {
"0",
"f",
"false",
"n",
"no"};
328 static_assert(
sizeof(kTrue) ==
sizeof(kFalse),
"true_false_equal");
330 if (
value ==
nullptr) {
void gpr_string_split(const char *input, const char *sep, char ***strs, size_t *nstrs)
std::string StrCat(const AlphaNum &a, const AlphaNum &b)
return memset(p, 0, total)
static dump_out dump_out_create(void)
static void hexdump(dump_out *out, const char *buf, size_t len)
void gpr_reverse_bytes(char *str, int len)
GPRAPI void * gpr_malloc(size_t size)
static void add_string_to_split(const char *beg, const char *end, char ***strs, size_t *nstrs, size_t *capstrs)
bool gpr_parse_bool_value(const char *value, bool *dst)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
char * gpr_strjoin(const char **strs, size_t nstrs, size_t *final_length)
GPRAPI void * gpr_realloc(void *p, size_t size)
static void asciidump(dump_out *out, const char *buf, size_t len)
char * gpr_leftpad(const char *str, char flag, size_t length)
char * gpr_strjoin_sep(const char **strs, size_t nstrs, const char *sep, size_t *final_length)
static void dump_out_append(dump_out *out, char c)
void * gpr_memrchr(const void *s, int c, size_t n)
std::string gpr_format_timespec(gpr_timespec tm)
char * gpr_strdup(const char *src)
int gpr_stricmp(const char *a, const char *b)
#define GPR_ARRAY_SIZE(array)
int gpr_parse_bytes_to_uint32(const char *buf, size_t len, uint32_t *result)
AllocList * next[kMaxLevel]
int int64_ttoa(int64_t value, char *output)
int gpr_parse_nonnegative_int(const char *value)
char * gpr_dump(const char *buf, size_t len, uint32_t flags)
int gpr_strincmp(const char *a, const char *b, size_t n)
OPENSSL_EXPORT pem_password_cb * cb
char * gpr_dump_return_len(const char *buf, size_t len, uint32_t flags, size_t *out_len)
int gpr_ltoa(long value, char *output)
grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:25