Data structure conversion method, vehicle-mounted message transmission method, equipment and medium

By converting the ASN1C data structure into a pure C/C++ data structure, the problem of data structure incompatibility when V2X technology and ADAS technology are integrated is solved, the transmission stability and security are improved, and the efficient and secure message transmission of the vehicle-mounted V2X module is realized. .

CN118550877APending Publication Date: 2024-08-27SHANGHAI JOYNEXT TECH CO LTD

Patent Information

Application Number
CN202410694324.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-31
Publication Date
2024-08-27

AI Technical Summary

Technical Problem

In smart transportation scenarios, when V2X technology and ADAS technology are integrated, there is an incompatibility problem with the ASN1C data structure, which makes software design and integration difficult. The ASN1C engine data structure is vulnerable to attacks, and there are serious security risks during the transmission process.

Method used

Provide a data structure conversion method that analyzes and processes the C language source code header files generated by the abstract syntax markup compiler, converts the ASN1C data structure into a pure C/C++ data structure, and generates a C/C++ reference header file to solve the problem Data structure incompatibility issues and improve transfer stability and security.

Benefits of technology

It has improved the stability and versatility of V2X messages in the transmission process, eliminated the security risks of the ASN1C engine data structure, improved the message transmission security of the vehicle-mounted V2X module, and avoided poor coding quality and The problem of low efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118550877A
    Figure CN118550877A
Patent Text Reader

Abstract

The invention provides a data structure conversion method, a vehicle-mounted message transmission method, equipment and a medium. The method comprises the following steps: performing data change processing on a C language source code header file according to a first data change processing rule to output a first header file list; merging the repeated descendant data structure header files in the first header file list to generate a second header file list, and writing data structures defined by the main data structure header files and the descendant data structure header files contained in the second header file list into an undetermined data cache structure; performing data change processing on a data structure contained in the undetermined data cache structure according to a second data change processing rule so as to generate a target data structure meeting a C / C + + data structure requirement; writing the target data structure into the C language source code header file to generate a C / C + + reference header file, and writing the C / C + + reference header file into the hpp file to generate a target data structure file of a pure C / C + + data structure; and data structure conversion is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a data structure conversion method, a vehicle-mounted message transmission method, a device and a medium. Background Art

[0002] In order to realize vehicle-road collaboration in smart transportation scenarios, it is necessary to integrate V2X (Vehicle to Everything) technology with ADAS (Advanced Driving Assistance System) technology or smart cockpit domain technology; V2X technology itself has its own standards and data structures to define its messages and the Dedicated Short Message Protocol (DSMP) dedicated to the transport layer; V2X messages are generated based on Abstract Syntax Notation One (ASN1), and then the ASN1C compiler is used to compile the ASN1C message definition source code corresponding to V2X to generate a C language data structure based on the ASN1C engine.

[0003] Normally, during software design and integration of the V2X Box, its protocol stack and application use C language data structures based on the ASN1C engine to transmit V2X messages; however, if the V2X Box is integrated with other ECUs (Electronic Control Units) of the car, such as ADAS and smart cockpit domains, when each software module and the protocol stack and application on the V2X Box transmit V2X messages with ASN1C data structures to each other, there will be problems with software design and integration, such as the problem that ADAS and smart cockpit domains do not support the ASN1C engine, that is, the problem that the C language data structure based on the ASN1C engine does not have specific software design and integration versatility.

[0004] Therefore, there is an urgent need for a data structure conversion method that can automatically convert ASN1C data structures into pure C / C++ data structures to solve the above technical problems. Summary of the invention

[0005] Based on this, it is necessary to provide a data structure conversion method, an in-vehicle message transmission method and a device to address the above-mentioned technical problems, so as to improve the versatility and stability of the in-vehicle messages generated by the in-vehicle V2X module during transmission.

[0006] In a first aspect, the present application provides a data structure conversion method, characterized in that the method comprises:

[0007] Performing data change processing on a C language source code header file according to a preset first data change processing rule to output a first header file list, wherein the first header file list includes a main data structure header file and a descendant data structure header file corresponding to the C language source code header file, wherein the C language source code header file is compiled and generated by an abstract syntax markup compiler;

[0008] Merging repeated descendant data structure header files in the first header file list to generate a second header file list, and writing data structures defined by the main data structure header file and the descendant data structure header file included in the second header file list into a pending data cache structure;

[0009] Performing data change processing on the data structure contained in the pending data cache structure according to a preset second data change processing rule to generate a target data structure that meets the C / C++ data structure requirements;

[0010] The target data structure is written into the C language source code header file to generate a C / C++ reference header file, and the C / C++ reference header file is written into an hpp file to generate a target data structure file of a pure C / C++ data structure.

[0011] In some embodiments, performing data change processing on the C language source code header file according to a preset first data change processing rule to output a first header file list includes:

[0012] Execute a main data structure change operation, the main data structure change operation comprising: changing the data type to be changed in the C language source code header file bound to the abstract syntax markup compiler to a target data type matching the C / C++ data structure requirement, generating a header file name to be processed corresponding to the target data type and outputting a main data structure header file corresponding to the header file name to be processed;

[0013] Executing a descendant data structure change operation, wherein the executing descendant data structure change operation includes: checking whether there is a header file to be processed corresponding to the name of the header file to be processed;

[0014] In response to detecting that the header file to be processed exists, changing the data type to be changed in the header file to be processed and bound to the abstract syntax markup compiler to a new target data type matching the C / C++ data structure requirement, generating a new header file name to be processed corresponding to the target data type, and outputting a descendant data structure header file corresponding to the header file name to be processed;

[0015] The descendant data structure change operation is recursively executed until no new header file name to be processed is generated.

[0016] In some embodiments, before changing the data type to be changed in the C language source code header file bound to the abstract syntax markup compiler to a target data type that matches the C / C++ data structure requirement, the method includes:

[0017] Parsing a target header file to generate a data type name, wherein the target header file includes the C language source code header file and the header file to be processed;

[0018] Performing a denoising operation on the code lines in the target header file to obtain valid lines in the target header file, and writing the valid lines into a pending data cache structure, wherein the noise includes spaces, comment statements, conditional statements, and lines where preset keywords are located;

[0019] In response to reading a code line containing the data type name in the target header file, the data type to be changed in the code line contained in the pending data cache structure and bound to the abstract syntax markup compiler is changed to a target data type that matches the C / C++ data structure requirement.

[0020] In some embodiments, before changing the data type to be changed in the C language source code header file bound to the abstract syntax markup compiler to a target data type that matches the C / C++ data structure requirement, the method includes:

[0021] Parsing a target header file to generate a data type name, wherein the target header file includes the C language source code header file and the header file to be processed;

[0022] Performing a denoising operation on the code lines in the target header file to obtain valid lines in the target header file, and writing the valid lines into a pending data cache structure, wherein the noise includes spaces, comment statements, conditional statements, and lines where preset keywords are located;

[0023] In response to reading a code line containing the data type name in the target header file, the data type to be changed in the code line contained in the pending data cache structure and bound to the abstract syntax markup compiler is changed to a target data type that matches the C / C++ data structure requirement.

[0024] In some embodiments, writing the data structure defined by the main data structure header file and the descendant data structure header file included in the second header file list into the pending data cache structure includes:

[0025] Clear pending data cache structure;

