Pigweed
 
Loading...
Searching...
No Matches
pw::Status Class Reference

#include <status.h>

Public Types

using Code = pw_Status
 

Public Member Functions

constexpr Status (Code code=PW_STATUS_OK)
 
constexpr Status (const Status &)=default
 
constexpr Statusoperator= (const Status &)=default
 
constexpr Code code () const
 Returns the Status::Code (pw_Status) for this Status.
 
constexpr bool ok () const
 
constexpr bool IsCancelled () const
 
constexpr bool IsUnknown () const
 
constexpr bool IsInvalidArgument () const
 
constexpr bool IsDeadlineExceeded () const
 
constexpr bool IsNotFound () const
 
constexpr bool IsAlreadyExists () const
 
constexpr bool IsPermissionDenied () const
 
constexpr bool IsResourceExhausted () const
 
constexpr bool IsFailedPrecondition () const
 
constexpr bool IsAborted () const
 
constexpr bool IsOutOfRange () const
 
constexpr bool IsUnimplemented () const
 
constexpr bool IsInternal () const
 
constexpr bool IsUnavailable () const
 
constexpr bool IsDataLoss () const
 
constexpr bool IsUnauthenticated () const
 
constexpr void Update (Status other)
 
constexpr void IgnoreError () const
 
const char * str () const
 Returns a null-terminated string representation of the Status.
 

Static Public Member Functions

static constexpr Status Cancelled ()
 
static constexpr Status Unknown ()
 
static constexpr Status InvalidArgument ()
 
static constexpr Status DeadlineExceeded ()
 
static constexpr Status NotFound ()
 
static constexpr Status AlreadyExists ()
 
static constexpr Status PermissionDenied ()
 
static constexpr Status ResourceExhausted ()
 
static constexpr Status FailedPrecondition ()
 
static constexpr Status Aborted ()
 
static constexpr Status OutOfRange ()
 
static constexpr Status Unimplemented ()
 
static constexpr Status Internal ()
 
static constexpr Status Unavailable ()
 
static constexpr Status DataLoss ()
 
static constexpr Status Unauthenticated ()
 

Detailed Description

Status is a thin, zero-cost abstraction around the pw_Status enum. It initializes to

embed:rst:inline :c:enumerator:`OK` 

by default and adds ok() and str() methods. Implicit conversions are permitted between pw_Status and pw::Status.

An

embed:rst:inline :c:enumerator:`OK` 

Status is created by the

embed:rst:inline :cpp:func:`pw::OkStatus` 

function or by the default Status constructor. Non-OK Status is created with a static member function that corresponds with the status code.

Member Function Documentation

◆ IgnoreError()

constexpr void pw::Status::IgnoreError ( ) const
inlineconstexpr

Ignores any errors. This method does nothing except potentially suppress complaints from any tools that are checking that errors are not dropped on the floor.

◆ ok()

constexpr bool pw::Status::ok ( ) const
inlineconstexpr

True if the status is

embed:rst:inline :c:enumerator:`OK` 

.

This function is provided in place of an IsOk() function.

◆ Update()

constexpr void pw::Status::Update ( Status  other)
inlineconstexpr

Updates this Status to the provided Status IF this status is

embed:rst:inline :c:enumerator:`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.


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