// SPDX-License-Identifier: MIT
#pragma once
#include <optional>
#include <string>
#include <vector>
#include "Message.hh"
/// \file Module.hh
/// \brief Everything one mstring run produces a header / source pair from.
struct Module
{
std::string Name { "NONAME" }; ///< `$MODULE name`, or `-m`.
std::optional<std::string> SourceExtension { "cpp" }; ///< Empty optional: `NOSOURCE`.
std::optional<std::string> HeaderExtension { "hh" }; ///< Empty optional: `NOHEADER`.
bool Inline { false }; ///< `INLINE`: definitions in the header.
std::string Export; ///< `$EXPORT MACRO`: visibility macro.
std::vector<std::string> Namespaces; ///< `$NAMESPACE a::b` → { "a", "b" }.
std::vector<std::string> Includes; ///< `"file"`, `<file>` or a macro name.
std::vector<std::string> Usings; ///< `$USING` entities.
MessageList Messages;
Message *FindMessage( const std::string &name );
};
inline Message *Module::FindMessage( const std::string &name )
{
for ( Message &message : Messages )
{
if ( message.Name == name )
{
return &message;
}
}
return nullptr;
}