Data type creation method, device, server and medium
By creating subclasses of virtual base classes and template classes, and generating target variable types based on the types of associated variables, the problem of inflexible variable type definitions in the prior art is solved, and higher flexibility and adaptability are achieved.
Patent Information
- Application Number
- CN202111214248.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-19
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2041-10-19
AI Technical Summary
In the existing technology, when defining a variable, only the variable name and variable type of the variable can be defined at the same time, which lacks flexibility and cannot flexibly assign variable types according to actual application requirements.
By creating a virtual base class and its subclass, the subclass is a template class, generating the variable type of the target variable based on the variable type of the class template and the associated variable of the target variable, and instantiating the parent class into a subclass object to achieve the target data type. Created, the subclass object has all the characteristics of the subclass.
It realizes the flexible assignment of variable types according to the variable types of associated variables, improves the flexibility of defining variable types, and solves the problem in the existing technology that only variable names and variable types can be defined at the same time.
Smart Images

Figure CN113971019B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of computer technology, and in particular, relates to a data type creation method, device, server and medium. Background Art
[0002] The Open Diagnostic eXchange format (ODX) is an open diagnostic data format based on Extensible Markup Language (XML) and is used for the exchange of diagnostic data throughout the vehicle life cycle. It was originally proposed by ASAM and formed into the standard MCD-2D. Later, it formed the ISO standard based on ODX2.2.0, namely the ISO 22901-1 standard. The Open Test sequence eXchange (OTX) is an open test sequence exchange format based on XML language, which is used to describe the requirements of basic functional tests to the entire test application, in accordance with the ISO 13209 standard.
[0003] In the related art, during the platform development process, such as the development of the ODX / OTX platform, when defining a variable in a program, it is usually necessary to define both the variable name and the variable type of the variable. However, in some application scenarios, it may be necessary to assign a variable type to a variable in combination with actual application requirements. For example, in some scenarios, a variable may be assigned a string type, and in other scenarios, an integer type may be assigned to a variable. In other words, the method in the related art that can only define the variable name and variable type of a variable at the same time is not flexible enough. Summary of the invention
[0004] The embodiments of the present application provide a data type creation method, device, server and medium, aiming to solve the problem in the related art that the method of only being able to define the variable name and variable type of a variable at the same time is not flexible enough.
[0005] In a first aspect, an embodiment of the present application provides a method for creating a data type, the method comprising:
[0006] Create a virtual base class, and determine the created virtual base class as a parent class;
[0007] Create a subclass of the parent class, the subclass is a template class, and the subclass is used to generate the variable type of the target variable based on the class template and the variable type of the associated variable of the target variable;
[0008] The parent class is instantiated into a subclass object, and the instantiated subclass object is determined as a target data type to achieve creation of the target data type, wherein the subclass object has all the characteristics of the subclass.
[0009] Furthermore, create a subclass of the parent class, including:
[0010] Identify the subclass as a template class;
[0011] Construct the subclass implementation function of the subclass;
[0012] The subclass implementation function includes: a type implementation function for determining the variable type of the target variable, the type implementation function generates the variable type of the target variable based on the class template and the variable type of the associated variable of the target variable.
[0013] Furthermore, the subclass implementation function also includes at least one of the following:
[0014] A value-taking implementation function for determining the value of a target variable, a pointer implementation function for determining the pointer of a target variable, and an assignment implementation function for assigning a value to a target variable.
[0015] Furthermore, the parent class is instantiated into a child class object, including:
[0016] Create a smart pointer of the parent class type;
[0017] Construct an information acquisition function for acquiring information from a subclass, wherein the information acquisition function includes at least one of the following: a value acquisition function, a pointer acquisition function, and a type acquisition function;
[0018] Among them, the subclass object includes a smart pointer and an information acquisition function.
[0019] Furthermore, instantiating the parent class into a child class object also includes:
[0020] Configuring overloadable target operators and target functions to implement overloading of target operators and / or target functions;
[0021] Among them, the subclass object also includes the target operator and the target function.
[0022] Furthermore, the method further comprises:
[0023] In response to detecting that there is a target variable with a target data type in the target program, an associated variable of the target variable and a variable type of the associated variable are searched from the target program, and the variable type of the target variable is determined according to the variable type of the associated variable.
[0024] Further, searching the target variable's associated variable and the variable type of the associated variable from the target program, and determining the variable type of the target variable according to the variable type of the associated variable, includes:
[0025] Find a variable connected to the target variable by an equal sign operator from a program following the target variable in the target program, and determine the found variable as an associated variable of the target variable;
[0026] An associated variable and a variable type of the associated variable are found in a program preceding the target variable in the target program, and the variable type of the associated variable is determined as the variable type of the target variable.
[0027] In a second aspect, an embodiment of the present application provides a data type creation device, the device comprising:
[0028] A first creation unit, used for creating a virtual base class and determining the created virtual base class as a parent class;
[0029] A second creation unit is used to create a subclass of the parent class, the subclass is a template class, and the subclass is used to generate a variable type of the target variable based on the class template and the variable type of the associated variable of the target variable;
[0030] The target creation unit is used to instantiate the parent class into a subclass object, and determine the instantiated subclass object as the target data type to achieve the creation of the target data type, wherein the subclass object has all the characteristics of the subclass.
[0031] In a third aspect, an embodiment of the present application provides a server, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned data type creation method when executing the computer program.
[0032] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps of the data type creation method are implemented.
[0033] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when executed on a server, enables the server to execute any one of the data type creation methods of the first aspect.
[0034] Compared with the related art, the embodiments of the present application have the following beneficial effects: creating a parent class and a subclass of the parent class, wherein the subclass can generate the variable type of the target variable based on the variable type of the associated variable of the target variable, and then instantiating the parent class into a subclass object to obtain a new target data type. Since the subclass object has all the characteristics of the subclass, the obtained target data type can automatically generate the variable type for the target variable based on the variable type of the associated variable of the target variable. Compared with the method in the related art that can only define the variable name and variable type of the variable at the same time, the present application can realize the combination of actual needs, based on the variable type of the associated variable, to assign the variable type to the variable, which is more flexible.
[0035] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0037] Figure 1 This is a system architecture diagram of the data type creation method application provided in one embodiment of the present application;
[0038] Figure 2 It is a flowchart of a method for creating a data type provided in an embodiment of the present application;
[0039] Figure 3 is a flowchart of a method for creating a data type provided by another embodiment of the present application;
[0040] Figure 4 It is a structural diagram of a data type creation device provided in an embodiment of the present application;
[0041] Figure 5 It is a schematic diagram of the structure of a server provided in one embodiment of the present application. DETAILED DESCRIPTION
[0042] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0043] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0044] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0045] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0046] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0047] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0048] In order to illustrate the technical solution of the present application, the following embodiments are used for illustration.
[0049] Embodiment 1
[0050] refer to Figure 1 , which is a system architecture diagram of an application of a data type creation method provided in an embodiment of the present application.
[0051] like Figure 1 As shown, the system architecture may include a user terminal 101 and a server 102, wherein the user terminal 101 and the server 102 may be connected via a network. The network is used to provide a medium for a communication link between the user terminal 101 and the server 102. The network may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0052] The server 102 may be any server, for example, a server for creating a target data type. In practice, the server 102 may create a virtual base class, and determine the created virtual base class as a parent class; create a subclass of the parent class, the subclass being a template class, and the subclass being used to generate the variable type of the target variable based on the class template and the variable type of the associated variable of the target variable; instantiate the parent class into a subclass object, and determine the instantiated subclass object as the target data type to achieve the creation of the target data type, wherein the subclass object has all the characteristics of the subclass.
[0053] It should be noted that the server can be hardware or software. When the server is hardware, it can be implemented as a distributed server cluster consisting of multiple servers, or it can be implemented as a single server. When the server is software, it can be implemented as multiple software or software modules, or it can be implemented as a single software or software module. No specific limitation is made here.
[0054] The user terminal 101 may be any electronic device having a display screen and supporting user information input, including but not limited to a tablet computer, a laptop computer, a desktop computer, etc. In practice, various applications, such as programming applications, etc., may be installed on the user terminal 101. When the user terminal 101 runs the programming application, the target data type created on the server 102 may be applied to realize automatic generation of the variable type of the target variable based on the variable type of the associated variable of the target variable.
[0055] It should be noted that the data type creation method provided in the embodiment of the present application is generally executed by the server 102 , and accordingly, the data type creation device is generally set in the server 102 .
[0056] It should be understood that Figure 1 The number of user terminals and servers in the embodiment is only for illustration. Any number of user terminals and servers may be provided according to implementation requirements.
[0057] Embodiment 2
[0058] refer to Figure 2 , is a flow chart of a method for creating a data type provided in an embodiment of the present application, such as Figure 2 The data type creation method shown includes:
[0059] Step 201: Create a virtual base class, and determine the created virtual base class as a parent class.
[0060] In this embodiment, the execution subject for executing the above data type creation method is usually a server (for example Figure 1 Server 102 shown).
[0061] Here, the execution subject may directly create a virtual base class, and use the created virtual base class as a parent class.
[0062] It should be pointed out that when there is a common base class on multiple inheritance paths, this common base class will generate multiple instances (or multiple copies) at the confluence of some of these paths. If you only want to save one instance of this base class, you can declare this common base class as a virtual base class.
[0063] Step 202, creating a subclass of the parent class, the subclass being a template class, and the subclass being used to generate the variable type of the target variable based on the class template and the variable type of the associated variable of the target variable.
[0064] The variable type includes any of the following: integer type, floating point type, Boolean type, character type.
[0065] Here, the execution subject can further create a subclass of the parent class based on the parent class, and configure the created subclass as a template class. Here, the created subclass is configured as a template class, in which various class templates can be stored, and the required variable types can be generated by using class templates. In practice, the execution subject can determine the relationship between the parent class and the subclass by executing a pre-set relationship declaration step. For example, if one class is A and the other class is B, the execution subject can determine the relationship between A and B by executing the following declaration: "class B: public A".
[0066] In practice, the variable type of the target variable is generated based on the class template and the variable type of the associated variable of the target variable. Usually, the class template is used to determine the variable type of the associated variable, and then the variable type that is the same as the variable type of the associated variable is generated. For example, if the variable type of the associated variable is an integer type, the variable type generated by the target variable is also an integer type.
[0067] Step 203: instantiate the parent class into a child class object, and determine the instantiated child class object as the target data type to achieve creation of the target data type.
[0068] Among them, the subclass object has all the characteristics of the subclass.
[0069] Among them, instantiation refers to the process of creating objects with classes in object-oriented programming. It is the process of making an abstract concept class specific to the physical object of that class.
[0070] Here, the execution subject may instantiate the parent class into a subclass object under a specific situation, and determine the instantiated subclass object as the target data type, thereby creating the target data type. As an example, the execution subject may instantiate the parent class into a subclass object by constructing a pointer of the parent class type.
[0071] The method provided in this embodiment creates a parent class and a subclass of the parent class, wherein the subclass can generate a variable type for the target variable based on the variable type of the associated variable of the target variable, and then obtain a new target data type by instantiating the parent class into a subclass object. Since the subclass object has all the characteristics of the subclass, the obtained target data type can automatically generate a variable type for the target variable based on the variable type of the associated variable of the target variable. Compared with the method in the related art that can only define the variable name and variable type of the variable at the same time, the present application can realize the assignment of variable types to variables based on the variable type of the associated variable in combination with actual needs, which is more flexible.
[0072] In some optional implementations of this embodiment, the above-mentioned creation of a subclass of a parent class includes: first, determining the subclass as a template class, and then constructing a subclass implementation function of the subclass.
[0073] The subclass implementation function includes: a type implementation function for determining the variable type of the target variable, the type implementation function generates the variable type of the target variable based on the class template and the variable type of the associated variable of the target variable.
[0074] The above subclass implementation function is usually a function for implementing the function of the subclass. In practice, the subclass implementation function may include: a type implementation function for determining the variable type of the target variable, the type implementation function generates the variable type of the target variable based on the class template and the variable type of the associated variable of the target variable.
[0075] In practice, in the above type realization function, the variable type of the target variable is generated based on the class template and the variable type of the associated variable of the target variable. Usually, the class template is used to determine the variable type of the associated variable, and then the variable type that is the same as the variable type of the associated variable is generated. For example, if the variable type of the associated variable is an integer type, the variable type generated for the target variable is also an integer type.
[0076] In some optional implementations, the subclass implementation function may also include at least one of the following: a value implementation function for determining the value of the target variable, a pointer implementation function for determining the pointer of the target variable, and an assignment implementation function for assigning a value to the target variable.
[0077] The above-mentioned value realization function is usually a function used to determine the value of the target variable. In practice, the value realization function usually performs the following steps: searching for the associated variable of the target variable, obtaining the value of the associated variable, and determining the value of the associated variable as the value of the target variable.
[0078] The pointer implementation function is usually a function for determining the pointer of the target variable. The assignment implementation function is usually a function for assigning a value to the target variable. Specifically, the assignment implementation function can directly assign the determined value of the target variable to the target variable.
[0079] It should be pointed out that the multiple functions included in the subclass implementation function can be implemented as one function or as multiple functions, which is not limited in this embodiment.
[0080] In some optional implementations of this embodiment, the instantiation of the parent class into a child class object includes: first, creating a smart pointer of the parent class type. Then, constructing an information acquisition function for acquiring information from the child class. The information acquisition function includes at least one of the following: a value acquisition function, a pointer acquisition function, and a type acquisition function. The child class object includes a smart pointer and an information acquisition function.
[0081] The above information acquisition function is usually a function that obtains information from a subclass. In practice, the information acquisition function usually obtains information from the output result of the subclass implementation function, such as obtaining the value information, pointer information, and type information of the target variable. The information acquisition function can be implemented as one function or multiple functions.
[0082] Among them, the above-mentioned smart pointer is usually a pointer that can automatically release memory. By instantiating the parent class into a child class object by means of a smart pointer, better memory management of variables of the target data type can be achieved, memory can be released in time, and storage resources can be saved.
[0083] In some implementations, instantiating a parent class into a child class object may also include: configuring an overloadable target operator and target function to implement overloading of the target operator and / or target function.
[0084] Among them, the subclass object also includes the target operator and the target function.
[0085] The target operator may be a preset operator, such as ">", "=", "!=", "==", etc. The target function may be a preset function, and in practice, the target function may be a constructor, a copy constructor, etc.
[0086] It should be pointed out that by configuring the overloadable target operator and target function in the instantiated subclass object, the target operator and the target function can be overloaded.
[0087] Embodiment 3
[0088] Further references Figure 3 , is a flow chart of a data type creation method provided in an embodiment of the present application. The data type creation method comprises the following steps:
[0089] Step 301: Create a virtual base class, and determine the created virtual base class as a parent class.
[0090] Step 302, creating a subclass of the parent class, the subclass being a template class, and the subclass being used to generate the variable type of the target variable based on the class template and the variable type of the associated variable of the target variable.
[0091] The variable type includes any of the following: integer type, floating point type, Boolean type, character type.
[0092] Step 303: instantiate the parent class into a child class object, and determine the instantiated child class object as the target data type to achieve creation of the target data type.
[0093] Among them, the subclass object has all the characteristics of the subclass.
[0094] In this embodiment, the specific operations of steps 301-303 are the same as Figure 2 The operations of steps 201-203 in the illustrated embodiment are substantially the same and will not be described in detail herein.
[0095] Step 304, in response to detecting that there is a target variable with a target data type in the target program, searching the target variable's associated variable and the variable type of the associated variable from the target program, and determining the variable type of the target variable according to the variable type of the associated variable.
[0096] The target program is usually a pre-set program, such as a program for developing a platform. The target variable is usually a variable with a target data type.
[0097] Here, the above-mentioned execution subject can detect whether there is a variable with the target data type in the target program. If there is a variable with the target data type, the above-mentioned execution subject can search for the associated variable and the variable type of the associated variable from the target program, and then determine the variable type of the associated variable as the variable type of the target variable.
[0098] This embodiment can realize that when the target data type is applied, the variable type for the target variable can be automatically generated based on the variable type of the associated variable of the target variable. It can also realize that the variable type can be assigned to the variable based on the variable type of the associated variable in accordance with actual needs, which is more flexible.
[0099] In some optional implementations, searching the target variable's associated variable and the variable type of the associated variable from the target program, and determining the variable type of the target variable according to the variable type of the associated variable may include:
[0100] First, a variable connected to the target variable by an equal sign operator is searched in a program following the target variable in the target program, and the found variable is determined as an associated variable of the target variable.
[0101] Then, the associated variable and the variable type of the associated variable are found in the program before the target variable in the target program, and the variable type of the associated variable is determined as the variable type of the target variable.
[0102] Here, the execution subject can use the target variable as a separator, find the variable connected to the target variable by the equal sign operator "=" from the program after the target variable, and determine the found variable as the associated variable of the target variable. Then, the execution subject can find the associated variable from the program before the target variable, and obtain the value and variable type of the associated variable. Afterwards, the execution subject can determine the variable type of the associated variable as the variable type of the target variable.
[0103] Embodiment 4
[0104] Further references Figure 4 , corresponding to the data type creation method in the above embodiment, Figure 4 The structural block diagram of the data type creation device 400 provided in the embodiment of the present application only shows the part related to the embodiment of the present application for the convenience of explanation.
[0105] Reference Figure 4 , the device comprises:
[0106] The first creation unit 401 is used to create a virtual base class and determine the created virtual base class as a parent class;
[0107] The second creation unit 402 is used to create a subclass of the parent class, where the subclass is a template class, and the subclass is used to generate a variable type of the target variable based on the class template and the variable type of the associated variable of the target variable;
[0108] The target creation unit 403 is used to instantiate the parent class into a child class object, and determine the instantiated child class object as the target data type to achieve the creation of the target data type, wherein the child class object has all the characteristics of the child class.
[0109] In some embodiments, the second creation unit 402 is specifically used to: determine the subclass as a template class; construct a subclass implementation function of the subclass; wherein the subclass implementation function includes: a type implementation function for determining the variable type of the target variable, the type implementation function generates the variable type of the target variable based on the class template and the variable type of the associated variable of the target variable.
[0110] In some embodiments, in the second creation unit 402, the subclass implementation function also includes at least one of the following: a value implementation function for determining the value of the target variable, a pointer implementation function for determining the pointer of the target variable, and an assignment implementation function for assigning a value to the target variable.
[0111] In some embodiments, the target creation unit 403 is specifically used to: create a smart pointer of the parent class type; construct an information acquisition function for obtaining information from the child class, the information acquisition function includes at least one of the following: a value acquisition function, a pointer acquisition function, and a type acquisition function; wherein the child class object includes a smart pointer and an information acquisition function.
[0112] In some embodiments, the target creation unit 403 is further specifically used to: configure overloadable target operators and target functions to implement overloading of target operators and / or target functions; wherein the subclass object also includes the target operator and the target function.
[0113] In some embodiments, the device further includes a type application unit (not shown in the figure). The type application unit is used to: in response to detecting that there is a target variable with a target data type in the target program, search for an associated variable of the target variable and a variable type of the associated variable from the target program, and determine the variable type of the target variable according to the variable type of the associated variable.
[0114] In some embodiments, the type application unit is specifically used to: search for variables connected to the target variable with an equal sign operator from a program after the target variable in the target program, and determine the found variables as associated variables of the target variable; search for associated variables and variable types of the associated variables from a program before the target variable in the target program, and determine the variable type of the associated variables as the variable type of the target variable.
[0115] The device provided in this embodiment creates a parent class and a subclass of the parent class, wherein the subclass can generate a variable type for the target variable based on the variable type of the associated variable of the target variable, and then obtain a new target data type by instantiating the parent class into a subclass object. Since the subclass object has all the characteristics of the subclass, the obtained target data type can automatically generate a variable type for the target variable based on the variable type of the associated variable of the target variable. Compared with the method in the related art that can only define the variable name and variable type of the variable at the same time, the present application can realize the assignment of variable type to the variable based on the variable type of the associated variable in combination with actual needs, which is more flexible.
[0116] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0117] Embodiment 5
[0118] Further references Figure 5 , Figure 5 FIG. 5 is a schematic diagram of the structure of a server 500 provided in an embodiment of the present application. Figure 5 As shown, the server 500 of this embodiment includes: at least one processor 501 ( Figure 5 Only one processor is shown in the figure), a memory 502, and a computer program 503 stored in the memory 502 and executable on at least one processor 501, such as a data type creation program. When the processor 501 executes the computer program 503, the steps in any of the above-mentioned method embodiments are implemented. When the processor 501 executes the computer program 503, the steps in the above-mentioned data type creation method embodiments are implemented. When the processor 501 executes the computer program 503, the functions of the modules / units in the above-mentioned device embodiments are implemented, such as Figure 4 The functions of units 401 to 403 are shown.
[0119] Exemplarily, the computer program 503 may be divided into one or more modules / units, one or more modules / units are stored in the memory 502, and are executed by the processor 501 to complete the present application. One or more modules / units may be a series of computer program instruction segments that can complete specific functions, and the instruction segments are used to describe the execution process of the computer program 503 in the server 500. For example, the computer program 503 may be divided into a first creation unit, a second creation unit, and a target creation unit. The specific functions of each unit have been described in the above embodiments and will not be repeated here.
[0120] The server 500 may be a computing device such as a server, a desktop computer, a tablet computer, a cloud server, and a mobile terminal. The server 500 may include, but is not limited to, a processor 501 and a memory 502. Those skilled in the art will appreciate that Figure 5 This is only an example of the server 500 and does not constitute a limitation on the server 500 . The server 500 may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the server may also include input and output devices, network access devices, buses, etc.
[0121] The processor 501 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0122] The memory 502 may be an internal storage unit of the server 500, such as a hard disk or memory of the server 500. The memory 502 may also be an external storage device of the server 500, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the server 500. Further, the memory 502 may also include both an internal storage unit of the server 500 and an external storage device. The memory 502 is used to store computer programs and other programs and data required by the server. The memory 502 may also be used to temporarily store data that has been output or is to be output.
[0123] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0124] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0125] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0126] In the embodiments provided in the present application, it should be understood that the disclosed devices / servers and methods can be implemented in other ways. For example, the device / server embodiments described above are merely schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0127] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0128] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0129] If the integrated module is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Among them, the computer-readable storage medium can be non-volatile or volatile. Based on this understanding, the present application implements all or part of the process in the above-mentioned embodiment method, and can also be completed by hardware related to computer program instructions. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable storage medium may include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in computer-readable storage media can be appropriately increased or decreased according to the requirements of legislation and patent practices in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practices, computer-readable storage media do not include electrical carrier signals and telecommunication signals.
[0130] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A data type creation method, characterized in that: The method comprises: Create a virtual base class, and determine the created virtual base class as a parent class; Creating a subclass of the parent class, wherein the subclass is a template class, and the subclass is used to generate a variable type of the target variable based on the class template and the variable type of the associated variable of the target variable; Instantiating the parent class into a child class object, and determining the instantiated child class object as a target data type to achieve creation of the target data type, wherein the child class object has all the characteristics of the child class; In response to detecting that the target variable having the target data type exists in the target program, searching the target variable's associated variable and the variable type of the associated variable from the target program, and determining the variable type of the target variable according to the variable type of the associated variable, including: searching the variable connected to the target variable with an equal sign operator from the program after the target variable in the target program, and determining the found variable as the associated variable of the target variable; searching the associated variable and the variable type of the associated variable from the program before the target variable in the target program, and determining the variable type of the associated variable as the variable type of the target variable.
2. The data type creation method according to claim 1, characterized in that: The step of creating a subclass of the parent class comprises: Identify the subclass as a template class; Construct the subclass implementation function of the subclass; The subclass implementation function includes: a type implementation function for determining the variable type of the target variable, wherein the type implementation function generates the variable type of the target variable based on the class template and the variable type of the associated variable of the target variable.
3. The data type creation method according to claim 2, characterized in that: The subclass implementation function also includes at least one of the following: A value realization function for determining the value of the target variable, a pointer realization function for determining the pointer of the target variable, and an assignment realization function for assigning a value to the target variable.
4. The data type creation method according to claim 1, characterized in that: The instantiating the parent class into a child class object comprises: Create a smart pointer of the parent class type; Constructing an information acquisition function for acquiring information from a subclass, wherein the information acquisition function includes at least one of the following: a value acquisition function, a pointer acquisition function, and a type acquisition function; Wherein, the subclass object includes the smart pointer and the information acquisition function.
5. The data type creation method according to claim 4, characterized in that: The instantiation of the parent class into a child class object further includes: Configuring overloadable target operators and target functions to implement overloading of target operators and / or target functions; The subclass object further includes a target operator and a target function.
6. A data type creation device, characterized in that: The device comprises: A first creation unit, used for creating a virtual base class and determining the created virtual base class as a parent class; a second creation unit, configured to create a subclass of the parent class, wherein the subclass is a template class, and the subclass is configured to generate a variable type of the target variable based on the class template and a variable type of an associated variable of the target variable; A target creation unit, configured to instantiate the parent class into a child class object, and determine the instantiated child class object as a target data type to achieve creation of the target data type, wherein the child class object has all the characteristics of the child class; A type application unit is used to, in response to detecting that the target variable with the target data type exists in the target program, search for an associated variable of the target variable and a variable type of the associated variable from the target program, and determine the variable type of the target variable according to the variable type of the associated variable, including: searching for a variable connected to the target variable with an equal sign operator from a program after the target variable in the target program, and determining the found variable as the associated variable of the target variable; searching for the associated variable and the variable type of the associated variable from a program before the target variable in the target program, and determining the variable type of the associated variable as the variable type of the target variable.
7. A server comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 5 is implemented.
8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Method and device for parameter processing
CN108932123A
An arbitrary function adapter implementation method
CN109840093A
