folly::toAppend

toAppend overloads

Synopses

Declared in <folly/IPAddress.h>

Variadic conversion to string. Appends each element in turn. If we have two or more things to append, we will not reserve the space for them and will depend on strings exponential growth. If you just append once consider using toAppendFit which reserves the space needed (but does not have exponential as a result).

template<class... Ts>
requires sizeof...(Ts) >= 3 &&
            IsSomeString<typename std::remove_pointer<
                detail::LastElement<Ts...>>::type>::value
void
toAppend(Ts const&... vs);
» more...

Variadic base case: do nothing.

template<class Tgt>
void
toAppend(Tgt* result)
requires IsSomeString<Tgt>::value;
» more...

Append a string representation of the IP address to an fbstring.

void
toAppend(
    IPAddress addr,
    fbstring* result);
» more...

overloadbrief Define toAppend() to allow IPAddress to be used with folly::to<string>

void
toAppend(
    IPAddress addr,
    std::string* result);
» more...

Append the string representation of an IP address to an fbstring.

void
toAppend(
    IPAddressV4 addr,
    fbstring* result);
» more...

overloadbrief Define toAppend() to allow IPAddress to be used with folly::to<string>

void
toAppend(
    IPAddressV4 addr,
    std::string* result);
» more...

Appends the address representation to an fbstring.

void
toAppend(
    IPAddressV6 addr,
    fbstring* result);
» more...

overloadbrief Define toAppend() to allow IPAddress to be used with folly::to<string>

void
toAppend(
    IPAddressV6 addr,
    std::string* result);
» more...

Appends the string form of a value to the given string.

void
toAppend(
    SocketOptionValue const& val,
    std::string* result);
» more...

Define toAppend() so to<string> will work

template<class Tgt>
void
toAppend(
    MacAddress address,
    Tgt* result)
requires IsSomeString<Tgt>::value;
» more...

and StringPiece objects too

template<class Tgt>
void
toAppend(
    StringPiece value,
    Tgt* result)
requires IsSomeString<Tgt>::value;
» more...

Special handling for 128 bit integers.

template<class Tgt>
void
toAppend(
    __int128 value,
    Tgt* result);
» more...

overloadbrief Appends conversion to string.

template<class Tgt>
void
toAppend(
    char value,
    Tgt* result);
» more...

Append a 128-bit unsigned integer to a string.

template<class Tgt>
void
toAppend(
    unsigned __int128 value,
    Tgt* result);
» more...

There's no implicit conversion from fbstring to other string types, so make a specialization.

template<class Tgt>
void
toAppend(
    fbstring const& value,
    Tgt* result)
requires IsSomeString<Tgt>::value;
» more...

Everything implicitly convertible to const char* gets appended.

template<
    class Tgt,
    class Src>
void
toAppend(
    Src value,
    Tgt* result)
requires std::is_convertible<Src, const char*>::value &&
    IsSomeString<Tgt>::value;
» more...

int32_t and int64_t to string (by appending) go through here. The result is APPENDED to a preexisting string passed as the second parameter. This should be efficient with fbstring because fbstring incurs no dynamic allocation below 23 bytes and no number has more than 22 bytes in its textual representation (20 for digits, one for sign, one for the terminating 0).

template<
    class Tgt,
    class Src>
void
toAppend(
    Src value,
    Tgt* result)
requires is_integral_v<Src> && is_signed_v<Src> && IsSomeString<Tgt>::value &&
    sizeof(Src) >= 4;
» more...

As above, but for uint32_t and uint64_t.

template<
    class Tgt,
    class Src>
void
toAppend(
    Src value,
    Tgt* result)
requires is_integral_v<Src> && !is_signed_v<Src> && IsSomeString<Tgt>::value &&
    sizeof(Src) >= 4;
» more...

All small signed and unsigned integers to string go through 32-bit types int32_t and uint32_t, respectively.

template<
    class Tgt,
    class Src>
void
toAppend(
    Src value,
    Tgt* result)
requires is_integral_v<Src> && IsSomeString<Tgt>::value && sizeof(Src) < 4;
» more...

Enumerated values get appended as integers.

template<
    class Tgt,
    class Src>
void
toAppend(
    Src value,
    Tgt* result)
requires std::is_enum<Src>::value && IsSomeString<Tgt>::value;
» more...

Append a floating-point value to a string.

template<
    class Tgt,
    class Src>
void
toAppend(
    Src value,
    Tgt* result)
requires std::is_floating_point<Src>::value && IsSomeString<Tgt>::value;
» more...

Strings get appended, too.

template<
    class Tgt,
    class Src>
void
toAppend(
    Src const& value,
    Tgt* result)
requires IsSomeString<Src>::value && IsSomeString<Tgt>::value;
» more...

Parameters

NameDescription
vsThe values to append, with the target string pointer last.
resultThe target string pointer.
addrThe address to append.
valThe value to format.
addressThe MAC address to append.
valueThe StringPiece to append.