template <typename Derived, _PW_STATUS_CODE auto kOkCode>
class StatusBase
Defined at line 53 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
alias `StatusOf
<kOkCode
>`. Derived classes should be declared
`[[nodiscard]]` unless using `StatusOf` (which is declared `[[nodiscard]]`).
Users should not interact directly `StatusBase`, except to instantiate a
custom status class. Do not use `StatusBase` for variables or function
parameters.
Template Parameters
Protected Members
Code code_
Public Methods
bool ok ()
Returns true if the status is the OK code.
Defined at line 59 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_base.h
Code code ()
Returns the underlying status code.
Defined at line 62 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 68 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 75 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 79 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 106 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 109 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 111 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 112 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_base.h
void StatusBase<Derived, kOkCode> (StatusBase<Derived, kOkCode> && )
Defined at line 113 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_base.h
StatusBase<Derived, kOkCode> & operator= (StatusBase<Derived, kOkCode> && )
Defined at line 114 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)