[0026] Reading the code lines contained in the main data structure header file contained in the second header file list line by line, and writing the read main data structure header file code to perform a denoising operation to obtain a valid line of the main data structure header file and write it into the pending data cache structure, until a code line containing the data type name matching the main data structure header file is read in the main data structure header file;

[0027] and, reading the code lines contained in the descendant data structure header file contained in the second header file list line by line, and writing the read descendant data structure header file code to perform a denoising operation to obtain valid lines of the descendant data structure header file and write them into the pending data cache structure, until the code line containing the data type name matching the descendant data structure header file is read in the descendant data structure header file.

[0028] In some embodiments, performing data change processing on the data structure included in the pending data cache structure according to a preset second data change processing rule to generate a target data structure that meets the C / C++ data structure requirements includes:

[0029] According to a preset keyword association relationship, the keyword to be changed in the pending data cache structure and bound to the abstract syntax markup compiler is changed to a target keyword that matches the C / C++ data structure requirement to form a transition data structure, wherein the keyword association relationship includes an association relationship between the keyword to be changed bound to the abstract syntax markup compiler and the target keyword that matches the C / C++ data structure requirement;

[0030] The transition data structure is analyzed line by line. After a code line containing the keyword "{" is detected in the transition data structure, if the keyword "union" is detected, the keyword "union" is replaced with the keyword "struct" to form a target data structure.

[0031] In some embodiments, the method further comprises:

[0032] Add serialization code in the target data structure, including:

[0033] Define the level variable and analyze the transition data structure line by line;

[0034] If a code line containing the keyword "{" is detected in the transition data structure and the keyword "struct" is detected, the value of the level variable is increased by 1;

[0035] If a code line containing the keyword "}" is detected in the target data structure, and the current level variable is greater than or equal to 0, then a serialization code is added before the code line containing the keyword "}", and the value of the level variable is reduced by 1;

[0036] Among them, multiple code behaviors between adjacent keywords "{" and keyword "}" are defined as target code lines that match the current level variables when the keyword "}" is detected, and the serialized code includes all variable names in the target code lines that match the current level values.

[0037] In a second aspect, the present application provides a vehicle-mounted message transmission method, the method comprising:

[0038] Compiling the in-vehicle message to be transmitted based on an abstract syntax markup compiler to generate a C language source code header file matching the in-vehicle message to be transmitted, wherein the in-vehicle message to be transmitted is an in-vehicle message generated by an in-vehicle V2X module for interacting with multiple software modules inside the vehicle;

[0039] Executing the data structure conversion method according to any one of claims 1 to 7 on the C language source code header file of the in-vehicle message to be transmitted, to generate a target data structure file matching the in-vehicle message to be transmitted;

[0040] Based on the target data structure file, the in-vehicle message to be transmitted is transmitted to a target module among the plurality of software modules in the vehicle.

[0041] In a third aspect, the present application provides a data structure conversion system, the system comprising:

[0042] a first changing module, configured to perform data change processing on a C language source code header file according to a preset first data change processing rule to output a first header file list, wherein the first header file list includes a main data structure header file and a descendant data structure header file corresponding to the C language source code header file, wherein the C language source code header file is compiled and generated by an abstract syntax markup compiler;

[0043] a merging module, configured to merge the repeated descendant data structure header files in the first header file list to generate a second header file list, and write the data structures defined by the main data structure header files and the descendant data structure header files included in the second header file list into a pending data cache structure;

[0044] A second change module, configured to perform data change processing on the data structure contained in the pending data cache structure according to a preset second data change processing rule to generate a target data structure that meets the C / C++ data structure requirements;

[0045] The file generation module writes the target data structure into the C language source code header file to generate a C / C++ reference header file, and writes the C / C++ reference header file into an hpp file to generate a target data structure file of a pure C / C++ data structure.

[0046] In a fourth aspect, the present application provides an electronic device, the electronic device comprising:

[0047] one or more processors;

[0048] and a memory associated with one or more processors, the memory being used to store program instructions, which, when read and executed by the one or more processors, perform the following operations:

[0049] Performing data change processing on a C language source code header file according to a preset first data change processing rule to output a first header file list, wherein the first header file list includes a main data structure header file and a descendant data structure header file corresponding to the C language source code header file, wherein the C language source code header file is compiled and generated by an abstract syntax markup compiler;

[0050] Merging repeated descendant data structure header files in the first header file list to generate a second header file list, and writing data structures defined by the main data structure header file and the descendant data structure header file included in the second header file list into a pending data cache structure;

[0051] Performing data change processing on the data structure contained in the pending data cache structure according to a preset second data change processing rule to generate a target data structure that meets the C / C++ data structure requirements;

[0052] The target data structure is written into the C language source code header file to generate a C / C++ reference header file, and the C / C++ reference header file is written into an hpp file to generate a target data structure file of a pure C / C++ data structure.

[0053] In a fifth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored, and the computer program enables a computer to perform the following operations:

[0054] Performing data change processing on a C language source code header file according to a preset first data change processing rule to output a first header file list, wherein the first header file list includes a main data structure header file and a descendant data structure header file corresponding to the C language source code header file, wherein the C language source code header file is compiled and generated by an abstract syntax markup compiler;

[0055] Merging repeated descendant data structure header files in the first header file list to generate a second header file list, and writing data structures defined by the main data structure header file and the descendant data structure header file included in the second header file list into a pending data cache structure;

[0056] Performing data change processing on the data structure contained in the pending data cache structure according to a preset second data change processing rule to generate a target data structure that meets the C / C++ data structure requirements;

[0057] The target data structure is written into the C language source code header file to generate a C / C++ reference header file, and the C / C++ reference header file is written into an hpp file to generate a target data structure file of a pure C / C++ data structure.

[0058] The beneficial effects achieved by this application are:

[0059] The present application provides a data structure conversion method, comprising performing data change processing on a C language source code header file according to a preset first data change processing rule to output a first header file list, wherein the first header file list includes a main data structure header file and a descendant data structure header file corresponding to the C language source code header file, wherein the C language source code header file is compiled and generated by an abstract syntax markup compiler; merging repeated descendant data structure header files in the first header file list to generate a second header file list, and writing the data structures defined by the main data structure header file and the descendant data structure header file included in the second header file list into a pending data cache structure; performing data change processing on the data structure included in the pending data cache structure according to a preset second data change processing rule to generate a target data structure that meets the requirements of the C / C++ data structure; writing the target data structure into the C language source code header file to generate a C / C++ reference header file, and writing the C / C++ reference header file into an hpp file to generate a target data structure file of a pure C / C++ data structure. The present application re-analyzes the C language source code header file compiled by the abstract syntax markup compiler, removes the ASN1C encoding and decoding engine code contained therein, extracts the data structure and data type, and regenerates the pure C / C++ header file; further, after being applied inside the vehicle, it solves the problem of software design and integration incompatibility when the various software modules and the protocol stack or application on the V2X Box transmit V2X messages after the V2X Box is integrated with other ECU modules of the car such as ADAS and smart cockpit, because the messages transmitted to each other are the ASN1C data structure; it greatly improves the stability and versatility of the V2X message in the transmission process, eliminates the problem that the V2X message is vulnerable to attacks due to the ASN1C engine data structure during transmission, and improves the security of V2X message transmission.

[0060] Furthermore, the present application supports automatic transformation processing of the C language source code header files generated by compiling the abstract syntax markup compiler of the multi-layer nested design layer by layer, including the main data structure and multiple descendant data structures, thereby avoiding the problems of poor quality and low efficiency of manual coding that may occur when faced with a multi-layer nested design resulting in huge data items.

