diff options
Diffstat (limited to 'contrib/libs/grpc/include/grpcpp/impl/codegen/slice.h')
-rw-r--r-- | contrib/libs/grpc/include/grpcpp/impl/codegen/slice.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/contrib/libs/grpc/include/grpcpp/impl/codegen/slice.h b/contrib/libs/grpc/include/grpcpp/impl/codegen/slice.h index 0b9752ccff..3de44c8f90 100644 --- a/contrib/libs/grpc/include/grpcpp/impl/codegen/slice.h +++ b/contrib/libs/grpc/include/grpcpp/impl/codegen/slice.h @@ -19,12 +19,13 @@ #ifndef GRPCPP_IMPL_CODEGEN_SLICE_H #define GRPCPP_IMPL_CODEGEN_SLICE_H +// IWYU pragma: private, include <grpcpp/support/slice.h> + +#include <grpc/impl/codegen/slice.h> #include <grpcpp/impl/codegen/config.h> #include <grpcpp/impl/codegen/core_codegen_interface.h> #include <grpcpp/impl/codegen/string_ref.h> -#include <grpc/impl/codegen/slice.h> - namespace grpc { /// A wrapper around \a grpc_slice. @@ -74,6 +75,11 @@ class Slice final { Slice(const Slice& other) : slice_(g_core_codegen_interface->grpc_slice_ref(other.slice_)) {} + /// Move constructor, steals a reference. + Slice(Slice&& other) noexcept : slice_(other.slice_) { + other.slice_ = g_core_codegen_interface->grpc_empty_slice(); + } + /// Assignment, reference count is unchanged. Slice& operator=(Slice other) { std::swap(slice_, other.slice_); @@ -107,6 +113,12 @@ class Slice final { /// Raw pointer to the end (one byte \em past the last element) of the slice. const uint8_t* end() const { return GRPC_SLICE_END_PTR(slice_); } + /// Returns a substring of the `slice` as another slice. + Slice sub(size_t begin, size_t end) const { + return Slice(g_core_codegen_interface->grpc_slice_sub(slice_, begin, end), + STEAL_REF); + } + /// Raw C slice. Caller needs to call grpc_slice_unref when done. grpc_slice c_slice() const { return g_core_codegen_interface->grpc_slice_ref(slice_); |