// SPDX-License-Identifier: MIT
#pragma once
#include <iosfwd>
#include <string>
#include "Module.hh"
/// \file MString.hh
/// \brief Turns a parsed `Module` into the C++ header / source pair.
/// \brief Reject message definitions the generated code could not compile
/// with (e.g. `MEMBER AS` without a streamable class). Throws `MException`.
void ValidateModule( const Module &module );
/// \brief The header file name (`name.hh`), or "" for `NOHEADER`.
std::string HeaderFileName( const Module &module );
/// \brief The source file name (`name.cpp`), or "" for `NOSOURCE`.
std::string SourceFileName( const Module &module );
/// \brief Write the header. \p input names the message file in the banner.
void WriteCppInterface( std::ostream &stream, const Module &module, const std::string &input );
/// \brief Write the source. With `NOHEADER` the declarations are written into
/// it, so it compiles on its own.
void WriteCppImplementation( std::ostream &stream, const Module &module, const std::string &input );
/// \brief Includes, helpers and the definitions of every message — the body
/// of the source, or the tail of the header for `INLINE`.
void WriteDefinitions( std::ostream &stream, const Module &module );
/// \brief Write \p content to \p path unless the file already holds exactly
/// that — an unchanged message file does not trigger a rebuild.
/// \return `true` if the file was written.
bool WriteIfChanged( const std::string &path, const std::string &content );