[0061] Furthermore, the present application also proposes to perform denoising on the code lines contained in the current C language source code header file to obtain valid lines before changing the data type to be changed contained in the C language source code header file and bound to the abstract syntax markup compiler to a target data type that matches the C / C++ data structure requirements, thereby avoiding invalid movement of the code lines and greatly improving the efficiency and accuracy of the subsequent changes to the above-mentioned data to be changed.

[0062] Furthermore, the present application also proposes to screen the header files included in the first header file list, delete the duplicate header files in the first header file list to ensure the uniqueness of the header files included in the finally generated second header file, and reduce the processing pressure for the subsequent processing of the data structure contained in the second header file.

[0063] Furthermore, the present application proposes that when writing the data structure contained in the second header file list into the pending data cache structure, the pending data cache structure is first cleared to ensure the consistency of the written data, and the valid lines in the main data structure header file and the descendant data structure header file are further read, thereby reducing the storage pressure of the pending cache data without affecting the normal call of the header file data.

[0064] Furthermore, the present application proposes to first change the keywords to be changed according to the preset keyword association relationship to generate a transition data structure, and further analyze the transition data structure on this basis to replace the specific keywords therein, and obtain the final target data structure that meets the requirements through multiple changes to the cache structure of the pending data, thereby improving the reliability of the final generated target data structure.

[0065] Furthermore, the present application optionally embeds serialization and compression codes in the C language source code header file, which greatly improves the maintainability of the relevant code, and avoids excessive consumption of CPU and Memory resources of each ECU by the serialization and compression process by decoupling from the ASN1C engine.

[0066] Furthermore, the present application also proposes that when the on-board message to be transmitted generated by the on-board V2X module is transmitted to the target module, the data structure of the on-board message to be transmitted is converted into a data structure of a pure C / C++ data structure, thereby solving the incompatibility problem caused by a specific type of target module when receiving the on-board V2X module and improving the versatility of the on-board message to be transmitted generated by the on-board V2X module. BRIEF DESCRIPTION OF THE DRAWINGS

[0067] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work, among which:

[0068] Figure 1 This is a schematic diagram of data structure conversion deployment provided by an embodiment of the present application;

[0069] Figure 2 It is a schematic diagram of a method for generating a first header file list provided in an embodiment of the present application;

[0070] Figure 3 It is a schematic diagram of a second header file list generation method provided in an embodiment of the present application;

[0071] Figure 4 It is a schematic diagram of a data structure conversion method provided in an embodiment of the present application;

[0072] Figure 5 This is a data structure conversion system architecture diagram provided by an embodiment of the present application;

[0073] Figure 6 This is a structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0074] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0075] It should be understood that in the description of the present application, unless the context clearly requires otherwise, words such as "include", "comprises", and the like in the entire specification and claims should be interpreted as inclusive rather than exclusive or exhaustive; that is, the meaning of "including but not limited to".

[0076] It should also be understood that the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in the description of this application, unless otherwise specified, "plurality" means two or more.

[0077] It should be noted that the terms "S1", "S2", etc. are only used for the purpose of describing the steps, and do not specifically refer to the order or sequence, nor are they used to limit the present application. They are only for the convenience of describing the method of the present application, and cannot be understood as indicating the order of the steps. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in this field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection required by the present application.

[0078] As shown in the background technology, after the V2X Box is integrated with the ADAS and smart cockpit domains, when each software module and the protocol stack or application on the V2XBox transmit V2X messages with ASN1C data structures to each other, there are problems with software design and integration, including: ADAS and smart cockpit domains do not support the ASN1C engine, and the C language data structure based on the ASN1C engine does not have specific software design and integration versatility; the ASN1C engine data structure is directly transmitted on the automotive Ethernet, which is subject to network attacks and V2X message tampering, and the final transmission and reception of V2X messages has security risks; although the data structure of the ASN1C engine has the advantage of high compression rate, However, its serialization and compression process consumes a lot of CPU and memory resources of each ECU, which is not the optimal system integration method; the data structure of the ASN1C engine is a nested design. The child data structures of a main data structure can be nested up to 5 layers or more, and the final data items can be as many as thousands. If a software engineer manually codes to design a pure C / C++ data structure, the coding workload is very large, the coding efficiency is low, it is easy to make errors, and the code quality is not high; if the ASN1C source code is upgraded or revised, the software engineer needs to repeat the manual coding work many times, and it is not easy to verify the change points, and the error rate is very high.

[0079] However, the prior art does not provide a method for changing the ASN1C data structure into a pure C / C++ data structure that can be applied to the V2X field and adapt to the POSIX (Portable Operating System Interface for UNIX) system. Therefore, the present application provides a data structure conversion method to analyze and process the C language source code header file compiled by the abstract syntax markup compiler, convert the ASN1C data structure into a pure C / C++ data structure, and automatically generate a C / C++ reference header file for reference and use by ECU software coding.

[0080] Embodiment 1

[0081] The embodiment of the present application provides a data structure conversion method. Specifically, the method disclosed in the embodiment of the present application is used to convert the ASN1C data structure generated by the abstract syntax markup compiler into a pure C / C++ data structure, such as Figure 1 As shown, including the following:

[0082] S1. Performing a change process on a C language source code header file to output a first header file list, which includes a main data structure header file and a descendant data structure header file corresponding to the C language source code header file.

[0083] It is necessary to first obtain a C language source code header file, which is a C language source code header file compiled and generated by an abstract syntax markup compiler. Specifically, the command line parameters can be read to parse the command line parameters to obtain the specified C language source code header file name and further search for the corresponding C language source code header file according to the C language source code header file name (i.e., fname); wherein the method of reading the command line parameters is determined by the programming language used and is implemented through specific instructions. For example, in C or C++ languages, it can be implemented through the following code:

[0084] int main(int argc,char*argv[]){

[0085] bool theFilterOptional=false;

[0086] std::vector <std::string>theGlobalJvsData;

[0087] std::vector <std::string>thGlobaleReadFileList;

[0088] if(argc<2){

[0089] std::cout<<"Uage:"<<std::endl;

[0090] std::cout<<"asn1tocpp***.hpp"<<std::endl;

[0091] return-1;

[0092] }

[0093] if(argc>=3)

[0094] theFilterOptional=(0==strcmp(argv[2],"true"))?true:false;

[0095] std::cout<<"Begin to deal with"<<argv[1]<<std::endl;

[0096] readfile(argv[1],thGlobaleReadFileList,theFilterOptional);

[0097] combineAllFiles(theGlobalJvsData,thGlobaleReadFileList,theFilterOptional);

[0098] std::cout<<std::endl;

[0099] std::cout<<"This filedepnes on"<<std::endl;

[0100] for(int i=0;i<thGlobaleReadFileList.size();i++){

[0101] std::cout<<thGlobaleReadFileList.at(i)<<std::endl;

[0102] }

[0103] std::cout<<std::endl;

[0104] std::cout<<"Final analysis result..."< <std::endl;

[0105] for(int i=0; i <theGlobalJvsData.size();i++){

[0106] std::cout< <theGlobalJvsData.at(i)<<std::endl;

[0107] }

[0108] if(argc>=4)

[0109] createHppFile(argv[3],theGlobalJvsData,thGlobaleReadFileList);

[0110] else

[0111] createHppFile("jvsoidata.hpp",theGlobalJvsData,thGlobaleReadFileList);

[0112] return 0;

[0113] }.

[0114] Further, the C language source code header file is subjected to data change processing according to a preset first data change processing rule to output a first header file list, wherein the first header file list includes a main data structure header file and a descendant data structure header file corresponding to the C language source code header file. It can be understood that the data structure of the C language source code header file compiled and generated by the abstract syntax markup compiler is usually a nested design, and the descendant data structures of a main data structure can be nested up to 5 layers or more, and the final data items can even be up to thousands; in the embodiments disclosed in the present application, not only the automatic change of the main data structure of the C language source code header file is realized, but also the automatic change of the descendant data structure of the C language source code header file is realized.

[0115] Specifically, Figure 2 As shown, the above-mentioned data change processing is performed on the C language source code header file according to the preset first data change processing rule to output the first header file list, including: executing a main data structure change operation, the main data structure change operation includes: changing the to-be-changed data type bound to the abstract syntax markup compiler in the C language source code header file to a target data type matching the C / C++ data structure requirement, generating a to-be-processed header file name corresponding to the target data type and outputting a main data structure header file corresponding to the to-be-processed header file name; executing a descendant data structure change operation, the descendant data structure change operation includes: checking whether there is a to-be-processed header file corresponding to the to-be-processed header file name; in response to checking that the to-be-processed header file exists, changing the to-be-changed data type bound to the abstract syntax markup compiler in the to-be-processed header file to a new target data type matching the C / C++ data structure requirement, generating a new to-be-processed header file name corresponding to the target data type and outputting a descendant data structure header file corresponding to the to-be-processed header file name; recursively executing the descendant data structure change operation until no new to-be-processed header file name is generated.

[0116] Furthermore, before changing the data type to be changed bound by the abstract syntax markup compiler in the C language source code header file to a target data type that matches the C / C++ data structure requirements, the method includes: parsing the target header file to generate a data type name, wherein the target header file includes a C language source code header file and a header file to be processed; performing a denoising operation on the code lines in the target header file to obtain valid lines in the target header file, and writing the valid lines into a pending data cache structure (denoted as theJvsData in the figure), wherein the noise includes spaces, comment statements, conditional statements, and lines where preset keywords are located; in response to reading a code line containing a data type name in the target header file, changing the data type to be changed bound by the abstract syntax markup compiler in the code line contained in the pending data cache structure to a target data type that matches the C / C++ data structure requirements.

[0117] Specifically, the above-mentioned execution of the main data structure change operation includes: reading the code lines contained in the pending data cache structure line by line, and performing lexical analysis on the currently read code line. If the keyword ";" is detected, if the keyword ";" is not detected, it is determined whether the current code line is the last line in the pending data cache structure. If so, the data change processing is terminated and the first header file list currently generated is output; otherwise, the lexical analysis of the next code line is continued to detect whether the keyword "}" exists. If the keyword "}" is detected, it is skipped and the lexical analysis of the next code line is continued; if the keyword "_t" is detected in the current code line, the current code line is continued to be analyzed to see whether the keyword "typedef" exists. If the keyword "typedef" is detected, the keyword is erased, and all spaces on the left of the current line are erased, and the current line is extracted. Type name, and erase the content after "_t", add ".h" at the end of the current line to generate szSonFname (that is, the new name of the header file to be processed), and output theReadFileList (that is, the first header file list) containing the name of the header file to be processed; on the contrary, if the keyword "_t" is not detected in the current code line, continue to analyze whether the current code line contains the keyword "struct", if the keyword "struct" exists, continue to analyze whether the current line contains the keyword "A_SEQUENCE_OF", if it exists, erase the content on the left of "("the content on the left, erase")", and get the name of the current struct, add ".h" at the end of the current line, generate the name of the header file to be processed, and output the first header file list containing the main data structure header file corresponding to the header file to be processed.

[0118] The above-mentioned execution of descendant data structure change operation includes: checking whether there is a header file to be processed corresponding to the header file name to be processed in the current first header file list, and if so, changing the data type to be changed bound to the abstract syntax tag compiler in the header file to be processed to a new target data type that matches the C / C++ data structure requirements, and generating a new header file name to be processed corresponding to the target data type and outputting the descendant structure data header file corresponding to the header file name to be processed; the specific change processing steps are consistent with the above-mentioned execution of the change operation in the main data structure, and this application will not repeat them here. It can be understood that the descendant data structure change operation of the current processing process is recursively called with the header file name to be processed and the first header file list as input until no new header file name to be processed is generated.

[0119] Among them, the above-mentioned denoising operation is performed on the code lines in the target header file to obtain valid lines in the target header file, and the valid lines are written into the pending data cache structure. The specific denoising operation includes: lexically analyzing the current code line, and skipping if the following preset keywords are detected, wherein the preset keywords include but are not limited to #define, #include, extern, #ifndef, #endif, struct, / *OPTIONAL*, asnstructctxt, asnstructfreef, asn_struct_print_f, asn_constr_check_f, ber_type_decoder_f, der_type_encoder_f, xer_type_decoder_f, xer_type_encoder_f, oer_type_decoder_f, oer_type_encoder_f, per_type_decoder_f, per_type_encoder_f. The above-mentioned denoising operation also includes: lexically analyzing the current code line, if the keyword #ifdef is found, then looping to read the next line, until the keyword #endif is found, and then skipping #ifdef and #endif and the code lines contained in between, that is, conditional statements. The above-mentioned denoising also includes: lexically analyzing the current code line, if the comment keyword " / *" is detected, then looping to read the next code line until the comment end keyword "* / " is detected, and then skipping " / *", "* / " and the code lines contained in between, that is, comment statements. The above-mentioned denoising also includes lexically analyzing the current code line, if the length of the current code line is 0 or all spaces, then skipping the code line. Among them, lexical analysis is the process of converting a character sequence into a word (Token) sequence in computer science, which is a conventional setting in this field; the program or function that performs lexical analysis is called a lexical analyzer (Lexical analyzer, abbreviated as Lexer), also called a scanner (Scanner). Lexical analyzers generally exist in the form of functions for grammatical analyzers to call, and this application will not go into details here.

[0120] S2. Merge the repeated descendant data structure header files in the first header file list to generate a second header file list; and write the data structures defined by the main data structure header file and the descendant data structure header files included in the second header file list into the pending data cache structure.

[0121] As mentioned above, the data structure of the C language source code header file generated by the compiler based on the abstract syntax markup is usually a nested design. Therefore, the descendant data structure header file generated by the descendant data structure change operation contained in the C language source code header file is prone to duplication; therefore, it is necessary to merge the repeated descendant data structure header files contained in the first header file list. Since the data structure definition recorded in the first header file list is from "parent structure" to "child structure", and the C / C++ data structure cannot be referenced forward, it is necessary to start the analysis from the back to the front when merging the repeated header files in the first header file list. Figure 3 As shown, the above-mentioned merging of repeated descendant data structure header files in the first header file list to generate a second header file list includes: reading the descendant data structure header file and the main data structure header file from back to front according to the writing order of the main data structure header file and the descendant data structure header file in the first header file list; checking whether there is a descendant data structure header file with the same header file name as the header file corresponding to the currently read descendant data structure header file in the second header file list; if there is a descendant data structure header file with the same header file name as the header file corresponding to the currently read descendant data structure header file in the second header file list, stopping writing the currently read descendant data structure header file to the second header file list; if there is no descendant data structure header file with the same header file name as the header file corresponding to the currently read descendant data structure header file in the second header file list, writing the currently read descendant data structure header file to the second header file list.

