XML serialization and deserialization implementation method based on Qt meta object technology

By using an XML serialization and deserialization method based on Qt meta-object technology, the problem of attributes and Chinese character naming in the Qt framework's XML nodes is solved, achieving an intuitive representation of the XML document structure and simplifying the code, thus improving maintainability and efficiency.

CN121364852APending Publication Date: 2026-01-20713TH RES INST OF CHINA STATE SHIPBUILDING CORP LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511532745.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-24
Publication Date
2026-01-20

AI Technical Summary

Technical Problem

The existing Qt framework cannot support scenarios where XML nodes contain attributes during XML serialization and deserialization. Furthermore, Chinese characters in the naming cause the compiler to fail to compile the code, and the framework lacks intuitiveness and maintainability.

Method used

This paper adopts an XML serialization and deserialization method based on Qt meta-object technology. By defining the basic data structure describing XML nodes, macro functions are used to simplify node definitions and generate an intuitive XML document structure. The relationships between nodes are represented by class inheritance and aggregation. Combined with Qt's metadata and reflection technology, automated data reading and writing are achieved.

Benefits of technology

It provides an intuitive representation of the XML document structure and simplifies code input, improving code maintainability and readability. It supports Chinese character naming, simplifies the need for custom XML node names, and improves the efficiency of serialization and deserialization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121364852A_ABST
    Figure CN121364852A_ABST
Patent Text Reader

Abstract

The invention discloses an XML (Extensible Markup Language) serialization and deserialization implementation method based on a Qt meta-object technology. The method comprises the following steps of: defining a basic data structure for describing an xml (Extensible Markup Language) node; the method comprises the following steps: defining an XML document structure needing to be serialized and deserialized into a class; declaring data items needing to be serialized and deserialized through attribute definition macros provided by Qt to ensure that relevant information is added into the meta-object system of the class; wherein the basic data structure should comprise an XML (Extensible Markup Language) document structure initialization process; generating an XML document structure according to XML node types represented by the attributes and association relationships among the attributes, filling attribute values contained in the class instances into the XML document structure, and generating an XML data stream; reading the XML data stream, searching the value of the specific node name in the XML data stream according to the document structure, filling the value into the attribute corresponding to the node name, and simplifying the definition of the XML file structure.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the field of software development and algorithm technology, and particularly relates to an XML serialization and deserialization implementation method based on Qt meta-object technology. BACKGROUND

[0002] In the object-oriented programming mode, data is defined in a multi-dimensional manner, that is, a specific variable is defined, and the simplest way needs to explicitly define the class in which the variable is located and the name of the variable in the class. At the same time, the transmission and storage requirements of data require the data to be a one-dimensional data stream. In order to solve the requirement of dimensionality reduction and dimensionality increase of data in the process of data representation, transmission and storage, object serialization technology is generated.

[0003] Due to the wide use of object serialization technology, many computer languages provide support for the function of object serialization through standard libraries at the language level. C++ language itself does not provide the function of object serialization in the standard library, and if object serialization needs to be implemented using C++ language, the developer can only design it himself or use a third-party library.

[0004] Qt framework can inject other information (such as: variable name, string representation of variable corresponding type, etc.) in addition to data type in the class or specific variable contained in the class through its meta-data and reflection function based on macro definition extension, and can dynamically read and implicitly call the read-write access function of the attribute through the reflection mechanism to read or write the value of the attribute.

[0005] The serialization and deserialization of classes in XML mode using Qt framework can be implemented by the above-mentioned method, for example, the open source QSerializer framework maps an XML composite node into a class based on QObject, the internal nodes of the XML composite node are mapped into specific type attributes contained in the above-mentioned subclass with QObject as the parent class, in the serialization, the definition name of the class and the value of the related attribute are read through reflection to complete the serialization operation; in the deserialization, after reading the XML file, the name of the attribute contained in the class is read through reflection and the corresponding value is found in the XML file, and the found value is written into the corresponding attribute through reflection to complete the related deserialization operation.

[0006] The framework has the following problems: the XML expression is simple, only supports the containing relationship between XML nodes and XML nodes, and does not support the scene requirement of containing attributes in XML nodes; the node name is the class name or the attribute name by default, if Chinese characters appear in the XML node, the class name and attribute name definition of the related code need to be named using Chinese characters, which leads to the fact that most of the current compilers cannot compile the related code. SUMMARY

[0007] To solve the above technical problems, the application provides an XML serialization and deserialization implementation method based on Qt meta-object technology, and the code generated by the method has intuitive XML document structure expression, strong readability, easy maintenance and simple use.

[0008] The specific scheme is as follows: The XML serialization and deserialization implementation method based on Qt meta-object technology comprises the following steps: S1) defining a basic data structure for describing an xml node; the basic data structure comprises a node type, a node alias, a node value, a set of attributes and leaf nodes contained by the node, a set of subsequent nodes of the node, and metadata information generated in the instantiation process of the node type, and the node type comprises two types: one is a leaf node, and the other is a block node; S2) defining an XML document structure to be serialized and deserialized into a class, and the data items to be serialized and deserialized in the class are inherited from the basic data structure in S1) or directly defined by using the basic data structure in S1), and are aggregated into the class, and the class itself also takes the basic data structure in S1) as a base class; S3) declaring the data items to be serialized and deserialized by using a property definition macro provided by Qt, so as to ensure that the related information of the data items is added to the meta-object system of the class; S4) including an XML document structure initialization process in the basic data structure in S1), generating an XML document structure by reading class structure information, and establishing an association relationship between the meta-object data of the attribute and the attribute; S5) performing serialization according to the basic data structure in S1), that is, generating an XML document structure according to the XML node type represented by the attribute and the association relationship between the attributes, filling the values of the attributes in S3) contained by the class instance into the XML document structure, and generating an XML data stream; S6) performing deserialization according to the basic data structure in S1), that is, reading an XML data stream, finding the value of a node with a specific name in the XML data stream according to the document structure, and filling the value into the attribute in S3) corresponding to the node name.

[0009] In S1), the node alias represents the name of the node that needs to be shown to the user when the node is generated; the node type represents the type of the XML document node corresponding to the node; the leaf node represents the bottom layer node of the XML and is directly expressed by the basic data structure of S1); the block node represents a node containing other nodes in the XML structure, is a derived class of the basic data structure of S1), and other XML nodes in the block are defined by aggregating the base class or the derived class of the base class on the basis of directly using or inheriting the base class.

[0010] In the attribute definition process in S3), the macro function and other pre-compilation technologies are used to simplify the node definition form, thereby reducing the code input amount and improving the compliance and intuitiveness of the code expression.

[0011] The basic data structure in S4) should include an XML document structure initialization method, including the following steps: S41): reading the metadata information of the class; S42): reading the content contained by the attribute declared in step S3) through the metadata information of the class, and storing the attribute according to the node type information contained in the attribute as 'xml attribute', 'xml node', and 'xml block'; S43): establishing the association relationship between the meta-object data of the attribute and the attribute, which is used for subsequent automatic reading or writing of the attribute value; S44): reading the variable information of the block node contained in the class, the base class of the variable is the basic data structure of S1), and the above steps S41), S42), and S43) are repeatedly called on the block node, so as to construct the attributes and the association relationship between the attributes in the block node that need to be serialized and deserialized, and construct the association relationship between the defined block variable attribute and the corresponding meta-object data.

[0012] In S5), the specific steps of serialization according to the basic data structure in S1) include, S51): reading the node type, node alias, and node value of the instance to be serialized, and generating the corresponding XML node as the parent node according to the node type and the node alias and value; S52): traversing the attribute set representing the XML node and the association relationship between the attributes extracted from the instance to be serialized by step S4); S53): for each attribute representing the XML node contained in the instance in S51), the following operations are performed according to the type of the attribute: For the leaf node and the attribute node, the following steps are included: a1) read the node type, the alias of the node and the value of the current node, generate an XML leaf node or an XML attribute node according to the node type definition; a2) according to the node type, add the generated XML node as an XML leaf node or an XML attribute to the node generated in step S51); For the block node, the subsequent node of the current node: Repeat the above steps S51), S52), S53) and a1) and a2) in S53) to complete the construction of the XML document; S54) The XML document corresponding to the class can be constructed through the above steps, and the output result of the serialization operation of the document is the XML serialization result of the data class instance.

[0013] According to the basic data structure in S1), the specific steps of deserialization include, S61) read the current data stream to be deserialized; S62) create an XML document and import the data stream to be serialized into the XML document. If there is no error, it means that the data stream itself is a legal structure XML data framework, otherwise give a prompt to exit the deserialization operation; S63) read all the child node sets corresponding to the current XML node, and create the deserialization target class instance corresponding to the XML document. Read the attribute set and the association between attributes generated by the target class through S4) to represent the XML structure of each node; S64) traverse the XML child node set to obtain the node name, and find the corresponding attribute in the attribute set generated in S4) according to the name. If the attribute exists, the following operations are performed according to the node type described in the attribute: For leaf nodes and attribute nodes: b1) read the value in the corresponding XML node; b2) through the attribute and the metadata information corresponding to the attribute, use the reflection method to automatically write the value of the XML node into the class member variable corresponding to the attribute, complete the assignment of the XML node value to the attribute variable corresponding to the class instance; For block nodes: Repeat the above steps S63), S64, and b1), b2) to complete the extraction of data from the XML document and write the data into the attributes contained in the corresponding class instance, and complete the deserialization operation of the data.

[0014] The beneficial effects of the present application are: the belonging relationship (precedence relationship and containing relationship) between nodes in an XML document is directly expressed by class inheritance and aggregation relationship, and the XML document structure is further expressed; the code of node definition and description is simplified by using macro function and other pre-compilation technologies, so that the expression mode is intuitive, the code and the XML structure are convenient to check, and the maintainability of the code is improved.

[0015] By using the metadata and reflection technology of Qt, automatic searching and reading of the member variable value of the XML document node corresponding to the entity class are realized in the serialization process, and the automatic setting of the value to the XML document node; in the deserialization process, automatic searching and assignment of the value from the XML document node to the corresponding attribute member of the entity class are realized, and the operation is simple.

[0016] The present application also solves the demand of customizing the XML node name, embeds the node name information in the corresponding node variable code and allows it to be Chinese characters, reduces the types and quantity of external configuration data of the program, and the whole framework can better meet the parsing demand of the XML document structure containing Chinese names.

[0017] Meanwhile, by using the meta-object technology combined with the object-oriented overload technology, the concepts such as object warehouse, template object and serialization manager are not needed in the present application; the macro function is used to simplify the definition of the XML file structure, and the consistency of the serializable C++ class definition expression and the XML document structure is improved. BRIEF DESCRIPTION OF DRAWINGS

[0018] Figure 1 is the association diagram between class structure initialization and generated data.

[0019] Figure 2 is the serialization process diagram.

[0020] Figure 3 is the deserialization process diagram.

[0021] Figure 4 is the XML node basic data definition table.

[0022] Figure 5 node type declaration and expansion result example diagram.

[0023] Figure 6 XML document structure initialization flowchart.

[0024] Figure 7 is the XML document structure diagram to be serialized.

[0025] Figure 8 is the document class of XML document block xml_block_base and its structure initialization function definition diagram.

[0026] Figure 9 This is a diagram of the document class and its structure initialization function definition for the XML document block xml_block_merge.

[0027] Figure 10 This is a diagram showing the document class of the XML document block xml_root and its structure initialization function definition.

[0028] Figure 11 This is a diagram illustrating the XML serialization result. Detailed Implementation

[0029] The technical solutions in the embodiments of the present invention will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the implementation of the present invention, and not all of it. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.

