|
@@ -123,16 +123,22 @@ void ClassGeneratorBase::printClass()
|
|
void ClassGeneratorBase::printProperties(const Descriptor *message)
|
|
void ClassGeneratorBase::printProperties(const Descriptor *message)
|
|
{
|
|
{
|
|
//private section
|
|
//private section
|
|
|
|
+ Indent();
|
|
for (int i = 0; i < message->field_count(); i++) {
|
|
for (int i = 0; i < message->field_count(); i++) {
|
|
printField(message->field(i), PropertyTemplate);
|
|
printField(message->field(i), PropertyTemplate);
|
|
}
|
|
}
|
|
for (int i = 0; i < message->field_count(); i++) {
|
|
for (int i = 0; i < message->field_count(); i++) {
|
|
printField(message->field(i), MemberTemplate);
|
|
printField(message->field(i), MemberTemplate);
|
|
}
|
|
}
|
|
|
|
+ Outdent();
|
|
|
|
+
|
|
printQEnums(message);
|
|
printQEnums(message);
|
|
|
|
|
|
//public section
|
|
//public section
|
|
printPublic();
|
|
printPublic();
|
|
|
|
+
|
|
|
|
+ //Body
|
|
|
|
+ Indent();
|
|
printConstructor();
|
|
printConstructor();
|
|
printCopyFunctionality(message);
|
|
printCopyFunctionality(message);
|
|
printEqualOperator(message);
|
|
printEqualOperator(message);
|
|
@@ -148,10 +154,15 @@ void ClassGeneratorBase::printProperties(const Descriptor *message)
|
|
printField(field, SetterTemplateSimpleType);
|
|
printField(field, SetterTemplateSimpleType);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ Outdent();
|
|
|
|
+
|
|
mPrinter.Print(SignalsBlockTemplate);
|
|
mPrinter.Print(SignalsBlockTemplate);
|
|
|
|
+
|
|
|
|
+ Indent();
|
|
for (int i = 0; i < message->field_count(); i++) {
|
|
for (int i = 0; i < message->field_count(); i++) {
|
|
printField(message->field(i), SignalTemplate);
|
|
printField(message->field(i), SignalTemplate);
|
|
}
|
|
}
|
|
|
|
+ Outdent();
|
|
}
|
|
}
|
|
|
|
|
|
void ClassGeneratorBase::printField(const FieldDescriptor *field, const char *fieldTemplate)
|
|
void ClassGeneratorBase::printField(const FieldDescriptor *field, const char *fieldTemplate)
|
|
@@ -205,20 +216,22 @@ void ClassGeneratorBase::printCopyFunctionality(const ::google::protobuf::Descri
|
|
mPrinter.Print({{"classname", mClassName}},
|
|
mPrinter.Print({{"classname", mClassName}},
|
|
CopyConstructorTemplate);
|
|
CopyConstructorTemplate);
|
|
|
|
|
|
|
|
+ Indent();
|
|
for (int i = 0; i < message->field_count(); i++) {
|
|
for (int i = 0; i < message->field_count(); i++) {
|
|
printField(message->field(i), CopyFieldTemplate);
|
|
printField(message->field(i), CopyFieldTemplate);
|
|
}
|
|
}
|
|
|
|
+ Outdent();
|
|
|
|
|
|
- mPrinter.Print(" ");
|
|
|
|
mPrinter.Print(SimpleBlockEnclosureTemplate);
|
|
mPrinter.Print(SimpleBlockEnclosureTemplate);
|
|
mPrinter.Print({{"classname", mClassName}},
|
|
mPrinter.Print({{"classname", mClassName}},
|
|
AssignmentOperatorTemplate);
|
|
AssignmentOperatorTemplate);
|
|
|
|
|
|
|
|
+ Indent();
|
|
for (int i = 0; i < message->field_count(); i++) {
|
|
for (int i = 0; i < message->field_count(); i++) {
|
|
printField(message->field(i), CopyFieldTemplate);
|
|
printField(message->field(i), CopyFieldTemplate);
|
|
}
|
|
}
|
|
|
|
+ Outdent();
|
|
|
|
|
|
- mPrinter.Print(" ");
|
|
|
|
mPrinter.Print(SimpleBlockEnclosureTemplate);
|
|
mPrinter.Print(SimpleBlockEnclosureTemplate);
|
|
|
|
|
|
}
|
|
}
|
|
@@ -269,7 +282,7 @@ void ClassGeneratorBase::printConstructor()
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
- mPrinter.Print(" {}\n\n");
|
|
|
|
|
|
+ mPrinter.Print(EmptyBlockTemplate);
|
|
}
|
|
}
|
|
|
|
|
|
void ClassGeneratorBase::printPublic()
|
|
void ClassGeneratorBase::printPublic()
|
|
@@ -278,7 +291,7 @@ void ClassGeneratorBase::printPublic()
|
|
}
|
|
}
|
|
|
|
|
|
void ClassGeneratorBase::printEqualOperator(const Descriptor *message)
|
|
void ClassGeneratorBase::printEqualOperator(const Descriptor *message)
|
|
-{
|
|
|
|
|
|
+{
|
|
bool isFirst = true;
|
|
bool isFirst = true;
|
|
PropertyMap properties;
|
|
PropertyMap properties;
|
|
mPrinter.Print({{"type", mClassName}}, EqualOperatorTemplate);
|
|
mPrinter.Print({{"type", mClassName}}, EqualOperatorTemplate);
|
|
@@ -286,13 +299,22 @@ void ClassGeneratorBase::printEqualOperator(const Descriptor *message)
|
|
const FieldDescriptor* field = message->field(i);
|
|
const FieldDescriptor* field = message->field(i);
|
|
if (producePropertyMap(field, properties)) {
|
|
if (producePropertyMap(field, properties)) {
|
|
if (!isFirst) {
|
|
if (!isFirst) {
|
|
- mPrinter.Print("\n && ");
|
|
|
|
|
|
+ mPrinter.Print("\n&& ");
|
|
|
|
+ } else {
|
|
|
|
+ Indent();
|
|
|
|
+ Indent();
|
|
|
|
+ isFirst = false;
|
|
}
|
|
}
|
|
- isFirst = false;
|
|
|
|
mPrinter.Print(properties, EqualOperatorPropertyTemplate);
|
|
mPrinter.Print(properties, EqualOperatorPropertyTemplate);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //Only if at least one field "copied"
|
|
|
|
+ if (!isFirst) {
|
|
|
|
+ Outdent();
|
|
|
|
+ Outdent();
|
|
|
|
+ }
|
|
|
|
+
|
|
mPrinter.Print(";\n");
|
|
mPrinter.Print(";\n");
|
|
- mPrinter.Print(" ");
|
|
|
|
mPrinter.Print(SimpleBlockEnclosureTemplate);
|
|
mPrinter.Print(SimpleBlockEnclosureTemplate);
|
|
}
|
|
}
|