[0122] Specifically, in some implementation scenarios, i can be set as the index of the currently accessed first header file list (denoted as theReadFileList), the maximum value range of i does not exceed the number of header files included in the first header file list, and a second header file list (denoted as theDependencyFileList) is defined to read the current header file (filepath) of the first header file list, that is, the header file name pointed to by theReadFileList.at(i), that is, filepath=theReadFileList.at(i),--when i<0, first read theReadFileList.at( i) and push it into theDependencyFileList. While pushing it, it is necessary to determine whether the header file pointed to by theReadFileList.at(i) already exists in the second header file list. If it does, stop writing and delete the header file pointed to by theReadFileList.at(i); if the second header file list does not contain the same header file as the header file pointed to by theReadFileList.at(i), push the header file pointed to by filepath into the second header file list; repeat the above steps until all header files in the first header file list are read and the second header file list is output.

[0123] It is understandable that if Figure 3 As shown, while generating the second header file list, it is also necessary to push the data structures defined by the main data structure header file and the descendant data structure header file contained in the second header file list into the pending data cache structure, specifically, including clearing the pending data cache structure (denoted as theJvsData in the figure); reading the code lines contained in the main data structure header file contained in the second header file list line by line, and writing the read main data structure header file code to perform denoising operation to obtain the main data structure header file valid line and write it to the pending data cache structure, until the main data structure header file contains the data type name matching the main data structure header file. The code line; and, reading the code lines contained in the descendant data structure header file contained in the second header file list line by line, and writing the read descendant data structure header file code to perform denoising operation to obtain the descendant data structure header file valid line and write it to the pending data cache structure, until the descendant data structure header file contains the data type name matching the descendant data structure header file. The above denoising process is consistent with the denoising process disclosed in the previous text, and this application will not repeat it here.

[0124] S3. The data structure contained in the pending data cache structure is changed to generate a target data structure, and based on the target data structure, a target data structure file of a pure C / C++ data structure is further generated.

[0125] Specifically, Figure 4 As shown, after the data structures defined by the main data structure header file and the descendant data structure header file included in the second header file list are written into the pending data cache structure, it is also necessary to perform data change processing on the data structure included in the pending data cache structure according to the preset second data change processing rule to generate a target data structure that meets the C / C++ data structure requirements, specifically including: according to the preset keyword association relationship, changing the to-be-changed keyword bound to the abstract syntax marker compiler in the pending data cache structure to the target keyword matching the C / C++ data structure requirements to form a transition data structure, the keyword association relationship including the association relationship between the to-be-changed keyword bound to the abstract syntax marker compiler and the target keyword matching the C / C++ data structure requirements; analyzing the transition data structure line by line, after detecting the code line of the keyword "{" in the transition data structure, if the keyword "union" is detected, replacing the keyword "union" with the keyword "struct" to form the target data structure (denoted as line in the figure). The preset keyword association relationship includes the correspondence between the keywords to be changed bound by the abstract syntax marker compiler and the target keywords required to match the C / C++ data structure, for example, the keyword to be changed "typedef struct" corresponds to the target keyword "typedef struct JVS", the keyword to be changed "typedef enum" corresponds to the target keyword "typedef enum JVS", the keyword to be changed "A_SEQUENCE_OF" corresponds to the target keyword "std::vector<szsturctName_t> szVarianttName" corresponds to the keyword to be changed "unit8_t*buf;" and the target keyword "std::vector<unint8_t> buf;" corresponds to the keyword to be changed "*" and the target keyword "" (space), and the keyword to be changed "_t" corresponds to the target keyword "_T" (except for _t included in C / C++ types such as unit8_t and size_t), etc.

[0126] Furthermore, the above-mentioned data change processing of the data structure in the pending data cache structure according to the preset second data change processing rule to generate a target data structure that meets the requirements of the C / C++ data structure also includes adding serialization code in the target data structure, specifically including: defining a level variable, and analyzing the transition data structure line by line; if a code line with the keyword "{" is detected in the transition data structure and the keyword "struct" is detected, then the value of the level variable is increased by 1; if a code line with the keyword "}" is detected in the target data structure, and the current level variable is greater than or equal to 0, then serialization code is added before the code line where the keyword "}" is located, and the value of the level variable is reduced by 1; wherein, multiple code behaviors between adjacent keywords "{" and keywords "}" are defined as target code lines that match the current level variable when the keyword "}" is detected, and the serialization code includes all variable names in the target code line that matches the current level value. The above steps are used to embed serialization and compression code in each layer of the structure.

[0127] Finally, the C language source code header file generates the C language source code header file comment line, writes the comment into the C language source code header file; and writes the system reference header file code, target data structure and C / C++ header file tail code into the C language source code header file in order to generate the C / C++ reference header file; writes the C / C++ reference header file into the hpp file to generate the target data structure file of the pure C / C++ data structure. Among them, the specific system reference header files are as follows:

[0128] #include<boost / iostreams / filtering_stream.hpp> ;

[0129] #include<boost / iostreams / device / file_descriptor.hpp> ;

[0130] #include<boost / iostreams / device / file.hpp> ;

[0131] #include<boost / iostreams / filter / gzip.hpp> ;

[0132] #include<boost / iostreams / filter / bzip2.hpp> ;

[0133] #include<boost / iostreams / copy.hpp> ;

[0134] #include<boost / serialization / access.hpp>;

[0135] #include<boost / serialization / string.hpp>;

[0136] #include<boost / serialization / shared_ptr.hpp>;

[0137] #include<boost / serialization / vector.hpp>;

[0138] #include<boost / archive / text_oarchive.hpp>;

[0139] #include<boost / smart_ptr / make_shared.hpp>;

[0140] #include<boost / archive / text_iarchive.hpp>;

[0141] #include <iostream>;

[0142] #include <sstream>.

[0143] The method disclosed in the embodiment of the present application realizes the conversion of the C language source code header file generated by the abstract syntax markup compiler mutation into a C / C++ data structure and a reference header file; realizes the unbinding of the C language source code header file from the ASN1C engine, greatly improving the versatility of messages transmitted using the C language source code header file.

[0144] Embodiment 2

[0145] Corresponding to the above-mentioned embodiment 1, the present application also provides an in-vehicle message transmission method in an embodiment, which specifically includes:

[0146] Compiling the in-vehicle message to be transmitted based on an abstract syntax markup compiler to generate a C language source code header file matching the in-vehicle message to be transmitted, wherein the in-vehicle message to be transmitted is an in-vehicle message generated by an in-vehicle V2X module for interacting with multiple software modules inside the vehicle;

[0147] Based on the C language source code header file of the in-vehicle message to be transmitted, generating a target data structure file matching the in-vehicle message to be transmitted;

[0148] Based on the target data structure file, the in-vehicle message to be transmitted is transmitted to a target module among the plurality of software modules in the vehicle.

[0149] The method for generating a target data structure file matching the in-vehicle message to be transmitted specifically includes:

[0150] Performing data change processing on a C language source code header file according to a preset first data change processing rule to output a first header file list, wherein the first header file list includes a main data structure header file and a descendant data structure header file corresponding to the C language source code header file, wherein the C language source code header file is compiled and generated by an abstract syntax markup compiler;

