CN109144565B - Processing method and device for configuration file - Google Patents

Processing method and device for configuration file Download PDF

Info

Publication number
CN109144565B
CN109144565B CN201811102870.4A CN201811102870A CN109144565B CN 109144565 B CN109144565 B CN 109144565B CN 201811102870 A CN201811102870 A CN 201811102870A CN 109144565 B CN109144565 B CN 109144565B
Authority
CN
China
Prior art keywords
parameters
configuration
binary data
configuration file
parameter
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811102870.4A
Other languages
Chinese (zh)
Other versions
CN109144565A (en
Inventor
赵肖勇
康高杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
3600 Technology Group Co ltd
Original Assignee
3600 Technology Group Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 3600 Technology Group Co ltd filed Critical 3600 Technology Group Co ltd
Priority to CN201811102870.4A priority Critical patent/CN109144565B/en
Publication of CN109144565A publication Critical patent/CN109144565A/en
Application granted granted Critical
Publication of CN109144565B publication Critical patent/CN109144565B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a method and a device for processing configuration files. The method comprises the following steps: acquiring one or more initial parameters of a configuration file to be written; encapsulating the one or more initial parameters into a data object of a specified type; generating configuration parameters according to the data objects; and writing the generated configuration parameters into the configuration file. According to the technical scheme, parameters written into the configuration file are not limited to few types such as integer, character and the like, the parameter types are widened, namely the configuration file can play a larger purpose when software runs, reading and writing are more convenient, and efficiency is higher.

Description

Processing method and device for configuration file
Technical Field
The invention relates to the technical field of computers, in particular to a method and a device for processing configuration files.
Background
Configuration files are important files needed by many software in running, and settings of various functions of the software are often stored in the configuration files, such as resolution, whether to self-start, and the like, and are often written in the configuration files as independent parameters in a certain format. However, the storage mode of the configuration file is single at present, which generally only supports integer and character type reading and writing, and the application scene is narrow.
Disclosure of Invention
The present invention has been made in view of the above problems, and it is an object of the present invention to provide a method and apparatus for processing a profile that overcomes or at least partially solves the above problems.
According to one aspect of the present invention, there is provided a method for processing a configuration file, including:
acquiring one or more initial parameters of a configuration file to be written;
encapsulating the one or more initial parameters into a data object of a specified type;
generating configuration parameters according to the data objects;
and writing the generated configuration parameters into the configuration file.
Optionally, the encapsulating the one or more initial parameters into a data object of a specified type includes:
the one or more initial parameters are packaged into a data object of a specified type based on a variable parameter template.
Optionally, the encapsulating the one or more initial parameters into a data object of a specified type based on a variable parameter template includes:
creating a tuple according to the parameter type of the one or more initial parameters, and writing the one or more initial parameters into the tuple.
Optionally, the generating configuration parameters according to the data object includes:
serializing the data object into binary data;
and converting the binary data into a character string with a specified format as a configuration parameter.
Optionally, the serializing the data object into binary data includes:
the data objects are serialized into binary data according to a preset method, and the preset method is realized according to a variable parameter template.
Optionally, the converting the binary data into a character string in a specified format includes:
and performing base64 coding on the binary data to obtain a corresponding base64 character string.
Optionally, the method further comprises:
reading the designated configuration parameters from the configuration file according to the parameters to be used;
converting the configuration parameters into binary data, and checking the binary data according to the parameter type of the parameters to be used;
after verification passes, the binary data is converted into usable parameters.
Optionally, the type of the initial parameter includes one or more of the following: trivial types, structures, vectors.
According to another aspect of the present invention, there is provided a processing apparatus for a configuration file, including:
the acquisition unit is suitable for acquiring one or more initial parameters of the configuration file to be written;
a packaging unit adapted to package the one or more initial parameters into a data object of a specified type;
a generating unit adapted to generate configuration parameters from the data objects;
and the writing unit is suitable for writing the generated configuration parameters into the configuration file.
Optionally, the packaging unit is adapted to package the one or more initial parameters into a data object of a specified type based on a variable parameter template.
Optionally, the encapsulation unit is adapted to create a tuple of the parameter type of the one or more initial parameters, and to write the one or more initial parameters to the tuple.
Optionally, the generating unit is adapted to serialize the data object into binary data; and converting the binary data into a character string with a specified format as a configuration parameter.
Optionally, the generating unit is adapted to serialize the data object into binary data according to a preset method, the preset method being implemented according to a variable parameter template.
Optionally, the generating unit is adapted to perform base64 encoding on the binary data to obtain a corresponding base64 string.
Optionally, the apparatus further comprises:
the reading unit is suitable for reading the designated configuration parameters from the configuration file according to the parameters to be used;
the parameter conversion unit is suitable for converting the configuration parameters into binary data, and checking the binary data according to the parameter type of the parameters to be used; after verification passes, the binary data is converted into usable parameters.
Optionally, the type of the initial parameter includes one or more of the following: trivial types, structures, vectors.
According to still another aspect of the present invention, there is provided an electronic apparatus including: a processor; and a memory arranged to store computer executable instructions that, when executed, cause the processor to perform a method as described in any of the above.
According to a further aspect of the present invention there is provided a computer readable storage medium storing one or more programs which when executed by a processor implement a method as described in any of the above.
As can be seen from the foregoing, according to the technical solution of the present invention, after obtaining one or more initial parameters of a configuration file to be written, the writing is not directly performed, but one or more initial parameters are encapsulated into a data object of a specified type, then the configuration parameters are generated according to the data object, and finally the generated configuration parameters are written into the configuration file. According to the technical scheme, parameters written into the configuration file are not limited to few types such as integer, character and the like, the parameter types are widened, namely the configuration file can play a larger purpose when software runs, reading and writing are more convenient, and efficiency is higher.
The foregoing description is only an overview of the present invention, and is intended to be implemented in accordance with the teachings of the present invention in order that the same may be more clearly understood and to make the same and other objects, features and advantages of the present invention more readily apparent.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to designate like parts throughout the figures. In the drawings:
FIG. 1 is a flow diagram of a method of processing a configuration file according to one embodiment of the invention;
FIG. 2 shows a schematic diagram of a configuration file processing device according to an embodiment of the present invention;
FIG. 3 shows a schematic diagram of an electronic device according to one embodiment of the invention;
fig. 4 illustrates a schematic structure of a computer-readable storage medium according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
Fig. 1 shows a flow diagram of a method for processing a configuration file according to an embodiment of the invention. As shown in fig. 1, the method includes:
step S110, one or more initial parameters of the configuration file to be written are obtained.
For example, the configuration file of a Windows platform is typically a file in the.ini format, and the configuration file of software is often named config. Configuration parameters corresponding to various functions of the software are typically saved in a configuration file, such as width=720 (page width is 720 pixels), userid=abc (user identifier is ABC), and so on. When the software needs to use the configuration parameters, the software can read the corresponding configuration parameters from the configuration file through commands such as get and the like.
In this embodiment, the parameters to be used and written are not stored in the configuration file in a plaintext manner, and a certain process is required. The parameter to be written is therefore referred to as the initial parameter.
Step S120 encapsulates one or more initial parameters into a data object of a specified type.
Step S130, generating configuration parameters according to the data object.
After the two steps of processing, the configuration parameters converted according to the initial parameters are obtained and then written into the configuration file.
Step S140, the generated configuration parameters are written into the configuration file.
It can be seen that, in the method shown in fig. 1, after obtaining one or more initial parameters of the configuration file to be written, the writing is not directly performed, but the one or more initial parameters are encapsulated into a data object of a specified type, then the configuration parameters are generated according to the data object, and finally the generated configuration parameters are written into the configuration file. According to the technical scheme, parameters written into the configuration file are not limited to few types such as integer, character and the like, the parameter types are widened, namely the configuration file can play a larger purpose when software runs, reading and writing are more convenient, and efficiency is higher.
In one embodiment of the present invention, in the above method, encapsulating one or more initial parameters into a data object of a specified type includes: one or more initial parameters are packaged into a specified type of data object based on the variable parameter template.
The variable parameter template function provided by c++11 can support almost any type and number of parameters. The use of a variable parameter template in this embodiment greatly widens the types of parameters supported by the configuration file. Thus, whether several parameters are written and the types of the parameters are the same or not, the parameters can be packaged in a mode based on a variable parameter template to obtain a data object with a specified type.
Specifically, in one embodiment of the present invention, in the above method, encapsulating one or more initial parameters into a specified type of data object based on a variable parameter template includes: a tuple is created with the parameter type of the one or more initial parameters, and the one or more initial parameters are written to the tuple.
This embodiment is implemented using tuples (tuple). For example, std:: complete is used for encapsulation. Thus, regardless of the integer parameters such as 1, 2, the character type parameters abc, def that are currently available, they can be packaged into a tuple.
In one embodiment of the present invention, in the method, generating the configuration parameter according to the data object includes: serializing the data object into binary data; the binary data is converted into a character string in a specified format as a configuration parameter.
In this embodiment, considering the compatibility between the data object and the format of the commonly used configuration file, ini, the data object is further processed, i.e. binary serialized, and the obtained binary data is converted into a character string, and then written into the configuration file, and when the configuration file is opened, the parameters such as actual 1, 2 and the like are not seen, but a string of character strings, for example userid=432 e3de21de2112e1e323421e.
In one embodiment of the present invention, in the above method, serializing the data object into binary data includes: the data objects are serialized into binary data according to a preset method, and the preset method is realized according to a variable parameter template.
Considering that the data objects are implemented according to a variable parameter template, in this embodiment, the variable parameter template is also used in binary serialization, and serialization is implemented according to the parameter type.
In one embodiment of the present invention, in the above method, converting binary data into a character string in a specified format includes, as configuration parameters: and performing base64 coding on the binary data to obtain a corresponding base64 character string.
In the memory, the direct transfer of binary data can be more efficient than the string, but considering that the scenario of the present invention is the processing of the configuration file, the binary data needs to be converted to obtain the string. In this embodiment, a base64 encoding format is used, where base64 is a method for representing binary data based on 64 printable characters, so that parameters in a configuration file are tidy and traceable.
In one embodiment of the present invention, the method further comprises: reading the designated configuration parameters from the configuration file according to the parameters to be used; converting the configuration parameters into binary data, and checking the binary data according to the parameter types of the parameters to be used; after the verification is passed, the binary data is converted into usable parameters.
The previous embodiments give examples of parameters being written into the configuration file, and in this embodiment it is further described how to use the parameters in the configuration file. It is conceivable that the process of writing is inverted, i.e., a process of restoring the configuration parameters to the usable parameters is obtained, and therefore, although not described in detail in the present embodiment, it should be understood that the manner of using the variable parameter template or the like in the foregoing embodiment is also applicable correspondingly in the present embodiment.
It is emphasized here that the parameter is written without consideration of the verification, whereas the verification is necessary when using the parameter. For example, the type of parameter corresponding to the resolution needs to be integer, reading the character type parameter may be erroneous, and we cannot determine whether the read parameter is integer (because the configuration file is easily modified). Thus, after obtaining the binary data, a check is required, which can be made here according to the type of available parameters to be used.
In one embodiment of the present invention, in the above method, the type of the initial parameter includes one or more of the following: trivial types, structures, vectors.
Trivial types refer to the types that are more commonly used in profiles of integer, character type, etc., and often do not support structures (especially custom structures), vector (sequential containers encapsulating arrays of dynamic sizes) in the prior art. For example, the RECT can store parameters appearing in pairs, but in the prior art, only the parameters contained in the RECT can be written one by one when the RECT is written in the configuration file, so that the 'pairs' are difficult to embody in the configuration file, errors are easy to occur, and the read-write is very inconvenient, and according to the embodiment, the parameters contained in the RECT can be packaged as a whole into a data object.
Fig. 2 shows a schematic structural diagram of a configuration file processing device according to an embodiment of the present invention. As shown in fig. 2, the configuration file processing apparatus 200 includes:
the obtaining unit 210 is adapted to obtain one or more initial parameters of the configuration file to be written.
For example, the configuration file of a Windows platform is typically a file in the.ini format, and the configuration file of software is often named config. Configuration parameters corresponding to various functions of the software are typically saved in a configuration file, such as width=720 (page width is 720 pixels), userid=abc (user identifier is ABC), and so on. When the software needs to use the configuration parameters, the software can read the corresponding configuration parameters from the configuration file through commands such as get and the like.
In this embodiment, the parameters to be used and written are not stored in the configuration file in a plaintext manner, and a certain process is required. The parameter to be written is therefore referred to as the initial parameter.
The encapsulation unit 220 is adapted to encapsulate one or more initial parameters into a data object of a specified type.
The generating unit 230 is adapted to generate configuration parameters from the data objects.
After the processing of the two units, the configuration parameters converted according to the initial parameters are obtained and then written into the configuration file.
The writing unit 240 is adapted to write the generated configuration parameters into the configuration file.
It can be seen that, in the device shown in fig. 2, after obtaining one or more initial parameters of the configuration file to be written, through the mutual cooperation of the units, the writing is not directly performed, but the one or more initial parameters are packaged into a data object of a specified type, then the configuration parameters are generated according to the data object, and finally the generated configuration parameters are written into the configuration file. According to the technical scheme, parameters written into the configuration file are not limited to few types such as integer, character and the like, the parameter types are widened, namely the configuration file can play a larger purpose when software runs, reading and writing are more convenient, and efficiency is higher.
In an embodiment of the present invention, in the above-described apparatus, the encapsulation unit 220 is adapted to encapsulate one or more initial parameters into a data object of a specified type based on a variable parameter template.
The variable parameter template function provided by c++11 can support almost any type and number of parameters. The use of a variable parameter template in this embodiment greatly widens the types of parameters supported by the configuration file. Thus, whether several parameters are written and the types of the parameters are the same or not, the parameters can be packaged in a mode based on a variable parameter template to obtain a data object with a specified type.
Specifically, in one embodiment of the present invention, in the above-described apparatus, the encapsulation unit 220 is adapted to create a tuple according to the parameter type of the one or more initial parameters, and write the one or more initial parameters to the tuple.
This embodiment is implemented using tuples (tuple). For example, std:: complete is used for encapsulation. Thus, regardless of the integer parameters such as 1, 2, the character type parameters abc, def that are currently available, they can be packaged into a tuple.
In an embodiment of the present invention, in the above apparatus, the generating unit 230 is adapted to serialize the data object into binary data; the binary data is converted into a character string in a specified format as a configuration parameter.
In this embodiment, considering the compatibility between the data object and the format of the commonly used configuration file, ini, the data object is further processed, i.e. binary serialized, and the obtained binary data is converted into a character string, and then written into the configuration file, and when the configuration file is opened, the parameters such as actual 1, 2 and the like are not seen, but a string of character strings, for example userid=432 e3de21de2112e1e323421e.
In an embodiment of the present invention, in the above apparatus, the generating unit 230 is adapted to serialize the data object into binary data according to a preset method, where the preset method is implemented according to a variable parameter template.
Considering that the data objects are implemented according to a variable parameter template, in this embodiment, the variable parameter template is also used in binary serialization, and serialization is implemented according to the parameter type.
In an embodiment of the present invention, in the foregoing apparatus, the generating unit 230 is adapted to perform base64 encoding on binary data to obtain a corresponding base64 string.
In the memory, the direct transfer of binary data can be more efficient than the string, but considering that the scenario of the present invention is the processing of the configuration file, the binary data needs to be converted to obtain the string. In this embodiment, a base64 encoding format is used, where base64 is a method for representing binary data based on 64 printable characters, so that parameters in a configuration file are tidy and traceable.
In one embodiment of the present invention, the apparatus further comprises: the reading unit is suitable for reading the appointed configuration parameters from the configuration file according to the parameters to be used; the parameter conversion unit is suitable for converting the configuration parameters into binary data, and checking the binary data according to the parameter type of the parameters to be used; after the verification is passed, the binary data is converted into usable parameters.
The previous embodiments give examples of parameters being written into the configuration file, and in this embodiment it is further described how to use the parameters in the configuration file. It is conceivable that the process of writing is inverted, i.e., a process of restoring the configuration parameters to the usable parameters is obtained, and therefore, although not described in detail in the present embodiment, it should be understood that the manner of using the variable parameter template or the like in the foregoing embodiment is also applicable correspondingly in the present embodiment.
It is emphasized here that the parameter is written without consideration of the verification, whereas the verification is necessary when using the parameter. For example, the type of parameter corresponding to the resolution needs to be integer, reading the character type parameter may be erroneous, and we cannot determine whether the read parameter is integer (because the configuration file is easily modified). Thus, after obtaining the binary data, a check is required, which can be made here according to the type of available parameters to be used.
In one embodiment of the present invention, in the above apparatus, the type of the initial parameter includes one or more of the following: trivial types, structures, vectors.
Trivial types refer to the types that are more commonly used in profiles of integer, character type, etc., and often do not support structures (especially custom structures), vector (sequential containers encapsulating arrays of dynamic sizes) in the prior art. For example, the RECT can store parameters appearing in pairs, but in the prior art, only the parameters contained in the RECT can be written one by one when the RECT is written in the configuration file, so that the 'pairs' are difficult to embody in the configuration file, errors are easy to occur, and the read-write is very inconvenient, and according to the embodiment, the parameters contained in the RECT can be packaged as a whole into a data object.
In summary, according to the technical scheme of the present invention, after one or more initial parameters of a configuration file to be written are obtained, the writing is not directly performed, but the one or more initial parameters are packaged into a data object of a specified type, then the configuration parameters are generated according to the data object, and finally the generated configuration parameters are written into the configuration file. According to the technical scheme, parameters written into the configuration file are not limited to few types such as integer, character and the like, the parameter types are widened, namely the configuration file can play a larger purpose when software runs, reading and writing are more convenient, and efficiency is higher.
It should be noted that:
the algorithms and displays presented herein are not inherently related to any particular computer, virtual machine, or other apparatus. Various general purpose devices may also be used with the teachings herein. The required structure for the construction of such devices is apparent from the description above. In addition, the present invention is not directed to any particular programming language. It will be appreciated that the teachings of the present invention described herein may be implemented in a variety of programming languages, and the above description of specific languages is provided for disclosure of enablement and best mode of the present invention.
In the description provided herein, numerous specific details are set forth. However, it is understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be construed as reflecting the intention that: i.e., the claimed invention requires more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of this invention.
Those skilled in the art will appreciate that the modules in the apparatus of the embodiments may be adaptively changed and disposed in one or more apparatuses different from the embodiments. The modules or units or components of the embodiments may be combined into one module or unit or component and, furthermore, they may be divided into a plurality of sub-modules or sub-units or sub-components. Any combination of all features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or units of any method or apparatus so disclosed, may be used in combination, except insofar as at least some of such features and/or processes or units are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings), may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
Furthermore, those skilled in the art will appreciate that while some embodiments described herein include some features but not others included in other embodiments, combinations of features of different embodiments are meant to be within the scope of the invention and form different embodiments. For example, in the following claims, any of the claimed embodiments can be used in any combination.
Various component embodiments of the invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. Those skilled in the art will appreciate that some or all of the functions of some or all of the components in a profile processing apparatus according to embodiments of the present invention may be implemented in practice using a microprocessor or Digital Signal Processor (DSP). The present invention can also be implemented as an apparatus or device program (e.g., a computer program and a computer program product) for performing a portion or all of the methods described herein. Such a program embodying the present invention may be stored on a computer readable medium, or may have the form of one or more signals. Such signals may be downloaded from an internet website, provided on a carrier signal, or provided in any other form.
For example, fig. 3 shows a schematic structural diagram of an electronic device according to an embodiment of the present invention. The electronic device comprises a processor 310 and a memory 320 arranged to store computer executable instructions (computer readable program code). The memory 320 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read only memory), an EPROM, a hard disk, or a ROM. The memory 320 has a memory space 330 storing computer readable program code 331 for performing any of the method steps described above. For example, the memory space 330 for storing computer readable program code may include respective computer readable program code 331 for implementing the respective steps in the above method, respectively. The computer readable program code 331 can be read from or written to one or more computer program products. These computer program products comprise a program code carrier such as a hard disk, a Compact Disc (CD), a memory card or a floppy disk. Such a computer program product is typically a computer readable storage medium as described for example in fig. 4. Fig. 4 illustrates a schematic structure of a computer-readable storage medium according to an embodiment of the present invention. The computer readable storage medium 400 stores computer readable program code 331 for performing the steps of the method according to the invention, which may be read by the processor 310 of the electronic device 300, which computer readable program code 331, when executed by the electronic device 300, causes the electronic device 300 to perform the steps of the method described above, in particular the computer readable program code 331 stored by the computer readable storage medium may perform the method shown in any of the embodiments described above. The computer readable program code 331 may be compressed in a suitable form.
It should be noted that the above-mentioned embodiments illustrate rather than limit the invention, and that those skilled in the art will be able to design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention may be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by one and the same item of hardware. The use of the words first, second, third, etc. do not denote any order. These words may be interpreted as names.
The invention discloses a method for processing a configuration file, which comprises the following steps:
acquiring one or more initial parameters of a configuration file to be written;
encapsulating the one or more initial parameters into a data object of a specified type;
generating configuration parameters according to the data objects;
and writing the generated configuration parameters into the configuration file.
A2. the method of A1, wherein said encapsulating the one or more initial parameters into a data object of a specified type comprises:
the one or more initial parameters are packaged into a data object of a specified type based on a variable parameter template.
A3, the method of A2, wherein the encapsulating the one or more initial parameters into a specified type of data object based on the variable parameter template comprises:
creating a tuple according to the parameter type of the one or more initial parameters, and writing the one or more initial parameters into the tuple.
A4. the method of A1, wherein the generating configuration parameters from the data objects includes:
serializing the data object into binary data;
and converting the binary data into a character string with a specified format as a configuration parameter.
A5. the method of A4, wherein the serializing the data object into binary data comprises:
the data objects are serialized into binary data according to a preset method, and the preset method is realized according to a variable parameter template.
A6. the method of A4, wherein the converting the binary data into a character string in a specified format includes, as configuration parameters:
and performing base64 coding on the binary data to obtain a corresponding base64 character string.
The method of A7, A4, wherein the method further comprises:
reading the designated configuration parameters from the configuration file according to the parameters to be used;
converting the configuration parameters into binary data, and checking the binary data according to the parameter type of the parameters to be used;
after verification passes, the binary data is converted into usable parameters.
A8, the method of any of A1-A7, wherein the type of initial parameters comprises one or more of: trivial types, structures, vectors.
The invention also discloses a B9 and a processing device of the configuration file, which comprises the following steps:
the acquisition unit is suitable for acquiring one or more initial parameters of the configuration file to be written;
a packaging unit adapted to package the one or more initial parameters into a data object of a specified type;
a generating unit adapted to generate configuration parameters from the data objects;
and the writing unit is suitable for writing the generated configuration parameters into the configuration file.
B10, the device of B9, wherein,
the packaging unit is adapted to package the one or more initial parameters into a data object of a specified type based on a variable parameter template.
B11, the device of B10, wherein,
the packaging unit is adapted to create a tuple according to the parameter type of the one or more initial parameters, and to write the one or more initial parameters to the tuple.
B12, the device of B9, wherein,
the generating unit is suitable for serializing the data object into binary data; and converting the binary data into a character string with a specified format as a configuration parameter.
B13, the device of B12, wherein,
the generation unit is suitable for serializing the data object into binary data according to a preset method, and the preset method is realized according to a variable parameter template.
The apparatus of B12, wherein,
the generating unit is suitable for performing base64 coding on the binary data to obtain a corresponding base64 character string.
B15, the apparatus of B12, wherein the apparatus further comprises:
the reading unit is suitable for reading the designated configuration parameters from the configuration file according to the parameters to be used;
the parameter conversion unit is suitable for converting the configuration parameters into binary data, and checking the binary data according to the parameter type of the parameters to be used; after verification passes, the binary data is converted into usable parameters.
B16, the apparatus of any one of B9-B15, wherein the type of initial parameter comprises one or more of: trivial types, structures, vectors.
The invention also discloses C17, an electronic device, wherein the electronic device comprises: a processor; and a memory arranged to store computer executable instructions that, when executed, cause the processor to perform the method of any of A1-A8.
The invention also discloses D18, a computer readable storage medium, wherein the computer readable storage medium stores one or more programs, which when executed by a processor, implement the method of any of A1-A8.