[0030] The implementation method of XML serialization and deserialization based on Qt meta-object technology includes the following steps: S1): Define the basic data structure describing the XML node; the basic data structure includes node type, node alias, node value, attributes contained in the node and leaf node set, subsequent node set of the node and metadata information generated during the instantiation of node type. The node type includes two types: one is leaf node and the other is block node. S2): Define the XML document structure that needs to be serialized and deserialized as a class. The data items that need to be serialized and deserialized in the class are all inherited from or directly defined using the basic data structure described in S1), and are aggregated into the class. At the same time, the class itself also uses the basic data structure described in S1 as its base class. S3): Declare the data items that need to be serialized and deserialized using the property definition macros provided by Qt to ensure that the information of the data items is added to the meta-object system of the class; S4): The basic data structure described in S1) should include an XML document structure initialization process. This involves reading class structure information to generate the XML document structure, and simultaneously generating the meta-object data of the attributes and the association relationships between those attributes; for example... Figure 1 ; S5): Serialization is performed based on the basic data structure described in S1), that is, an XML document structure is generated according to the XML node type represented by the attributes and the association between attributes. The values ​​of the attributes described in S3) contained in the class instance are filled into the XML document structure and an XML data stream is generated; for example... Figure 2 ; S6): Deserialize according to the basic data structure described in S1), that is, read the XML data stream, find the value of a specific name node in the XML data stream according to the document structure, and fill the value into the attribute described in S3) corresponding to the node name.

[0031] In S1), the node alias represents the name of the node that needs to be shown to the user when the node is generated; the node type represents the type of the XML document node corresponding to the node; the leaf node represents the lowest level node of the XML, which is directly represented by the basic data structure described in S1); the block node represents a node that contains other nodes in the XML structure, which is a derived class of the basic data structure described in S1 as the base class, and the other XML nodes in the block are defined by aggregating the base class or the derived class of the base class based on directly using and inheriting the base class.

[0032] In the attribute definition process of S3, pre-compilation techniques such as macro functions are used to simplify the node definition form, which simplifies the amount of code input while improving the conformity and intuitiveness of code expression.

[0033] The basic data structure described in S4 should include a method for initializing the XML document structure, including the following steps: S41): Read the metadata information of the class; S42): Using the metadata information of the class, read the content contained in the attributes declared in step S3), and classify and store the attributes according to the node type information contained in the attributes as 'xml attribute', 'xml node', and 'xml block'. S43): Establish the association between the meta-object data of the attribute and the attribute, for subsequent automatic reading or writing of the attribute value; S44): Read the variable information of the block node contained in the class. The base class of the variable is the basic data structure described in S1). Repeatedly call the above steps S41), S42), and S43) on the block node to construct the attributes in the block node that need to be serialized and deserialized, as well as the relationship between the attributes, and construct the relationship between the defined block variable attributes and their corresponding meta-object data.

[0034] like Figure 2 As shown in S5), the specific steps for serialization based on the basic data structure described in S1) include: S51): Read the node type, alias, and value of the instance to be serialized, and generate the corresponding XML node as the parent node based on the node type, alias, and value. S52) : traversing the property set and the association between properties of the representative XML node extracted by step S4) for the instance to be serialized; S53) : for each property of the representative XML node contained in the instance in S51), the following operations are performed respectively according to whether the property is a leaf node, an attribute node or a block node: For the leaf node and the attribute node, the following steps are included: a1) reading the node type, the alias of the node and the value of the current node, and generating an XML leaf node or an XML attribute node conforming to the definition of the node type; a2) according to the node type, the generated XML node is added to the node generated in step S51) as an XML leaf node or an XML attribute; For the block node, i.e. the subsequent node of the current node: The above steps S51), S52), S53) and a1) and a2) in S53) are repeatedly called to complete the construction of the XML document; S54) : through the above steps, the XML document corresponding to the class can be constructed, and through the serialization operation of the document, the output result is the XML serialization result of the data class instance.