[0151] Merging repeated descendant data structure header files in the first header file list to generate a second header file list, and writing data structures defined by the main data structure header file and the descendant data structure header file included in the second header file list into a pending data cache structure;

[0152] Performing data change processing on the data structure contained in the pending data cache structure according to a preset second data change processing rule to generate a target data structure that meets the C / C++ data structure requirements;

[0153] The target data structure is written into the C language source code header file to generate a C / C++ reference header file, and the C / C++ reference header file is written into an hpp file to generate a target data structure file of a pure C / C++ data structure.

[0154] In some embodiment scenarios, performing data change processing on the C language source code header file according to a preset first data change processing rule to output a first header file list includes:

[0155] Execute a main data structure change operation, the main data structure change operation comprising: changing the data type to be changed in the C language source code header file bound to the abstract syntax markup compiler to a target data type matching the C / C++ data structure requirement, generating a header file name to be processed corresponding to the target data type and outputting a main data structure header file corresponding to the header file name to be processed;

[0156] Executing a descendant data structure change operation, wherein the executing descendant data structure change operation includes: checking whether there is a header file to be processed corresponding to the name of the header file to be processed;

[0157] In response to detecting that the header file to be processed exists, changing the data type to be changed in the header file to be processed and bound to the abstract syntax markup compiler to a new target data type matching the C / C++ data structure requirement, generating a new header file name to be processed corresponding to the target data type, and outputting a descendant data structure header file corresponding to the header file name to be processed;

[0158] The descendant data structure change operation is recursively executed until no new header file name to be processed is generated.

[0159] In some embodiment scenarios, before changing the data type to be changed in the C language source code header file bound to the abstract syntax markup compiler to a target data type that matches the C / C++ data structure requirement, the method includes:

[0160] Parsing a target header file to generate a data type name, wherein the target header file includes the C language source code header file and the header file to be processed;

[0161] Performing a denoising operation on the code lines in the target header file to obtain valid lines in the target header file, and writing the valid lines into a pending data cache structure, wherein the noise includes spaces, comment statements, conditional statements, and lines where preset keywords are located;

[0162] In response to reading a code line containing the data type name in the target header file, the data type to be changed in the code line contained in the pending data cache structure and bound to the abstract syntax markup compiler is changed to a target data type that matches the C / C++ data structure requirement.

[0163] In some embodiment scenarios, merging the repeated descendant data structure header files in the first header file list to generate a second header file list includes:

[0164] According to the writing order of the main data structure header file and the descendant data structure header file in the first header file list, read the descendant data structure header file and the main data structure header file from back to front;

[0165] Check whether there is a descendant data structure header file in the second header file list having the same header file name as the descendant data structure header file currently read;

[0166] If there is a descendant data structure header file in the second header file list having the same header file name as that corresponding to the currently read descendant data structure header file, then stop writing the currently read descendant data structure header file into the second header file list;

[0167] If there is no descendant data structure header file with the same header file name as that corresponding to the currently read descendant data structure header file in the second header file list, the currently read descendant data structure header file is written to the second header file list.

[0168] In some embodiment scenarios, writing the data structure defined by the main data structure header file and the descendant data structure header file included in the second header file list into the pending data cache structure includes:

[0169] Clear pending data cache structure;

[0170] Reading the code lines contained in the main data structure header file contained in the second header file list line by line, and writing the read main data structure header file code to perform a denoising operation to obtain a valid line of the main data structure header file and write it into the pending data cache structure, until a code line containing the data type name matching the main data structure header file is read in the main data structure header file;

[0171] and, reading the code lines contained in the descendant data structure header file contained in the second header file list line by line, and writing the read descendant data structure header file code to perform a denoising operation to obtain valid lines of the descendant data structure header file and write them into the pending data cache structure, until the code line containing the data type name matching the descendant data structure header file is read in the descendant data structure header file.

[0172] In some embodiment scenarios, performing data change processing on the data structure included in the pending data cache structure according to a preset second data change processing rule to generate a target data structure that meets the C / C++ data structure requirements includes:

[0173] According to a preset keyword association relationship, the keyword to be changed in the pending data cache structure and bound to the abstract syntax markup compiler is changed to a target keyword that matches the C / C++ data structure requirement to form a transition data structure, wherein the keyword association relationship includes an association relationship between the keyword to be changed bound to the abstract syntax markup compiler and the target keyword that matches the C / C++ data structure requirement;

[0174] The transition data structure is analyzed line by line. After a code line containing the keyword "{" is detected in the transition data structure, if the keyword "union" is detected, the keyword "union" is replaced with the keyword "struct" to form a target data structure.

[0175] In some embodiment scenarios, the method further includes:

[0176] Add serialization code in the target data structure, including:

[0177] Define the level variable and analyze the transition data structure line by line;

[0178] If a code line containing the keyword "{" and the keyword "struct" is detected in the transition data structure, the value of the level variable is increased by 1;

[0179] If a code line containing the keyword "}" is detected in the target data structure, and the current level variable is greater than or equal to 0, then add serialization code before the code line containing the keyword "}" and reduce the value of the level variable by 1;

[0180] Among them, multiple code behaviors between adjacent keywords "{" and keywords "}" are defined as target code lines that match the current level variables when detecting the keyword "}", and the serialized code includes all variable names in the target code lines that match the current level values.

[0181] Embodiment 3

[0182] Corresponding to the above-mentioned embodiment 1 and embodiment 2, as Figure 5 As shown, the embodiment of the present application also provides a data structure conversion system, including:

[0183] A first changing module 510 is used to perform data change processing on a C language source code header file according to a preset first data change processing rule to output a first header file list, wherein the first header file list includes a main data structure header file and a descendant data structure header file corresponding to the C language source code header file, wherein the C language source code header file is compiled and generated by an abstract syntax markup compiler;

[0184] A merging module 520 is used to merge the repeated descendant data structure header files in the first header file list to generate a second header file list, and write the data structures defined by the main data structure header files and the descendant data structure header files included in the second header file list into the pending data cache structure;

[0185] A second changing module 530 is used to perform data change processing on the data structure included in the pending data cache structure according to a preset second data change processing rule to generate a target data structure that meets the C / C++ data structure requirements;

[0186] The file generation module 540 is used to write the target data structure into the C language source code header file to generate a C / C++ reference header file, and write the C / C++ reference header file into an hpp file to generate a target data structure file of a pure C / C++ data structure.

[0187] In some implementation scenarios, the first change module 510 is used to perform a main data structure change operation, which includes: changing the data type to be changed bound to the abstract syntax markup compiler in the C language source code header file to a target data type matching the C / C++ data structure requirement, generating a header file name to be processed corresponding to the target data type and outputting a main data structure header file corresponding to the header file name to be processed; performing a descendant data structure change operation, which includes: checking whether there is a header file to be processed corresponding to the header file name to be processed; in response to checking that the header file to be processed exists, changing the data type to be changed bound to the abstract syntax markup compiler in the header file to be processed to a new target data type matching the C / C++ data structure requirement, generating a new header file name to be processed corresponding to the target data type and outputting a descendant data structure header file corresponding to the header file name to be processed; and recursively performing the descendant data structure change operation until no new header file name to be processed is generated.