Claims (16)

1. A method for processing a configuration file, comprising:
acquiring one or more initial parameters of a configuration file to be written;
encapsulating the one or more initial parameters into a data object of a specified type, comprising: encapsulating the one or more initial parameters into a specified type of data object based on a variable parameter template;
generating configuration parameters according to the data objects;
and writing the generated configuration parameters into the configuration file.
2. The method of claim 1, wherein the encapsulating the one or more initial parameters into a specified type of data object based on a variable parameter template comprises:
creating a tuple according to the parameter type of the one or more initial parameters, and writing the one or more initial parameters into the tuple.
3. The method of claim 1, wherein the generating configuration parameters from the data objects comprises:
serializing the data object into binary data;
and converting the binary data into a character string with a specified format as a configuration parameter.
4. The method of claim 3, wherein the serializing the data object into binary data comprises:
the data objects are serialized into binary data according to a preset method, and the preset method is realized according to a variable parameter template.
5. The method of claim 3, wherein the converting the binary data into a string of a specified format as a configuration parameter comprises:
and performing base64 coding on the binary data to obtain a corresponding base64 character string.
6. A method as claimed in claim 3, wherein the method further comprises:
reading the designated configuration parameters from the configuration file according to the parameters to be used;
converting the configuration parameters into binary data, and checking the binary data according to the parameter type of the parameters to be used;
after verification passes, the binary data is converted into usable parameters.
7. The method of any of claims 1-6, wherein the type of initial parameter comprises one or more of: trivial types, structures, vectors.
8. A device for processing a configuration file, comprising:
the acquisition unit is suitable for acquiring one or more initial parameters of the configuration file to be written;
a packaging unit adapted to package the one or more initial parameters into a data object of a specified type;
the packaging unit is suitable for packaging the one or more initial parameters into a data object of a specified type based on a variable parameter template;
a generating unit adapted to generate configuration parameters from the data objects;
and the writing unit is suitable for writing the generated configuration parameters into the configuration file.
9. The apparatus of claim 8, wherein,
the encapsulation unit is adapted to create a tuple of the parameter type of the one or more initial parameters, and to write the one or more initial parameters into the tuple.
10. The apparatus of claim 8, wherein,
the generating unit is suitable for serializing the data object into binary data; and converting the binary data into a character string with a specified format as a configuration parameter.
11. The apparatus of claim 10, wherein,
the generation unit is suitable for serializing the data object into binary data according to a preset method, and the preset method is realized according to a variable parameter template.
12. The apparatus of claim 10, wherein,
the generating unit is suitable for performing base64 coding on the binary data to obtain a corresponding base64 character string.
13. The apparatus of claim 10, wherein the apparatus further comprises:
the reading unit is suitable for reading the designated configuration parameters from the configuration file according to the parameters to be used;
the parameter conversion unit is suitable for converting the configuration parameters into binary data, and checking the binary data according to the parameter type of the parameters to be used; after verification passes, the binary data is converted into usable parameters.
14. The apparatus of any of claims 8-13, wherein the type of initial parameter comprises one or more of: trivial types, structures, vectors.
15. An electronic device, wherein the electronic device comprises: a processor; and a memory arranged to store computer executable instructions which, when executed, cause the processor to perform the method of any of claims 1-7.
16. A computer readable storage medium, wherein the computer readable storage medium stores one or more programs, which when executed by a processor, implement the method of any of claims 1-7.
CN201811102870.4A 2018-09-20 2018-09-20 Processing method and device for configuration file Active CN109144565B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811102870.4A CN109144565B (en) 2018-09-20 2018-09-20 Processing method and device for configuration file

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811102870.4A CN109144565B (en) 2018-09-20 2018-09-20 Processing method and device for configuration file

