File description method and device, electronic equipment and computer storage medium

By dividing the data protocol into protocol header description and protocol body description, and generating file description information, the problems of poor scalability and high maintenance cost in the prior art are solved, dynamic expansion and flexible adaptation of the protocol are achieved, and the scalability and parsing efficiency of the system are improved.

CN120201097APending Publication Date: 2025-06-24PINGHU SPACE PERCEPTION LAB TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510172590.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-17
Publication Date
2025-06-24

AI Technical Summary

Technical Problem

In the data communication and computer technology, it is difficult to achieve dynamic expansion and flexible adaptation of data protocols, resulting in poor scalability, high maintenance costs and insufficient flexibility.

Method used

By dividing the data protocol into a protocol header description and a protocol body description, file description information is generated, dynamic configuration is supported, and parsing logic is automatically generated to achieve the separation of data and protocol.

Benefits of technology

It realizes dynamic expansion and flexible adaptation of the protocol, reduces maintenance costs, and improves the scalability and parsing efficiency of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120201097A_ABST
    Figure CN120201097A_ABST
Patent Text Reader

Abstract

The invention relates to a file description method and device, electronic equipment and a computer storage medium. The method comprises the steps that a to-be-described file and protocol attribute information of a data protocol corresponding to the to-be-described file are acquired; according to the protocol attribute information, protocol header description is generated, and the protocol header description is description information used for describing a data protocol; according to the file to be described, protocol body description is generated, and the protocol body description is description information used for describing data in the file to be described; and generating file description information of the to-be-described file based on the protocol header description and the protocol body description. By means of the method, the data protocol is divided into protocol header description and protocol body description, dynamic configuration is supported, analysis logic can be automatically generated based on the file description information of the file to be described, and separation of data and the protocol is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the fields of data communication and computer technology. Specifically, the present invention relates to a file description method, apparatus, electronic device, and computer storage medium. Background Art

[0002] In the system implementation of the prior art, whether it is for network packets, data files, and other scenarios involving binary data interaction, it is necessary to use a data format protocol to agree on the consistent parsing and understanding of the binary data content by both parties of the interaction. The conventional solution is to sort out all the data formats involved within the system, uniformly formulate specification standards, and require all relevant functions and processes to comply. When the protocol changes or new protocols are added, adaptation can only be achieved through code modification, recompilation, and deployment, resulting in the following problems:

[0003] 1. Poor scalability: Adding new protocols requires a large amount of development resources and it is difficult to quickly respond to business requirements;

[0004] 2. High maintenance cost: Protocol changes require repeated code modification, which is likely to introduce compatibility issues;

[0005] 3. Lack of flexibility: It is unable to dynamically adapt to protocol structures (such as complex forms like nesting and queues).

[0006] For example: In the scenario of Internet of Things device access in the traditional solution, due to the diverse and frequently updated device protocols, the system code needs to be adjusted frequently, seriously affecting the system stability and development efficiency. Summary of the Invention

[0007] The technical problem to be solved by the present invention is to provide a file description method, apparatus, electronic device, and computer storage medium, aiming to solve at least one of the above technical problems.

[0008] In a first aspect, the technical solution of the present invention to solve the above technical problem is as follows: A file description method, the method includes:

[0009] Obtain the file to be described and the protocol attribute information of the data protocol corresponding to the file to be described;

[0010] Generate a protocol header description according to the protocol attribute information, where the protocol header description is description information for describing the data protocol;

[0011] Generate a protocol body description according to the file to be described, where the protocol body description is description information for describing the data in the file to be described;

[0012] Generate the file description information of the file to be described based on the protocol header description and the protocol body description.

[0013] The beneficial effects of the present invention are as follows: The data protocol is divided into a protocol header description and a protocol body description, supporting dynamic configuration. Moreover, based on the file description information of the file to be described, the parsing logic can be automatically generated to achieve the separation of data and the protocol.

[0014] On the basis of the above technical solution, the present invention can be further improved as follows.

[0015] Further, the protocol attribute information includes the data protocol name, data protocol version number, protocol effective time, configuration object, contact information, and element description queue.

[0016] Further, generating the protocol body description according to the file to be described includes:

[0017] Generating a basic element description corresponding to each basic element in the file to be described according to the element attribute information of each basic element in the file to be described. The basic element is the smallest data unit in the file to be described. For each basic element description, the basic element description is the description information for describing the corresponding basic element.

[0018] Generating a combined element description corresponding to each element combination according to each element combination corresponding to all basic elements. The combined element description is the description information for describing the corresponding element combination.

[0019] Generating the protocol body description according to all basic element descriptions and all combined element descriptions.

[0020] Further, for the basic element description corresponding to each basic element, the basic element description includes the basic element body description corresponding to the basic element, and the basic element body description includes a combined element identifier, and the combined element identifier is used to describe whether the basic element is a part of the combined element.

[0021] Further, the method further includes:

[0022] Performing layer-by-layer parsing on the file to be described according to the protocol header description and the protocol body description in the file description information, where the layer-by-layer parsing is to first parse the basic element and then parse the combined element identifier corresponding to the basic element to determine whether the basic element is a part of the combined element.

[0023] Further, performing layer-by-layer parsing on the file to be described according to the protocol header description and the protocol body description in the file description information includes:

[0024] Determining the data protocol corresponding to the file to be described according to the protocol header description.

[0025] Read each basic element from the data in the file to be described into memory according to the data protocol and protocol body description;

[0026] Among them, for the i-th basic element, the following steps are performed for reading:

[0027] S1, if the i-th basic element has not been read, parse the i-th basic element according to the protocol body description;

[0028] S2, if the i-th basic element has been read, based on the combined element identifier in the basic element body description corresponding to the i-th basic element, determine whether the i-th basic element is part of a combined element;

[0029] S3, if it is determined that the i-th basic element is part of a combined element, read other basic elements in the combined element corresponding to the i-th basic element according to the protocol body description;

[0030] S4, if it is determined that the i-th basic element is not part of a combined element, determine whether the (i + 1)-th element has been read.

[0031] Further, the step of, if the i-th basic element has not been read, parsing the i-th basic element according to the protocol body description, further includes:

[0032] If the i-th basic element has not been read, read the basic elements corresponding to the number of element repetitions in the file to be described according to the number of element repetitions in the basic element body description corresponding to the i-th basic element in the protocol body description, where the number of element repetitions represents the number of times the i-th basic element appears in the file to be described.

[0033] In a second aspect, the present invention also provides a file description device to solve the above technical problems. The device includes:

[0034] An acquisition module, configured to acquire a file to be described and protocol attribute information of a data protocol corresponding to the file to be described;

[0035] A protocol header description generation module, configured to generate a protocol header description according to the protocol attribute information, where the protocol header description is description information for describing a data protocol;

[0036] A protocol body description generation module, configured to generate a protocol body description according to the file to be described, where the protocol body description is description information for describing data in the file to be described;

[0037] A file description information generation module, configured to generate file description information of the file to be described based on the protocol header description and the protocol body description.

[0038] In a third aspect, to solve the above technical problems, the present invention also provides an electronic device, which includes a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the file description method of the present application is implemented.

[0039] In a fourth aspect, to solve the above technical problems, the present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the file description method of the present application is implemented.

[0040] Additional aspects and advantages of the present application will be given in part in the following description, which will become apparent from the following description, or can be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] To more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for the description of the embodiments of the present invention.

[0042] Figure 1 A schematic flowchart of a file description method provided by an embodiment of the present invention;

[0043] Figure 2 A schematic diagram of the parsing process of a file to be described provided by an embodiment of the present invention;

[0044] Figure 3 A schematic structural diagram of a file description device provided by an embodiment of the present invention;

[0045] Figure 4 A schematic structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0046] The principles and features of the present invention are described below. The examples given are only used to explain the present invention and are not used to limit the scope of the present invention.

[0047] The technical solutions of the present invention and how the technical solutions of the present invention solve the above technical problems are described in detail below with specific embodiments. These several specific embodiments can be combined with each other. For the same or similar concepts or processes, they may not be repeated in some embodiments. The embodiments of the present invention will be described below with reference to the drawings.

[0048] The solution provided by the embodiments of the present invention can be applicable to any application scenario that requires describing a file to be described. The solution provided by the embodiments of the present invention can be executed by any electronic device. For example, it can be the user's terminal device, including at least one of the following: smart phone, tablet computer, notebook computer, desktop computer, smart speaker, smart watch, smart TV, and smart vehicle-mounted device.

[0049] The embodiments of the present invention provide a possible implementation manner. As Figure 1 shown, a flowchart of a file description method is provided. This solution can be executed by any electronic device. For example, it can be a terminal device, or jointly executed by a terminal device and a server. For the convenience of description, the method provided by the embodiments of the present invention will be described below by taking the terminal device as the execution subject as an example. As Figure 1 shown in the flowchart, the method may include the following steps:

