Commit Graph

4 Commits

Author SHA1 Message Date
Ewout van Bekkum
f89f1379d4 pw_string: redo pw::string::Length
Moves and renames the existing pw::string::Length to
pw::string::internal::ClampedLength. Instead two new helpers are added:
1) pw::string::NullTerminatedLength(...) which returns the length IFF
   the string is null terminated.
2) pw::string::ClampedCString(...) which returns a string_view of
   the clamped string. This is considered safer compared to strnlen_s
   and the existing internal::ClampedLength implementation, since
   sting_view does not require null termination.

Change-Id: Ie6486df13b205332633f3970109ca97f578e6993
Requires: pigweed-internal:12460
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/43463
Reviewed-by: Ewout van Bekkum <ewout@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
Pigweed-Auto-Submit: Ewout van Bekkum <ewout@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
2021-05-13 16:27:34 +00:00
Ewout van Bekkum
c2e9d88a21 pw_string: add pw::string::Copy methods
Adds pw::string::Copy helper methods as a safer alternative to
std::strncpy which unfortunately does not always null terminate.

In addition, the existing StringCopy methods are renamed to
StringOrNullCopy to denote that they support nullptr source strings
unlike pw::string::Copy.

Change-Id: I046c12da02721c5ad2f6601b9ac742d9dfa90c71
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/42931
Reviewed-by: Ewout van Bekkum <ewout@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
Pigweed-Auto-Submit: Ewout van Bekkum <ewout@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
2021-05-12 23:59:13 +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
ce9b952f05 pw_string: StringBuilder utility class
StringBuilder can be used to flexibly and safely build strings in
fixed-size buffers.

Change-Id: Ie4453e1bcd11ef522bb0211304e9cf758ac17827
2019-11-25 18:08:31 +00:00