15#ifndef AMINO_CORE_MESSAGE_H
16#define AMINO_CORE_MESSAGE_H
24#include <Amino/Core/internal/Format.h>
25#include <Amino/Core/internal/PImpl.h>
27#define AMINO_API AMINO_CORE_SHARED_DECL
101 return static_cast<void const*
>(m_name.
data()) ==
102 static_cast<void const*
>(o.m_name.
data());
140 : m_format{literal} {}
183 return "Unknown"_asv;
203 template <
typename Arg,
typename... Args>
212 std::move(source), kind, cls, text,
213 SpanParam{Internal::FormatArgs{arg, args...}}} {}
234 explicit operator bool()
const {
return isValid(); }
250 template <
typename Os>
252 Os& os,
bool newline =
true)
const {
253 internal_toStream(toStreamFor<Os>,
static_cast<void*
>(&os));
254 if (newline) os <<
'\n';
274 template <
typename Os>
275 static void toStreamFor(
277 Os& os = *
static_cast<Os*
>(client);
278 for (
auto const& s : strs) os.write(s.data(), s.size());
293 AMINO_API void internal_toStream(FormatFn fn,
void* client)
const;
297 Internal::PImpl<Message, 2> m_impl;
323 return static_cast<Level>(kind);
Definition of macros for symbol visibility.
Forward declarations for task observer classes.
String view class (similar to std::string_view)
MessageKind
The kind of message (error, warning, info, debug).
The "class" of the message.
bool operator==(MessageClass const &o) const
Equality operator.
constexpr MessageClass(StringLiteral literal) noexcept
Constructor from a string literal.
AMINO_CORE_SHARED_DECL bool isDefault() const
Returns true if this is the default message class or not.
AMINO_CORE_SHARED_DECL MessageClass()
Default constructor (default message class).
bool operator!=(MessageClass const &o) const
Inequality operator.
StringView getName() const
Returns the name of the message class.
The text content from which to construct a message (with optional formatting specifiers).
constexpr MessageText(StringLiteral literal) noexcept
Constructor from a string literal.
StringView getFormat() const &
Get the format string.
A Message object that of a specific MessageKind, optional MessageClass, and a MessageText that relate...
AMINO_INTERNAL_FORCEINLINE void toStream(Os &os, bool newline=true) const
Write the formatted message to the given output stream.
AMINO_CORE_SHARED_DECL bool isValid() const
Whether the message is valid or not (not default constructed).
AMINO_CORE_SHARED_DECL MessageKind getKind() const
Get the kind of message.
AMINO_CORE_SHARED_DECL Message & operator=(Message const &o)
Copy assignment operator.
AMINO_CORE_SHARED_DECL Message()
Default constructor (empty message).
AMINO_CORE_SHARED_DECL ~Message()
Destructor.
AMINO_CORE_SHARED_DECL MessageClass getClass() const
Get the message class.
static constexpr StringView toString(MessageKind kind)
Get the string representation of the MessageKind.
Message(Source source, MessageKind kind, MessageClass cls, MessageText text, Arg const &arg, Args const &... args)
Constructs a message with the given Source, MessageKind, MessageClass, and MessageText and format arg...
AMINO_CORE_SHARED_DECL Message(Message const &o)
Copy constructor.
AMINO_CORE_SHARED_DECL Message & operator=(Message &&o) noexcept
Move assignment operator.
AMINO_CORE_SHARED_DECL String getFormattedText() const
Get the formatted text of the message.
AMINO_CORE_SHARED_DECL Source const & getSource() const
Get the source of the message.
AMINO_CORE_SHARED_DECL Message(Source source, MessageKind kind, MessageClass cls, MessageText text)
Constructs a message with the given Source, MessageKind, MessageClass, and MessageText.
AMINO_CORE_SHARED_DECL Message(Message &&o) noexcept
Move constructor.
AMINO_CORE_SHARED_DECL String getText() const
Get the message text.
Helper class to filter messages based on their MessageKind.
static constexpr Level asLevel(MessageKind kind)
Get the Level corresponding to the given MessageKind.
Level getLevel() const
Get the message filter Level.
bool isEnabled(MessageKind kind) const
Returns whether the given MessageKind is enabled.
MessageFilter() noexcept=default
Default constructor.
Level
Same as MessageKind with the addition of a disabled level.
void setLevel(MessageKind lvl)
Enables the MessageKind up to (and including) the given level.
bool isEnabled() const
Returns whether logging is enabled (i.e. the level isn't eDisabled).
MessageFilter(Level lvl) noexcept
Constructs a message filter from the given level.
void setLevel(Level lvl)
Enables the MessageKind up to (and including) the given level.
Generic opaque handle to a source (provenance).
Same as Span but the constructor from a range is implicit, making it more convenient and safe to use ...
The string class used by Amino.
String view class (similar to std::string_view).
constexpr char const * data() const noexcept
Get the string view data.