Browse Source

clean code

pull/640/head
13291271729 3 years ago
parent
commit
0ba1a7a24c
2 changed files with 17 additions and 14 deletions
  1. +10
    -7
      parser/common/convert/message2operator.cc
  2. +7
    -7
      parser/common/convert/message2operator.h

+ 10
- 7
parser/common/convert/message2operator.cc View File

@@ -58,7 +58,7 @@ Status Message2Operator::ParseOperatorAttrs(const google::protobuf::Message *mes
return SUCCESS; return SUCCESS;
} }


void Message2Operator::ParseBaseTypeField(const google::protobuf::Reflection *reflection,
Status Message2Operator::ParseBaseTypeField(const google::protobuf::Reflection *reflection,
const google::protobuf::Message *message, const google::protobuf::Message *message,
const google::protobuf::FieldDescriptor *field, ge::Operator &ops) { const google::protobuf::FieldDescriptor *field, ge::Operator &ops) {
switch (field->cpp_type()) { switch (field->cpp_type()) {
@@ -93,16 +93,18 @@ void Message2Operator::ParseBaseTypeField(const google::protobuf::Reflection *re
break; break;
} }
default: { default: {
break;
return FAILED;
} }
} }
return SUCCESS;
} }


Status Message2Operator::ParseField(const google::protobuf::Reflection *reflection, Status Message2Operator::ParseField(const google::protobuf::Reflection *reflection,
const google::protobuf::Message *message, const google::protobuf::Message *message,
const google::protobuf::FieldDescriptor *field, int depth, ge::Operator &ops) { const google::protobuf::FieldDescriptor *field, int depth, ge::Operator &ops) {
GELOGD("Start to parse field: %s.", field->name().c_str()); GELOGD("Start to parse field: %s.", field->name().c_str());
ParseBaseTypeField(reflection, message, field, ops);
GE_CHK_BOOL_RET_STATUS(ParseBaseTypeField(reflection, message, field, ops) == FAILED, SUCCESS,
"Parse field: %s success.", field->name().c_str());
switch (field->cpp_type()) { switch (field->cpp_type()) {
case google::protobuf::FieldDescriptor::CPPTYPE_ENUM: { case google::protobuf::FieldDescriptor::CPPTYPE_ENUM: {
GE_CHECK_NOTNULL(reflection->GetEnum(*message, field)); GE_CHECK_NOTNULL(reflection->GetEnum(*message, field));
@@ -136,7 +138,7 @@ Status Message2Operator::ParseField(const google::protobuf::Reflection *reflecti
return SUCCESS; return SUCCESS;
} }


void Message2Operator::ParseRepeatedBaseTypeField(const google::protobuf::Reflection *reflection,
Status Message2Operator::ParseRepeatedBaseTypeField(const google::protobuf::Reflection *reflection,
const google::protobuf::Message *message, const google::protobuf::Message *message,
const google::protobuf::FieldDescriptor *field, const google::protobuf::FieldDescriptor *field,
ge::Operator &ops, const int field_size) { ge::Operator &ops, const int field_size) {
@@ -196,9 +198,10 @@ void Message2Operator::ParseRepeatedBaseTypeField(const google::protobuf::Reflec
break; break;
} }
default: { default: {
break;
return FAILED;
} }
} }
return SUCCESS;
} }


Status Message2Operator::ParseRepeatedField(const google::protobuf::Reflection *reflection, Status Message2Operator::ParseRepeatedField(const google::protobuf::Reflection *reflection,
@@ -212,8 +215,8 @@ Status Message2Operator::ParseRepeatedField(const google::protobuf::Reflection *
GELOGE(FAILED, "[Check][Size]Size of repeated field %s must bigger than 0", field->name().c_str()); GELOGE(FAILED, "[Check][Size]Size of repeated field %s must bigger than 0", field->name().c_str());
return FAILED; return FAILED;
} }
ParseRepeatedBaseTypeField(reflection, message, field, ops, field_size);
GE_CHK_BOOL_RET_STATUS(ParseRepeatedBaseTypeField(reflection, message, field, ops, field_size) == FAILED, SUCCESS,
"Parse repeated field: %s success.", field->name().c_str());
switch (field->cpp_type()) { switch (field->cpp_type()) {
case google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE: { case google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE: {
nlohmann::json message_json; nlohmann::json message_json;


+ 7
- 7
parser/common/convert/message2operator.h View File

@@ -34,14 +34,14 @@ class Message2Operator {
const google::protobuf::Message *message, const google::protobuf::Message *message,
const google::protobuf::FieldDescriptor *field, ge::Operator &ops); const google::protobuf::FieldDescriptor *field, ge::Operator &ops);


static void ParseBaseTypeField(const google::protobuf::Reflection *reflection,
const google::protobuf::Message *message,
const google::protobuf::FieldDescriptor *field, ge::Operator &ops);
static Status ParseBaseTypeField(const google::protobuf::Reflection *reflection,
const google::protobuf::Message *message,
const google::protobuf::FieldDescriptor *field, ge::Operator &ops);


static void ParseRepeatedBaseTypeField(const google::protobuf::Reflection *reflection,
const google::protobuf::Message *message,
const google::protobuf::FieldDescriptor *field,
ge::Operator &ops, const int field_size);
static Status ParseRepeatedBaseTypeField(const google::protobuf::Reflection *reflection,
const google::protobuf::Message *message,
const google::protobuf::FieldDescriptor *field,
ge::Operator &ops, const int field_size);
}; };
} // namespace ge } // namespace ge
#endif // PARSER_MESSAGE2OPERATOR_H #endif // PARSER_MESSAGE2OPERATOR_H

Loading…
Cancel
Save