[0188] In some implementation scenarios, the first change module 510 is also used to parse the target header file to generate a data type name, wherein the target header file includes the C language source code header file and the header file to be processed; perform a denoising operation on the code lines in the target header file to obtain valid lines in the target header file, and write the valid lines into the pending data cache structure, wherein the noise includes spaces, comment statements, conditional statements, and lines where preset keywords are located; in response to reading a code line containing the data type name in the target header file, change the data type to be changed in the code line contained in the pending data cache structure and bound to the abstract syntax markup compiler to a target data type that matches the C / C++ data structure requirements.

[0189] In some implementation scenarios, the merging module 520 is also used to read the descendant data structure header file and the main data structure header file from back to front according to the writing order of the main data structure header file and the descendant data structure header file in the first header file list; check whether there is a descendant data structure header file with the same header file name as the header file corresponding to the currently read descendant data structure header file in the second header file list; if there is a descendant data structure header file with the same header file name as the header file corresponding to the currently read descendant data structure header file in the second header file list, stop writing the currently read descendant data structure header file to the second header file list; if there is no descendant data structure header file with the same header file name as the header file corresponding to the currently read descendant data structure header file in the second header file list, write the currently read descendant data structure header file to the second header file list.

[0190] In some implementation scenarios, the merge module 520 is also used to clear the pending data cache structure; read the code lines contained in the main data structure header file included in the second header file list line by line, and write the read main data structure header file code to perform a denoising operation to obtain the valid lines of the main data structure header file and write them into the pending data cache structure, until the code line containing the data type name matching the main data structure header file is read in the main data structure header file; and, read the code lines contained in the descendant data structure header file included in the second header file list line by line, and write the read descendant data structure header file code to perform a denoising operation to obtain the valid lines of the descendant data structure header file and write them into the pending data cache structure, until the code line containing the data type name matching the descendant data structure header file is read in the descendant data structure header file.

[0191] In some implementation scenarios, the second change module 530 is further used to change the keyword to be changed bound to the abstract syntax markup compiler in the pending data cache structure to a target keyword that matches the C / C++ data structure requirements to form a transitional data structure according to a preset keyword association relationship, wherein the keyword association relationship includes an association relationship between the keyword to be changed bound to the abstract syntax markup compiler and the target keyword that matches the C / C++ data structure requirements; analyze the transitional data structure line by line, and after detecting a code line containing the keyword "{" in the transitional data structure, if the keyword "union" is detected, replace the keyword "union" with the keyword "struct" to form a target data structure.

[0192] In some implementation scenarios, the second change module 530 is also used to add serialization code in the target data structure, specifically including: defining a level variable and analyzing the transition data structure line by line; if a code line with the keyword "{" is detected in the transition data structure and the keyword "struct" is detected, the value of the level variable is increased by 1; if a code line with the keyword "}" is detected in the target data structure, and the current level variable is greater than or equal to 0, then serialization code is added before the code line where the keyword "}" is located, and the value of the level variable is reduced by 1; wherein, a target code line that matches the current level variable when the keyword "}" is detected is defined as multiple code behaviors between adjacent keywords "{" and keywords "}", and the serialization code includes all variable names in the target code line that matches the current level value.

[0193] Embodiment 4

[0194] Corresponding to all the above embodiments, an embodiment of the present application provides an electronic device, including: one or more processors; and a memory associated with the one or more processors, the memory is used to store program instructions, and when the program instructions are read and executed by the one or more processors, the following operations are performed:

[0195] Performing data change processing on a C language source code header file according to a preset first data change processing rule to output a first header file list, wherein the first header file list includes a main data structure header file and a descendant data structure header file corresponding to the C language source code header file, wherein the C language source code header file is compiled and generated by an abstract syntax markup compiler;

[0196] Merging repeated descendant data structure header files in the first header file list to generate a second header file list, and writing data structures defined by the main data structure header file and the descendant data structure header file included in the second header file list into a pending data cache structure;

[0197] Performing data change processing on the data structure contained in the pending data cache structure according to a preset second data change processing rule to generate a target data structure that meets the C / C++ data structure requirements;

[0198] The target data structure is written into the C language source code header file to generate a C / C++ reference header file, and the C / C++ reference header file is written into an hpp file to generate a target data structure file of a pure C / C++ data structure.

[0199] in, Figure 6 The architecture of the electronic device is shown exemplarily, and may include a processor 610, a video display adapter 611, a disk drive 612, an input / output interface 613, a network interface 614, and a memory 620. The processor 610, the video display adapter 611, the disk drive 612, the input / output interface 613, the network interface 614, and the memory 620 may be communicatively connected via a bus 630.

[0200] Among them, the processor 610 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solution provided in this application.

[0201] The memory 620 can be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 620 can store an operating system 621 for controlling the execution of the electronic device 600, and a basic input and output system (BIOS) 622 for controlling the low-level operations of the electronic device 600. In addition, a web browser 623, a data storage management system 624, and an icon font processing system 625, etc. can also be stored. The above-mentioned icon font processing system 625 can be an application program that specifically implements the operations of the aforementioned steps in the embodiment of the present application. In short, when the technical solution provided in the present application is implemented by software or firmware, the relevant program code is stored in the memory 620 and is called and executed by the processor 610.

[0202] The input / output interface 613 is used to connect the input / output module to realize information input and output. The input / output module can be configured in the device as a component (not shown in the figure), or it can be externally connected to the device to provide corresponding functions. The input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc.

[0203] The network interface 614 is used to connect to a communication module (not shown) to realize communication interaction between the device and other devices. The communication module can realize communication through a wired mode (such as USB, network cable, etc.) or a wireless mode (such as mobile network, WIFI, Bluetooth, etc.).

[0204] The bus 630 comprises a pathway for transmitting information between the various components of the device (eg, the processor 610, the video display adapter 611, the disk drive 612, the input / output interface 613, the network interface 614, and the memory 620).

[0205] In addition, the electronic device 600 can also obtain information on specific collection conditions from the virtual resource object collection condition information database for use in condition judgment, etc.

[0206] It should be noted that, although the above device only shows a processor 610, a video display adapter 611, a disk drive 612, an input / output interface 613, a network interface 614, a memory 620, a bus 630, etc., in the specific implementation process, the device may also include other components necessary for normal execution. In addition, it can be understood by those skilled in the art that the above device may also only include components necessary for implementing the solution of the present application, and does not necessarily include all the components shown in the figure.

[0207] It can be seen from the description of the above implementation methods that those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform. Based on this understanding, the technical solution of the present application can essentially or in other words, the part that contributes to the prior art can be embodied in the form of a software product, which can be stored in a storage medium such as ROM / RAM, a disk, an optical disk, etc., including several instructions for a computer device (which can be a personal computer, a cloud service end, or a network device, etc.) to execute the methods of various embodiments of the present application or certain parts of the embodiments.

[0208] Embodiment 5

[0209] Corresponding to all the above embodiments, the embodiments of the present application further provide a computer-readable storage medium, characterized in that it stores a computer program, and the computer program enables a computer to perform the following operations:

[0210] Performing data change processing on a C language source code header file according to a preset first data change processing rule to output a first header file list, wherein the first header file list includes a main data structure header file and a descendant data structure header file corresponding to the C language source code header file, wherein the C language source code header file is compiled and generated by an abstract syntax markup compiler;

[0211] Merging repeated descendant data structure header files in the first header file list to generate a second header file list, and writing data structures defined by the main data structure header file and the descendant data structure header file included in the second header file list into a pending data cache structure;