Publications (2)

Publication Number Publication Date
CN109144565A CN109144565A (en) 2019-01-04
CN109144565B true CN109144565B (en) 2023-05-23

Family

ID=64822979

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811102870.4A Active CN109144565B (en) 2018-09-20 2018-09-20 Processing method and device for configuration file

Country Status (1)

Country Link
CN (1) CN109144565B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7010615B1 (en) * 1999-11-12 2006-03-07 Fujitsu Limited Communication network management system for automatically converting action parameters to network technology dependent parameters using a selected conversion rule conforming to a network technology
CN102566984A (en) * 2010-12-07 2012-07-11 北大方正集团有限公司 Method and device for configuring parameters
CN103677790A (en) * 2012-09-26 2014-03-26 腾讯科技(深圳)有限公司 Software function modifying method
CN104243202A (en) * 2014-08-25 2014-12-24 中兴通讯股份有限公司 Data processing method and device of parameter configuration and parameter configuration method and device
CN104737123A (en) * 2012-10-19 2015-06-24 哈利伯顿能源服务公司 Self-defining configuration apparatus, methods, and systems

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7010615B1 (en) * 1999-11-12 2006-03-07 Fujitsu Limited Communication network management system for automatically converting action parameters to network technology dependent parameters using a selected conversion rule conforming to a network technology
CN102566984A (en) * 2010-12-07 2012-07-11 北大方正集团有限公司 Method and device for configuring parameters
CN103677790A (en) * 2012-09-26 2014-03-26 腾讯科技(深圳)有限公司 Software function modifying method
CN104737123A (en) * 2012-10-19 2015-06-24 哈利伯顿能源服务公司 Self-defining configuration apparatus, methods, and systems
CN104243202A (en) * 2014-08-25 2014-12-24 中兴通讯股份有限公司 Data processing method and device of parameter configuration and parameter configuration method and device