[0050] S10, obtaining the file to be described and the protocol attribute information of the data protocol corresponding to the file to be described;

[0051] S20, generating a protocol header description according to the protocol attribute information, where the protocol header description is description information for describing the data protocol;

[0052] S30, generating a protocol body description according to the file to be described, where the protocol body description is description information for describing the data in the file to be described;

[0053] S40, generating the file description information of the file to be described based on the protocol header description and the protocol body description.

[0054] Through the method of the present invention, the data protocol is divided into a protocol header description and a protocol body description, which supports dynamic configuration. Moreover, based on the file description information of the file to be described, the parsing logic can be automatically generated to realize the separation of data and protocol.

[0055] The solution of the present invention will be further described below in conjunction with the following specific embodiments. In this embodiment, a file description method provided may include the following steps:

[0056] S10, obtaining the file to be described and the protocol attribute information of the data protocol corresponding to the file to be described;

[0057] Among them, the file to be described refers to the file that needs to be described, and the protocol attribute information refers to the information for describing the attributes of the data protocol. Optionally, the protocol attribute information includes the data protocol name, data protocol version number, protocol effective time, configuration object, contact information, and element description queue.

[0058] Among them, different protocol attribute information corresponds to different description information. For a protocol attribute information, the description information corresponding to the protocol attribute information can be information used to describe the requirements that the protocol attribute information needs to meet.

[0059] S20. Generate a protocol header description according to the protocol attribute information, where the protocol header description is description information for describing a data protocol;

[0060] Among them, the protocol header description includes description information corresponding to at least one of a data protocol name, a data protocol version number, a protocol effective time, a configuration object, a contact method, and an element description queue.

[0061] As an example, see the protocol header description shown in Table 1:

[0062] Table 1

[0063]

[0064]

[0065] Among them, each piece of information in the protocol attribute information can correspond to an identifier. For example, the identifier corresponding to the data protocol name is ProtoName, the identifier corresponding to the data protocol version number is Version, the identifier corresponding to the protocol effective time is ValidTime, the identifier corresponding to the configuration object is DefinePer, where the configuration object refers to the executor for processing the text description information this time, which can be a person or a unit, the identifier corresponding to the contact method is Contact, and the identifier corresponding to the element description queue is ProtoBody. The element description queue refers to the manifestation form of basic elements.

[0066] The description information corresponding to each piece of information in the protocol attribute information can be seen in the description part of Table 1. For example, the meaning of the description corresponding to the data protocol name is that the data protocol name can be customized, and the naming requirement for the data protocol name is to be named in English. Some other supplementary description information can be filled in the remarks of Table 1.

[0067] S30. Generate a protocol body description according to the file to be described, where the protocol body description is description information for describing the data in the file to be described;

[0068] Optionally, the above S30 includes:

[0069] S301. Generate a corresponding basic element description for each basic element according to the element attribute information of each basic element in the file to be described. The basic element is the smallest data unit in the file to be described. For each basic element description, the basic element description is description information for describing the corresponding basic element;

[0070] S302. Generate a combined element description corresponding to each element combination corresponding to all basic elements, where the combined element description is description information for describing the corresponding element combination.

[0071] S303. Generate a protocol body description based on all basic element descriptions and all combined element descriptions.

[0072] Among them, the protocol body description includes the description information corresponding to each basic element in the file to be described. For each basic element, the basic element description mainly includes the element name, the number of times the element is repeated, the basic element body, the dimension after the element value is interpreted, the verification rule, and the description information corresponding to the literal description.

[0073] As an example, refer to Figure 2 the basic element description of a basic element shown in

[0074] Table 2

[0075]

[0076] Among them, each piece of information in the element name, the number of times the element is repeated, the basic element body, the dimension after the element value is interpreted, and the verification rule corresponds to an identifier, and can be correspondingly referred to the content in the item column in Table 2. The description information corresponding to each piece of information can be referred to the content in the description column in Table 2. In the solution of this application, there are two types of verification rules. The first is ElIsValid, which indicates whether to verify the corresponding basic element. When ElIsValid = 0, it means not to verify. When ElIsValid is the default value or 1, it means to verify. The second is ElValidValue, which indicates whether to perform a valid value verification on the corresponding basic element. The verification can be performed before dimension processing, and the verification value and length are consistent with the descriptions of ElType and ElbyteLen.

