Result<T> Class

Template Parameters | Constructors & Destructor | Member Functions | Member Variables

Represents either an expected function return value or an error result.

Definition

Line 18 of System.Base/Result.cm

Template Parameters

T

Constructors & Destructor

public Result()
public Result(ErrorId errorId_) Use this constructor when constructing an error result.
public Result(T&& value_) Constructs an expected function result.
public Result(const T& value_) Constructs an expected function result.

Member Functions

public Result AndThen(const Result& second) If the result represented by this result is an error result, returns this result. Otherwise returns the second result.
public inline bool Error() const Returns true if the result represents an error result and false otherwise.
public inline int GetErrorId() const Returns the contained error id.
public String<char> GetErrorMessage() const Returns the error message associated with the error id.
public void SetErrorId(int errorId_) Sets the contained error id.
public inline T& Value() Returns the expected return value.
public inline const T& Value() const Returns the expected return value.

Member Variables

private int errorId
private T value

Constructor& Destructor Details

Result Constructor

public Result()

Definition
Line 20 of System.Base/Result.cm


Result Constructor

public Result(ErrorId errorId_)

Use this constructor when constructing an error result.

The error id can be obtained by calling the AllocateError function.

Definition
Line 23 of System.Base/Result.cm


Result Constructor

public Result(T&& value_)

Constructs an expected function result.

Definition
Line 22 of System.Base/Result.cm


Result Constructor

public Result(const T& value_)

Constructs an expected function result.

Definition
Line 21 of System.Base/Result.cm


Member Function Details

AndThen Member Function

public Result AndThen(const Result& second)

If the result represented by this result is an error result, returns this result. Otherwise returns the second result.

Definition
Line 24 of System.Base/Result.cm


Error Member Function

public inline bool Error()

Returns true if the result represents an error result and false otherwise.

An error result will have an error id that is a positive integer. A successful result will have an error id that is zero.

Definition
Line 27 of System.Base/Result.cm


GetErrorId Member Function

public inline int GetErrorId()

Returns the contained error id.

A positive error id indicates error. A zero error id indicates success.

Definition
Line 28 of System.Base/Result.cm


GetErrorMessage Member Function

public String<char> GetErrorMessage()

Returns the error message associated with the error id.

The error message will contain a stack trace on debug builds.

Definition
Line 30 of System.Base/Result.cm


SetErrorId Member Function

public void SetErrorId(int errorId_)

Sets the contained error id.

Definition
Line 29 of System.Base/Result.cm


Value Member Function

public inline T& Value()

Returns the expected return value.

Definition
Line 26 of System.Base/Result.cm


Value Member Function

public inline const T& Value()

Returns the expected return value.

Definition
Line 25 of System.Base/Result.cm