XII Release 0.1.0
Loading...
Searching...
No Matches
xiiStatus Struct Reference

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 xiiStringGetMessageString () 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.
 

Detailed Description

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:

xiiStatus status = SomeFunction();
if (status.Failed())
static void Error(xiiLogInterface *pInterface, const xiiFormatString &string)
An error that needs to be fixed as soon as possible.
Definition Log.cpp:352
XII_ALWAYS_INLINE xiiStatus(const char *szError)
Constructs a failure status with the given C-string error message.
Definition Status.h:28
XII_ALWAYS_INLINE const xiiString & GetMessageString() const
Returns the stored error message string (may be empty).
Definition Status.h:71
XII_ALWAYS_INLINE bool Failed() const
Returns true if the result indicates failure.
Definition Status.h:68

Constructor & Destructor Documentation

◆ xiiStatus()

xiiStatus::xiiStatus ( const xiiFormatString & fmt)
explicit

Constructs a failure status from a formatted string.

Useful for creating detailed messages with placeholders using xiiFmt().

Member Function Documentation

◆ AssertSuccess()

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.

◆ IgnoreResult()

XII_ALWAYS_INLINE void xiiStatus::IgnoreResult ( )
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.

◆ LogFailure()

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]].


The documentation for this struct was generated from the following files: