GRPC C++ 0.10.0.0

- Main Page
- Namespaces
- Data Structures
- Files

- File List
- Globals

All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
slice.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 GRPCXX_SLICE_H
35 #define GRPCXX_SLICE_H
36
37 #include <grpc/support/slice.h>
38 #include <grpc++/config.h>
39
40 namespace grpc {
41
42 class Slice GRPC_FINAL {
43 public:
44 // construct empty slice
45 Slice();
46 // destructor - drops one ref
47 ~Slice();
48 // construct slice from grpc slice, adding a ref
49 enum AddRef { ADD_REF };
50 Slice(gpr_slice slice, AddRef);
51 // construct slice from grpc slice, stealing a ref
52 enum StealRef { STEAL_REF };
53 Slice(gpr_slice slice, StealRef);
54 // copy constructor - adds a ref
55 Slice(const Slice& other);
56 // assignment - ref count is unchanged
57 Slice& operator=(Slice other) {
58 std::swap(slice_, other.slice_);
59 return *this;
60 }
61
62 size_t size() const { return GPR_SLICE_LENGTH(slice_); }
63 const gpr_uint8* begin() const { return GPR_SLICE_START_PTR(slice_); }
64 const gpr_uint8* end() const { return GPR_SLICE_END_PTR(slice_); }
65
66 private:
67 friend class ByteBuffer;
68
69 gpr_slice slice_;
70 };
71
72 } // namespace grpc
73
74 #endif // GRPCXX_SLICE_H
grpc::Slice::~Slice
~Slice()
grpc::Slice::end
const gpr_uint8 * end() const
Definition: slice.h:64
grpc::Slice::StealRef
StealRef
Definition: slice.h:52
grpc::Slice
Definition: slice.h:42
config.h
grpc::Slice::begin
const gpr_uint8 * begin() const
Definition: slice.h:63
GRPC_FINAL
#define GRPC_FINAL
Definition: config.h:71
grpc::Slice::ADD_REF
Definition: slice.h:49
grpc::Slice::STEAL_REF
Definition: slice.h:52
grpc::Slice::Slice
Slice()
grpc::Slice::size
size_t size() const
Definition: slice.h:62
grpc::Slice::operator=
Slice & operator=(Slice other)
Definition: slice.h:57
grpc::Slice::AddRef
AddRef
Definition: slice.h:49
grpc::ByteBuffer
Definition: byte_buffer.h:49