Relative Content

Tag Archive for pythonc++protocol-buffers

Generate a protobuf C++ serialized string by SerializeToArray and parsing in python by ParseFromString

C++ clang++ 14.0.6 protobuf v21.7 C++ serialization: *response = new char[report.ByteSizeLong()]; report.SerializeToArray(*response,report.ByteSizeLong()); *response_length = report.ByteSizeLong(); Python python 3.8.10 protoc v26.1 (generate .py and .pyi file) protobuf==5.26.1 Python de-serialization: from ctypes import cdll, c_char_p, c_int, byref __so = cdll.LoadLibrary(self.__file) __report_in_pb = c_char_p() __report_ob_size = c_int() __so.handle_message_v1(__data, len(__data),byref(__report_in_pb), byref(__report_ob_size)) if __report_ob_size.value > 0: try: __report: RulesReport = […]