This header file includes <strf.hpp>
namespace strf {

template < typename CharT
         , typename Traits = std::char_traits<CharT>
         , typename Allocator = std::allocator<CharT> >
class basic_string_appender final: public destination<CharT>
{ /*...*/ };

template < typename CharT
         , typename Traits = std::char_traits<CharT>
         , typename Allocator = std::allocator<CharT> >
class basic_string_maker final: public destination<CharT>
{ /*...*/ };

template < typename CharT
         , typename Traits = std::char_traits<CharT>
         , typename Allocator = std::allocator<CharT> >
class basic_sized_string_maker final: public destination<CharT>
{ /*...*/ };

using string_appender           = basic_string_appender<char>;
using u8string_appender         = basic_string_appender<char8_t>;
using u16string_appender        = basic_string_appender<char16_t>;
using u32string_appender        = basic_string_appender<char32_t>;
using wstring_appender          = basic_string_appender<wchar_t>;

using string_maker              = basic_string_maker<char>;
using u8string_maker            = basic_string_maker<char8_t>;
using u16string_maker           = basic_string_maker<char16_t>;
using u32string_maker           = basic_string_maker<char32_t>;
using wstring_maker             = basic_string_maker<wchar_t>;

using pre_sized_string_maker    = basic_sized_string_maker<char>;
using pre_sized_u8string_maker  = basic_sized_string_maker<char8_t>;
using pre_sized_u16string_maker = basic_sized_string_maker<char16_t>;
using pre_sized_u32string_maker = basic_sized_string_maker<char32_t>;
using pre_sized_wstring_maker   = basic_sized_string_maker<wchar_t>;

template <typename CharT, typename Traits, typename Allocator>
/*...*/ append(std::basic_string<CharT, Traits, Allocator>& str);

template <typename CharT, typename Traits, typename Allocator>
/*...*/ assign(std::basic_string<CharT, Traits, Allocator>& str);

template < typename CharT
         , typename Traits = std::char_traits<CharT>
         , typename Allocator = std::allocator<CharT> >
constexpr /* ... */ to_basic_string {};

constexpr auto to_u8string      = to_basic_string<char8_t>;
constexpr auto to_string        = to_basic_string<char_t>;
constexpr auto to_u16string     = to_basic_string<char16_t>;
constexpr auto to_u32string     = to_basic_string<char32_t>;
constexpr auto to_wstring       = to_basic_string<wchar_t>;

} // namespace strf

1. Class template basic_string_maker

1.1. Synopsis

namespace strf {

template < typename CharT
         , typename Traits = std::char_traits<CharT>
         , typename Allocator = std::allocator<CharT> >
class basic_string_maker final: public {destination}<CharT> {
public:
    basic_string_maker();
    basic_string_maker(const basic_string_maker&) = delete;
    basic_string_maker(basic_string_maker&&) = delete;
    void recycle() override;
    basic_string<CharT, Traits, Allocator> finish();
};

// Global type aliases

using string_maker    = basic_string_maker<char>;
using u16string_maker = basic_string_maker<char16_t>;
using u32string_maker = basic_string_maker<char32_t>;
using wstring_maker   = basic_string_maker<wchar_t>;
using u8string_maker  = basic_string_maker<char8_t>;

} // namespace strf

1.2. Public member functions

void recycle() override;
Effects
  • If good() is true then calls str.append(p0, buffer_ptr()), where str is the private string object that is later returned by finish(), and p0 is the value that buffer_ptr() would return before any call to advance and advance_to since the last call to recycle(), or since this object’s contruction, whatever happened last.

  • Calls set_buffer_ptr and/or set_buffer_end.

Postconditions

buffer_space() >= min_destination_buffer_size

basic_string<CharT, Traits, Allocator> finish()
Effects

Calls recycle() and set_good(false) and returns the internal string.

Postconditions

good() == false

2. Class template basic_sized_string_maker

2.1. Synopsis

namespace strf {

template < typename CharT
         , typename Traits = std::char_traits<CharT>
         , typename Allocator = std::allocator<CharT> >
class basic_sized_string_maker final : public {destination}<CharT> {
public:
    explicit basic_sized_string_maker(std::size_t capacity);

