MCPcopy Create free account
hub / github.com/apache/brpc / is_map_entry

Function is_map_entry

src/mcpack2pb/generator.cpp:247–268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

245 "}\n"
246
247static bool is_map_entry(const google::protobuf::Descriptor* d) {
248 if (d->field_count() != 2 ||
249 d->field(0)->name() != "key" ||
250 d->field(0)->number() != 1 ||
251 d->field(1)->name() != "value" ||
252 d->field(1)->number() != 2) {
253 return false;
254 }
255 if (d->field(0)->is_repeated()) {
256 LOG(ERROR) << d->field(0)->full_name() << " must be required or optional";
257 return false;
258 }
259 if (d->field(1)->is_repeated()) {
260 LOG(ERROR) << d->field(1)->full_name() << " must be required or optional";
261 return false;
262 }
263 if (d->field(0)->cpp_type() != google::protobuf::FieldDescriptor::CPPTYPE_STRING) {
264 LOG(ERROR) << "key of idl map must be string";
265 return false;
266 }
267 return true;
268}
269
270static bool generate_parsing(const google::protobuf::Descriptor* d,
271 std::set<std::string> & ref_msgs,

Callers 2

generate_parsingFunction · 0.85
generate_serializingFunction · 0.85

Calls 3

field_countMethod · 0.80
fieldMethod · 0.80
nameMethod · 0.45

Tested by

no test coverage detected