Commit Graph

7 Commits

Author SHA1 Message Date
Wyatt Hepler
d78f7c6b75 pw_status: Update Status::CODE to Status::Code()
- Update Status::CODE style to Status::Code() using
  pw_status/update_style.py.
- Make minor adjustments to the pw_assert tests to get them passing.

Change-Id: Ie54c3c605178fd1e42c7cedbcff324115f3ed279
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/19165
Commit-Queue: Wyatt Hepler <hepler@google.com>
Reviewed-by: Ewout van Bekkum <ewout@google.com>
2020-09-30 18:09:44 +00:00
Wyatt Hepler
6d1a6c6939 pw_span: Move pw_string, pw_unit_test to std::span
- Update pw_string and the test framework to std::span.
- Have pw_string pass std::span by value, for consistency with other
  uses in Pigweed.
- Recommend using template specializations instead of overloads for
  custom ToString implementations. Template specializations are
  preferred because the main ToString definition is a template.

Change-Id: Ib67c6bce1752c4a90e2138bdb1f20c6671f55d50
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/12841
Reviewed-by: Keir Mierle <keir@google.com>
Commit-Queue: Wyatt Hepler <hepler@google.com>
2020-06-23 20:45:28 +00:00
Wyatt Hepler
f707880fbe pw_status: StatusWithSize constants
- Provide StatusWithSize constants that can be used similarly to
  Status::Codes. For example, StatusWithSize::DATA_LOSS constructs a
  StatusWithSize with status DATA_LOSS and size 0.
- Remove the default constructor argument for the size. Use the
  constants instead.
- Update uses of StatusWithSize(Status::X) to use StatusWithSize::X.

Change-Id: I901b7bb0bbbb4fde52f6b3acc3047f366b250515
2020-02-25 13:50:41 -08:00
Wyatt Hepler
50f70779c8 Remove StatusWithSize implicit conversions
- Disallow implicit conversions between Status and StatusWithSize, which
  can be problematic.
- Add TRY_WITH_SIZE to pw_kvs to handle returning StatusWithSize from
  functions.
- Make zero the default size argument for StatusWithSize.
- Expand tests for StatusWithSize.

Change-Id: Ia1c36e5a39402a50138d93e89afbaa5e772adb8a
2020-02-14 17:59:00 +00:00
Wyatt Hepler
2596fe5418 pw_string: Rename va_list Format to FormatVaList
On Windows, sometimes the va_list overload would be used when formatting
with a single argument. To avoid potential conflicts like these, the
va_list versions of string::Format and StringBuilder::Format are renamed
to FormatVaList.

Change-Id: Id29fae21b13ed420b13841a479e3748a1d3b91ce
2020-01-24 22:53:22 +00:00
Wyatt Hepler
1a96094ce6 Fix copyright notices
- Add missing copright header in conf.py.
- Fix inconsistent copyright notice line breaking.

Change-Id: Ib78f7768643069c49ff986a48a176df9fd06e891
2019-11-27 22:34:02 +00:00
Wyatt Hepler
e2dc6d18d6 Safer snprintf / vsnprintf functions
Provide a string::Format function that writes to a span. The snprintf
return value is interpreted and returned as a StatusWithSize.

Change-Id: Ib7fed684dc333d5feaef85c1bb558cb45e3936bd
2019-11-15 21:54:48 +00:00