[0077] Optionally, for the basic element description corresponding to each basic element, the basic element description includes a basic element body description corresponding to the basic element, and the basic element body description includes a combined element identifier, where the combined element identifier is used to describe whether the basic element is a part of the combined element.

[0078] Among them, the basic element body description is information for describing the basic attributes of the corresponding basic element, and is used to distinguish other basic elements. Therefore, different basic element bodies can be accurately distinguished based on the basic element body description.

[0079] For a basic element, the description of the basic element body corresponding to the basic element may include description information of at least one type of information, and the at least one type of information may include element data type, byte length of the element, byte storage mechanism, code pattern (original code, one's complement, two's complement corresponding to integer values).

[0080] If all the information in the descriptions of the basic element bodies of two basic elements is the same, it can be indicated that these two basic elements are the same basic element.

[0081] As an example, the description of the basic element body corresponding to a basic element can be as shown in Table 3:

[0082] Table 3

[0083]

[0084] Among them, in Table 3, the identifier corresponding to the element data type is ElType, the identifier corresponding to the byte length of the element is ElByteLen, the identifier corresponding to the byte storage mechanism is ElEndianMode, where LittleEndian = 0 represents the little-endian format, BigEndian = 1 represents the big-endian format, and the identifier corresponding to the code pattern is ElBitForm.

[0085] S40. Based on the protocol header description and the protocol body description, generate the file description information of the file to be described.

[0086] Among them, based on the file description information, the file to be described can be divided into a protocol header description and a protocol body description. Through the protocol header description and the protocol body description, dynamic configuration of the file to be described can be achieved. For example, configure the data protocol name, element name, etc. corresponding to the file to be described, so that new data protocols or changes to the original data protocol can be supported without modifying the code; at the same time, by replacing hard coding with a standardized description file, protocol management is simplified.

[0087] Among them, a combined element refers to an element combination including at least two basic elements. If a combined element includes multiple basic elements, in the combined element, some basic elements can be represented in the form of a queue, and some elements can be represented in a nested form.

[0088] Optionally, in the solution of the present application, any combined element can be divided into an element description queue and an element combination; then the element description queue refers to representing basic elements in the form of a queue, and the element combination refers to representing basic elements in the form of a queue or a nested form.

[0089] The description corresponding to the element description queue is the element queue description, which refers to organizing and explaining the basic element descriptions of basic elements in the form of a queue, such as [element description 1, element description 2...] to form an element queue; among them, element description 1 refers to the basic element description corresponding to basic element 1, and element description 2 refers to the basic element description corresponding to basic element 2. The description corresponding to the element combination is the combined element description, which refers to organizing and explaining the basic element descriptions of basic elements in the form of a queue or nesting, and supports complex structures (such as message header + payload).

[0090] As an example, the combined element description can be seen in Table 4 as follows:

[0091] Table 4

[0092]

[0093] Among them, the combined element description is the description information used to describe the combined element, including information such as the combined body name, repetition times, combined element body, etc. The identifiers corresponding to each piece of information can be seen in the content of the item column in Table 4. Among them, the three items of dimension, whether to verify, and verification value are invalid.

[0094] If the ElBody content of a basic element contains the basic elements or element description queues of other basic elements, a combined element is formed.

[0095] Optionally, the method further includes:

[0096] According to the protocol header description and protocol body description in the file description information, perform layer-by-layer parsing on the file to be described, where layer-by-layer parsing is to first parse the basic element and then parse the combined element identifier corresponding to the basic element to determine whether the basic element is a part of the combined element. Based on the above parsing logic, the data in the file to be described can be parsed.

[0097] Further, the performing layer-by-layer parsing on the file to be described according to the protocol header description and protocol body description in the file description information includes:

[0098] According to the protocol header description, determine the data protocol corresponding to the file to be described; specifically, it can be determined based on the data protocol name in the protocol header description.

[0099] According to the data protocol and protocol body description, read each basic element from the data in the file to be described into memory;

[0100] Among them, for the i-th basic element, the following steps are performed for reading, where i is an integer not less than 1 and less than the total number of all basic elements included in the text to be described:

[0101] S1, if the i-th basic element has not been read, the i-th basic element can be parsed according to the protocol body description to obtain the i-th basic element; specifically, the i-th basic element can be parsed based on the basic element description corresponding to the i-th basic element in the protocol body description.

[0102] S2, if the i-th basic element has been read, judging whether the i-th basic element is a part of a combined element based on the combined element identifier in the basic element body description corresponding to the i-th basic element;

