class StatusWithSize

Defined at line 51 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

`StatusWithSize` stores a status and an unsigned integer. The integer must

not exceed `StatusWithSize::max_size()`, which is 134,217,727 (2**27 - 1) on

32-bit systems.

`StatusWithSize` is useful for reporting the number of bytes read or written

in an operation along with the status. For example, a function that writes a

formatted string may want to report both the number of characters written

and whether it ran out of space.

`StatusWithSize` is more efficient than its alternatives. It packs a status

and size into a single word, which can be returned from a function in a

register. Because they are packed together, the size is limited to

max_size().

`StatusWithSize`'s alternatives result in larger code size. For example:

1. Return status, pass size output as a pointer argument.

Requires an additional argument and forces the output argument to the

stack in order to pass an address, increasing code size.

2. Return an object with Status and size members.

At least for ARMv7-M, the returned struct is created on the stack,

which increases code size.

Public Methods

StatusWithSize Cancelled (size_t size)

Defined at line 53 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

StatusWithSize Unknown (size_t size)

Defined at line 56 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

StatusWithSize InvalidArgument (size_t size)

Defined at line 59 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

StatusWithSize DeadlineExceeded (size_t size)

Defined at line 62 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

StatusWithSize NotFound (size_t size)

Defined at line 65 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

StatusWithSize AlreadyExists (size_t size)

Defined at line 68 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

StatusWithSize PermissionDenied (size_t size)

Defined at line 71 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

StatusWithSize Unauthenticated (size_t size)

Defined at line 74 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

StatusWithSize ResourceExhausted (size_t size)

Defined at line 77 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

StatusWithSize FailedPrecondition (size_t size)

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

StatusWithSize Aborted (size_t size)

Defined at line 83 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

StatusWithSize OutOfRange (size_t size)

Defined at line 86 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

StatusWithSize Unimplemented (size_t size)

Defined at line 89 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

StatusWithSize Internal (size_t size)

Defined at line 92 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

StatusWithSize Unavailable (size_t size)

Defined at line 95 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

StatusWithSize DataLoss (size_t size)

Defined at line 98 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

void StatusWithSize ()

Creates a `StatusWithSize` with status `OK` and a size of 0.

Defined at line 103 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

template <typename T, typename = std::enable_if_t<std::is_integral<T>::value>>
void StatusWithSize (T size)

Creates a `StatusWithSize` with status `OK` and the provided size.

`std::enable_if` is used to prevent enum types (e.g. `Status::Code`) from

being used.

Defined at line 109 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

void StatusWithSize (Status status, size_t size)

Creates a StatusWithSize with the provided status and size.

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

void StatusWithSize (const StatusWithSize & )

Defined at line 118 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

StatusWithSize & operator= (const StatusWithSize & )

Defined at line 119 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

void UpdateAndAdd (StatusWithSize new_status_with_size)

`Update` s this status and adds to `size`.

The resulting `StatusWithSize` will have a size of `this->size() +

new_status_with_size.size()`

The resulting status will be `OK` if both statuses are `OK`, otherwise it

will take on the earliest non-`OK` status.

Defined at line 128 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

void ZeroIfNotOk ()

Zeroes the size if the status is not `OK`.

Defined at line 140 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

size_t size ()

Returns the size. The size is always present, even if `status()` is an

error.

Defined at line 148 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

size_t max_size ()

The maximum valid value for size.

Defined at line 151 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

bool ok ()

True if status() == OkStatus().

Defined at line 154 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

void IgnoreError ()

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.

Defined at line 161 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

Status status ()

Defined at line 163 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

bool IsCancelled ()

Functions for checking which status the StatusWithSize contains.

Defined at line 168 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

bool IsUnknown ()

Defined at line 171 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

bool IsInvalidArgument ()

Defined at line 174 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

bool IsDeadlineExceeded ()

Defined at line 177 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

bool IsNotFound ()

Defined at line 180 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

bool IsAlreadyExists ()

Defined at line 183 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

bool IsPermissionDenied ()

Defined at line 186 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

bool IsResourceExhausted ()

Defined at line 189 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

bool IsFailedPrecondition ()

Defined at line 192 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

bool IsAborted ()

Defined at line 195 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

bool IsOutOfRange ()

Defined at line 198 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

bool IsUnimplemented ()

Defined at line 201 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

bool IsInternal ()

Defined at line 204 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

bool IsUnavailable ()

Defined at line 207 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

bool IsDataLoss ()

Defined at line 210 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h

bool IsUnauthenticated ()

Defined at line 213 of file ../../third_party/pigweed/src/pw_status/public/pw_status/status_with_size.h