GRPC Core  3.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
slice_buffer.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015, Google Inc.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above
13  * copyright notice, this list of conditions and the following disclaimer
14  * in the documentation and/or other materials provided with the
15  * distribution.
16  * * Neither the name of Google Inc. nor the names of its
17  * contributors may be used to endorse or promote products derived from
18  * this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
33 
34 #ifndef GRPC_SLICE_BUFFER_H
35 #define GRPC_SLICE_BUFFER_H
36 
37 #include <grpc/slice.h>
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 /* initialize a slice buffer */
45 /* destroy a slice buffer - unrefs any held elements */
47 /* Add an element to a slice buffer - takes ownership of the slice.
48  This function is allowed to concatenate the passed in slice to the end of
49  some other slice if desired by the slice buffer. */
51 /* add an element to a slice buffer - takes ownership of the slice and returns
52  the index of the slice.
53  Guarantees that the slice will not be concatenated at the end of another
54  slice (i.e. the data for this slice will begin at the first byte of the
55  slice at the returned index in sb->slices)
56  The implementation MAY decide to concatenate data at the end of a small
57  slice added in this fashion. */
59  grpc_slice slice);
61  size_t n);
62 /* add a very small (less than 8 bytes) amount of data to the end of a slice
63  buffer: returns a pointer into which to add the data */
64 GPRAPI uint8_t *grpc_slice_buffer_tiny_add(grpc_slice_buffer *sb, size_t len);
65 /* pop the last buffer, but don't unref it */
67 /* clear a slice buffer, unref all elements */
69 /* swap the contents of two slice buffers */
71 /* move all of the elements of src into dst */
73  grpc_slice_buffer *dst);
74 /* remove n bytes from the end of a slice buffer */
76  grpc_slice_buffer *garbage);
77 /* move the first n bytes of src into dst */
79  grpc_slice_buffer *dst);
80 /* move the first n bytes of src into dst (copying them) */
82  grpc_slice_buffer *src,
83  size_t n, void *dst);
84 /* take the first slice in the slice buffer */
86 /* undo the above with (a possibly different) \a slice */
88  grpc_slice slice);
89 
90 #ifdef __cplusplus
91 }
92 #endif
93 
94 #endif /* GRPC_SLICE_BUFFER_H */
GPRAPI void grpc_slice_buffer_destroy(grpc_slice_buffer *sb)
GPRAPI void grpc_slice_buffer_undo_take_first(grpc_slice_buffer *src, grpc_slice slice)
GPRAPI uint8_t * grpc_slice_buffer_tiny_add(grpc_slice_buffer *sb, size_t len)
GPRAPI grpc_slice grpc_slice_buffer_take_first(grpc_slice_buffer *src)
GPRAPI size_t grpc_slice_buffer_add_indexed(grpc_slice_buffer *sb, grpc_slice slice)
Definition: slice.h:90
#define GPRAPI
Definition: port_platform.h:410
Definition: slice.h:108
GPRAPI void grpc_slice_buffer_addn(grpc_slice_buffer *sb, grpc_slice *slices, size_t n)
GPRAPI void grpc_slice_buffer_reset_and_unref(grpc_slice_buffer *sb)
GPRAPI void grpc_slice_buffer_init(grpc_slice_buffer *sb)
GPRAPI void grpc_slice_buffer_move_first(grpc_slice_buffer *src, size_t n, grpc_slice_buffer *dst)
struct grpc_exec_ctx grpc_exec_ctx
Definition: exec_ctx_fwd.h:39
GPRAPI void grpc_slice_buffer_pop(grpc_slice_buffer *sb)
GPRAPI void grpc_slice_buffer_add(grpc_slice_buffer *sb, grpc_slice slice)
GPRAPI void grpc_slice_buffer_trim_end(grpc_slice_buffer *src, size_t n, grpc_slice_buffer *garbage)
GPRAPI void grpc_slice_buffer_swap(grpc_slice_buffer *a, grpc_slice_buffer *b)
GPRAPI void grpc_slice_buffer_move_first_into_buffer(grpc_exec_ctx *exec_ctx, grpc_slice_buffer *src, size_t n, void *dst)
GPRAPI void grpc_slice_buffer_move_into(grpc_slice_buffer *src, grpc_slice_buffer *dst)