Code View

mstring / mstring-1.3.1.2 / src / MFormat.hh
// SPDX-License-Identifier: MIT
#pragma once

#include "MWriter.hh"

/// \file MFormat.hh
/// \brief Writes one `{$expression;format}` format as a statement on `stream`.
///
/// A format that starts with '.' or calls a `std::ostream` member
/// (`width(4)`, `precision(2)`, `fill('0')`, `setf(...)`, `unsetf(...)`,
/// `flags(...)`, `imbue(...)`) becomes a member call, `stream.precision(2);`.
/// Anything else is a manipulator, `stream << std::setw(4);`.
class FormatWriter
  : public Writer
{
  public:
    FormatWriter( std::ostream &stream, std::string &indent );

    void operator( )( const std::string &format );
};