ruby_generator_map-inl.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 GRPC_INTERNAL_COMPILER_RUBY_GENERATOR_MAP_INL_H
20 #define GRPC_INTERNAL_COMPILER_RUBY_GENERATOR_MAP_INL_H
21 
22 #include <initializer_list>
23 #include <iostream>
24 #include <map>
25 #include <ostream> // NOLINT
26 #include <vector>
27 
28 #include "src/compiler/config.h"
29 
30 using std::initializer_list;
31 using std::map;
32 using std::vector;
33 
34 namespace grpc_ruby_generator {
35 
36 // Converts an initializer list of the form { key0, value0, key1, value1, ... }
37 // into a map of key* to value*. Is merely a readability helper for later code.
38 inline std::map<std::string, std::string> ListToDict(
39  const initializer_list<std::string>& values) {
40  if (values.size() % 2 != 0) {
41  std::cerr << "Not every 'key' has a value in `values`." << std::endl;
42  }
43  std::map<std::string, std::string> value_map;
44  auto value_iter = values.begin();
45  for (unsigned i = 0; i < values.size() / 2; ++i) {
46  std::string key = *value_iter;
47  ++value_iter;
48  std::string value = *value_iter;
49  value_map[key] = value;
50  ++value_iter;
51  }
52  return value_map;
53 }
54 
55 } // namespace grpc_ruby_generator
56 
57 #endif // GRPC_INTERNAL_COMPILER_RUBY_GENERATOR_MAP_INL_H
config.h
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
grpc_ruby_generator::ListToDict
std::map< std::string, std::string > ListToDict(const initializer_list< std::string > &values)
Definition: ruby_generator_map-inl.h:38
map
zval * map
Definition: php/ext/google/protobuf/encode_decode.c:480
value
const char * value
Definition: hpack_parser_table.cc:165
key
const char * key
Definition: hpack_parser_table.cc:164
grpc_ruby_generator
Definition: src/compiler/ruby_generator.cc:38
values
std::array< int64_t, Size > values
Definition: abseil-cpp/absl/container/btree_benchmark.cc:608
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230


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