Also Published As

Publication number Publication date
CN109144565A (en) 2019-01-04

Similar Documents

Publication Publication Date Title
TWI728266B (en) Two-dimensional bar code generation, business processing method, device and equipment, and two-dimensional bar code
JP5744187B2 (en) Schema contract for data integration
JP5197688B2 (en) Integrated environment generator
US20130125092A1 (en) Generating deployable code from simulation models
CN110069259B (en) ID L file-based parsing method and device, electronic equipment and storage medium
CN103425632A (en) Serializing method, device and processor
CN106202158A (en) The using method of a kind of graphics file format and device
CN111209736A (en) Text file analysis method and device, computer equipment and storage medium
US10496423B2 (en) Method for opening up data and functions of terminal application based on reconstruction technology
CN113885935A (en) Resource packaging method and device, electronic equipment and computer readable storage medium
CN107092474B (en) Program development method, ETL processing method and device
CN109144565B (en) Processing method and device for configuration file
CN109766123B (en) Application program packaging method and device
CN113032202A (en) Chip verification method, system, device, computer equipment and storage medium
CN110795165A (en) Neural network model data loading method and related device
JP6703114B2 (en) Application program execution method and apparatus
CN114117992A (en) Serialization and deserialization method and device and electronic equipment
CN111078529B (en) Client writing module testing method and device and electronic equipment
CN111274120A (en) Interface document verification method and device
CN109584091B (en) Generation method and device of insurance image file
US10042612B2 (en) Software development support apparatus, software development support method, and computer readable medium
CN102360381B (en) Device and method for performing lossless compression on embedded program
CN105045893B (en) Method and device for adapting pictures in webpage
CN109324838B (en) Execution method and execution device of single chip microcomputer program and terminal
CN113050921A (en) Webpage conversion method, device, storage medium and computer equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20230508

Address after: Room 03, 2nd Floor, Building A, No. 20 Haitai Avenue, Huayuan Industrial Zone (Huanwai), Binhai New Area, Tianjin, 300450

Applicant after: 3600 Technology Group Co.,Ltd.

Address before: 100088 room 112, block D, 28 new street, new street, Xicheng District, Beijing (Desheng Park)

Applicant before: BEIJING QIHOO TECHNOLOGY Co.,Ltd.

GR01 Patent grant
GR01 Patent grant