diff options
author | Abseil Team <absl-team@google.com> | 2021-03-01 06:24:39 -0800 |
---|---|---|
committer | vslashg <gfalcon@google.com> | 2021-03-01 11:09:42 -0500 |
commit | a76698790753d2ec71f655cdc84d61bcb27780d4 (patch) | |
tree | 86722313204661d2e0501b1fa6f9d8b439ae8757 /absl/status/status.cc | |
parent | 998805a4c79d5d7a771f7e5a8ee3cbbbcba04f94 (diff) |
Export of internal Abseil changes
--
a9eb3c976c6d8ef4fca3d416847f8fca4bd90dd7 by Derek Mauro <dmauro@google.com>:
Remove the deprecated container library, which doesn't do anything.
This will help prevent user confusion, as seen in #183.
PiperOrigin-RevId: 360172262
--
4f872f651e25a528bdc59ee4e24543fbbd358f00 by Abseil Team <absl-team@google.com>:
Remove unused nspace alias.
PiperOrigin-RevId: 359487559
--
43e877e464886cf9226012f5bb47910b8995e70f by Abseil Team <absl-team@google.com>:
Create a StatusToStringMode to control how the ToString behaves.
PiperOrigin-RevId: 359339603
--
0da1291569e167341613359846948c72c8a838e1 by Greg Falcon <gfalcon@google.com>:
Fix a bug in SimpleAtoi/SimpleAtof, which accepted a prefix of "+-" (e.g., "+-5" was parsed as 5.0).
This regression was introduced when we migrated these functions to use absl::from_chars.
PiperOrigin-RevId: 359135105
GitOrigin-RevId: a9eb3c976c6d8ef4fca3d416847f8fca4bd90dd7
Change-Id: I0e2072cad80651e473ba1d34b1fb3a033dfaba80
Diffstat (limited to 'absl/status/status.cc')
-rw-r--r-- | absl/status/status.cc | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/absl/status/status.cc b/absl/status/status.cc index 7962bb9e..51a0d268 100644 --- a/absl/status/status.cc +++ b/absl/status/status.cc @@ -291,20 +291,26 @@ bool Status::EqualsSlow(const absl::Status& a, const absl::Status& b) { return true; } -std::string Status::ToStringSlow() const { +std::string Status::ToStringSlow(StatusToStringMode mode) const { std::string text; absl::StrAppend(&text, absl::StatusCodeToString(code()), ": ", message()); - status_internal::StatusPayloadPrinter printer = - status_internal::GetStatusPayloadPrinter(); - this->ForEachPayload([&](absl::string_view type_url, - const absl::Cord& payload) { - absl::optional<std::string> result; - if (printer) result = printer(type_url, payload); - absl::StrAppend( - &text, " [", type_url, "='", - result.has_value() ? *result : absl::CHexEscape(std::string(payload)), - "']"); - }); + + const bool with_payload = (mode & StatusToStringMode::kWithPayload) == + StatusToStringMode::kWithPayload; + + if (with_payload) { + status_internal::StatusPayloadPrinter printer = + status_internal::GetStatusPayloadPrinter(); + this->ForEachPayload([&](absl::string_view type_url, + const absl::Cord& payload) { + absl::optional<std::string> result; + if (printer) result = printer(type_url, payload); + absl::StrAppend( + &text, " [", type_url, "='", + result.has_value() ? *result : absl::CHexEscape(std::string(payload)), + "']"); + }); + } return text; } |