GRPC C++  1.13.0-dev
metadata_map.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015 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 GRPCPP_IMPL_CODEGEN_METADATA_MAP_H
20 #define GRPCPP_IMPL_CODEGEN_METADATA_MAP_H
21 
23 
24 namespace grpc {
25 
26 namespace internal {
27 class MetadataMap {
28  public:
29  MetadataMap() { memset(&arr_, 0, sizeof(arr_)); }
30 
33  }
34 
35  void FillMap() {
36  for (size_t i = 0; i < arr_.count; i++) {
37  // TODO(yangg) handle duplicates?
38  map_.insert(std::pair<grpc::string_ref, grpc::string_ref>(
40  StringRefFromSlice(&arr_.metadata[i].value)));
41  }
42  }
43 
44  std::multimap<grpc::string_ref, grpc::string_ref>* map() { return &map_; }
45  const std::multimap<grpc::string_ref, grpc::string_ref>* map() const {
46  return &map_;
47  }
48  grpc_metadata_array* arr() { return &arr_; }
49 
50  private:
52  std::multimap<grpc::string_ref, grpc::string_ref> map_;
53 };
54 } // namespace internal
55 
56 } // namespace grpc
57 
58 #endif // GRPCPP_IMPL_CODEGEN_METADATA_MAP_H
grpc::string_ref StringRefFromSlice(const grpc_slice *slice)
Definition: slice.h:120
virtual void grpc_metadata_array_destroy(grpc_metadata_array *array)=0
Definition: metadata_map.h:27
grpc_slice key
the key, value values are expected to line up with grpc_mdelem: if changing them, update metadata...
Definition: grpc_types.h:426
grpc_slice value
Definition: grpc_types.h:427
Definition: grpc_types.h:466
grpc_metadata * metadata
Definition: grpc_types.h:469
MetadataMap()
Definition: metadata_map.h:29
std::multimap< grpc::string_ref, grpc::string_ref > * map()
Definition: metadata_map.h:44
An Alarm posts the user provided tag to its associated completion queue upon expiry or cancellation...
Definition: alarm.h:31
~MetadataMap()
Definition: metadata_map.h:31
CoreCodegenInterface * g_core_codegen_interface
Definition: call.h:46
grpc_metadata_array * arr()
Definition: metadata_map.h:48
size_t count
Definition: grpc_types.h:467
void FillMap()
Definition: metadata_map.h:35
const std::multimap< grpc::string_ref, grpc::string_ref > * map() const
Definition: metadata_map.h:45