[0103] S3. If it is determined that the i-th basic element is part of a combined element, then according to the protocol body description, other basic elements in the combined element corresponding to the i-th basic element are read; if the i-th basic element has been read, then other basic elements in the combined element corresponding to the i-th basic element can be further read into the memory based on the combined element identifier in the basic element body description corresponding to the i-th basic element.

[0104] S4: If it is determined that the i-th basic element is not a part of the combined element, it is determined whether the i+1-th element has been read.

[0105] Furthermore, if the i-th basic element is not read, parsing the i-th basic element according to the protocol body description further includes:

[0106] If the i-th basic element is not read, read the basic element corresponding to the number of element repetitions in the file to be described according to the number of element repetitions in the basic element body description corresponding to the i-th basic element in the protocol body description, wherein the number of element repetitions represents the number of times the i-th basic element appears in the file to be described.

[0107] In the process of reading the i-th basic element, the basic element identical to the i-th basic element may also be read simultaneously.

[0108] In order to better illustrate and understand the principle of the method provided by the present invention, the scheme of the present invention is described below in conjunction with an optional specific embodiment. It should be noted that the specific implementation of each step in the specific embodiment should not be understood as a limitation to the scheme of the present invention. On the basis of the principle of the scheme provided by the present invention, other implementations that can be thought of by those skilled in the art should also be considered within the scope of protection of the present invention.

[0109] In this embodiment, the overall process of dynamic analysis is as follows:

[0110] 1. Load the protocol description file (JSON format);

[0111] 2. Parse the binary data layer by layer according to the protocol body and recursively process the combined elements;

[0112] 3. Apply dimension conversion and verification rules to output structured data.

[0113] In this embodiment, refer to Figure 2 the flow diagram of parsing the file to be described as shown, and the specific parsing process may include the following steps:

[0114] 1. Define the description protocol corresponding to the data, that is, based on the protocol header description corresponding to the file to be described, determine the data protocol of the file to be described. The file to be described can be a message, and the data protocol description is in Json format;

[0115] 2. Read the data into memory, that is, according to the data protocol and the protocol body description corresponding to the file to be described, read the basic elements in the file to be described into memory;

[0116] 3. Parse the i-th element of the protocol body to obtain the description (if there is nesting, iterate). That is, for the i-th basic element, based on the basic element description corresponding to the i-th basic element, obtain the basic element body description corresponding to the i-th basic element. If, based on the combined element identifier in the basic element body description corresponding to the i-th basic element, it is determined that the i-th basic element is part of a combined element, then other basic elements in the combined element corresponding to the i-th basic element can be read into memory. If it is determined that the i-th basic element is not part of a combined element, then execute the next step:

[0117] 4. Determine whether the traversal of the element queue in the protocol body has been completed, that is, determine whether the i-th basic element is the last unread basic element in the file to be described. If so, end. If not, then execute the next step;

[0118] 5. Obtain the data length (byte length of the element) and parsing type (element data type) corresponding to the i-th basic element;

[0119] 6. Process the repetition times, default is 1. If the ElName (element name) in the RepList is matched, then repeat according to the specified times (ElRepCtl). That is, if the i-th basic element has not been read, read a basic element with the same element name as the i-th basic element in the file to be described, and at this time the repetition times + 1;

[0120] 7. Determine whether the requirement of the repetition times is met, that is, determine whether the repetition times of the read basic element (the basic element with the same name as the i-th basic element) (the repetition times corresponding after executing step 6) reaches the element repetition times corresponding to the i-th basic element;

[0121] 8. If it is achieved, repeat the above steps 3 to 7 to read the (i + 1)-th basic element until all basic elements in the file to be described are read; if not, execute the next step;

[0122] 9. The data read into the memory is parsed according to the element type and length, that is, for the basic elements already read into the memory (including the i-th basic element and a basic element identical to the i-th basic element), they are parsed according to the element data type and the byte length of the element corresponding to each basic element;

[0123] 10. Determine whether it is a repeated control quantity, that is, whether ElRepCtl is empty, and determine whether the current number of repetitions is the number of repetitions of the element corresponding to the i-th basic element, that is, determine whether there are other basic elements identical to the i-th basic element. If so, record the repeated element name ElName into the repetition queue RepList; then parse the element body, record the number of repetitions, and update the number of repetitions of the corresponding ElName in RepList, thereby completing the parsing of the i-th basic element; if not, execute the next step;

