slice_internal.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2016 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #ifndef GRPC_CORE_LIB_SLICE_SLICE_INTERNAL_H
20 #define GRPC_CORE_LIB_SLICE_SLICE_INTERNAL_H
21 
23 
24 #include <stdint.h>
25 
26 #include <cstddef>
27 #include <string>
28 
29 #include "absl/strings/string_view.h"
30 
31 #include <grpc/slice.h>
32 #include <grpc/support/log.h>
33 
37 
40  size_t idx);
42 
43 // Returns a pointer to the first slice in the slice buffer without giving
44 // ownership to or a reference count on that slice.
46  GPR_DEBUG_ASSERT(sb->count > 0);
47  return &sb->slices[0];
48 }
49 
50 // Removes the first slice from the slice buffer.
52 
53 // Calls grpc_slice_sub with the given parameters on the first slice.
55  size_t end);
56 
58 // if slice matches a static slice, returns the static slice
59 // otherwise returns the passed in slice (without reffing it)
60 // used for surface boundaries where we might receive an un-interned static
61 // string
63  bool* returned_slice_is_different);
66 
70 }
71 
73  size_t len);
76 
77 // Returns the memory used by this slice, not counting the slice structure
78 // itself. This means that inlined and slices from static strings will return
79 // 0. All other slices will return the size of the allocated chars.
81 
82 namespace grpc_core {
83 
84 struct SliceHash {
85  std::size_t operator()(const grpc_slice& slice) const {
87  }
88 };
89 
90 extern uint32_t g_hash_seed;
91 
92 // Converts grpc_slice to absl::string_view.
94  return absl::string_view(
95  reinterpret_cast<const char*>(GRPC_SLICE_START_PTR(slice)),
97 }
98 
99 } // namespace grpc_core
100 
101 inline bool operator==(const grpc_slice& s1, const grpc_slice& s2) {
102  return grpc_slice_eq(s1, s2);
103 }
104 
105 #endif /* GRPC_CORE_LIB_SLICE_SLICE_INTERNAL_H */
grpc_core::SliceHash
Definition: slice_internal.h:84
xds_interop_client.str
str
Definition: xds_interop_client.py:487
log.h
GPR_DEBUG_ASSERT
#define GPR_DEBUG_ASSERT(x)
Definition: include/grpc/impl/codegen/log.h:103
begin
char * begin
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1007
slice.h
grpc_core
Definition: call_metric_recorder.h:31
seed
static const uint8_t seed[20]
Definition: dsa_test.cc:79
absl::string_view
Definition: abseil-cpp/absl/strings/string_view.h:167
grpc_slice_buffer::slices
grpc_slice * slices
Definition: include/grpc/impl/codegen/slice.h:89
grpc_core::StringViewFromSlice
absl::string_view StringViewFromSlice(const grpc_slice &slice)
Definition: slice_internal.h:93
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
grpc_slice_buffer_destroy_internal
void grpc_slice_buffer_destroy_internal(grpc_slice_buffer *sb)
Definition: slice/slice_buffer.cc:123
a
int a
Definition: abseil-cpp/absl/container/internal/hash_policy_traits_test.cc:88
xds_manager.p
p
Definition: xds_manager.py:60
grpc_static_slice_hash
uint32_t grpc_static_slice_hash(grpc_slice s)
memory.h
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
grpc_core::SliceHash::operator()
std::size_t operator()(const grpc_slice &slice) const
Definition: slice_internal.h:85
grpc_test_only_set_slice_hash_seed
void grpc_test_only_set_slice_hash_seed(uint32_t seed)
Definition: slice_refcount.cc:33
grpc_static_slice_eq
int grpc_static_slice_eq(grpc_slice a, grpc_slice b)
end
char * end
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1008
grpc_slice_buffer::count
size_t count
Definition: include/grpc/impl/codegen/slice.h:91
slice
grpc_slice slice
Definition: src/core/lib/surface/server.cc:467
grpc_slice_from_moved_string
grpc_slice grpc_slice_from_moved_string(grpc_core::UniquePtr< char > p)
Definition: slice/slice.cc:197
grpc_slice_from_moved_buffer
grpc_slice grpc_slice_from_moved_buffer(grpc_core::UniquePtr< char > p, size_t len)
Definition: slice/slice.cc:181
GRPC_SLICE_START_PTR
#define GRPC_SLICE_START_PTR(slice)
Definition: include/grpc/impl/codegen/slice.h:101
grpc_slice
Definition: include/grpc/impl/codegen/slice.h:65
grpc_slice_buffer_reset_and_unref_internal
void grpc_slice_buffer_reset_and_unref_internal(grpc_slice_buffer *sb)
Definition: slice/slice_buffer.cc:238
b
uint64_t b
Definition: abseil-cpp/absl/container/internal/layout_test.cc:53
operator==
bool operator==(const grpc_slice &s1, const grpc_slice &s2)
Definition: slice_internal.h:101
grpc_slice_buffer_peek_first
grpc_slice * grpc_slice_buffer_peek_first(grpc_slice_buffer *sb)
Definition: slice_internal.h:45
grpc_core::UniquePtr
std::unique_ptr< T, DefaultDeleteChar > UniquePtr
Definition: src/core/lib/gprpp/memory.h:43
stdint.h
setup.idx
idx
Definition: third_party/bloaty/third_party/capstone/bindings/python/setup.py:197
grpc_slice_buffer_partial_unref_internal
void grpc_slice_buffer_partial_unref_internal(grpc_slice_buffer *sb, size_t idx)
GRPC_SLICE_LENGTH
#define GRPC_SLICE_LENGTH(slice)
Definition: include/grpc/impl/codegen/slice.h:104
grpc_slice_buffer_sub_first
void grpc_slice_buffer_sub_first(grpc_slice_buffer *sb, size_t begin, size_t end)
Definition: slice/slice_buffer.cc:459
grpc_slice_buffer_remove_first
void grpc_slice_buffer_remove_first(grpc_slice_buffer *sb)
Definition: slice/slice_buffer.cc:449
string_view
absl::string_view string_view
Definition: attr.cc:22
grpc_slice_from_cpp_string
grpc_slice grpc_slice_from_cpp_string(std::string str)
Definition: slice/slice.cc:202
grpc_slice_hash_internal
uint32_t grpc_slice_hash_internal(const grpc_slice &s)
Definition: slice_internal.h:67
slice_refcount.h
murmur_hash.h
grpc_slice_memory_usage
size_t grpc_slice_memory_usage(grpc_slice s)
Definition: slice/slice.cc:76
grpc_slice_buffer
Definition: include/grpc/impl/codegen/slice.h:83
grpc_slice_maybe_static_intern
grpc_slice grpc_slice_maybe_static_intern(grpc_slice slice, bool *returned_slice_is_different)
len
int len
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:46
gpr_murmur_hash3
uint32_t gpr_murmur_hash3(const void *key, size_t len, uint32_t seed)
Definition: murmur_hash.cc:36
grpc_slice_eq
GPRAPI int grpc_slice_eq(grpc_slice a, grpc_slice b)
Definition: slice/slice.cc:387
grpc_core::g_hash_seed
uint32_t g_hash_seed
Definition: slice_refcount.cc:23
port_platform.h


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:19