template<class Prefix>
Message class
Forward declaration of the Message template class.
| Template parameters | |
|---|---|
| Prefix | The prefix type for the message. |
Base template class for formatted message output.
Base template class for formatted message output with customizable prefixes.
Base class for creating formatted messages with customizable prefixes, colors, and styles. Messages support stream-like insertion operators for building content incrementally. This class is used as the base for Exception, Warning, Info, and Success message types.
The Message class handles:
- Formatted output with colored prefixes
- Automatic indentation for multi-line messages
- Stream-like insertion operators for content
- Integration with the Alert tag types (NewLine, Raise, etc.)
Example usage (through derived classes):
Exception() << "Error in function: " << funcName << NewLine << "Invalid parameter value: " << value << Raise;
Constructors, destructors, conversion operators
Public functions
- auto what() const -> const char* noexcept
- Gets the message content as a C-string.
-
template<class T>auto operator<<(const T& v) -> std::enable_if_t<Internal::
CanBeOutput<T>::Value, Message&> noexcept - Stream insertion operator for arbitrary streamable types.
- auto operator<<(const NewLineT&) -> Message&
- Stream insertion operator for NewLine tag.
- void operator<<(const RaiseT&)
- Stream insertion operator for Raise tag.
- void raise() const virtual
- Raises (outputs) the message to the user.
- void setOutputStream(std::ostream& os)
- Sets the output stream for this message.
Function documentation
template<class Prefix>
Rodin:: Alert:: Message<Prefix>:: Message(std::ostream& os,
const Prefix& prefix) noexcept
Constructs a message with output stream and prefix.
| Parameters | |
|---|---|
| os | The output stream to write the message to. |
| prefix | The message prefix object. |
template<class Prefix>
const char* Rodin:: Alert:: Message<Prefix>:: what() const noexcept
Gets the message content as a C-string.
| Returns | Null-terminated string containing the message. |
|---|
Returns the accumulated message content without formatting or color codes. Useful for logging or storing the message text.
template<class Prefix>
template<class T>
std::enable_if_t<Internal:: CanBeOutput<T>::Value, Message&> Rodin:: Alert:: Message<Prefix>:: operator<<(const T& v) noexcept
Stream insertion operator for arbitrary streamable types.
| Template parameters | |
|---|---|
| T | The type to insert (must be streamable). |
| Parameters | |
| v | The value to insert into the message. |
| Returns | Reference to this Message object for method chaining. |
Appends content to the message. Handles automatic indentation when content follows a newline. Only enabled for types that can be output to an ostream.
template<class Prefix>
Message& Rodin:: Alert:: Message<Prefix>:: operator<<(const NewLineT&)
Stream insertion operator for NewLine tag.
| Returns | Reference to this Message object for method chaining. |
|---|
Inserts a newline character and marks the next insertion for automatic indentation to align with the message prefix.
template<class Prefix>
void Rodin:: Alert:: Message<Prefix>:: operator<<(const RaiseT&)
Stream insertion operator for Raise tag.
Triggers the raise() method to output the message and perform any associated actions (such as program termination for exceptions).
template<class Prefix>
void Rodin:: Alert:: Message<Prefix>:: raise() const virtual
Raises (outputs) the message to the user.
Default behavior outputs the formatted message to the configured output stream. Derived classes may override this to add additional behavior (e.g., Exception terminates the program).
template<class Prefix>
void Rodin:: Alert:: Message<Prefix>:: setOutputStream(std::ostream& os)
Sets the output stream for this message.
| Parameters | |
|---|---|
| os | The new output stream. |
Changes where the message will be output when raised.