[0035] According to the basic data structure in S1), the specific steps for deserialization include, As Figure 3 S61) : reading the current data stream to be deserialized; S62) : creating an XML document and importing the data stream to be serialized into the XML document, if there is no error, it means that the data stream itself is a legal structure XML data framework, otherwise, a prompt is given to exit the deserialization operation; S63) : reading all the child node sets corresponding to the current XML node, creating a deserialization target class instance corresponding to the XML document, and reading the property set and the association between properties of each node in the XML structure generated by S4) ; S64) : traversing the XML child node set, obtaining the node name, and searching for the corresponding property in the property set generated in S4) according to the node name, if the property exists, the following operations are performed respectively according to the node type described in the property: For the leaf node and the attribute node: b1) : reading the value in the XML node corresponding thereto; b2) : through the property and the metadata information corresponding to the property, the value of the XML node is automatically written into the class member variable corresponding to the property in a reflective manner, completing the assignment of the XML node value to the property corresponding to the class instance; For the block node: Repeat steps S63), S64, and b1) and b2) above to extract data from the XML document and write the data into the properties contained in the corresponding class instance, thus completing the data deserialization operation.

[0036] The following is a specific implementation based on the above ideas, using Qt 5.12 and the MSVC 2015 compiler. In this implementation, three types of nodes are defined according to the differences in XML node parsing methods: Attribute nodes, leaf nodes, and XML data blocks; The declaration is defined as: enumxml_node_type { block, leaf_element, attribute}; in, An XML data block is itself an XML node, but this node contains attribute nodes or (and) leaf nodes, identified by 'block'. A leaf node represents a data item in XML that has no subsequent nodes and is identified by 'leaf_element'. Attribute nodes represent the attributes of a node in XML, and are identified by the 'attribute' keyword.

[0037] The DOM framework provided by Qt is used as the carrier for XML serialization and deserialization. The DOM reads the entire XML document at once and constructs it into a tree in memory, which is called the DOM tree. Representing the XML file as a tree facilitates random access to nodes within it.

[0038] 1. Define the basic XML node data. In this embodiment, the basic XML node data definition is named QXmlNode. Its related public and inheritable member variables and functions are defined and described as follows: Figure 4 As shown: Define the basic data structure of the XML node, which corresponds to... Figure 4 middle, Node type, which indicates the type of node in the XML document, corresponding to the variable 'm_xml_node_type'; The node alias represents the name that the user should see when the node is generated; the corresponding variable is 'm_xml_node_tag_symbol'. The node value corresponds to the variable 'm_xml_node_value'; The attribute and leaf node set contained by the node, corresponding to the variable'm_xml_attr_contain' and'm_xml_element_contain' set; The subsequent node set of the node, corresponding to the variable'm_xml_block_contain'; The metadata information corresponding to the type at the time of definition, corresponding to the variable'm_meta_property'.

[0039] 2. Simplified expression of attribute declaration, because the declaration of different types of attributes is different, and the declaration of the meta-object structure related attributes in Qt is more cumbersome, the declaration of variables and variable attributes is simplified by using macro function.

[0040] Firstly, the mapping conversion mechanism between variables and attributes is defined by macro function, and the related macro function is defined as follows: #define XML_ITEM_PROPERTY_NAME(var_name) property_##var_name##_accessor If the variable name is "a", the attribute name corresponding to the variable is "property_a_accessor".

[0041] Further, different macro functions are defined according to different node types: Attribute node definition: #define XML_ATTR(var_name, var_value, xml_attr_tag_symbol) \ QXmlNode var_name = QXmlNode(QVariant(var_value), xml_node_type::attribute, u8#xml_attr_tag_symbol); \ Q_PROPERTY(QXmlNode XML_ITEM_PROPERTY_NAME(var_name) MEMBER var_name) Leaf node attribute definition: #define XML_ELEMENT(var_name, var_value, xml_element_tag_symbol)\ QXmlNode var_name = QXmlNode(QVariant(var_value), xml_node_type::leaf_element,u8#xml_element_tag_symbol);\ Q_PROPERTY(QXmlNode XML_ITEM_PROPERTY_NAME(var_name) MEMBERvar_name) XML data block definition: #define XML_BLOCK(xml_block_type, xml_block_var_name, xml_block_tag_symbol)\ xml_block_typexml_block_var_name = xml_block_type(u8#xml_block_tag_symbol); \ Q_PROPERTY(xml_block_type XML_ITEM_PROPERTY_NAME(xml_block_var_name) MEMBER xml_block_var_name) Its usage, expansion results and interpretation are shown in Figure 5 .

