This document is still a work in progress.
This header files includes <strf.hpp>
namespace strf {

template <typename CharT, std::size_t BuffSize>
class narrow_cfile_writer final: public basic_outbuff<CharT>
{ /*...*/ };

class wide_cfile_writer final: public basic_outbuff<wchar_t>
{ /*...*/ };

// Destination makers:

template <typename CharT = char>
/* ... */  to(std::FILE*);

/* ... */ wto(std::FILE*);

} // namespace strf

1. Class template narrow_cfile_writer

1.1. Synopsis

namespace strf {

template <typename CharT, std::size_t BuffSize>
class narrow_cfile_writer final: public basic_outbuff<CharT> {
public:
    explicit narrow_cfile_writer(std::FILE* dest);

    narrow_cfile_writer(const narrow_cfile_writer&) = delete;
    narrow_cfile_writer(narrow_cfile_writer&&) = delete;

    void recycle() noexcept;

    struct result  {
        std::size_t count;
        bool success;
    };

    result finish();

private:
    CharT buffer[BuffSize]; // exposition only
};

} // namespace strf

1.2. Public member functions

void recycle() override;
Effects
  • If good() == true, calls std::fwrite(p0, pointer() - p0, sizeof(CharT), dest), where dest is the FILE* used to initialize this object, and p0 is value pointer() 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.

  • If the returned value of std::fwrite is less than (pointer() - p0), calls set_good(false).

  • Calls set_pointer and/or set_end.

Postconditions

space() >= BuffSize

result finish();
Effects
  • Calls recycle() and set_good(false).

Return value
  • result::count is the sum of values returned by all calls std::fwrite done by this object.

  • result::success is the value good() would return before this call to finish()

2. Class template wide_cfile_writer

2.1. Synopsis

namespace strf {

class wide_cfile_writer final: public basic_outbuff<wchar_t> {
public:
    explicit wide_cfile_writer(std::FILE* dest);

    wide_cfile_writer(const narrow_cfile_writer&) = delete;
    wide_cfile_writer(narrow_cfile_writer&&) = delete;

    void recycle() noexcept;

    struct result {
        std::size_t count;
        bool success;
    };

    result finish();
};

} // namespace strf

2.2. Public member functions

void recycle() override;
Effects
  • If good() == true, for each character ch in the range [ p0, pointer() ) calls std::fputwc(ch, dest), until WEOF is returned or the whole range is read, where dest is the FILE* used to initialize this object, and p0 is the value pointer() 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.

  • If std::fputwc returns WEOF, calls set_good(false).

  • Calls set_pointer and/or set_end.

result finish();
Effects
  • Calls recycle() and set_good(false).

Return value
  • result::count is the number of calls to std::fputwc by this object that did not return WEOF .

  • result::success is the value good() would return before this call to finish()

3. Function template to

namespace strf {

template <typename CharT = char>
/* see below */ to(std::FILE* dest);

} // namespace strf
Return type

destination_no_reserve<OBC>, where OBC is an implementation-defined type that satifies OutbuffCreator.

Return value

A destination object whose internal OutbuffCreator object obc is such that obc.create() returns a narrow_cfile_writer<CharT, min_space_after_recycle<CharT>()> object initialized with dest.

4. Function wto

namespace strf {

/* see below */ wto(std::FILE* dest);

} // namespace strf
Return type

destination_no_reserve<OBC>, where OBC is an implementation-defined type that satifies OutbuffCreator.

Return value

A destination object whose internal OutbuffCreator object obc is such that obc.create() returns a wide_cfile_writer object initialized with dest.