GRPC C++  1.6.0
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 GRPCXX_IMPL_CODEGEN_METADATA_MAP_H
20 #define GRPCXX_IMPL_CODEGEN_METADATA_MAP_H
21 
23 
24 namespace grpc {
25 
26 class MetadataMap {
27  public:
28  MetadataMap() { memset(&arr_, 0, sizeof(arr_)); }
29 
32  }
33 
34  void FillMap() {
35  for (size_t i = 0; i < arr_.count; i++) {
36  // TODO(yangg) handle duplicates?
37  map_.insert(std::pair<grpc::string_ref, grpc::string_ref>(
39  StringRefFromSlice(&arr_.metadata[i].value)));
40  }
41  }
42 
43  std::multimap<grpc::string_ref, grpc::string_ref> *map() { return &map_; }
44  const std::multimap<grpc::string_ref, grpc::string_ref> *map() const {
45  return &map_;
46  }
47  grpc_metadata_array *arr() { return &arr_; }
48 
49  private:
51  std::multimap<grpc::string_ref, grpc::string_ref> map_;
52 };
53 
54 } // namespace grpc
55 
56 #endif // GRPCXX_IMPL_CODEGEN_METADATA_MAP_H
const std::multimap< grpc::string_ref, grpc::string_ref > * map() const
Definition: metadata_map.h:44
grpc::string_ref StringRefFromSlice(const grpc_slice *slice)
Definition: slice.h:27
virtual void grpc_metadata_array_destroy(grpc_metadata_array *array)=0
grpc_metadata_array * arr()
Definition: metadata_map.h:47
grpc_slice key
the key, value values are expected to line up with grpc_mdelem: if changing them, update metadata...
Definition: grpc_types.h:386
grpc_slice value
Definition: grpc_types.h:387
Definition: metadata_map.h:26
Definition: grpc_types.h:426
void FillMap()
Definition: metadata_map.h:34
grpc_metadata * metadata
Definition: grpc_types.h:429
std::multimap< grpc::string_ref, grpc::string_ref > * map()
Definition: metadata_map.h:43
CoreCodegenInterface * g_core_codegen_interface
Definition: call.h:49
MetadataMap()
Definition: metadata_map.h:28
size_t count
Definition: grpc_types.h:427
~MetadataMap()
Definition: metadata_map.h:30