[0042] 3. XML initialization structure method description The 'void InializeXmlScheme ()' function in Figure 4 is the initialization method of the implemented XML document structure. This method is an overloadable virtual function. Its initialization idea is shown in Figure 6 .

[0043] 4. Examples Suppose the current XML document structure is as shown in Figure 7 . The corresponding xml serialization and deserialization class definitions of the related document structure are shown in Figure 8 , Figure 9 and Figure 10 . Among them: Figure 7 The class declaration form of the XML document xml_block_base in Figure 8 is shown; Figure 7 The class declaration form of the XML document xml_block_merge in Figure 9 is shown; Figure 7 The class declaration form of the XML document xml_root in Figure 10 is shown.

[0044] It can be seen that the aggregation relationship between classes in the declaration process corresponds to the belonging relationship between nodes in the XML document, and the definition is intuitive.

[0045] Call Figure 4 The 'QDomNodetoXml()' in the table completes the serialization of the class instance to XML, and the specific declaration and calling mode are as follows: xml_root root(u8"node0"); root.InializeXmlNodeScheme(); QDomNodedom_node=root.toXml(); After the above code is executed, the return result dom_node is serialized to generate an XML file format as shown in Figure 11 .

[0046] The reverse process of the serialization process is the inverse process of the above process, and the 'bool fromXml(const QDomNode&node)' is not discussed.

[0047] After the 'void InializeXmlScheme ()' function is compiled, the serialization of XML is realized by sequentially calling 'voidInializeXmlScheme ()', 'QDomNodetoXml()'; the reverse serialization function of XML is realized by sequentially calling 'voidInializeXmlScheme ()', 'bool fromXml(const QDomNode&node)', and the operation is simple.

[0048] The technical means disclosed in the scheme of the present application is not limited to the technical means disclosed in the above-mentioned embodiments, and also includes the technical solutions composed of any combination of the above technical features. It should be pointed out that for ordinary skilled persons in the art, without departing from the principle of the present application, a number of improvements and refinements can be made, and these improvements and refinements are also considered to be within the protection scope of the present application.

Claims

1. An implementation method of XML serialization and deserialization based on Qt meta-object technology, characterized in that The method comprises the following steps: S1) defining a basic data structure for describing an XML node, wherein the basic data structure comprises a node type, a node alias, a node value, a node contained attribute and leaf node set, a node subsequent node set, and metadata information generated in the node type instantiation process, and the node type comprises two types, one is a leaf node, and the other is a block node; S2) defining an XML document structure to be serialized and deserialized into a class, wherein data items to be serialized and deserialized are inherited from the basic data structure in S1) or directly defined by using the basic data structure in S1), and are aggregated into the class, and the class itself also takes the basic data structure in S1) as a base class; S3) declaring data items to be serialized and deserialized by using a property definition macro provided by Qt, so as to ensure that information of the data items is added to a meta object system of the class; S4) including an XML document structure initialization process in the basic data structure in S1), generating an XML document structure by reading class structure information, and establishing an association relationship between attribute meta object data and the attribute; S5) serializing according to the basic data structure in S1), generating an XML document structure according to an XML node type represented by an attribute and an association relationship between attributes, filling values of the attributes in S3) contained in a class instance into the XML document structure, and generating an XML data stream; S6) deserializing according to the basic data structure in S1), reading an XML data stream, finding a value of a node with a specific name in the XML data stream according to a document structure, and filling the value into the attribute in S3) corresponding to the node name.