[0212] Performing data change processing on the data structure contained in the pending data cache structure according to a preset second data change processing rule to generate a target data structure that meets the C / C++ data structure requirements;

[0213] The target data structure is written into the C language source code header file to generate a C / C++ reference header file, and the C / C++ reference header file is written into an hpp file to generate a target data structure file of a pure C / C++ data structure.

[0214] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system or system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment. The system and system embodiments described above are merely schematic, in which the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0215] The above are only preferred embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application.< / sstream> < / iostream> < / std::string> < / std::string>

Claims

1. A data structure conversion method, characterized in that: The method comprises: Performing data change processing on a C language source code header file according to a preset first data change processing rule to output a first header file list, wherein the first header file list includes a main data structure header file and a descendant data structure header file corresponding to the C language source code header file, wherein the C language source code header file is compiled and generated by an abstract syntax markup compiler; Merging repeated descendant data structure header files in the first header file list to generate a second header file list, and writing data structures defined by the main data structure header file and the descendant data structure header file included in the second header file list into a pending data cache structure; Performing data change processing on the data structure contained in the pending data cache structure according to a preset second data change processing rule to generate a target data structure that meets the C / C++ data structure requirements; The target data structure is written into the C language source code header file to generate a C / C++ reference header file, and the C / C++ reference header file is written into an hpp file to generate a target data structure file of a pure C / C++ data structure.

2. The method according to claim 1, characterized in that: The step of performing data change processing on the C language source code header file according to a preset first data change processing rule to output a first header file list includes: Execute a main data structure change operation, the main data structure change operation comprising: changing the data type to be changed in the C language source code header file bound to the abstract syntax markup compiler to a target data type matching the C / C++ data structure requirement, generating a header file name to be processed corresponding to the target data type and outputting a main data structure header file corresponding to the header file name to be processed; Executing a descendant data structure change operation, wherein the executing descendant data structure change operation includes: checking whether there is a header file to be processed corresponding to the name of the header file to be processed; In response to detecting that the header file to be processed exists, changing the data type to be changed in the header file to be processed and bound to the abstract syntax markup compiler to a new target data type matching the C / C++ data structure requirement, generating a new header file name to be processed corresponding to the target data type, and outputting a descendant data structure header file corresponding to the header file name to be processed; The descendant data structure change operation is recursively executed until no new header file name to be processed is generated.

3. The method according to claim 2, characterized in that Before changing the data type to be changed in the C language source code header file bound to the abstract syntax markup compiler to a target data type that matches the C / C++ data structure requirement, the method includes: Parsing a target header file to generate a data type name, wherein the target header file includes the C language source code header file and the header file to be processed; Performing a denoising operation on the code lines in the target header file to obtain valid lines in the target header file, and writing the valid lines into a pending data cache structure, wherein the noise includes spaces, comment statements, conditional statements, and lines where preset keywords are located; In response to reading a code line containing the data type name in the target header file, the data type to be changed in the code line contained in the pending data cache structure and bound to the abstract syntax markup compiler is changed to a target data type that matches the C / C++ data structure requirement.

4. The method according to claim 3, characterized in that The step of merging the repeated descendant data structure header files in the first header file list to generate a second header file list comprises: According to the writing order of the main data structure header file and the descendant data structure header file in the first header file list, read the descendant data structure header file and the main data structure header file from back to front; Check whether there is a descendant data structure header file in the second header file list having the same header file name as the descendant data structure header file currently read; If there is a descendant data structure header file in the second header file list having the same header file name as that corresponding to the currently read descendant data structure header file, then stop writing the currently read descendant data structure header file into the second header file list; If there is no descendant data structure header file with the same header file name as that corresponding to the currently read descendant data structure header file in the second header file list, the currently read descendant data structure header file is written to the second header file list.

5. The method according to claim 4, characterized in that The step of writing the data structure defined by the main data structure header file and the descendant data structure header file included in the second header file list into the pending data cache structure includes: Clear pending data cache structure; Reading the code lines contained in the main data structure header file contained in the second header file list line by line, and writing the read main data structure header file code to perform a denoising operation to obtain a valid line of the main data structure header file and write it into the pending data cache structure, until a code line containing the data type name matching the main data structure header file is read in the main data structure header file; and, reading the code lines contained in the descendant data structure header file contained in the second header file list line by line, and writing the read descendant data structure header file code to perform a denoising operation to obtain valid lines of the descendant data structure header file and write them into the pending data cache structure, until the code line containing the data type name matching the descendant data structure header file is read in the descendant data structure header file.

6. The method according to any one of claims 1 to 5, characterized in that: The step of performing data change processing on the data structure contained in the pending data cache structure according to a preset second data change processing rule to generate a target data structure that meets the C / C++ data structure requirements includes: According to a preset keyword association relationship, the keyword to be changed in the pending data cache structure and bound to the abstract syntax markup compiler is changed to a target keyword that matches the C / C++ data structure requirement to form a transition data structure, wherein the keyword association relationship includes an association relationship between the keyword to be changed bound to the abstract syntax markup compiler and the target keyword that matches the C / C++ data structure requirement; The transition data structure is analyzed line by line. After a code line containing the keyword "{" is detected in the transition data structure, if the keyword "union" is detected, the keyword "union" is replaced with the keyword "struct" to form a target data structure.

7. The method according to claim 6, characterized in that The method further comprises: Add serialization code in the target data structure, including: Define the level variable and analyze the transition data structure line by line; If a code line containing the keyword "{" and the keyword "struct" is detected in the transition data structure, the value of the level variable is increased by 1; If a code line containing the keyword "}" is detected in the target data structure, and the current level variable is greater than or equal to 0, then add serialization code before the code line containing the keyword "}" and reduce the value of the level variable by 1; Among them, multiple code behaviors between adjacent keywords "{" and keywords "}" are defined as target code lines that match the current level variables when detecting the keyword "}", and the serialized code includes all variable names in the target code lines that match the current level values.

8. A vehicle-mounted message transmission method, characterized in that: The method comprises: Compiling the in-vehicle message to be transmitted based on an abstract syntax markup compiler to generate a C language source code header file matching the in-vehicle message to be transmitted, wherein the in-vehicle message to be transmitted is an in-vehicle message generated by an in-vehicle V2X module for interacting with multiple software modules inside the vehicle; Executing the data structure conversion method according to any one of claims 1 to 7 on the C language source code header file of the in-vehicle message to be transmitted, to generate a target data structure file matching the in-vehicle message to be transmitted; Based on the target data structure file, the in-vehicle message to be transmitted is transmitted to a target module among the plurality of software modules in the vehicle.

9. An electronic device, characterized in that: The electronic device comprises: one or more processors; And a memory associated with the one or more processors, the memory is used to store program instructions, and when the program instructions are read and executed by the one or more processors, the method according to any one of claims 1-7 is executed.

10. A computer storage medium, characterized in that: The computer program stores a computer program, wherein the computer program enables a computer to execute the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • C language codec implementation method and system based on TTCN-3 test platform

    CN111176657A

  • Method for automatically generating interface control document through C language data structure code

    CN115686493A

  • Code conversion method and device, equipment, medium and program product

    CN116841559A

  • Code conversion method and device, computer equipment and storage medium

    CN117289949A

  • System representation and handling techniques

    US20090222799A1

Cited By

  • Automatic conversion method for data structure of vehicle communication system and computing equipment

    CN121187596A