template <typename Derived, _PW_STATUS_CODE auto kOkCode>

class StatusBase

Defined at line 54 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_base.h

Base class providing standard status operations for status types using CRTP.

`StatusBase` provides common functionality for status types that wrap an

enum or integer status code, including checking for success (`ok()`),

retrieving the code (`code()`), string formatting (`str()`), updating,

and equality comparisons.

Custom status types should derive from `StatusBase

<Derived

, kOkCode>` or use

the `PW_STATUS_TYPE` macro. Derived classes should be declared

`[[nodiscard]]` unless created using `PW_STATUS_TYPE` (which applies

`[[nodiscard]]` automatically).

Users should not interact directly `StatusBase`, except to instantiate a

custom status class. Do not use `StatusBase` for variables or function

parameters.

Template Parameters

Derived The derived status class (CRTP parameter).
kOkCode Code value that represents success (`ok() == true`).

Protected Members

Code code_

Public Methods

bool ok ()

Returns true if the status is the OK code.

Defined at line 60 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_base.h

Code code ()

Returns the underlying status code.

Defined at line 63 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_base.h

void Update (Derived other)

Updates this status to `other` if this status is currently `ok()`.

This is useful for tracking the first encountered error, as calls to this

helper will not change one error status to another error status.

Defined at line 69 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_base.h

void IgnoreError ()

Ignores any errors, suppressing unused-result warnings.

Defined at line 76 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_base.h

const char * str ()

Returns a string representation of the status. Only supported for status

types with enum codes.

Defined at line 80 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_base.h

Protected Methods

void StatusBase<Derived, kOkCode> ()

Defaults to `kOkCode` (`ok() == true`).

Defined at line 107 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_base.h

void StatusBase<Derived, kOkCode> (Code code)

Explicitly construct from the underlying code.

Defined at line 110 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_base.h

void StatusBase<Derived, kOkCode> (const StatusBase<Derived, kOkCode> & )

Defined at line 112 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_base.h

StatusBase<Derived, kOkCode> & operator= (const StatusBase<Derived, kOkCode> & )

Defined at line 113 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_base.h

void StatusBase<Derived, kOkCode> (StatusBase<Derived, kOkCode> && )

Defined at line 114 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_base.h

StatusBase<Derived, kOkCode> & operator= (StatusBase<Derived, kOkCode> && )

Defined at line 115 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_base.h

Friends

template <typename Derived, _PW_STATUS_CODE auto kOkCode>
bool StatusBase (Code lhs, Derived rhs)
template <typename Derived, _PW_STATUS_CODE auto kOkCode>
bool StatusBase (Derived lhs, Code rhs)
template <typename Derived, _PW_STATUS_CODE auto kOkCode>
bool StatusBase (Code lhs, Derived rhs)
template <typename Derived, _PW_STATUS_CODE auto kOkCode>
bool StatusBase (Derived lhs, Code rhs)
template <typename Derived, _PW_STATUS_CODE auto kOkCode>
bool StatusBase (Derived lhs, Derived rhs)
template <typename Derived_PW_STATUS_CODE auto kOkCode>
bool StatusBase (Derived lhsDerived rhs)