|
@@ -38,6 +38,10 @@ using namespace ::google::protobuf;
|
|
using namespace ::google::protobuf::io;
|
|
using namespace ::google::protobuf::io;
|
|
using namespace ::google::protobuf::compiler;
|
|
using namespace ::google::protobuf::compiler;
|
|
|
|
|
|
|
|
+namespace {
|
|
|
|
+const std::string VariantList("QVariantList");
|
|
|
|
+}
|
|
|
|
+
|
|
ClassGeneratorBase::ClassGeneratorBase(std::string mClassName, std::unique_ptr<::google::protobuf::io::ZeroCopyOutputStream> out) : mOutput(std::move(out))
|
|
ClassGeneratorBase::ClassGeneratorBase(std::string mClassName, std::unique_ptr<::google::protobuf::io::ZeroCopyOutputStream> out) : mOutput(std::move(out))
|
|
, mPrinter(mOutput.get(), '$')
|
|
, mPrinter(mOutput.get(), '$')
|
|
, mClassName(std::move(mClassName))
|
|
, mClassName(std::move(mClassName))
|
|
@@ -100,6 +104,13 @@ void ClassGeneratorBase::printIncludes(const Descriptor *message)
|
|
mPrinter.Print(properties, includeTemplate);
|
|
mPrinter.Print(properties, includeTemplate);
|
|
existingIncludes.insert(newinclude);
|
|
existingIncludes.insert(newinclude);
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ std::string stringInclude = properties["type"];
|
|
|
|
+ if (stringInclude == VariantList
|
|
|
|
+ && existingIncludes.find(stringInclude) == std::end(existingIncludes)) {
|
|
|
|
+ mPrinter.Print(properties, ExternalIncludeTemplate);
|
|
|
|
+ existingIncludes.insert(stringInclude);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -198,7 +209,7 @@ std::string ClassGeneratorBase::getTypeName(const FieldDescriptor *field)
|
|
}
|
|
}
|
|
} else if (field->type() == FieldDescriptor::TYPE_ENUM) {
|
|
} else if (field->type() == FieldDescriptor::TYPE_ENUM) {
|
|
if (field->is_repeated()) {
|
|
if (field->is_repeated()) {
|
|
- typeName = std::string("QVariantList");
|
|
|
|
|
|
+ typeName = VariantList;
|
|
} else {
|
|
} else {
|
|
typeName = field->enum_type()->name();
|
|
typeName = field->enum_type()->name();
|
|
}
|
|
}
|
|
@@ -206,7 +217,7 @@ std::string ClassGeneratorBase::getTypeName(const FieldDescriptor *field)
|
|
auto it = TypeReflection.find(field->type());
|
|
auto it = TypeReflection.find(field->type());
|
|
if (it != std::end(TypeReflection)) {
|
|
if (it != std::end(TypeReflection)) {
|
|
if (field->is_repeated()) {
|
|
if (field->is_repeated()) {
|
|
- typeName = std::string("QVariantList");
|
|
|
|
|
|
+ typeName = VariantList;
|
|
} else {
|
|
} else {
|
|
typeName = it->second;
|
|
typeName = it->second;
|
|
}
|
|
}
|