[0124] 11. Parse the element body (element body description), according to the code pattern, endianness, dimension, etc., to obtain all basic elements identical to the i-th basic element, thereby completing the parsing of the i-th basic element, return to step 7 until the requirement for the number of repetitions is reached, and return to step 3 to read the (i + 1)-th basic element.

[0125] In this embodiment, it is presented in Json format as follows:

[0126] Table 5

[0127]

[0128]

[0129] Through the solution of the present invention, compared with the prior art, there are the following beneficial effects:

[0130] 1. High scalability: The protocol is dynamically extended through the protocol description file without code modification;

[0131] 2. Convenient maintenance: The protocol change only requires updating the description file, avoiding system redeployment;

[0132] 3. Flexible adaptation: Support complex structures such as nesting and queues to meet diverse protocol requirements;

[0133] 4. Efficient parsing: The dynamic engine automatically adapts to the protocol, improving the data processing efficiency.

[0134] Based on and Figure 1Based on the same principle as the method shown in Figure 3 As shown in , the file description device 20 may include an acquisition module 210, a protocol header description generation module 220, a protocol body description generation module 230, and a file description information generation module 240, where:

[0135] The acquisition module 210 is configured to acquire the file to be described and the protocol attribute information of the data protocol corresponding to the file to be described;

[0136] The protocol header description generation module 220 is configured to generate a protocol header description according to the protocol attribute information, where the protocol header description is description information for describing the data protocol;

[0137] The protocol body description generation module 230 is configured to generate a protocol body description according to the file to be described, where the protocol body description is description information for describing the data in the file to be described;

[0138] The file description information generation module 240 is configured to generate the file description information of the file to be described based on the protocol header description and the protocol body description.

[0139] Optionally, the protocol attribute information includes a data protocol name, a data protocol version number, a protocol effective time, a configuration object, a contact method, and an element description queue.

[0140] Optionally, when the protocol body description generation module 230 generates a protocol body description according to the file to be described, it is specifically configured to:

[0141] Generate a basic element description corresponding to each basic element in the file to be described according to the element attribute information of each basic element in the file to be described, where the basic element is the smallest data unit in the file to be described, and for each basic element description, the basic element description is description information for describing the corresponding basic element;

[0142] Generate a combined element description corresponding to each element combination according to each element combination corresponding to all basic elements, where the combined element description is description information for describing the corresponding element combination;

[0143] Generate a protocol body description according to all basic element descriptions and all combined element descriptions.

[0144] Optionally, for the basic element description corresponding to each basic element, the basic element description includes a basic element body description corresponding to the basic element, and the basic element body description includes a combined element identifier, where the combined element identifier is used to describe whether the basic element is a part of the combined element.

[0145] Optionally, the device further includes:

[0146] A layer-by-layer parsing module, configured to perform layer-by-layer parsing on the file to be described according to the protocol header description and protocol body description in the file description information, where the layer-by-layer parsing is to first parse the basic elements and then parse the combined element identifier corresponding to the basic element to determine whether the basic element is a part of the combined element.

[0147] Optionally, when performing layer-by-layer parsing on the file to be described according to the protocol header description and protocol body description in the file description information, the layer-by-layer parsing module is specifically configured to:

[0148] Determine the data protocol corresponding to the file to be described according to the protocol header description;

[0149] Read each basic element from the data in the file to be described into the memory according to the data protocol and protocol body description;

[0150] Wherein, for the i-th basic element, the parsing module reads it by performing the following steps:

[0151] S1. If the i-th basic element has not been read, parse the i-th basic element according to the protocol body description;

[0152] S2. If the i-th basic element has been read, determine whether the i-th basic element is a part of the combined element based on the combined element identifier in the basic element body description corresponding to the i-th basic element;

[0153] S3. If it is determined that the i-th basic element is a part of the combined element, read the other basic elements in the combined element corresponding to the i-th basic element according to the protocol body description;

[0154] S4. If it is determined that the i-th basic element is not a part of the combined element, determine whether the (i + 1)-th element has been read.

[0155] Optionally, it further includes a repeated reading module, configured to, when the i-th basic element has not been read, read the basic elements corresponding to the number of repetitions of the element in the file to be described according to the number of repetitions of the element in the basic element body description corresponding to the i-th basic element in the protocol body description, where the number of repetitions of the element represents the number of times the i-th basic element appears in the file to be described.