    basic_sized_string_maker(const basic_sized_string_maker&) = delete;
    basic_sized_string_maker(basic_sized_string_maker&&) = delete;

    void recycle() override;
    std::basic_string<CharT, Traits, Allocator> finish();
};

using pre_sized_string_maker    = basic_sized_string_maker<char>;
using pre_sized_u16string_maker = basic_sized_string_maker<char16_t>;
using pre_sized_u32string_maker = basic_sized_string_maker<char32_t>;
using pre_sized_wstring_maker   = basic_sized_string_maker<wchar_t>;

} // namespace strf
explicit basic_sized_string_maker(std::size_t capacity);
Effect

Causes the capacity of the internal string to be equal to or greater than capacity.

basic_string<CharT, Traits, Allocator> finish()
Return value

A string containing what has been written into this destination object ( assuming it’s the the first call ).

Postconditions

good() == false

Note

This function should be called only once. Further calls may return empty strings.

3. Class template basic_string_appender

3.1. Synopsis

namespace strf {

template < typename CharT
         , typename Traits = std::char_traits<CharT>
         , typename Allocator = std::allocator<CharT> >
class basic_string_appender final: public {destination}<CharT>
{
public:
    explicit basic_string_appender(basic_string<CharT, Traits, Allocator>& dest);
    basic_string_appender(const basic_string_appender&) = delete;
    basic_string_appender(basic_string_appender&&) = delete;
    void recycle() override;
    void finish();
};

// Global type aliases

using string_appender    = basic_string_appender<char>;
using u16string_appender = basic_string_appender<char16_t>;
using u32string_appender = basic_string_appender<char32_t>;
using wstring_appender   = basic_string_appender<wchar_t>;

} // namespace strf

3.2. Public member functions

void recycle() override;
Effects
  • If good() is true then calls str.append(p0, buffer_ptr()), where str is the reference that this object was initialized with, and p0 is the return value of buffer_ptr() before any call to advance and advance_to since the last call to recycle() ( all in this object ), or since this object’s contruction, whatever happened last.

  • Calls set_buffer_ptr and/or set_buffer_end.

Postconditions

buffer_space() >= min_destination_buffer_size

void finish()
Effects

Calls recycle() and set_good(false).

Postcondition

good() == false

4. Function template append

namespace strf {

template <typename CharT, typename Traits, typename Allocator>
/* see below */ append(std::basic_string<CharT, Traits, Allocator>& str);

} // namespace strf
Return type

printing_syntax<DestCreator>, where DestCreator is an implementation-defined type that satisfies DestinationCreator and SizedDestinationCreator

Return value

An object whose DestCreator object _dest_creator is such that

  • _dest_creator.create() returns basic_string_appender<CharT, Traits, Allocator>{str}

  • _dest_creator.create(capacity) calls str.reserve(str.size() + capacity) and returns basic_string_appender<CharT, Traits, Allocator>{str}

5. Function template assign

namespace strf {

template <typename CharT, typename Traits, typename Allocator>
/* see below */ assign(std::basic_string<CharT, Traits, Allocator>& str)

} // namespace strf
Effects

Calls str.clear() and returns append(str).

6. Variable template to_basic_string

namespace strf {

template < typename CharT
         , typename Traits = std::char_traits<CharT>
         , typename Allocator = std::allocator<CharT> >
constexpr </* see below */>  to_basic_string {};

} // namespace strf
Type

printing_syntax<DestCreator>, where DestCreator is an implementation-defined type that satisfies DestinationCreator and SizedDestinationCreator.

Value

An object whose DestCreator object _dest_creator is such that

6.1. Aliases

namespace strf {

constexpr auto to_u8string  = to_basic_string<char8_t>;
constexpr auto to_string    = to_basic_string<char_t>;
constexpr auto to_u16string = to_basic_string<char16_t>;
constexpr auto to_u32string = to_basic_string<char32_t>;
constexpr auto to_wstring   = to_basic_string<wchar_t>;

} // namespace strf