本文整理汇总了C++中conv_10函数的典型用法代码示例。如果您正苦于以下问题:C++ conv_10函数的具体用法?C++ conv_10怎么用?C++ conv_10使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了conv_10函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: conv_10
void StringBuffer::append(int n) {
char buf[12];
int is_negative;
int len;
char *p = conv_10(n, &is_negative, buf + 12, &len);
append(p, len);
}
示例2: concat_is
/**
* concat_is will incRef the output string
*/
StringData* concat_is(int64_t v1, StringData* v2) {
char intbuf[21];
// Convert the int to a string
auto const s1 = conv_10(v1, intbuf + sizeof(intbuf));
auto const s2 = v2->slice();
return StringData::Make(s1, s2);
}
示例3: conv_10
static char *conv_apr_sockaddr(apr_sockaddr_t *sa, char *buf_end, int *len)
{
char *p = buf_end;
bool_int is_negative;
int sub_len;
char *ipaddr_str;
p = conv_10(sa->port, TRUE, &is_negative, p, &sub_len);
*--p = ':';
apr_sockaddr_ip_get(&ipaddr_str, sa);
sub_len = strlen(ipaddr_str);
#if APR_HAVE_IPV6
if (sa->family == APR_INET6 &&
!IN6_IS_ADDR_V4MAPPED(&sa->sa.sin6.sin6_addr)) {
*(p - 1) = ']';
p -= sub_len + 2;
*p = '[';
memcpy(p + 1, ipaddr_str, sub_len);
}
else
#endif
{
p -= sub_len;
memcpy(p, ipaddr_str, sub_len);
}
*len = buf_end - p;
return (p);
}
示例4: buildStringData
StringData* buildStringData(int64_t n) {
char tmpbuf[21];
tmpbuf[20] = '\0';
auto const sl = conv_10(n, &tmpbuf[20]);
return StringData::Make(sl, CopyString);
}
示例5: concat_is
/**
* concat_is will incRef the output string
*/
StringData* concat_is(int64_t v1, StringData* v2) {
char intbuf[21];
// Convert the int to a string
auto const s1 = conv_10(v1, intbuf + sizeof(intbuf));
StringSlice s2 = v2->slice();
StringData* ret = StringData::Make(s1, s2);
ret->incRefCount();
return ret;
}
示例6: equalAsStr
bool equalAsStr(int64 v1, litstr v2) {
char tmpbuf[21];
char *p;
int is_negative;
int len;
tmpbuf[20] = '\0';
p = conv_10(v1, &is_negative, &tmpbuf[20], &len);
return strcmp(p, v2) == 0;
}
示例7: return
static char *conv_10_quad(widest_int num, register bool_int is_unsigned,
register bool_int *is_negative, char *buf_end,
register int *len)
{
register char *p = buf_end;
u_widest_int magnitude;
/*
* We see if we can use the faster non-quad version by checking the
* number against the largest long value it can be. If <=, we
* punt to the quicker version.
*/
if ((num <= ULONG_MAX && is_unsigned)
|| (num <= LONG_MAX && num >= LONG_MIN && !is_unsigned))
return(conv_10( (wide_int)num, is_unsigned, is_negative,
buf_end, len));
if (is_unsigned) {
magnitude = (u_widest_int) num;
*is_negative = FALSE;
}
else {
*is_negative = (num < 0);
/*
* On a 2's complement machine, negating the most negative integer
* results in a number that cannot be represented as a signed integer.
* Here is what we do to obtain the number's magnitude:
* a. add 1 to the number
* b. negate it (becomes positive)
* c. convert it to unsigned
* d. add 1
*/
if (*is_negative) {
widest_int t = num + 1;
magnitude = ((u_widest_int) -t) + 1;
}
else
magnitude = (u_widest_int) num;
}
/*
* We use a do-while loop so that we write at least 1 digit
*/
do {
u_widest_int new_magnitude = magnitude / 10;
*--p = (char) (magnitude - new_magnitude * 10 + '0');
magnitude = new_magnitude;
}
while (magnitude);
*len = buf_end - p;
return (p);
}
示例8: buildStringData
StringData* buildStringData(int64_t n) {
char tmpbuf[21];
char* p;
int is_negative;
int len;
tmpbuf[20] = '\0';
p = conv_10(n, &is_negative, &tmpbuf[20], &len);
return StringData::Make(p, len, CopyString);
}
示例9: buildStringData
StringData* buildStringData(int n) {
char tmpbuf[12];
char* p;
int is_negative;
int len;
tmpbuf[11] = '\0';
p = conv_10(n, &is_negative, &tmpbuf[11], &len);
return NEW(StringData)(p, len, CopyString);
}
示例10: switch
static char *conv_os_thread_t(apr_os_thread_t *tid, char *buf_end, int *len)
{
union {
apr_os_thread_t tid;
apr_uint64_t alignme;
} u;
int is_negative;
u.tid = *tid;
switch(sizeof(u.tid)) {
case sizeof(apr_int32_t):
return conv_10(*(apr_uint32_t *)&u.tid, TRUE, &is_negative, buf_end, len);
case sizeof(apr_int64_t):
return conv_10_quad(*(apr_uint64_t *)&u.tid, TRUE, &is_negative, buf_end, len);
default:
/* not implemented; stick 0 in the buffer */
return conv_10(0, TRUE, &is_negative, buf_end, len);
}
}
示例11: buildStringData
StringData* buildStringData(int n) {
char tmpbuf[12];
char* p;
int is_negative;
int len;
TAINT_OBSERVER(TAINT_BIT_MUTATED, TAINT_BIT_NONE);
tmpbuf[11] = '\0';
p = conv_10(n, &is_negative, &tmpbuf[11], &len);
return NEW(StringData)(p, len, CopyString);
}
示例12: conv_10
static char *conv_sockaddr_in(struct sockaddr_in *si, char *buf_end, int *len)
{
char *p = buf_end;
bool_int is_negative;
int sub_len;
p = conv_10(ntohs(si->sin_port), TRUE, &is_negative, p, &sub_len);
*--p = ':';
p = conv_in_addr(&si->sin_addr, p, &sub_len);
*len = buf_end - p;
return (p);
}
示例13: conv_10
String::String(int n) {
char tmpbuf[12];
char *p;
int is_negative;
int len;
char *buf;
tmpbuf[11] = '\0';
p = conv_10(n, &is_negative, &tmpbuf[11], &len);
buf = (char*)malloc(len + 1);
memcpy(buf, p, len + 1); // including the null terminator.
SmartPtr<StringData>::operator=(NEW(StringData)(buf, AttachString));
}
示例14: conv_10
void StringBuffer::append(int64 n) {
char buf[21];
int is_negative;
int len;
const StringData *sd = String::GetIntegerStringData(n);
char *p;
if (!sd) {
p = conv_10(n, &is_negative, buf + 21, &len);
} else {
p = (char *)sd->data();
len = sd->size();
}
append(p, len);
}
示例15: conv_10
void StringBuffer::append(int64_t n) {
char buf[21];
int len;
const StringData *sd = String::GetIntegerStringData(n);
char *p;
if (!sd) {
auto sl = conv_10(n, buf + 21);
p = const_cast<char*>(sl.ptr);
len = sl.len;
} else {
p = (char *)sd->data();
len = sd->size();
}
append(p, len);
}