[0156] The file description device according to an embodiment of the present invention can execute the file description method provided by the embodiment of the present invention, and its implementation principle is similar. The actions performed by each module and unit in the file description device in each embodiment of the present invention correspond to the steps in the file description method in each embodiment of the present invention. For the detailed function description of each module of the file description device, reference can be specifically made to the description in the corresponding file description method shown above, and details are not described herein again.

[0157] Among them, the above file description device can be a computer program (including program code) running in a computer device. For example, the file description device is an application software; the device can be used to execute the corresponding steps in the method provided by the embodiment of the present invention.

[0158] In some embodiments, the file description device provided by the embodiment of the present invention can be implemented in a combination of software and hardware. As an example, the file description device provided by the embodiment of the present invention can be a processor in the form of a hardware decoding processor, which is programmed to execute the file description method provided by the embodiment of the present invention. For example, the processor in the form of a hardware decoding processor can adopt one or more application specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field programmable gate arrays (FPGAs) or other electronic components.

[0159] In other embodiments, the file description device provided by the embodiment of the present invention can be implemented in software. Figure 3 The file description device stored in the memory is shown, which can be software in the form of a program and a plug-in, etc., and includes a series of modules, including an acquisition module 210, a protocol header description generation module 220, a protocol body description generation module 230, and a file description information generation module 240, for implementing the file description method provided by the embodiment of the present invention.

[0160] The modules involved in the embodiments of the present invention can be implemented in software or in hardware. Among them, the name of the module does not constitute a limitation to the module itself in some cases.

[0161] Based on the same principle as the method shown in the embodiments of the present invention, embodiments of the present invention also provide an electronic device, which may include but is not limited to: a processor and a memory; the memory is used to store a computer program; the processor is used to execute the method shown in any embodiment of the present invention by calling the computer program.

[0162] In an alternative embodiment, an electronic device is provided, as Figure 4 shown Figure 4 The electronic device 4000 shown includes: a processor 4001 and a memory 4003. Among them, the processor 4001 and the memory 4003 are connected, such as connected through a bus 4002. Optionally, the electronic device 4000 may further include a transceiver 4004, and the transceiver 4004 may be used for data interaction between this electronic device and other electronic devices, such as data sending and / or data receiving, etc. It should be noted that in actual applications, the transceiver 4004 is not limited to one, and the structure of the electronic device 4000 does not constitute a limitation to the embodiments of the present invention.

[0163] The processor 4001 may be a CPU (Central Processing Unit, central processor), a general-purpose processor, a DSP (Digital Signal Processor, data signal processor), an ASIC (Application Specific Integrated Circuit, application-specific integrated circuit), an FPGA (Field Programmable Gate Array, field programmable gate array) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It can implement or execute various exemplary logic blocks, modules and circuits described in connection with the disclosure of the present invention. The processor 4001 may also be a combination that implements computing functions, such as a combination including one or more microprocessors, a combination of a DSP and a microprocessor, etc.

[0164] The bus 4002 may include a path for transmitting information between the above components. The bus 4002 may be a PCI (Peripheral Component Interconnect, peripheral component interconnect standard) bus or an EISA (Extended Industry Standard Architecture, extended industry standard structure) bus, etc. The bus 4002 may be divided into an address bus, a data bus, a control bus, etc. For the sake of representation, Figure 4 only a thick line is used to represent it in the figure, but it does not mean that there is only one bus or one type of bus.

[0165] The memory 4003 can be a ROM (Read Only Memory), or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory), or other types of dynamic storage devices that can store information and instructions. It can also be an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory), or other optical disc storage, optical disc storage (including compact discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.), magnetic disk storage media, or other magnetic storage devices, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto.

[0166] The memory 4003 is used to store the application program code (computer program) for implementing the solution of the present invention and is controlled by the processor 4001 for execution. The processor 4001 is used to execute the application program code stored in the memory 4003 to implement the content shown in the foregoing method embodiments.

[0167] Among them, the electronic device can also be a terminal device. Figure 4 The electronic device shown is only an example and should not impose any limitations on the functions and usage scope of the embodiments of the present invention.

[0168] The embodiments of the present invention provide a computer-readable storage medium on which a computer program is stored. When it runs on a computer, it enables the computer to execute the corresponding content in the foregoing method embodiments.

[0169] According to another aspect of the present invention, there is also provided a computer program product or a computer program. The computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, enabling the computer device to execute the methods provided in the above various implementation manners of the embodiments.

[0170] Computer program code for performing the operations of the present invention may be written in one or more programming languages or combinations thereof. The programming languages include object-oriented programming languages such as Java, Smalltalk, C++, and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, executed as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., connected through the Internet using an Internet service provider).

