diff --git a/src/struct_pb/protoc-plugin/CMakeLists.txt b/src/struct_pb/protoc-plugin/CMakeLists.txt index 36395eefd..82aaaee16 100644 --- a/src/struct_pb/protoc-plugin/CMakeLists.txt +++ b/src/struct_pb/protoc-plugin/CMakeLists.txt @@ -7,6 +7,7 @@ project(protoc-gen-struct_pb) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/bin) find_package(Protobuf QUIET) if (Protobuf_FOUND) diff --git a/src/struct_pb/protoc-plugin/FileGenerator.cpp b/src/struct_pb/protoc-plugin/FileGenerator.cpp index 41183d506..116204820 100644 --- a/src/struct_pb/protoc-plugin/FileGenerator.cpp +++ b/src/struct_pb/protoc-plugin/FileGenerator.cpp @@ -54,6 +54,36 @@ void FileGenerator::generate_shared_header_code( } +void FileGenerator::generate_pcl_helper(google::protobuf::io2::Printer *p) +{ + if (!file_->options().GetExtension(write_pcl_helper)) { + return; + } + p->PrintRaw( +R"(namespace pcl { +template +inline void to_json_impl(Stream& s, const pcl::PointXYZI& t) { +iguana::to_json(*(float(*)[8]) & t, s); +} + +template +IGUANA_INLINE void from_json_impl(pcl::PointXYZI& value, It&& it, It&& end) { +iguana::from_json(*(float(*)[8]) & value, it, end); +} + +template +inline void to_json_impl(Stream& s, const pcl::PointCloud& t) { +// iguana::to_json(*(_Scalar(*)[_Row * _Col]) & t, s); +} + +template +IGUANA_INLINE void from_json_impl(pcl::PointCloud& value, It&& it, It&& end) { +// iguana::from_json(*(_Scalar(*)[_Row * _Col]) & value, it, end); +} + +})"); + +} void FileGenerator::generate_eigen_helper(google::protobuf::io2::Printer *p) { if (!file_->options().GetExtension(write_eigen_helper)) { @@ -109,6 +139,7 @@ void FileGenerator::generate_enum_helper(google::protobuf::io2::Printer *p) { void FileGenerator::generate_header(google::protobuf::io2::Printer *p) { auto basename = strip_proto(file_->name()); + Formatter format(p); p->Print( {{"filename", file_->name()}, {"pb_header_file", basename + ".pb.h"} @@ -132,6 +163,15 @@ void FileGenerator::generate_header(google::protobuf::io2::Printer *p) { #include "$pb_header_file$" )"); + if(file_->options().GetExtension(write_pcl_helper)) + { + p->PrintRaw( +R"(#include +#include +)"); + } + + generate_dependency_includes(p); // 包含的其他头文件 generate_ns_open(p); // 写命名空间 generate_shared_header_code(p); @@ -146,6 +186,8 @@ void FileGenerator::generate_header(google::protobuf::io2::Printer *p) { generate_eigen_helper(p); generate_enum_helper(p); + generate_pcl_helper(p); + p->Print("// clang-format on\n"); } @@ -154,11 +196,15 @@ void FileGenerator::generate_fwd_decls(google::protobuf::io2::Printer *p) { for (int i = 0; i < file_->message_type_count(); ++i) { auto m = file_->message_type(i); auto eigen_name = m->options().GetExtension(eigen_typename); - if (eigen_name.empty()) { - format("struct $1$;\n", resolve_keyword(m->name())); + auto pcl_name = m->options().GetExtension(pcl_typename); + if (!eigen_name.empty()) { + format("using $1$ = $2$;\n", resolve_keyword(m->name()), eigen_name); + } + else if (!pcl_name.empty()) { + format("using $1$ = $2$;\n", resolve_keyword(m->name()), pcl_name); } else { - format("using $1$ = $2$;\n", resolve_keyword(m->name()), eigen_name); + format("struct $1$;\n", resolve_keyword(m->name())); } // std::cerr << " i= " << i << ", name = " << m->name() << "\n"; } diff --git a/src/struct_pb/protoc-plugin/FileGenerator.h b/src/struct_pb/protoc-plugin/FileGenerator.h index a9b593909..8954bb41b 100644 --- a/src/struct_pb/protoc-plugin/FileGenerator.h +++ b/src/struct_pb/protoc-plugin/FileGenerator.h @@ -41,6 +41,7 @@ class FileGenerator : public GeneratorBase { void generate_message_class2struct_source(google::protobuf::io2::Printer *p); void generate_message_tostring_source(google::protobuf::io2::Printer *p); void generate_eigen_helper(google::protobuf::io2::Printer *p); + void generate_pcl_helper(google::protobuf::io2::Printer *p); void generate_enum_helper(google::protobuf::io2::Printer *p); private: diff --git a/src/struct_pb/protoc-plugin/MessageGenerator.cpp b/src/struct_pb/protoc-plugin/MessageGenerator.cpp index 3f57b9c74..7952b78ed 100644 --- a/src/struct_pb/protoc-plugin/MessageGenerator.cpp +++ b/src/struct_pb/protoc-plugin/MessageGenerator.cpp @@ -56,12 +56,16 @@ void MessageGenerator::generate_struct_definition( if (!d_->options().GetExtension(eigen_typename).empty()) { return; } + // added 跳过pcl类型的定义 + if (!d_->options().GetExtension(pcl_typename).empty()) { + return; + } std::string parent = ""; for (int i = 0; i < d_->field_count(); ++i) { auto fd = d_->field(i); if (fd->options().GetExtension(inherits_from)) { - parent = std::string(": public ") + fg_map_.get(fd).cpp_type_name(); + parent += (i == 0 ? ":" : ",") + std::string("public ") + fg_map_.get(fd).cpp_type_name(); } } @@ -240,23 +244,22 @@ void MessageGenerator::generate_struct_to_class_to(google::protobuf::io2::Printe if (std::string eigen_name = d_->options().GetExtension(eigen_typename); !eigen_name.empty()) { - if (eigen_name == "Eigen::MatrixXd") { + if (eigen_name.find("Eigen::Matrix") != std::string::npos) { format("result.mutable_data()->CopyFrom({in.data(),in.data()+in.size()});""\n"); format("result.set_col(in.cols());\n"); format("result.set_row(in.rows());\n"); } - else if (eigen_name == "Eigen::Vector3d" || - eigen_name == "Eigen::Vector2d" || - eigen_name == "Eigen::Vector4d") { + else if (eigen_name.find("Eigen::Vector") != std::string::npos || eigen_name.find("Eigen::Quaternion") != std::string::npos) { for (int i = 0; i < d_->field_count(); ++i) { auto f = d_->field(i); - format("result.set_$1$(in[$2$]);\n", f->name(), std::to_string(i)); + format("result.set_$1$(in.$1$());\n", f->name()); + } } - else if (eigen_name == "Eigen::Quaterniond") { + else if (eigen_name.find("pcl::") != std::string::npos) { for (int i = 0; i < d_->field_count(); ++i) { auto f = d_->field(i); - format("result.set_$1$(in.$1$());\n", f->name()); + // format("result.set_$1$(in.$1$());\n", f->name()); } } else { @@ -286,21 +289,20 @@ void MessageGenerator::generate_class_to_struct_to(google::protobuf::io2::Printe if (std::string eigen_name = d_->options().GetExtension(eigen_typename); !eigen_name.empty()) { - if (eigen_name == "Eigen::MatrixXd") { + if (eigen_name.find("Eigen::Matrix") != std::string::npos) { format("result = Eigen::Map(in.data().begin(), in.row(),in.col());\n"); } - else if (eigen_name == "Eigen::Vector3d" || - eigen_name == "Eigen::Vector2d" || - eigen_name == "Eigen::Vector4d") { + else if (eigen_name.find("Eigen::Vector") != std::string::npos || eigen_name.find("Eigen::Quaternion") != std::string::npos) { for (int i = 0; i < d_->field_count(); ++i) { auto f = d_->field(i); - format("result[$1$] = in.$2$();\n", std::to_string(i), f->name()); + // format("result[$1$] = in.$2$();\n", std::to_string(i), f->name()); + format("result.$1$() = in.$1$();\n", f->name()); } } - else if (eigen_name == "Eigen::Quaterniond") { + else if (eigen_name.find("pcl::") != std::string::npos) { for (int i = 0; i < d_->field_count(); ++i) { auto f = d_->field(i); - format("result.$1$() = in.$1$();\n", f->name()); + // format("result.$1$() = in.$1$();\n", f->name()); } } else { diff --git a/src/struct_pb/protoc-plugin/PrimitiveFieldGenerator.cpp b/src/struct_pb/protoc-plugin/PrimitiveFieldGenerator.cpp index 97126d4d6..daf178d2a 100644 --- a/src/struct_pb/protoc-plugin/PrimitiveFieldGenerator.cpp +++ b/src/struct_pb/protoc-plugin/PrimitiveFieldGenerator.cpp @@ -449,5 +449,32 @@ void RepeatedPrimitiveFieldGenerator::generate_deserialization_unpacked_only( PrimitiveFieldGenerator g(d_, options_); g.generate_deserialization_only(p, output); } + + // added +void RepeatedPrimitiveFieldGenerator::generate_struct_to_class( + google::protobuf::io2::Printer *p) const { + Formatter format(p); + auto v_class_name = "result.mutable_" + name() + "()"; + auto v_struct_name = "in." + name(); + int size = d_->options().GetExtension(fix_size); + std::string size_str = size > 0 ? std::to_string(size) : (v_struct_name + ".size()"); + p->Print({{"result", v_class_name}, {"in", v_struct_name}, {"cpp_name", cpp_type_name()}, {"size",size_str}}, +R"($result$->Reserve($size$); +for(int i = 0;i < $size$;++i) { *$result$->Mutable(i) = $in$[i];} +)"); +} +void RepeatedPrimitiveFieldGenerator::generate_class_to_struct( + google::protobuf::io2::Printer *p) const { + auto v_class_name = "in." + name() + ""; + auto v_struct_name = "result." + name(); + int size = d_->options().GetExtension(fix_size); + std::string size_str = size > 0 ? std::to_string(size) : (v_class_name + "().size()"); + + p->Print({{"in", v_class_name}, {"result", v_struct_name},{"cpp_name", cpp_type_name()},{"size",size_str}}, +R"(for(int i = 0;i < $size$;++i) {$result$[i] = $in$(i);} +)"); + +} + } // namespace compiler } // namespace struct_pb \ No newline at end of file diff --git a/src/struct_pb/protoc-plugin/PrimitiveFieldGenerator.h b/src/struct_pb/protoc-plugin/PrimitiveFieldGenerator.h index 98541d215..a2db0c105 100644 --- a/src/struct_pb/protoc-plugin/PrimitiveFieldGenerator.h +++ b/src/struct_pb/protoc-plugin/PrimitiveFieldGenerator.h @@ -49,7 +49,9 @@ class RepeatedPrimitiveFieldGenerator : public FieldGenerator { const std::string &max_size) const; void generate_deserialization_unpacked_only(google::protobuf::io2::Printer *p, const std::string &output) const; - + // added + void generate_struct_to_class(google::protobuf::io2::Printer *p) const override; + void generate_class_to_struct(google::protobuf::io2::Printer *p) const override; private: bool is_packed() const; std::string packed_tag() const; diff --git a/src/struct_pb/protoc-plugin/example/CMakeLists.txt b/src/struct_pb/protoc-plugin/example/CMakeLists.txt index 59c348dae..e4b9072cc 100644 --- a/src/struct_pb/protoc-plugin/example/CMakeLists.txt +++ b/src/struct_pb/protoc-plugin/example/CMakeLists.txt @@ -6,6 +6,10 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/examples) include(../cmake/struct_pb.cmake) +cmake_policy(SET CMP0075 NEW) +find_package(PCL REQUIRED package common) + + if (Protobuf_FOUND) # generate .pb.cc .pb.h @@ -19,15 +23,17 @@ if (Protobuf_FOUND) state.proto chasis.proto perception.proto + # pointcloud.proto ) add_executable(struct_pb_tutorial tutorial.cpp ${PROTO_SRCS} ${PROTO_HDRS}) - target_link_libraries(struct_pb_tutorial protobuf::libprotobuf) + target_link_libraries(struct_pb_tutorial protobuf::libprotobuf pcl_common) target_include_directories(struct_pb_tutorial PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_LIST_DIR} + ${PCL_INCLUDE_DIRS} ) target_protos_struct_pb(struct_pb_tutorial PRIVATE @@ -38,6 +44,7 @@ if (Protobuf_FOUND) state.proto chasis.proto perception.proto + # pointcloud.proto OPTION "namespace=inner_struct,converter_namespace=converter") endif() diff --git a/src/struct_pb/protoc-plugin/example/base.proto b/src/struct_pb/protoc-plugin/example/base.proto index 7efa45d7b..6a08a3a87 100644 --- a/src/struct_pb/protoc-plugin/example/base.proto +++ b/src/struct_pb/protoc-plugin/example/base.proto @@ -64,18 +64,27 @@ message ZFrame string channel_name = 5; } +message Vector4f +{ + option(eigen_typename) = "Eigen::Vector4f"; + + float x = 1; + float y = 2; + float z = 3; + float w = 4; +} -message Point4D +message Vector4d { option(eigen_typename) = "Eigen::Vector4d"; double x = 1; double y = 2; double z = 3; - double i = 4; + double w = 4; } -message Point3D +message Vector3d { option(eigen_typename) = "Eigen::Vector3d"; @@ -84,7 +93,7 @@ message Point3D double z = 3; } -message Point2D +message Vector2d { option(eigen_typename) = "Eigen::Vector2d"; @@ -92,7 +101,7 @@ message Point2D double y = 2; } -message Quaternion { +message Quaterniond { option(eigen_typename) = "Eigen::Quaterniond"; double w = 1; @@ -101,6 +110,15 @@ message Quaternion { double z = 4; } +message Quaternionf { + option(eigen_typename) = "Eigen::Quaternionf"; + + float w = 1; + float x = 2; + float y = 3; + float z = 4; + } + message PointLLH { double lon = 1; double lat = 2; @@ -108,7 +126,7 @@ message PointLLH { } // hard code, never edit -message Matrix +message MatrixXd { option(eigen_typename) = "Eigen::MatrixXd"; diff --git a/src/struct_pb/protoc-plugin/example/chasis.proto b/src/struct_pb/protoc-plugin/example/chasis.proto index e96cf35ca..0afa5a90f 100644 --- a/src/struct_pb/protoc-plugin/example/chasis.proto +++ b/src/struct_pb/protoc-plugin/example/chasis.proto @@ -7,8 +7,8 @@ import "proto_to_struct.proto"; message ZChassis { ZFrame header = 1 [(inherits_from) = true]; - Point4D vel = 2; - Point4D spd_status = 3; + Vector4d vel = 2; + Vector4d spd_status = 3; double steering_percentage = 4; double brake_percentage = 5; bool parking_brake = 6; diff --git a/src/struct_pb/protoc-plugin/example/gnss.proto b/src/struct_pb/protoc-plugin/example/gnss.proto index 3f90b5398..7afd828be 100644 --- a/src/struct_pb/protoc-plugin/example/gnss.proto +++ b/src/struct_pb/protoc-plugin/example/gnss.proto @@ -9,17 +9,17 @@ message ZGnss ZFrame header = 1 [(inherits_from) = true];; int32 msg_type = 2; double hdop = 3; - Point3D pos = 4; + Vector3d pos = 4; int32 status = 5; int32 sat_num = 6; double rtk_age = 7; - Point3D std_pos = 8; - Point3D vel = 9; + Vector3d std_pos = 8; + Vector3d vel = 9; double azi_track = 10; double speed = 11; - Point3D std_vel = 12; - Point2D dual_antenna_angle =13; - Point2D dual_antenna_std = 14; + Vector3d std_vel = 12; + Vector2d dual_antenna_angle =13; + Vector2d dual_antenna_std = 14; int32 heading_status = 15; int32 heading_sat_num = 16; } \ No newline at end of file diff --git a/src/struct_pb/protoc-plugin/example/imu.proto b/src/struct_pb/protoc-plugin/example/imu.proto index 596c5b08f..2acb2a375 100644 --- a/src/struct_pb/protoc-plugin/example/imu.proto +++ b/src/struct_pb/protoc-plugin/example/imu.proto @@ -7,8 +7,8 @@ import "proto_to_struct.proto"; message ZImu { ZFrame header = 1 [(inherits_from) = true]; - Point3D acc = 2; // 加速度 g - Point3D gyr = 3; // 角速度 rad/s + Vector3d acc = 2; // 加速度 g + Vector3d gyr = 3; // 角速度 rad/s double temper = 4; // 温度 ℃ } diff --git a/src/struct_pb/protoc-plugin/example/perception.proto b/src/struct_pb/protoc-plugin/example/perception.proto index a4b1f0518..823df5fff 100644 --- a/src/struct_pb/protoc-plugin/example/perception.proto +++ b/src/struct_pb/protoc-plugin/example/perception.proto @@ -9,8 +9,8 @@ message ZPercBase int32 track_id = 1; string id = 2; // 需要单帧独立 float object_confidence = 3; - repeated Point3D points = 4; - repeated Point3D points_confidence = 5; + repeated Vector3d points = 4; + repeated Vector3d points_confidence = 5; } message ZPercLine diff --git a/src/struct_pb/protoc-plugin/example/pointcloud.proto b/src/struct_pb/protoc-plugin/example/pointcloud.proto new file mode 100644 index 000000000..2ff26fe7f --- /dev/null +++ b/src/struct_pb/protoc-plugin/example/pointcloud.proto @@ -0,0 +1,34 @@ +syntax = "proto3"; +package inner_class; + +import "base.proto"; +import "proto_to_struct.proto"; + +option(write_pcl_helper) = true; + +message PointXYZI +{ + option(pcl_typename) = "pcl::PointXYZI"; + repeated float data = 3 [(fix_size) = 4]; // data[0-2] x y z + repeated float data_c = 4 [(fix_size) = 4]; // data_c[0] intensity +} + +message PclCloudXYZI +{ + option(pcl_typename) = "pcl::PointCloud"; + + repeated PointXYZI points = 1; + uint32 width = 2; + uint32 height = 3; + bool is_dense = 4; + Vector4f sensor_origin_ = 5; + Quaternionf sensor_orientation_ = 6; +} + +message ZPointCloudXYZI +{ + ZFrame header = 1 [(inherits_from) = true]; + // PclCloudXYZI point_cloud = 2 [(inherits_from) = true]; + bytes points = 2; +} + diff --git a/src/struct_pb/protoc-plugin/example/proto_to_struct.proto b/src/struct_pb/protoc-plugin/example/proto_to_struct.proto index dc7805c9b..97fabd262 100644 --- a/src/struct_pb/protoc-plugin/example/proto_to_struct.proto +++ b/src/struct_pb/protoc-plugin/example/proto_to_struct.proto @@ -5,15 +5,18 @@ import "google/protobuf/descriptor.proto"; extend google.protobuf.FileOptions { // 当前message是否解析 bool write_eigen_helper = 20000; + bool write_pcl_helper = 20001; } extend google.protobuf.MessageOptions { // 当前message是否解析 - string eigen_typename = 20001; + string eigen_typename = 20100; + string pcl_typename = 20101; } extend google.protobuf.FieldOptions { // 当前message是否解析 - bool inherits_from = 20002; + bool inherits_from = 20200; + int32 fix_size = 20201; // 生成固定长度的数组 } diff --git a/src/struct_pb/protoc-plugin/example/state.proto b/src/struct_pb/protoc-plugin/example/state.proto index 4900a3401..3f3f08550 100644 --- a/src/struct_pb/protoc-plugin/example/state.proto +++ b/src/struct_pb/protoc-plugin/example/state.proto @@ -6,32 +6,32 @@ import "proto_to_struct.proto"; message ZState{ ZFrame header = 1 [(inherits_from) = true]; - Point3D pos = 2;//位置: X Y Z - Point3D pos_llh = 3; //位置:纬度 经度 高度 - Point3D vel = 4; // 速度: ENU - Point3D att = 5; //姿态: 俯仰 横滚 航向 - Point3D wv = 6;// 车体系下的角速度 - Point3D fv = 7;// 车体系下的运动加速度 + Vector3d pos = 2;//位置: X Y Z + Vector3d pos_llh = 3; //位置:纬度 经度 高度 + Vector3d vel = 4; // 速度: ENU + Vector3d att = 5; //姿态: 俯仰 横滚 航向 + Vector3d wv = 6;// 车体系下的角速度 + Vector3d fv = 7;// 车体系下的运动加速度 double mileage = 8; // 总里程数 int32 status = 9;// 定位状态 } message IntrinsicImuPara{ - Point3D ba = 1; - Point3D bg = 2; + Vector3d ba = 1; + Vector3d bg = 2; } message AugmentationState{ double t0 = 1; - Point3D pos = 2; - Quaternion qua = 3; + Vector3d pos = 2; + Quaterniond qua = 3; } message ZExtendState{ ZState state = 1 [(inherits_from) = true]; IntrinsicImuPara imu_in_para = 2; - Point4D odo_in_para = 3; - Matrix cov = 4; + Vector4d odo_in_para = 3; + MatrixXd cov = 4; int32 vs = 5; int32 fs = 6; repeated AugmentationState augmentation_state = 7; diff --git a/src/struct_pb/protoc-plugin/example/tutorial.cpp b/src/struct_pb/protoc-plugin/example/tutorial.cpp index e04ac9392..dfb3b20f0 100644 --- a/src/struct_pb/protoc-plugin/example/tutorial.cpp +++ b/src/struct_pb/protoc-plugin/example/tutorial.cpp @@ -5,8 +5,6 @@ // #include "addressbook.struct_pb.h" #include "imu.struct_pb.h" -// protobuf - int main() { @@ -20,6 +18,14 @@ int main() { std::cout << imu3 << std::endl; + // inner_struct::ZPointCloudXYZI pc1; + // pc1.points.push_back(pcl::PointXYZI()); + // pc1.points.push_back(pcl::PointXYZI()); + // pcl::PointXYZI p1; + + // std::cout << p1 << std::endl; + + std::cout << "Done!!!" << std::endl; return 0; diff --git a/src/struct_pb/protoc-plugin/proto_to_struct.pb.cc b/src/struct_pb/protoc-plugin/proto_to_struct.pb.cc index 902ad1be5..2ef5f782d 100644 --- a/src/struct_pb/protoc-plugin/proto_to_struct.pb.cc +++ b/src/struct_pb/protoc-plugin/proto_to_struct.pb.cc @@ -61,21 +61,35 @@ void protobuf_AddDesc_proto_5fto_5fstruct_2eproto() { ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( "\n\025proto_to_struct.proto\032 google/protobuf" "/descriptor.proto::\n\022write_eigen_helper\022" - "\034.google.protobuf.FileOptions\030\240\234\001 \001(\010:9\n" - "\016eigen_typename\022\037.google.protobuf.Messag" - "eOptions\030\241\234\001 \001(\t:6\n\rinherits_from\022\035.goog" - "le.protobuf.FieldOptions\030\242\234\001 \001(\010b\006proto3", 240); + "\034.google.protobuf.FileOptions\030\240\234\001 \001(\010:8\n" + "\020write_pcl_helper\022\034.google.protobuf.File" + "Options\030\241\234\001 \001(\010:9\n\016eigen_typename\022\037.goog" + "le.protobuf.MessageOptions\030\204\235\001 \001(\t:7\n\014pc" + "l_typename\022\037.google.protobuf.MessageOpti" + "ons\030\205\235\001 \001(\t:6\n\rinherits_from\022\035.google.pr" + "otobuf.FieldOptions\030\350\235\001 \001(\010:1\n\010fix_size\022" + "\035.google.protobuf.FieldOptions\030\351\235\001 \001(\005b\006" + "proto3", 406); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "proto_to_struct.proto", &protobuf_RegisterTypes); ::google::protobuf::internal::ExtensionSet::RegisterExtension( &::google::protobuf::FileOptions::default_instance(), 20000, 8, false, false); + ::google::protobuf::internal::ExtensionSet::RegisterExtension( + &::google::protobuf::FileOptions::default_instance(), + 20001, 8, false, false); + ::google::protobuf::internal::ExtensionSet::RegisterExtension( + &::google::protobuf::MessageOptions::default_instance(), + 20100, 9, false, false); ::google::protobuf::internal::ExtensionSet::RegisterExtension( &::google::protobuf::MessageOptions::default_instance(), - 20001, 9, false, false); + 20101, 9, false, false); + ::google::protobuf::internal::ExtensionSet::RegisterExtension( + &::google::protobuf::FieldOptions::default_instance(), + 20200, 8, false, false); ::google::protobuf::internal::ExtensionSet::RegisterExtension( &::google::protobuf::FieldOptions::default_instance(), - 20002, 8, false, false); + 20201, 5, false, false); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_proto_5fto_5fstruct_2eproto); } @@ -88,13 +102,23 @@ struct StaticDescriptorInitializer_proto_5fto_5fstruct_2eproto { ::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::FileOptions, ::google::protobuf::internal::PrimitiveTypeTraits< bool >, 8, false > write_eigen_helper(kWriteEigenHelperFieldNumber, false); +::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::FileOptions, + ::google::protobuf::internal::PrimitiveTypeTraits< bool >, 8, false > + write_pcl_helper(kWritePclHelperFieldNumber, false); const ::std::string eigen_typename_default(""); ::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::MessageOptions, ::google::protobuf::internal::StringTypeTraits, 9, false > eigen_typename(kEigenTypenameFieldNumber, eigen_typename_default); +const ::std::string pcl_typename_default(""); +::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::MessageOptions, + ::google::protobuf::internal::StringTypeTraits, 9, false > + pcl_typename(kPclTypenameFieldNumber, pcl_typename_default); ::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::FieldOptions, ::google::protobuf::internal::PrimitiveTypeTraits< bool >, 8, false > inherits_from(kInheritsFromFieldNumber, false); +::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::FieldOptions, + ::google::protobuf::internal::PrimitiveTypeTraits< ::google::protobuf::int32 >, 5, false > + fix_size(kFixSizeFieldNumber, 0); // @@protoc_insertion_point(namespace_scope) diff --git a/src/struct_pb/protoc-plugin/proto_to_struct.pb.h b/src/struct_pb/protoc-plugin/proto_to_struct.pb.h index 8235eeded..adfeecb83 100644 --- a/src/struct_pb/protoc-plugin/proto_to_struct.pb.h +++ b/src/struct_pb/protoc-plugin/proto_to_struct.pb.h @@ -43,14 +43,26 @@ static const int kWriteEigenHelperFieldNumber = 20000; extern ::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::FileOptions, ::google::protobuf::internal::PrimitiveTypeTraits< bool >, 8, false > write_eigen_helper; -static const int kEigenTypenameFieldNumber = 20001; +static const int kWritePclHelperFieldNumber = 20001; +extern ::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::FileOptions, + ::google::protobuf::internal::PrimitiveTypeTraits< bool >, 8, false > + write_pcl_helper; +static const int kEigenTypenameFieldNumber = 20100; extern ::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::MessageOptions, ::google::protobuf::internal::StringTypeTraits, 9, false > eigen_typename; -static const int kInheritsFromFieldNumber = 20002; +static const int kPclTypenameFieldNumber = 20101; +extern ::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::MessageOptions, + ::google::protobuf::internal::StringTypeTraits, 9, false > + pcl_typename; +static const int kInheritsFromFieldNumber = 20200; extern ::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::FieldOptions, ::google::protobuf::internal::PrimitiveTypeTraits< bool >, 8, false > inherits_from; +static const int kFixSizeFieldNumber = 20201; +extern ::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::FieldOptions, + ::google::protobuf::internal::PrimitiveTypeTraits< ::google::protobuf::int32 >, 5, false > + fix_size; // =================================================================== diff --git a/src/struct_pb/protoc-plugin/proto_to_struct.proto b/src/struct_pb/protoc-plugin/proto_to_struct.proto index dc7805c9b..97fabd262 100644 --- a/src/struct_pb/protoc-plugin/proto_to_struct.proto +++ b/src/struct_pb/protoc-plugin/proto_to_struct.proto @@ -5,15 +5,18 @@ import "google/protobuf/descriptor.proto"; extend google.protobuf.FileOptions { // 当前message是否解析 bool write_eigen_helper = 20000; + bool write_pcl_helper = 20001; } extend google.protobuf.MessageOptions { // 当前message是否解析 - string eigen_typename = 20001; + string eigen_typename = 20100; + string pcl_typename = 20101; } extend google.protobuf.FieldOptions { // 当前message是否解析 - bool inherits_from = 20002; + bool inherits_from = 20200; + int32 fix_size = 20201; // 生成固定长度的数组 }