![]() |
XII Release 0.1.0
|
A wrapper around xiiResult that includes an optional error message. More...
#include <Status.h>
Public Member Functions | |
Constructors | |
| XII_ALWAYS_INLINE | xiiStatus (const char *szError) |
| Constructs a failure status with the given C-string error message. | |
| XII_ALWAYS_INLINE | xiiStatus (xiiStringView sError) |
| Constructs a failure status with the given string view error message. | |
| xiiStatus (const xiiFormatString &fmt) | |
| Constructs a failure status from a formatted string. | |
| XII_ALWAYS_INLINE | xiiStatus (xiiResult result) |
| Constructs a status with the given result (success or failure), without a message. | |
| XII_ALWAYS_INLINE | xiiStatus (xiiResultEnum result) |
| Constructs a status with the given result enum, without a message. | |
Query Functions | |
| XII_ALWAYS_INLINE xiiResult | GetResult () const |
| Returns the underlying xiiResult value. | |
| XII_ALWAYS_INLINE bool | Succeeded () const |
| Returns true if the result indicates success. | |
| XII_ALWAYS_INLINE bool | Failed () const |
| Returns true if the result indicates failure. | |
| XII_ALWAYS_INLINE const xiiString & | GetMessageString () const |
| Returns the stored error message string (may be empty). | |
Control and Logging | |
| XII_ALWAYS_INLINE void | IgnoreResult () |
| Used to suppress [[nodiscard]] warnings when the result doesn't need handling. | |
| bool | LogFailure (xiiLogInterface *pLog=nullptr) |
| Logs the error message if this represents a failure. | |
| void | AssertSuccess (const char *szMsg=nullptr) const |
| Asserts that the status indicates success. | |
A wrapper around xiiResult that includes an optional error message.
The xiiStatus structure represents a success or failure state. If failure is indicated, an additional message provides context or details. Intended to be returned from functions to communicate success/failure in a structured manner.
Usage example:
|
explicit |
Constructs a failure status from a formatted string.
Useful for creating detailed messages with placeholders using xiiFmt().
| void xiiStatus::AssertSuccess | ( | const char * | szMsg = nullptr | ) | const |
Asserts that the status indicates success.
If the assertion fails, the program will terminate. A custom message can be passed, and the internal error string is appended.
|
inline |
Used to suppress [[nodiscard]] warnings when the result doesn't need handling.
Call this if you're intentionally ignoring the result, e.g., inside a cleanup function.
| bool xiiStatus::LogFailure | ( | xiiLogInterface * | pLog = nullptr | ) |
Logs the error message if this represents a failure.
Uses the provided log interface or falls back to the thread-local default. Returns true if this is a failure (same as Failed()), but not marked [[nodiscard]].