• Home
  • Raw
  • Download

Lines Matching full:slice

27 #include <grpc/slice.h>
31 // This public slice definition largely based of the internal grpc_core::Slice
33 // internal grpc_core::Slice type as well.
39 class Slice; variable
44 // Returns an empty slice.
48 // It does export immutable access into the slice, such that this can be shared
87 // Size of the slice
103 explicit BaseSlice(const grpc_slice& slice) : slice_(slice) {} in BaseSlice() argument
107 void SetCSlice(const grpc_slice& slice) { slice_ = slice; } in SetCSlice() argument
190 explicit MutableSlice(const grpc_slice& slice);
206 // Return a sub slice of this one. Leaves this slice in an indeterminate but
221 class GPR_MSVC_EMPTY_BASE_CLASS_WORKAROUND Slice
223 public slice_detail::CopyConstructors<Slice> {
225 Slice() = default;
226 ~Slice();
227 explicit Slice(const grpc_slice& slice) : slice_detail::BaseSlice(slice) {} in Slice() argument
228 explicit Slice(slice_detail::BaseSlice&& other) in Slice() function
231 Slice(const Slice&) = delete;
232 Slice& operator=(const Slice&) = delete;
233 Slice(Slice&& other) noexcept : slice_detail::BaseSlice(other.TakeCSlice()) {} in Slice() function
234 Slice& operator=(Slice&& other) noexcept {
239 // A slice might refer to some memory that we keep a refcount to (this is
240 // owned), or some memory that's inlined into the slice (also owned), or some
243 // that we need to keep that slice text for longer than our API's guarantee us
246 // TakeOwned returns an owned slice regardless of current ownership, and
247 // leaves the current slice in a valid but externally unpredictable state - in
248 // doing so it can avoid adding a ref to the underlying slice.
249 Slice TakeOwned();
251 // AsOwned returns an owned slice but does not mutate the current slice,
252 // meaning that it may add a reference to the underlying slice.
253 Slice AsOwned() const;
255 // TakeMutable returns a MutableSlice, and leaves the current slice in an
257 // A mutable slice requires only one reference to the bytes of the slice -
260 // If the current slice is refcounted and there are more than one references
261 // to that slice, then the slice is copied in order to achieve a mutable
265 // Return a sub slice of this one. Leaves this slice in an indeterminate but
267 Slice TakeSubSlice(size_t pos, size_t n) { in TakeSubSlice()
268 return Slice(grpc_slice_sub_no_ref(TakeCSlice(), pos, pos + n)); in TakeSubSlice()
271 // Return a sub slice of this one. Adds a reference to the underlying slice.
272 Slice RefSubSlice(size_t pos, size_t n) const { in RefSubSlice()
273 return Slice(grpc_slice_sub(c_slice(), pos, pos + n)); in RefSubSlice()
276 // Split this slice, returning a new slice containing (split:end] and
277 // leaving this slice with [begin:split).
278 Slice Split(size_t split) { in Split()
279 return Slice(grpc_slice_split_tail(c_slice_ptr(), split)); in Split()
282 Slice Ref() const;
284 Slice Copy() const { return Slice(grpc_slice_copy(c_slice())); } in Copy()
286 static Slice FromRefcountAndBytes(grpc_slice_refcount* r,
292 struct SliceCastable<Slice, grpc_slice> {};
294 struct SliceCastable<grpc_slice, Slice> {};
302 struct SliceCastable<MutableSlice, Slice> {};
304 struct SliceCastable<Slice, MutableSlice> {};