diff options
Diffstat (limited to 'absl/status')
-rw-r--r-- | absl/status/BUILD.bazel | 1 | ||||
-rw-r--r-- | absl/status/CMakeLists.txt | 1 | ||||
-rw-r--r-- | absl/status/internal/status_internal.h | 51 | ||||
-rw-r--r-- | absl/status/status.h | 22 |
4 files changed, 54 insertions, 21 deletions
diff --git a/absl/status/BUILD.bazel b/absl/status/BUILD.bazel index d164252d..c4c5e497 100644 --- a/absl/status/BUILD.bazel +++ b/absl/status/BUILD.bazel @@ -31,6 +31,7 @@ licenses(["notice"]) # Apache 2.0 cc_library( name = "status", srcs = [ + "internal/status_internal.h", "status.cc", "status_payload_printer.cc", ], diff --git a/absl/status/CMakeLists.txt b/absl/status/CMakeLists.txt index c041d695..b48989d1 100644 --- a/absl/status/CMakeLists.txt +++ b/absl/status/CMakeLists.txt @@ -19,6 +19,7 @@ absl_cc_library( HDRS "status.h" SRCS + "internal/status_internal.h" "status.cc" "status_payload_printer.h" "status_payload_printer.cc" diff --git a/absl/status/internal/status_internal.h b/absl/status/internal/status_internal.h new file mode 100644 index 00000000..1f82b8e4 --- /dev/null +++ b/absl/status/internal/status_internal.h @@ -0,0 +1,51 @@ +// Copyright 2019 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#ifndef ABSL_STATUS_INTERNAL_STATUS_INTERNAL_H_ +#define ABSL_STATUS_INTERNAL_STATUS_INTERNAL_H_ + +#include <string> + +#include "absl/container/inlined_vector.h" +#include "absl/strings/cord.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN + +enum class StatusCode : int; + +namespace status_internal { + +// Container for status payloads. +struct Payload { + std::string type_url; + absl::Cord payload; +}; + +using Payloads = absl::InlinedVector<Payload, 1>; + +// Reference-counted representation of Status data. +struct StatusRep { + std::atomic<int32_t> ref; + absl::StatusCode code; + std::string message; + std::unique_ptr<status_internal::Payloads> payloads; +}; + +absl::StatusCode MapToLocalCode(int value); +} // namespace status_internal + +ABSL_NAMESPACE_END +} // namespace absl + +#endif // ABSL_STATUS_INTERNAL_STATUS_INTERNAL_H_ diff --git a/absl/status/status.h b/absl/status/status.h index 42530621..8097b05a 100644 --- a/absl/status/status.h +++ b/absl/status/status.h @@ -18,6 +18,7 @@ #include <string> #include "absl/container/inlined_vector.h" +#include "absl/status/internal/status_internal.h" #include "absl/strings/cord.h" #include "absl/types/optional.h" @@ -164,27 +165,6 @@ std::string StatusCodeToString(StatusCode code); // Streams StatusCodeToString(code) to `os`. std::ostream& operator<<(std::ostream& os, StatusCode code); -namespace status_internal { - -// Container for status payloads. -struct Payload { - std::string type_url; - absl::Cord payload; -}; - -using Payloads = absl::InlinedVector<Payload, 1>; - -// Reference-counted representation of Status data. -struct StatusRep { - std::atomic<int32_t> ref; - absl::StatusCode code; - std::string message; - std::unique_ptr<status_internal::Payloads> payloads; -}; - -absl::StatusCode MapToLocalCode(int value); -} // namespace status_internal - class ABSL_MUST_USE_RESULT Status final { public: // Creates an OK status with no message or payload. |