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

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

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

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 destination<CharT> {
public:
    explicit narrow_cfile_writer(std::FILE* dest);

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

    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

~narrow_cfile_writer();
Effect

Calls recycle()

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

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

  • Calls set_buffer_ptr and/or set_buffer_end.

Postconditions

buffer_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 destination<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;
    ~wide_cfile_writer();

    void recycle() noexcept;

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

    result finish();

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

} // namespace strf

2.2. Public member functions

~wide_cfile_writer();
Effect

Calls recycle()

void recycle() override;
Effects
  • If good() == true, for each character ch in the range [ p0, buffer_ptr() ) 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 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.

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

  • Calls set_buffer_ptr and/or set_buffer_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

printing_syntax<DestCreator>, where DestCreator is an implementation-defined type that satifies DestinationCreator.

Return value

An object whose DestCreator object _dest_creator is such that _dest_creator.create() returns

4. Function wto

namespace strf {

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

} // namespace strf
Return type

printing_syntax<DestCreator>, where DestCreator is an implementation-defined type that satifies DestinationCreator.

Return value

An object whose DestCreator object _dest_creator is such that _dest_creator.create() returns

wide_cfile_writer<CharT, Traits>{dest}