Sane C++ Libraries
C++ Platform Abstraction Libraries
SC::Result Struct Reference

An ascii string used as boolean result. SC_TRY macro forwards errors to caller. More...

#include <Result.h>

Public Member Functions

constexpr Result (bool result)
 Build a Result object from a boolean. More...
 
constexpr operator bool () const
 Converts to true if the Result is valid, to false if it's invalid. More...
 

Static Public Member Functions

template<int numChars>
static constexpr Result Error (const char(&msg)[numChars])
 Constructs an Error from a pointer to an ASCII string literal. More...
 
static constexpr Result FromStableCharPointer (const char *msg)
 Constructs an Error from a pointer to an ascii string. More...
 

Public Attributes

const char * message
 If == nullptr then Result is valid. If != nullptr it's the reason of the error. More...
 

Detailed Description

An ascii string used as boolean result. SC_TRY macro forwards errors to caller.

Constructor & Destructor Documentation

◆ Result()

constexpr SC::Result::Result ( bool  result)
inlineexplicitconstexpr

Build a Result object from a boolean.

Parameters
resultPassing true constructs a valid Result. Passing false constructs invalid Result.

Member Function Documentation

◆ Error()

template<int numChars>
static constexpr Result SC::Result::Error ( const char(&)  msg[numChars])
inlinestaticconstexpr

Constructs an Error from a pointer to an ASCII string literal.

Template Parameters
numCharsSize of the character array holding the ASCII string
Parameters
msgThe custom error message
Returns
A Result object in invalid state

◆ FromStableCharPointer()

static constexpr Result SC::Result::FromStableCharPointer ( const char *  msg)
inlinestaticconstexpr

Constructs an Error from a pointer to an ascii string.

Caller of this function must ensure such pointer to be valid until Result is used.

Parameters
msgPointer to ASCII string representing the message.
Returns
A Result object in invalid state

◆ operator bool()

constexpr SC::Result::operator bool ( ) const
inlineconstexpr

Converts to true if the Result is valid, to false if it's invalid.

Member Data Documentation

◆ message

const char* SC::Result::message

If == nullptr then Result is valid. If != nullptr it's the reason of the error.


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