[0171] It should be understood that the flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code that contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and the combination of blocks in the block diagram and / or flowchart, may be implemented by a dedicated hardware-based system for performing the specified functions or operations, or may be implemented by a combination of dedicated hardware and computer instructions.

[0172] The computer-readable storage medium provided by the embodiments of the present invention may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, the computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0173] The above computer-readable storage medium stores one or more programs, which, when executed by the electronic device, cause the electronic device to perform the method shown in the above embodiments.

[0174] The above description is only a preferred embodiment of the present invention and an explanation of the applied technical principles. Those skilled in the art should understand that the scope of disclosure involved in the present invention is not limited to the technical solutions formed by the specific combination of the above technical features, but also covers other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosure concept. For example, the technical solutions formed by mutually replacing the above features with the technical features (but not limited to) having similar functions disclosed in the present invention.

Claims

1. A file description method, characterized in that: The following steps are involved: Acquire a file to be described and protocol attribute information of a data protocol corresponding to the file to be described; Generate a protocol header description according to the protocol attribute information, wherein the protocol header description is description information used to describe the data protocol; Generate a protocol body description according to the file to be described, wherein the protocol body description is description information used to describe the data in the file to be described; Based on the protocol header description and the protocol body description, file description information of the file to be described is generated.

2. The method according to claim 1, characterized in that The protocol attribute information includes a data protocol name, a data protocol version number, a protocol effective time, a configuration object, a contact method, and an element description queue.

3. The method according to claim 1, characterized in that The step of generating a protocol body description according to the file to be described includes: Generate a basic element description corresponding to each basic element according to the element attribute information of each basic element in the file to be described, wherein the basic element is the smallest data unit in the file to be described, and for each basic element description, the basic element description is description information for describing the corresponding basic element; Generate, according to each element combination corresponding to all basic elements, a combination element description corresponding to each element combination, wherein the combination element description is description information used to describe the corresponding element combination; Generate a protocol body description based on all basic element descriptions and all combined element descriptions.

4. The method according to claim 3, characterized in that For the basic element description corresponding to each basic element, the basic element description includes the basic element body description corresponding to the basic element, and the basic element body description includes a combined element identifier, and the combined element identifier is used to describe whether the basic element is a part of the combined element.

5. The method according to claim 4, characterized in that The method further comprises: According to the protocol header description and the protocol body description in the file description information, the file to be described is parsed layer by layer, wherein the layer by layer parsing is first parsing the basic element and then parsing the combined element identifier corresponding to the basic element to determine whether the basic element is a part of the combined element.

6. The method according to claim 5, characterized in that The step of parsing the file to be described layer by layer according to the protocol header description and the protocol body description in the file description information includes: Determine the data protocol corresponding to the file to be described according to the protocol header description; According to the data protocol and the protocol body description, read each basic element from the data in the file to be described into the memory; For the i-th basic element, the following steps are performed to read: S1, if the i-th basic element has not been read, parse and obtain the i-th basic element according to the protocol body description; S2, if the i-th basic element has been read, judging whether the i-th basic element is a part of a combined element based on the combined element identifier in the basic element body description corresponding to the i-th basic element; S3, if it is determined that the i-th basic element is part of a composite element, then read other basic elements in the composite element corresponding to the i-th basic element according to the protocol body description; S4: If it is determined that the i-th basic element is not a part of the combined element, it is determined whether the i+1-th element has been read.

7. The method according to claim 6, characterized in that If the i-th basic element is not read, the i-th basic element is parsed according to the protocol body description, and further includes: If the i-th basic element is not read, read the basic element corresponding to the number of element repetitions in the file to be described according to the number of element repetitions in the basic element body description corresponding to the i-th basic element in the protocol body description, wherein the number of element repetitions represents the number of times the i-th basic element appears in the file to be described.

8. A file description device, characterized in that: include: An acquisition module, used to acquire the file to be described and the protocol attribute information of the data protocol corresponding to the file to be described; A protocol header description generating module, used to generate a protocol header description according to the protocol attribute information, wherein the protocol header description is description information used to describe the data protocol; A protocol body description generating module, used to generate a protocol body description according to the file to be described, wherein the protocol body description is description information used to describe the data in the file to be described; The file description information generating module is used to generate the file description information of the file to be described based on the protocol header description and the protocol body description.

9. An electronic device, characterized in that: The method comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.