diff options
author | Dmitri Gribenko <dmitrig@google.com> | 2024-01-25 09:49:41 -0800 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2024-01-25 09:50:27 -0800 |
commit | 42624b3d9d56ae6fd5c48b28715044667942b9d8 (patch) | |
tree | 819eb7cfcf3b76a3dc47b4c0f67e21b250d09e73 /absl/strings/escaping.h | |
parent | 27f15a052ba54c984faa1eb6044de59b237e6f37 (diff) |
Add nullability annotations
PiperOrigin-RevId: 601477629
Change-Id: I3b683d94192b04f233ce5ec636586ccb90d24602
Diffstat (limited to 'absl/strings/escaping.h')
-rw-r--r-- | absl/strings/escaping.h | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/absl/strings/escaping.h b/absl/strings/escaping.h index bf2a5898..f6f7a29c 100644 --- a/absl/strings/escaping.h +++ b/absl/strings/escaping.h @@ -28,6 +28,7 @@ #include <vector> #include "absl/base/macros.h" +#include "absl/base/nullability.h" #include "absl/strings/ascii.h" #include "absl/strings/str_join.h" #include "absl/strings/string_view.h" @@ -69,10 +70,12 @@ ABSL_NAMESPACE_BEGIN // ... // } // EXPECT_EQ(unescaped_s, "foo\rbar\nbaz\t"); -bool CUnescape(absl::string_view source, std::string* dest, std::string* error); +bool CUnescape(absl::string_view source, absl::Nonnull<std::string*> dest, + absl::Nullable<std::string*> error); // Overload of `CUnescape()` with no error reporting. -inline bool CUnescape(absl::string_view source, std::string* dest) { +inline bool CUnescape(absl::string_view source, + absl::Nonnull<std::string*> dest) { return CUnescape(source, dest, nullptr); } @@ -122,7 +125,7 @@ std::string Utf8SafeCHexEscape(absl::string_view src); // Encodes a `src` string into a base64-encoded 'dest' string with padding // characters. This function conforms with RFC 4648 section 4 (base64) and RFC // 2045. -void Base64Escape(absl::string_view src, std::string* dest); +void Base64Escape(absl::string_view src, absl::Nonnull<std::string*> dest); std::string Base64Escape(absl::string_view src); // WebSafeBase64Escape() @@ -130,7 +133,8 @@ std::string Base64Escape(absl::string_view src); // Encodes a `src` string into a base64 string, like Base64Escape() does, but // outputs '-' instead of '+' and '_' instead of '/', and does not pad 'dest'. // This function conforms with RFC 4648 section 5 (base64url). -void WebSafeBase64Escape(absl::string_view src, std::string* dest); +void WebSafeBase64Escape(absl::string_view src, + absl::Nonnull<std::string*> dest); std::string WebSafeBase64Escape(absl::string_view src); // Base64Unescape() @@ -140,7 +144,7 @@ std::string WebSafeBase64Escape(absl::string_view src); // `src` contains invalid characters, `dest` is cleared and returns `false`. // If padding is included (note that `Base64Escape()` does produce it), it must // be correct. In the padding, '=' and '.' are treated identically. -bool Base64Unescape(absl::string_view src, std::string* dest); +bool Base64Unescape(absl::string_view src, absl::Nonnull<std::string*> dest); // WebSafeBase64Unescape() // @@ -149,7 +153,8 @@ bool Base64Unescape(absl::string_view src, std::string* dest); // invalid characters, `dest` is cleared and returns `false`. If padding is // included (note that `WebSafeBase64Escape()` does not produce it), it must be // correct. In the padding, '=' and '.' are treated identically. -bool WebSafeBase64Unescape(absl::string_view src, std::string* dest); +bool WebSafeBase64Unescape(absl::string_view src, + absl::Nonnull<std::string*> dest); // HexStringToBytes() // |