2. The Qt meta-object technology based XML serialization and deserialization implementation method according to claim 1, characterized in that: In S1), the node alias represents a name of the node for a user to see when the node is generated; the node type represents a type of an XML document node corresponding to the node; the leaf node represents a bottommost node of XML and is directly expressed by the basic data structure in S1); the block node represents that the node contains other nodes in the XML structure, is a derived class of the basic data structure in S1), and other XML nodes in the block are defined by aggregating the basic class or the derived class of the basic class on the basis of directly using or inheriting the basic class. 3.The Qt meta-object technology based XML serialization and deserialization implementation method according to claim 1, characterized in that: In the property definition process in S3), a macro function and other precompilation technologies are used to simplify a node definition form, so as to reduce code input quantity and improve conformity and intuitiveness of code expression.

4. The Qt meta-object technology based XML serialization and deserialization implementation method of claim 1, wherein: The basic data structure in S4) should include an XML document structure initialization method, and the method comprises the following steps: S41) reading metadata information of the class; S42) reading content of an attribute declared in S3) by using the metadata information of the class, and storing the attribute according to 'xml attribute', 'xml node', and 'xml block' according to node type information contained in the attribute; S43): Establishing the association between the meta-object data of the attribute and the attribute, for subsequent automatic reading or writing of the value of the attribute; S44): Reading the variable information of the block node contained in the class, the base class of the variable being the basic data structure in S1), and repeatedly calling the above S41), S42), and S43) steps on the block node, so as to construct the attributes in the block node that need to be serialized and deserialized and the association between the attributes, and to construct the association between the defined block variable attributes and the corresponding meta-object data.

5. The Qt meta-object technology based XML serialization and deserialization implementation method of claim 1, wherein: In S5, according to the basic data structure in S1, the specific steps of serialization include, S51): Reading the node type, node alias, and node value of the instance to be serialized, and generating a corresponding XML node as a parent node according to the node type and node alias and value; S52): Traversing the attribute set and the association between the attributes of the XML node extracted by step S4) representing the instance to be serialized; S53): For each attribute of the XML node contained in the instance in S51), the following operations are performed according to the type of the attribute, which is a leaf node, an attribute node, or a block node: For leaf nodes and attribute nodes, the following steps are included: a1) reading the node type, node alias, and current node value, and generating an XML leaf node or an XML attribute node according to the node type definition; a2) according to the node type, adding the generated XML node as an XML leaf node or an XML attribute to the node generated in step S51); For block nodes, i.e., subsequent nodes of the current node: Repeat the above steps S51), S52), S53), and a1) and a2) in S53) to complete the construction of the XML document; S54): The XML document corresponding to the class can be constructed through the above steps, and the output result of the serialization operation of the document is the XML serialization result of the data class instance.

6. The Qt meta-object technology based XML serialization and deserialization implementation method of claim 1, wherein: According to the basic data structure in S1, the specific steps of deserialization include, S61): Reading the current data stream to be deserialized; S62): Creating an XML document and importing the data stream to be serialized into the XML document. If there is no error, it means that the data stream itself is a legal structure XML data framework, otherwise, give a prompt to exit the deserialization operation; S63): Reading all the child node sets corresponding to the current XML node, creating a deserialization target class instance corresponding to the XML document, and reading the attribute set and the association between the attributes of each node in the XML structure generated by S4) representing the XML structure; S64): Traversing the XML child node set, obtaining the node name, and searching for the corresponding attribute in the attribute set generated in S4) according to the name. If the attribute exists, the following operations are performed according to the node type described in the attribute: For leaf nodes and attribute nodes: b1): reading the value in the XML node corresponding thereto; b2): through the metadata information corresponding to the attribute and the attribute, in a reflective way, the value of the XML node is automatically written into the class member variable corresponding to the attribute, completing the assignment of the value of the XML node to the attribute variable corresponding to the class instance; For block nodes: Repeat the above S63), S64, and b1), b2) steps to complete the extraction of data from the XML document and write the data into the attributes contained in the corresponding class instance, completing the deserialization operation of the data.