[go: up one dir, main page]

CN106484427A - A kind of generation method of code file and device - Google Patents

A kind of generation method of code file and device Download PDF

Info

Publication number
CN106484427A
CN106484427A CN201610917151.2A CN201610917151A CN106484427A CN 106484427 A CN106484427 A CN 106484427A CN 201610917151 A CN201610917151 A CN 201610917151A CN 106484427 A CN106484427 A CN 106484427A
Authority
CN
China
Prior art keywords
code
file
sentence
default
statement
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.)
Pending
Application number
CN201610917151.2A
Other languages
Chinese (zh)
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.)
Fujian Cnfol Information Technology Co Ltd
Original Assignee
Fujian Cnfol Information Technology 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 Fujian Cnfol Information Technology Co Ltd filed Critical Fujian Cnfol Information Technology Co Ltd
Priority to CN201610917151.2A priority Critical patent/CN106484427A/en
Publication of CN106484427A publication Critical patent/CN106484427A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

Embodiments provide a kind of generation method of code file and device, methods described includes:Obtain and there is admittedly substantial first default file and second file with changing content;By default programming function, read the intrinsic content of described first default file line by line, determine the first code sentence reaching default sentence condition;According to described first code sentence, from described second file, search first code definition corresponding with described first code sentence, and define corresponding first code section backup in the 3rd file by the definition of described first code and with described first code;After the completion of all described first codes being defined and backing up in described 3rd file with the described first code corresponding code segment of definition, the final code segment in described 3rd file is generated code file.The application embodiment of the present invention is capable of automatically quickly generating code file, improves the purpose of work efficiency.

Description

A kind of generation method of code file and device
Technical field
The present invention relates to computer software programming field, more particularly to a kind of generation method of code file and device.
Background technology
With high speed information development, the written in code amount of programmer is increasing, and code redundancies are high, repeat to write phase Same simple code leads to programmer's inefficiency, and the formation speed of code file is low.
In real work, in order to avoid identical simple code carries out repeating to write every time, programmer would generally be In existing code file, the code file identical code searching and write, and by identical code copies to the generation write In code file, generate code file.But manually generated code file speed is low, inefficiency.
Content of the invention
The purpose of the embodiment of the present invention is to provide a kind of generation method of code file and device, automatically quick to realize Generate code file, improve the purpose of work efficiency.Concrete technical scheme is as follows:
The embodiment of the invention discloses a kind of generation method of code file, including:
Obtain and there is admittedly substantial first default file and second file with changing content, wherein, described first The intrinsic content of default file at least includes:Multiple code statements to be found, the changing content of described second file at least wraps Include:Code definition corresponding with the plurality of code statement to be found code segment corresponding with described code definition;
By default programming function, read the intrinsic content of described first default file line by line, determine and reach default sentence The first code sentence of condition;
According to described first code sentence, from described second file, search corresponding with described first code sentence the One code definition, and the definition of described first code and first code section corresponding with the definition of described first code are backed up the 3rd In file;
All described first codes are defined and defines corresponding first code section the described 3rd with described first code After the completion of backing up in file, the final code segment in described 3rd file is generated code file, wherein, described final code segment Including:First code section.
Preferably, described program function by default, read the intrinsic content of described first default file line by line, determination reaches Arrive the first code sentence of default sentence condition, including:
By described default programming function, the intrinsic content of described first default file is read line by line, read Meeting described default sentence condition to described solid substantial multiple code statements is that line character length is less than preset characters length And code statement be macrodefinition sentence when, the code statement being up to described default sentence condition is defined as described first code language Sentence;And/or
By described default programming function, the intrinsic content of described first default file is read line by line, read Meeting described default sentence condition to described solid substantial multiple code statements is that line character length is less than described preset characters When length and code statement are function interface sentence, the code statement being up to described default sentence condition is defined as described first Code statement;And/or
By described default programming function, the intrinsic content of described first default file is read line by line, read Meeting described default sentence condition to described solid substantial multiple code statements is that line character length is less than described preset characters When length and code statement are DPS, the code statement being up to described default sentence condition is defined as described first Code statement;And/or
By described default programming function, the intrinsic content of described first default file is read line by line, read Meeting described default sentence condition to described solid substantial multiple code statements is that line character length is less than described preset characters When length and code statement are front end alternate statement, the code statement being up to described default sentence condition is defined as described first Code statement.
Preferably, described first code is defined as:In described second file, with code statement in described first code sentence Identical, and the code statement occurring first;
Described first code section is:In described second file, the code segment that described first code definition is located.
Preferably, described define all described first codes and define corresponding first code section with described first code After the completion of described 3rd file backs up, the final code segment in described 3rd file is generated code file, wraps further Include:
Read all intrinsic content finishing in described first default file, and the priority according to multiple default sentence conditions Sequentially, determine the first code sentence reaching described default sentence condition successively, and in described second file, search and finish institute The corresponding first code of described first code sentence is had to define;Wherein, the multiple default sentence condition of sequencing is followed successively by:OK Character length be less than described preset characters length and code statement be described macrodefinition sentence, line character length be less than described default Character length and code statement are described function interface sentence, line character length is less than described preset characters length and code statement For described DPS, line character length is less than described preset characters length and code statement is that described front end interacts language Sentence;
All described first codes are defined and defines corresponding first code section according to described pre- with described first code If after the completion of the order of sentence condition backs up in described 3rd file, the final code segment in described 3rd file is generated generation Code file;Wherein, described final code segment includes:First code section.
The embodiment of the invention also discloses a kind of generating means of code file, including:
File acquisition module, for obtaining the second literary composition having admittedly substantial first default file and having changing content Part, wherein, the intrinsic content of described first default file at least includes:Multiple code statements to be found, described second file Changing content at least include:Code definition corresponding with the plurality of code statement to be found and described code definition pair The code segment answered;
First code sentence determining module, for by default programming function, reading described first default file line by line Intrinsic content, determines the first code sentence reaching default sentence condition;
Backup module, for according to described first code sentence, from described second file, searches and described first code The corresponding first code of sentence defines, and defines corresponding first code by the definition of described first code and with described first code Section backup is in the 3rd file;
Code file generation module, for defining all described first codes and defining with described first code corresponding After the completion of first code section backs up in described 3rd file, the final code segment in described 3rd file is generated code literary composition Part, wherein, described final code segment includes:First code section.
Preferably, described first code sentence determining module, including:
Macrodefinition first code sentence determination sub-module, for by described default programming function, default to described first The intrinsic content of file is read line by line, meets described default sentence reading described solid substantial multiple code statements Condition is, line character length is less than preset characters length and when code statement is macrodefinition sentence, is up to described default sentence The code statement of condition is defined as described first code sentence;And/or
Function interface first code sentence determination sub-module, for by described default programming function, pre- to described first If the intrinsic content of file is read line by line, meet described default language reading described solid substantial multiple code statements Sentence condition is, line character length is less than described preset characters length and code statement when being function interface sentence, is up to described The code statement of default sentence condition is defined as described first code sentence;And/or
Data processing first code sentence determination sub-module, for by described default programming function, pre- to described first If the intrinsic content of file is read line by line, meet described default language reading described solid substantial multiple code statements Sentence condition is, line character length is less than described preset characters length and code statement when being DPS, is up to described The code statement of default sentence condition is defined as described first code sentence;And/or
Front end interacts first code sentence determination sub-module, for by described default programming function, pre- to described first If the intrinsic content of file is read line by line, meet described default language reading described solid substantial multiple code statements Sentence condition is, line character length is less than described preset characters length and code statement when being front end alternate statement, is up to described The code statement of default sentence condition is defined as described first code sentence.
Preferably, described first code is defined as:In described second file, with code statement in described first code sentence Identical, and the code statement occurring first;
Described first code section is:In described second file, the code segment that described first code definition is located.
Preferably, described code file generation module, further include:
Order reads searches submodule, for reading all intrinsic content finishing in described first default file, and presses According to the sequencing of multiple default sentence conditions, determine the first code sentence reaching described default sentence condition successively, and In described second file, search and finish the definition of all described first code sentences corresponding first code;Wherein, sequencing Multiple default sentence conditions are followed successively by:Line character length is less than described preset characters length and code statement is described macrodefinition language Sentence, line character length are less than that described preset characters length and code statement are described function interface sentence, line character length is less than Described preset characters length and code statement are described DPS, line character length is less than described preset characters length and Code statement is described front end alternate statement;
Code file generates submodule, for defining all described first codes and defining with described first code corresponding First code section back up in described 3rd file according to the order of described default sentence condition after the completion of, by the described 3rd literary composition Final code segment in part generates code file;Wherein, described final code segment includes:First code section.
As seen from the above technical solutions, in embodiments of the present invention, obtain and there is admittedly substantial first default file And there is the second file of changing content.Read to be found in described first default file line by line using default programming function Code statement.When the code statement reading meets default sentence condition, it is up to the code language of described default sentence condition Sentence is defined as first code sentence.According to described first code sentence, the second file finds described first code sentence The definition of corresponding first code, and the definition of described first code and described first code are defined corresponding code segment backup the In three files.Search and complete all the elements of described first default file, and in the second file, all reach described default language The first code sentence corresponding first code definition of sentence condition, and the described first code corresponding code segment of definition is described When backup completes in 3rd file, final code segment in the 3rd file is generated code file.The embodiment of the present invention is passed through pre- If programming function searches the first default file and the second file automatically, can automatically obtain the code language being frequently necessary to repeat to write The code segment of sentence, quickly generates code file, it is possible to increase work efficiency automatically.Certainly, implement the present invention arbitrary product or Method must be not necessarily required to reach all the above advantage simultaneously.
Brief description
In order to be illustrated more clearly that the embodiment of the present invention or technical scheme of the prior art, below will be to embodiment or existing Have technology description in required use accompanying drawing be briefly described it should be apparent that, drawings in the following description be only this Some embodiments of invention, for those of ordinary skill in the art, on the premise of not paying creative work, acceptable Other accompanying drawings are obtained according to these accompanying drawings.
Fig. 1 is a kind of schematic flow sheet of the generation method of code file of the embodiment of the present invention;
Fig. 2 is another kind of schematic flow sheet of the generation method of code file of the embodiment of the present invention;
Fig. 3 is another schematic flow sheet of the generation method of code file of the embodiment of the present invention;
Fig. 4 is the structural representation of the generating means of code file of the embodiment of the present invention.
Specific embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is carried out clear, complete Site preparation description is it is clear that described embodiment is only a part of embodiment of the present invention, rather than whole embodiments.It is based on Embodiment in the present invention, it is every other that those of ordinary skill in the art are obtained under the premise of not making creative work Embodiment, broadly falls into the scope of protection of the invention.
The embodiment of the invention discloses a kind of generation method of code file and device, can automatically quickly generate code literary composition Part, improves work efficiency.
First below a kind of generation method of code file provided in an embodiment of the present invention is introduced.
Programmer, in written in code work, in the face of being frequently necessary to the code statement repeating to write, takes artificial lookup side Formula, searches and is frequently necessary to the code statement identical code language repeating to write in existing one or more code files Sentence, the code segment that this identical code statement is located is copied in the file destination write.But manually search code statement, copy The workload of shellfish code segment is big, leads to the speed generating code file low, inefficiency.
The present invention passes through default programming function, and the code statement in the first default file obtaining is read line by line, When the code statement reading meets default sentence condition, determine that the code statement reaching default sentence condition is first code Sentence.Obtain the second file in search first code sentence corresponding first code definition, and by first code definition and Define corresponding first code section with first code to back up in the 3rd file.Until the code statement of the first default file reads Finish, the whole determination of first code sentence reaching default sentence condition finishes, and in the second file, first code sentence corresponds to First code definition and with first code define corresponding first code section all backed up in the 3rd file when, by the 3rd In file, all of code segment generates code file.
It is preset with the code statement being frequently necessary to repeat to write, by this in first default file and default sentence condition Bright, automatically search the first default file and the second file, the code statement being frequently necessary to repeat to write can be found corresponding Code segment, and automatic code generating file, the present invention can improve codelookup speed and work efficiency.And the code of the present invention The code statement that the generation method of file can be applied to multiple default sentence conditions does not have the field of mutual logic function relation The code statement of scape and multiple default sentence condition has the scene of mutual logic function relation, with each for being actually needed generation Plant code file, the code file generation method of the present invention can be widely applied for code programming field, has practicality.
Referring to Fig. 1, Fig. 1 is a kind of schematic flow sheet of the generation method of code file of the embodiment of the present invention, including such as Lower step:
Step 101, obtains and has admittedly substantial first default file and second file with changing content.
The template file that first default file generates according to the experience of writing in advance for programmer, this template file contains program Member is frequently necessary to the code statement repeating to write.
The intrinsic content of the first default file at least includes:Multiple code statements to be found, wherein, multiple to be found Code statement includes the code statement that programmer is frequently necessary to repeat to write.The intrinsic content of the first default file still means that, In code file generating process, the content of the first default file is constant.
Second file is one or more existing files to be found, and this file to be found contains programmer and is frequently necessary to weight The code statement write again and corresponding code segment.This file to be found can be understood as in existing artificial lookup mode, by journey The artificial code file searched of sequence person.
The changing content of the second file at least includes:Code definition corresponding with multiple code statements to be found and generation Code defines corresponding code segment.Wherein, code definition is in the second file, corresponding with the code statement in the first default file Code statement, the corresponding code segment of code definition is, the code segment that in the second file, code definition is located.The change of the second file Content still means that, in code file generating process, the second file can be one or more files, and the content of the second file can To change.
Collect in first default file and have programmer to be frequently necessary to the code statement repeating to write, using the first default file The search program person being capable of maximum magnitude as template file is frequently necessary to the code statement repeating to write, and in code file In the long process generating, according to the new code statement being frequently necessary to repeat to write continuously emerging, can be default to first The content of file is modified and is increased, and can improve constantly the scope of codelookup and search speed.
Step 102, by default programming function, reads the intrinsic content of the first default file, determination reaches default line by line The first code sentence of sentence condition.
Default programming function is the programming function being read code statement line by line.Default programming function at least includes storehouse letter Count getline (), built-in function getline () is:For reading the character of code statement in file line by line, when reading line feed Terminate when symbol or end mark to read, and the character reading is saved in the programming function in Computer Cache.Can carry out by The programming function of row reading code statement can serve as the default programming function of the embodiment of the present invention, and here does not repeat one by one.
Default sentence condition is preset in advance, the condition that code statement meets.Default sentence condition at least includes:Code The line character length range condition of sentence and the content conditions of code statement.
First code sentence is the code statement meeting default sentence condition in the first default file.
Read the code language multiple to be found in the intrinsic content of the first default file using default programming function line by line Sentence, takes code statement then to lead to the situation of codelookup mistake to occur it can be avoided that skip.
Determine that the first code sentence reaching default sentence condition is capable of determining that the code language being frequently necessary to repeat to write Sentence, so that the lookup of the second file afterwards is the code statement being frequently necessary to repeat to write for this carry out, Neng Gouti The specific aim of high codelookup and accuracy, and improve codelookup speed.
Step 103, according to first code sentence, from the second file, searches the first generation corresponding with first code sentence Code definition, and define corresponding first code section backup in the 3rd file by first code definition and with first code.
First code is defined as:In second file, and code statement identical in first code sentence, and occur first Code statement.
First code section is:In second file, the code segment that first code definition is located.
3rd file is the file destination needing to write.
In the second file, search first code corresponding with first code sentence definition, and first code is defined and Define corresponding first code section with first code to back up in the 3rd file, complete to being frequently necessary to the code language that repeats to write Sentence automatically write work, it is to avoid manually repeat to write and manually search, copy is frequently necessary to the code statement that repeats to write Code segment work, it is possible to increase work efficiency.
Step 104, defines corresponding first code Duan tri- file by the definition of all first codes and with first code After the completion of middle backup, the final code segment in the 3rd file is generated code file.
Repeat step 102, step 103, until the intrinsic content of the first default file all reads completing, reach default language All determination finishes the first code sentence of sentence condition, and in the second file, first code corresponding with first code sentence When definition, the corresponding first code section of first code definition all have backed up in the 3rd file.By in the 3rd file Whole code segment generates code file.Wherein, final code segment is all code segments in the 3rd file, and final code segment includes: First code section.
Code file is the final file destination needing to write.
Search the first default file and the second file by automatic, automated back-up is frequently necessary to the code statement repeating to write And the corresponding code segment of code statement, can automatically, quickly generate code file, improve work efficiency.
It can be seen that, method provided in an embodiment of the present invention, obtain and there is admittedly substantial first default file and there is change Second file of content, reads the code statement to be found in the first default file line by line using default programming function.Work as reading When the code statement got meets default sentence condition, the code statement being up to default sentence condition is defined as first code language Sentence.According to first code sentence, the second file finds the definition of first code sentence corresponding first code, and by first Code definition and first code define corresponding first code section and back up in the 3rd file.Search and complete the first default file All the elements, corresponding first code sentence all determines and completes, and in the second file, all reaches default sentence condition The corresponding first code of first code sentence defines, and the corresponding first code section of first code definition is standby in the 3rd file When part completes, the final code segment in the 3rd file is generated code file.The embodiment of the present invention passes through default programming function certainly Dynamic lookup the first default file and the second file, can obtain the code segment of the code statement being frequently necessary to repeat to write automatically, Automatically quickly generate code file, it is possible to increase work efficiency.
On the basis of Fig. 1, as the first preferred embodiment, the code statement for multiple default sentence conditions does not have There is the scene of mutual logic function relation.Referring to Fig. 2, Fig. 2 is the another of the generation method of code file of the embodiment of the present invention Plant schematic flow sheet.Comprise the steps:
Step 201, obtains and has admittedly substantial first default file and second file with changing content.
First default file, the intrinsic content of the first default file, the second file, the second file changing content no longer superfluous State.
The file format of the first default file and the second file is the file format supporting default programming function to read, file Form at least includes electronic file form and spreadsheet format, supports that the file format that default programming function reads can be made The first default file for the embodiment of the present invention and the file format of the second file, here does not repeat one by one.
Using multiple file formats supporting default programming function to read, the file format of the first default file can be expanded Scope, and the acquisition scope of the second file, then can improve the seeking scope of code and search speed, improve work efficiency.
Collect in first default file and have programmer to be frequently necessary to the code statement repeating to write, using the first default file The search program person being capable of maximum magnitude as template file is frequently necessary to the code statement repeating to write, and in code file In the long process generating, according to the new code statement being frequently necessary to repeat to write continuously emerging, can be default to first The content of file is modified and is increased, and can improve constantly the scope of codelookup and search speed.
Step 202, by default programming function, is read line by line to the intrinsic content of the first default file, is being read Meeting default sentence condition to solid substantial multiple code statements is that line character length is less than preset characters length and code language When sentence is for macrodefinition sentence, the code statement being up to default sentence condition is defined as first code sentence.Or
By default programming function, the intrinsic content of the first default file is read line by line, inherently interior reading The multiple code statements holding meet default sentence condition, and line character length is less than preset characters length and code statement is function During interface statement, the code statement being up to default sentence condition is defined as first code sentence.Or
By default programming function, the intrinsic content of the first default file is read line by line, inherently interior reading The multiple code statements holding meet default sentence condition, and line character length is less than preset characters length and code statement is data When processing sentence, the code statement being up to default sentence condition is defined as first code sentence.Or
By default programming function, the intrinsic content of the first default file is read line by line, inherently interior reading The multiple code statements holding meet default sentence condition, and line character length is less than preset characters length and code statement is front end During alternate statement, the code statement being up to default sentence condition is defined as first code sentence.Wherein, preset characters length is According to the character length of industrial requirement or the code statement of artificial setting, such as 20.
Macrodefinition sentence includes:Such as #define DATALENGTH 10.Function interface sentence at least includes:Case (num){case 1:break;default:break;}.DPS includes carrying out the difference of different pieces of information processing business Sentence.Front end alternate statement at least includes:RECV()、send().
Default programming function, default sentence condition, first code sentence repeat no more.
Read the code language multiple to be found in the intrinsic content of the first default file using default programming function line by line Sentence, takes code statement then to lead to the situation of codelookup mistake to occur it can be avoided that skip.Determine and reach default sentence The first code sentence of condition is capable of determining that the code statement being frequently necessary to repeat to write, so that the second file afterwards Lookup is that the code statement being frequently necessary to repeat to write for this is carried out, it is possible to increase the specific aim of codelookup and accurately Property, and improve codelookup speed.
The embodiment of the present invention can be directed to above-mentioned four kinds default sentence conditions, reads first line by line by default programming function Default file, determines four kinds of default sentence conditions corresponding first code sentence respectively.The targeted default sentence bar of the present invention Part is not limited to four kinds of default sentence conditions of above-described embodiment, carrying out in code file generating process using the inventive method, According to being actually needed, default sentence condition can be modified or increase.
Step 203, is that line character length is less than preset characters length and code statement is according to reaching default sentence condition The first code sentence of macrodefinition sentence, from the second file, searches the definition of first code sentence corresponding first code, and will First code definition and first code section corresponding with first code definition back up in the 3rd file.Wherein, macrodefinition sentence Corresponding first code section is used for defining agreement, reputable code function.Or
It is that line character length is less than preset characters length and code statement is function interface according to reaching default sentence condition Sentence, from the second file, searches the definition of first code sentence corresponding first code, and by first code definition and with first Code definition corresponding first code section backs up in the 3rd file.Wherein, function interface sentence corresponding first code section is used The memory interface being allocated by the different types of data that front end obtains in determination.Or
It is that line character length is less than preset characters length and code statement is data processing according to reaching default sentence condition Sentence, from the second file, searches the definition of first code sentence corresponding first code, and by first code definition and with first Code definition corresponding first code section backs up in the 3rd file.Wherein, DPS corresponding first code section is used Obtain data in backstage.Or
It is that line character length is less than preset characters length and code statement interacts for front end according to reaching default sentence condition Sentence, from the second file, searches the definition of first code sentence corresponding first code, and by first code definition and with first Code definition corresponding first code section backs up in the 3rd file.Wherein, after interaction corresponding first code section in front end is used for Platform feedback data is to front end.Wherein, front end at least includes webpage, backstage be computer server, data at least include numerical value, Field, video cartoon and or picture.
First code definition, first code section are and the 3rd file repeats no more.
The embodiment of the present invention can be directed to above-mentioned four kinds default sentence conditions, search four kinds respectively and preset in the second file First code definition corresponding to each self-corresponding first code sentence of sentence condition, and each self-corresponding first code is defined And define corresponding first code section backup in the 3rd file so that having one or more in the 3rd file with first code The corresponding first code section of default sentence condition.And the corresponding first code section of each default sentence condition is respectively provided with respective work( Energy.The code statement that the embodiment of the present invention is directed to multiple default sentence conditions does not have the scene of mutual logic function relation, can Using the basic skills generating as code file, it is widely used in code programming field.
In the second file, search first code corresponding with first code sentence definition, and first code is defined and Define corresponding first code section with first code to back up in the 3rd file, complete to being frequently necessary to the code language that repeats to write Sentence automatically write work, it is to avoid manually repeat to write and manually search, copy is frequently necessary to the code statement that repeats to write Code segment work, it is possible to increase work efficiency.
Step 204, repeat step 202, step 203, until reading all intrinsic content finishing in the first default file, Determine and finish the corresponding first code sentence of multiple default sentence conditions, and in the second file, search and finish all first generation Code sentence corresponding first code definition, and define corresponding first code section by the definition of all first codes and with first code After the completion of backing up in the 3rd file, the final code segment in the 3rd file is generated code file.Wherein, final code segment bag Include:First code section.Final code segment includes:
Line character length is less than preset characters length and code statement is corresponding for the default sentence condition of macrodefinition sentence First code sentence, in the second file, corresponding first code defines and defines corresponding first code section with first code. Or
Line character length is less than preset characters length and code statement corresponds to for the default sentence condition of function interface sentence First code sentence, corresponding first code definition and define corresponding first code with first code in the second file Section.Or
Line character length is less than preset characters length and code statement corresponds to for the default sentence condition of DPS First code sentence, corresponding first code definition and define corresponding first code with first code in the second file Section.Or
Line character length is less than preset characters length and code statement corresponds to for the default sentence condition of front end alternate statement First code sentence, corresponding first code definition and define corresponding first code with first code in the second file Section.
The code statement that the embodiment of the present invention is directed to multiple default sentence conditions does not have the field of mutual logic function relation Scape, the corresponding first code section of multiple default sentence condition in the code file of generation has separate function, can Basic code as code programming field is widely used.The application embodiment of the present invention can quickly generate code literary composition automatically Part, improves work efficiency.
It can be seen that, method provided in an embodiment of the present invention, obtain and there is admittedly substantial first default file and there is change Second file of content, reads the code statement to be found in the first default file line by line using default programming function.For Multiple default sentence conditions, when the code statement reading meets a default sentence condition, are up to default sentence condition Code statement is defined as corresponding first code sentence.According to corresponding first code sentence, it is right to find in the second file The first code sentence corresponding first code definition answered, and first code definition and first code are defined the corresponding first generation Code section backs up in the 3rd file.Search all the elements completing the first default file, corresponding first code sentence is all true Surely complete, and in the second file, all first code sentence corresponding first code definition reaching default sentence condition, and The corresponding first code section of first code definition backs up when completing in the 3rd file, by the final code segment in the 3rd file Generate code file.The embodiment of the present invention is passed through default programming function and is automatically searched the first default file and the second file, can Obtain corresponding code segment respectively for multiple default sentence conditions, can automatically obtain the code language being frequently necessary to repeat to write The code segment of sentence, quickly generates code file, it is possible to increase work efficiency automatically.
On the basis of Fig. 1, as second preferred embodiment, the code statement for multiple default sentence conditions has The scene of mutual logic function relation.Referring to Fig. 3, Fig. 3 is another of the generation method of code file of the embodiment of the present invention Schematic flow sheet.Comprise the steps:
Step 301, obtains and has admittedly substantial first default file and second file with changing content.
First default file, the intrinsic content of the first default file, the second file, the second file changing content no longer superfluous State.
The file format of the first default file and the second file is the file format supporting default programming function to read, file Form at least includes electronic file form and spreadsheet format, supports that the file format that default programming function reads can be made The first default file for the embodiment of the present invention and the file format of the second file, here does not repeat one by one.
Using multiple file formats supporting default programming function to read, the file format of the first default file can be expanded Scope, and the acquisition scope of the second file, then can improve the seeking scope of code and search speed, improve work efficiency.
Collect in first default file and have programmer to be frequently necessary to the code statement repeating to write, using the first default file The search program person being capable of maximum magnitude as template file is frequently necessary to the code statement repeating to write, and in code file In the long process generating, according to the new code statement being frequently necessary to repeat to write continuously emerging, can be default to first The content of file is modified and is increased, and can improve constantly the scope of codelookup and search speed.
Step 302, by default programming function, is read line by line to the intrinsic content of the first default file, is being read Meeting default sentence condition to solid substantial multiple code statements is that line character length is less than preset characters length and code language When sentence is for macrodefinition sentence, the code statement being up to default sentence condition is defined as first code sentence.And
By default programming function, the intrinsic content of the first default file is read line by line, inherently interior reading The multiple code statements holding meet default sentence condition, and line character length is less than preset characters length and code statement is function During interface statement, the code statement being up to default sentence condition is defined as first code sentence.And
By default programming function, the intrinsic content of the first default file is read line by line, inherently interior reading The multiple code statements holding meet default sentence condition, and line character length is less than preset characters length and code statement is data When processing sentence, the code statement being up to default sentence condition is defined as first code sentence.And
By default programming function, the intrinsic content of the first default file is read line by line, inherently interior reading The multiple code statements holding meet default sentence condition, and line character length is less than preset characters length and code statement is front end During alternate statement, the code statement being up to default sentence condition is defined as first code sentence.Wherein, preset characters length is According to the character length of industrial requirement or the code statement of artificial setting, such as 20.
Macrodefinition sentence includes:Such as #define DATALENGTH 10.Function interface sentence at least includes:Case (num){case 1:break;default:break;}.DPS includes carrying out the difference of different pieces of information processing business Sentence.Front end alternate statement at least includes:RECV()、send().
Default programming function, default sentence condition, first code sentence repeat no more.
By default programming function, read the intrinsic content of the first default file line by line, it can be avoided that the first default file In the skip of code statement take the situation leading to codelookup mistake to occur.Determine the first code reaching default sentence condition Sentence, can clearly identify the code statement being frequently necessary to repeat to write, so that follow-up search generation in the second file Code sentence is to carry out for the code statement being frequently necessary to repeat to write, and codelookup specific aim is higher, searches speed faster. And the embodiment of the present invention, according to the default sentence condition with sequencing, is up to the code statement of default sentence condition successively It is defined as corresponding first code sentence, search in the second file after enabling to and backup first code sentence is corresponding First code section be according to the first code sentence with sequencing carry out so that the code file ultimately producing is foundation First code definition and the code file with logic function relation being sequentially generated of first code section.
The targeted default sentence condition of the present invention is not limited to four kinds of default sentence conditions of above-described embodiment, using this Inventive method carries out in code file generating process, according to being actually needed, default sentence condition can be modified or increase.
Step 203, is that line character length is less than preset characters length and code statement is according to reaching default sentence condition The first code sentence of macrodefinition sentence, from the second file, searches the definition of first code sentence corresponding first code, and will First code definition and first code section corresponding with first code definition back up in the 3rd file.By first code definition and Defining corresponding first code section backup with first code is to be saved in the 3rd file in macrodefined mode in the 3rd file In, such as #define NUMLENGTH 10, represent that the character length of code statement is 10.#define DATALENGTH 10 table Show that grand " DATALENGTH " in program all can be with 10 replacements.Wherein, macrodefinition sentence corresponding first code section is used for defining Agreement, reputable code function.Versatility, the readability of code can be improved using macrodefinition, improve code concordance, transplantation Property, and reduce input error, and be easily modified.And
It is that line character length is less than preset characters length and code statement is function interface according to reaching default sentence condition Sentence, from the second file, searches the definition of first code sentence corresponding first code, and by first code definition and with first Code definition corresponding first code section backs up in the 3rd file.Wherein, function interface sentence corresponding first code section is used In determining the memory interface being allocated by the different types of data that front end obtains, accessed not by judging the different value obtaining Same memory interface, such as:Receiving data is to access the memory interface on the left side when 1, and receiving data is to access depositing of the right when 2 Storage interface.The form of function interface sentence such as Case (num) { case 1:break;default:break;}.Wherein break table Show and jump out this statement loop, default represents default implied termss.Concrete sentence is such as:switch(num){case 1: GetName()}.Switch case statement is used for executing different operating according to different condition.Wherein case 1:GetName() Represent that interface 1 execution obtains the operation of user's name.And
It is that line character length is less than preset characters length and code statement is data processing according to reaching default sentence condition Sentence, from the second file, searches the definition of first code sentence corresponding first code, and by first code definition and with first Code definition corresponding first code section backs up in the 3rd file.Wherein, DPS corresponding first code section is used Obtain data in backstage, be specifically interpreted as that backstage is passed through to inquire about the operation acquisition data such as data base or calculating.And
It is that line character length is less than preset characters length and code statement interacts for front end according to reaching default sentence condition Sentence, from the second file, searches the definition of first code sentence corresponding first code, and by first code definition and with first Code definition corresponding first code section backs up in the 3rd file.Wherein, front end alternate statement corresponding first code section is used In backstage feedback data to front end, specifically it is interpreted as user to front-end access, front end sends data to backstage, data is replied on backstage To front end so that front end after receiving the data display data or give the one or more feedback information in backstage.Wherein, front end At least include webpage, backstage be computer server, data at least include numerical value, field, video cartoon and or picture, instead Feedforward information at least includes receiving successful information, display successful information, He or error in data information.As:RECV () represents reception Data, send () represent transmission data.
The embodiment of the present invention order backup obtain first code section between there is logic function relation, for front end and after Platform carries out data interaction.
First code definition, first code section are and the 3rd file repeats no more.
The embodiment of the present invention can find, in the second file, the code statement being frequently necessary to repeat to write, and will be often The corresponding code segment of code statement that repeats to write is needed to back up to object code file, it is to avoid manually to repeat to write or manually Locating file, copy are frequently necessary to the work of the code segment of code statement repeating to write, it is possible to increase codelookup speed and Work efficiency.Improve the formation speed of code file.And the first code section backing up is have logic function relation multiple Code segment, is capable of a complete logic function, carries out data interaction for front end and backstage.The preferred embodiment of the invention Method can be applied to the code statement of multiple default sentence conditions there is the scene of mutual logic function relation, can apply In the code programming field realizing a complete logical function.Concrete scene here does not repeat one by one.
Step 304, reads all intrinsic content finishing in the first default file, and according to multiple default sentence conditions Sequencing, determines successively and reaches the first code sentence of default sentence condition, and in the second file, searches and finishes all the The corresponding first code of one code statement defines;Wherein, the multiple default sentence condition of sequencing is followed successively by:Line character length Less than preset characters length and code statement be macrodefinition sentence, line character length is less than preset characters length and code statement and is Function interface sentence, line character length be less than preset characters length and code statement be DPS, line character length little In preset characters length and code statement be front end alternate statement;
Define corresponding first code section by the definition of all first codes and with first code according to default sentence condition After the completion of order backs up in the 3rd file, the final code segment in the 3rd file is generated code file;Wherein, final code Section includes:First code section.Final code segment includes:
Line character length is less than preset characters length and code statement is corresponding for the default sentence condition of macrodefinition sentence First code sentence, in the second file, corresponding first code defines and defines corresponding first code section with first code. And
Line character length is less than preset characters length and code statement corresponds to for the default sentence condition of function interface sentence First code sentence, corresponding first code definition and define corresponding first code with first code in the second file Section.And
Line character length is less than preset characters length and code statement corresponds to for the default sentence condition of DPS First code sentence, corresponding first code definition and define corresponding first code with first code in the second file Section.And
Line character length is less than preset characters length and code statement corresponds to for the default sentence condition of front end alternate statement First code sentence, corresponding first code definition and define corresponding first code with first code in the second file Section.
The code statement that the embodiment of the present invention is directed to multiple default sentence conditions has the scene of mutual logic function relation, Between the corresponding first code section of multiple default sentence condition in the code file generating, there is mutual logic function relation, real An existing complete logic function is used for front end and backstage carries out data interaction.The generation method of the code file of the embodiment of the present invention Work efficiency can be improved.And the embodiment of the present invention can be applied to the scene that code file realizes a complete logic function, The different function requirements that programming field can be directed to obtain corresponding code file, have popularity and practicality, multiple have The scene here of complete logic function does not repeat one by one.
It can be seen that, method provided in an embodiment of the present invention, obtain and there is admittedly substantial first default file and there is change Second file of content, reads the code statement to be found in the first default file line by line using default programming function.Work as reading When the code statement got meets the default sentence condition with sequencing, sequentially it is up to the code language of default sentence condition Sentence is defined as corresponding first code sentence.According to corresponding first code sentence, in the second file, sequential search is to correspondence First code sentence corresponding first code definition, and by first code definition and first code define corresponding first code Section backup is in the 3rd file.Search all the elements completing the first default file, and in the second file, all reaching has Default sentence condition, the first code sentence corresponding first code definition of sequencing and first code define corresponding the One code segment backs up when completing in the 3rd file, and final code segment in the 3rd file is sequentially generated code file.This Inventive embodiments are passed through default programming function and are automatically searched the first default file and the second file, obtain and are frequently necessary to repeat to write The corresponding code segment of code statement, can automatically quickly generate code file, it is possible to increase work efficiency, and for having The default sentence condition of sequencing, sequential search, the corresponding code segment of backup, one can be generated there is complete logic function Code file, can be directed to programming field different function requirements obtain corresponding code file, have popularity and practicality Property.
Referring to Fig. 4, Fig. 4 is the structural representation of the generating means of code file of the embodiment of the present invention, including:
File acquisition module 401, for obtain there is admittedly substantial first default file and there is changing content the Two files, wherein, the intrinsic content of the first default file at least includes:Multiple code statements to be found, the change of the second file Change content at least to include:Code definition corresponding with multiple code statements to be found code segment corresponding with code definition.
First code sentence determining module 402, for by default programming function, reading consolidating of the first default file line by line There is content, determine the first code sentence reaching default sentence condition.
Backup module 403, for according to first code sentence, from the second file, searches corresponding with first code sentence First code definition, and by first code definition and define corresponding first code section with first code and back up in the 3rd file In;.
Code file generation module 404, defines corresponding first for by the definition of all first codes and with first code After the completion of code segment backs up in the 3rd file, the final code segment in the 3rd file is generated code file, wherein, final generation Code section includes:First code section.
It should be noted that the device of the embodiment of the present invention is the device of the generation method applying above-mentioned code file, then All embodiments of the generation method of above-mentioned application code file are all applied to this device, and all can reach and same or analogous have Beneficial effect.
It can be seen that, a kind of generating means of code file provided in an embodiment of the present invention, main inclusion:Acquisition has inherently interior The first default file holding and second file with changing content.Read the first default file using default programming function line by line In code statement to be found, when the code statement that reads meets default sentence condition, be up to default sentence condition Code statement be defined as first code sentence.According to first code sentence, the second file finds first code sentence Corresponding first code definition, and first code definition and first code are defined corresponding code segment backup in the 3rd file In.Search all the elements completing the first default file, and in the second file, all first generation reaching default sentence condition The code corresponding first code of sentence defines, and the corresponding first code section of first code definition backs up in the 3rd file and completes When, final code segment in the 3rd file is generated code file.The embodiment of the present invention is passed through default programming function and is automatically searched First default file and the second file, obtain the code statement section needing to write, automatically quickly generate code file, it is possible to increase Work efficiency.
On the basis of Fig. 4, as the first preferred embodiment, the code statement for multiple default sentence conditions does not have There is the scene of mutual logic function relation.Including:
File acquisition module, for obtaining the second literary composition having admittedly substantial first default file and having changing content Part.
First default file, the intrinsic content of the first default file, the second file, the second file changing content no longer superfluous State.
The file format of the first default file and the second file is the file format supporting default programming function to read, file Form at least includes electronic file form and spreadsheet format, supports that the file format that default programming function reads can be made The first default file for the embodiment of the present invention and the file format of the second file, here does not repeat one by one.
Using multiple file formats supporting default programming function to read, the file format of the first default file can be expanded Scope, and the acquisition scope of the second file, then can improve the seeking scope of code and search speed, improve work efficiency.
Collect in first default file and have programmer to be frequently necessary to the code statement repeating to write, using the first default file The search program person being capable of maximum magnitude as template file is frequently necessary to the code statement repeating to write, and in code file In the long process generating, according to the new code statement being frequently necessary to repeat to write continuously emerging, can be default to first The content of file is modified and is increased, and can improve constantly the scope of codelookup and search speed.
First code sentence determining module, for by default programming function, entering to the intrinsic content of the first default file Row reads line by line, is that line character length is less than pre- read admittedly substantial multiple code statement meeting default sentence condition If character length and code statement are macrodefinition sentence, the code statement being up to default sentence condition is defined as first code Sentence.Or
By default programming function, the intrinsic content of the first default file is read line by line, inherently interior reading The multiple code statements holding meet default sentence condition, and line character length is less than preset characters length and code statement is function During interface statement, the code statement being up to default sentence condition is defined as first code sentence.Or
By default programming function, the intrinsic content of the first default file is read line by line, inherently interior reading The multiple code statements holding meet default sentence condition, and line character length is less than preset characters length and code statement is data When processing sentence, the code statement being up to default sentence condition is defined as first code sentence.Or
By default programming function, the intrinsic content of the first default file is read line by line, inherently interior reading The multiple code statements holding meet default sentence condition, and line character length is less than preset characters length and code statement is front end During alternate statement, the code statement being up to default sentence condition is defined as first code sentence.Wherein, preset characters length is According to the character length of industrial requirement or the code statement of artificial setting, such as 20.
Macrodefinition sentence includes:Such as #define DATALENGTH 10.Function interface sentence at least includes:Case (num){case 1:break;default:break;}.DPS includes carrying out the difference of different pieces of information processing business Sentence.Front end alternate statement at least includes:RECV()、send().Default programming function, default sentence condition, first code language Sentence repeats no more.
Read the code language multiple to be found in the intrinsic content of the first default file using default programming function line by line Sentence, takes code statement then to lead to the situation of codelookup mistake to occur it can be avoided that skip.Determine and reach default sentence The first code sentence of condition is capable of determining that the code statement being frequently necessary to repeat to write, so that the second file afterwards Lookup is that the code statement being frequently necessary to repeat to write for this is carried out, it is possible to increase the specific aim of codelookup and accurately Property, and improve codelookup speed.
The embodiment of the present invention can be directed to above-mentioned four kinds default sentence conditions, reads first line by line by default programming function Default file, determines four kinds of default sentence conditions corresponding first code sentence respectively.The targeted default sentence bar of the present invention Part is not limited to four kinds of default sentence conditions of above-described embodiment, carrying out in code file generating process using the inventive method, According to being actually needed, default sentence condition can be modified or increase.
Backup module, for being that line character length is less than preset characters length and code according to reaching default sentence condition Sentence is the first code sentence of macrodefinition sentence, from the second file, searches the corresponding first code of first code sentence fixed Justice, and define corresponding first code section backup in the 3rd file by first code definition and with first code.Wherein, grand fixed The corresponding first code section of adopted sentence is used for defining agreement, reputable code function.Or
It is that line character length is less than preset characters length and code statement is function interface according to reaching default sentence condition Sentence, from the second file, searches the definition of first code sentence corresponding first code, and by first code definition and with first Code definition corresponding first code section backs up in the 3rd file.Wherein, function interface sentence corresponding first code section is used The memory interface being allocated by the different types of data that front end obtains in determination.Or
It is that line character length is less than preset characters length and code statement is data processing according to reaching default sentence condition Sentence, from the second file, searches the definition of first code sentence corresponding first code, and by first code definition and with first Code definition corresponding first code section backs up in the 3rd file.Wherein, DPS corresponding first code section is used Obtain data in backstage.Or
It is that line character length is less than preset characters length and code statement interacts for front end according to reaching default sentence condition Sentence, from the second file, searches the definition of first code sentence corresponding first code, and by first code definition and with first Code definition corresponding first code section backs up in the 3rd file.Wherein, after interaction corresponding first code section in front end is used for Platform feedback data is to front end.Wherein, front end at least includes webpage, backstage be computer server, data at least include numerical value, Field, video cartoon and or picture.
First code definition, first code section are and the 3rd file repeats no more.
The embodiment of the present invention can be directed to above-mentioned four kinds default sentence conditions, search four kinds respectively and preset in the second file First code definition corresponding to each self-corresponding first code sentence of sentence condition, and each self-corresponding first code is defined And define corresponding first code section backup in the 3rd file so that having one or more in the 3rd file with first code The corresponding first code section of default sentence condition.And the corresponding first code section of each default sentence condition is respectively provided with respective work( Energy.The code statement that the embodiment of the present invention is directed to multiple default sentence conditions does not have the scene of mutual logic function relation, can Using the basic skills generating as code file, it is widely used in code programming field.
In the second file, search first code corresponding with first code sentence definition, and first code is defined and Define corresponding first code section with first code to back up in the 3rd file, complete to being frequently necessary to the code language that repeats to write Sentence automatically write work, it is to avoid manually repeat to write and manually search, copy is frequently necessary to the code statement that repeats to write Code segment work, it is possible to increase work efficiency.
Code file generation module, for until reading all intrinsic content finishing in the first default file, having determined Finish the corresponding first code sentence of multiple default sentence conditions, and in the second file, search and finish all first code sentences Corresponding first code definition, and define corresponding first code Duan tri- by the definition of all first codes and with first code After the completion of backing up in file, the final code segment in the 3rd file is generated code file.Wherein, final code segment includes:The One code segment.Wherein, final code segment includes:
Line character length is less than preset characters length and code statement is corresponding for the default sentence condition of macrodefinition sentence First code sentence, in the second file, corresponding first code defines and defines corresponding first code section with first code. Or
Line character length is less than preset characters length and code statement corresponds to for the default sentence condition of function interface sentence First code sentence, corresponding first code definition and define corresponding first code with first code in the second file Section.Or
Line character length is less than preset characters length and code statement corresponds to for the default sentence condition of DPS First code sentence, corresponding first code definition and define corresponding first code with first code in the second file Section.Or
Line character length is less than preset characters length and code statement corresponds to for the default sentence condition of front end alternate statement First code sentence, corresponding first code definition and define corresponding first code with first code in the second file Section.
The code statement that the embodiment of the present invention is directed to multiple default sentence conditions does not have the field of mutual logic function relation Scape, the corresponding first code section of multiple default sentence condition in the code file of generation has separate function, can Basic code as code programming field is widely used.The application embodiment of the present invention can quickly generate code literary composition automatically Part, improves work efficiency.
It can be seen that, device provided in an embodiment of the present invention, obtain and there is admittedly substantial first default file and there is change Second file of content, reads the code statement to be found in the first default file line by line using default programming function.For Multiple default sentence conditions, when the code statement reading meets a default sentence condition, are up to default sentence condition Code statement is defined as corresponding first code sentence.According to corresponding first code sentence, it is right to find in the second file The first code sentence corresponding first code definition answered, and first code definition and first code are defined the corresponding first generation Code section backs up in the 3rd file.Search all the elements completing the first default file, corresponding first code sentence is all true Surely complete, and in the second file, all first code sentence corresponding first code definition reaching default sentence condition, and The corresponding first code section of first code definition backs up when completing in the 3rd file, by the final code segment in the 3rd file Generate code file.The embodiment of the present invention is passed through default programming function and is automatically searched the first default file and the second file, can Obtain corresponding code segment respectively for multiple default sentence conditions, can automatically obtain the code language being frequently necessary to repeat to write The code segment of sentence, quickly generates code file, it is possible to increase work efficiency automatically.
On the basis of Fig. 4, as second preferred embodiment, the code statement for multiple default sentence conditions has The scene of mutual logic function relation.Including:
File acquisition module, for obtaining the second literary composition having admittedly substantial first default file and having changing content Part.
First default file, the intrinsic content of the first default file, the second file, the second file changing content no longer superfluous State.
The file format of the first default file and the second file is the file format supporting default programming function to read, file Form at least includes electronic file form and spreadsheet format, supports that the file format that default programming function reads can be made The first default file for the embodiment of the present invention and the file format of the second file, here does not repeat one by one.
Using multiple file formats supporting default programming function to read, the file format of the first default file can be expanded Scope, and the acquisition scope of the second file, then can improve the seeking scope of code and search speed, improve work efficiency.
Collect in first default file and have programmer to be frequently necessary to the code statement repeating to write, using the first default file The search program person being capable of maximum magnitude as template file is frequently necessary to the code statement repeating to write, and in code file In the long process generating, according to the new code statement being frequently necessary to repeat to write continuously emerging, can be default to first The content of file is modified and is increased, and can improve constantly the scope of codelookup and search speed.
First code sentence determining module, for by default programming function, entering to the intrinsic content of the first default file Row reads line by line, is that line character length is less than pre- read admittedly substantial multiple code statement meeting default sentence condition If character length and code statement are macrodefinition sentence, the code statement being up to default sentence condition is defined as first code Sentence.And
By default programming function, the intrinsic content of the first default file is read line by line, inherently interior reading The multiple code statements holding meet default sentence condition, and line character length is less than preset characters length and code statement is function During interface statement, the code statement being up to default sentence condition is defined as first code sentence.And
By default programming function, the intrinsic content of the first default file is read line by line, inherently interior reading The multiple code statements holding meet default sentence condition, and line character length is less than preset characters length and code statement is data When processing sentence, the code statement being up to default sentence condition is defined as first code sentence.And
By default programming function, the intrinsic content of the first default file is read line by line, inherently interior reading The multiple code statements holding meet default sentence condition, and line character length is less than preset characters length and code statement is front end During alternate statement, the code statement being up to default sentence condition is defined as first code sentence.Wherein, preset characters length is According to the character length of industrial requirement or the code statement of artificial setting, such as 20.
Macrodefinition sentence includes:Such as #define DATALENGTH 10.Function interface sentence at least includes:Case (num){case 1:break;default:break;}.DPS includes carrying out the difference of different pieces of information processing business Sentence.Front end alternate statement at least includes:RECV()、send().Default programming function, default sentence condition, first code language Sentence repeats no more.
By default programming function, read the intrinsic content of the first default file line by line, it can be avoided that the first default file In the skip of code statement take the situation leading to codelookup mistake to occur.Determine the first code reaching default sentence condition Sentence, can clearly identify the code statement being frequently necessary to repeat to write, so that follow-up search generation in the second file Code sentence is to carry out for the code statement being frequently necessary to repeat to write, and codelookup specific aim is higher, searches speed faster. And the embodiment of the present invention, according to the default sentence condition with sequencing, is up to the code statement of default sentence condition successively It is defined as corresponding first code sentence, search in the second file after enabling to and backup first code sentence is corresponding First code section be according to the first code sentence with sequencing carry out so that the code file ultimately producing is foundation First code definition and the code file with logic function relation being sequentially generated of first code section.
The targeted default sentence condition of the present invention is not limited to four kinds of default sentence conditions of above-described embodiment, using this Inventive method carries out in code file generating process, according to being actually needed, default sentence condition can be modified or increase.
Backup module, for being that line character length is less than preset characters length and code according to reaching default sentence condition Sentence is the first code sentence of macrodefinition sentence, from the second file, searches the corresponding first code of first code sentence fixed Justice, and define corresponding first code section backup in the 3rd file by first code definition and with first code.By the first generation Code definition and first code section backup corresponding with first code definition are to be saved in macrodefined mode in the 3rd file In 3rd file, such as #define NUMLENGTH 10, represent that the character length of code statement is 10.#define Grand " DATALENGTH " in DATALENGTH 10 representation program can be with 10 replacements.Wherein, macrodefinition sentence corresponding first Code segment is used for defining agreement, reputable code function, can improve versatility, the readability of code using macrodefinition, improves generation Code concordance, portability, and reduce input error, and be easily modified.And
It is that line character length is less than preset characters length and code statement is function interface according to reaching default sentence condition Sentence, from the second file, searches the definition of first code sentence corresponding first code, and by first code definition and with first Code definition corresponding first code section backs up in the 3rd file.Wherein, function interface sentence corresponding first code section is used In determining the memory interface being allocated by the different types of data that front end obtains, accessed not by judging the different value obtaining Same memory interface, such as:Receiving data is to access the memory interface on the left side when 1, and receiving data is to access depositing of the right when 2 Storage interface.The form of function interface sentence such as Case (num) { case 1:break;default:break;}.Wherein break table Show and jump out this statement loop, default represents default implied termss.Concrete sentence is such as:switch(num){case 1: GetName()}.Switch case statement is used for executing different operating according to different condition.Wherein case 1:GetName() Represent that interface 1 execution obtains the operation of user's name.And
It is that line character length is less than preset characters length and code statement is data processing according to reaching default sentence condition Sentence, from the second file, searches the definition of first code sentence corresponding first code, and by first code definition and with first Code definition corresponding first code section backs up in the 3rd file.Wherein, DPS corresponding first code section is used Obtain data in backstage, be specifically interpreted as that backstage is passed through to inquire about the operation acquisition data such as data base or calculating.And
It is that line character length is less than preset characters length and code statement interacts for front end according to reaching default sentence condition Sentence, from the second file, searches the definition of first code sentence corresponding first code, and by first code definition and with first Code definition corresponding first code section backs up in the 3rd file.Wherein, front end alternate statement corresponding first code section is used In backstage feedback data to front end, specifically it is interpreted as user to front-end access, front end sends data to backstage, data is replied on backstage To front end so that front end after receiving the data display data or give the one or more feedback information in backstage.Wherein, front end At least include webpage, backstage be computer server, data at least include numerical value, field, video cartoon and or picture, instead Feedforward information at least includes receiving successful information, display successful information, He or error in data information.As:RECV () represents reception Data, send () represent transmission data.
The embodiment of the present invention order backup obtain first code section between there is logic function relation, for front end and after Platform carries out data interaction.First code definition, first code section are and the 3rd file repeats no more.
The embodiment of the present invention can find, in the second file, the code statement being frequently necessary to repeat to write, and will be often The corresponding code segment of code statement that repeats to write is needed to back up to object code file, it is to avoid manually to repeat to write or manually Locating file, copy are frequently necessary to the work of the code segment of code statement repeating to write, it is possible to increase codelookup speed and Work efficiency.Improve the formation speed of code file.And the first code section backing up is have logic function relation multiple Code segment, is capable of a complete logic function, carries out data interaction for front end and backstage.The preferred embodiment of the invention Method can be applied to the code statement of multiple default sentence conditions there is the scene of mutual logic function relation, can apply In the code programming field realizing a complete logical function.Concrete scene here does not repeat one by one.
Code file generation module, for reading all intrinsic content finishing in the first default file, and according to multiple The sequencing of default sentence condition, determines the first code sentence reaching default sentence condition successively, and in the second file, Lookup finishes the definition of all first code sentences corresponding first code;Wherein, the multiple default sentence condition of sequencing according to Secondary it is:Line character length be less than preset characters length and code statement be macrodefinition sentence, line character length be less than preset characters Length and code statement are function interface sentence, line character length is less than preset characters length and code statement is data processing language Sentence, line character length are less than preset characters length and code statement is front end alternate statement.
Define corresponding first code section by the definition of all first codes and with first code according to default sentence condition After the completion of order backs up in the 3rd file, the final code segment in the 3rd file is generated code file;Wherein, final code Section includes:First code section.Final code segment includes:
Line character length is less than preset characters length and code statement is corresponding for the default sentence condition of macrodefinition sentence First code sentence, in the second file, corresponding first code defines and defines corresponding first code section with first code. And
Line character length is less than preset characters length and code statement corresponds to for the default sentence condition of function interface sentence First code sentence, corresponding first code definition and define corresponding first code with first code in the second file Section.And
Line character length is less than preset characters length and code statement corresponds to for the default sentence condition of DPS First code sentence, corresponding first code definition and define corresponding first code with first code in the second file Section.And
Line character length is less than preset characters length and code statement corresponds to for the default sentence condition of front end alternate statement First code sentence, corresponding first code definition and define corresponding first code with first code in the second file Section.
The code statement that the embodiment of the present invention is directed to multiple default sentence conditions has the scene of mutual logic function relation, Between the corresponding first code section of multiple default sentence condition in the code file generating, there is mutual logic function relation, real An existing complete logic function is used for front end and backstage carries out data interaction.The generation method of the code file of the embodiment of the present invention Work efficiency can be improved.And the embodiment of the present invention can be applied to the scene that code file realizes a complete logic function, The different function requirements that programming field can be directed to obtain corresponding code file, have popularity and practicality, multiple have The scene here of complete logic function does not repeat one by one.
It can be seen that, device provided in an embodiment of the present invention, obtain and there is admittedly substantial first default file and there is change Second file of content, reads the code statement to be found in the first default file line by line using default programming function.Work as reading When the code statement got meets the default sentence condition with sequencing, sequentially it is up to the code language of default sentence condition Sentence is defined as corresponding first code sentence.According to corresponding first code sentence, in the second file, sequential search is to correspondence First code sentence corresponding first code definition, and by first code definition and first code define corresponding first code Section backup is in the 3rd file.Search all the elements completing the first default file, and in the second file, all reaching has Default sentence condition, the first code sentence corresponding first code definition of sequencing and first code define corresponding the One code segment backs up when completing in the 3rd file, and final code segment in the 3rd file is sequentially generated code file.This Inventive embodiments are passed through default programming function and are automatically searched the first default file and the second file, obtain and are frequently necessary to repeat to write The corresponding code segment of code statement, can automatically quickly generate code file, it is possible to increase work efficiency, and for having The default sentence condition of sequencing, sequential search, the corresponding code segment of backup, one can be generated there is complete logic function Code file, can be directed to programming field different function requirements obtain corresponding code file, have popularity and practicality Property.
It should be noted that herein, such as first and second or the like relational terms are used merely to a reality Body or operation are made a distinction with another entity or operation, and not necessarily require or imply these entities or deposit between operating In any this actual relation or order.And, term " inclusion ", "comprising" or its any other variant are intended to Comprising of nonexcludability, wants so that including a series of process of key elements, method, article or equipment and not only including those Element, but also include other key elements being not expressly set out, or also include for this process, method, article or equipment Intrinsic key element.In the absence of more restrictions, the key element that limited by sentence "including a ..." it is not excluded that Also there is other identical element including in the process of key element, method, article or equipment.
Each embodiment in this specification is all described by the way of related, identical similar portion between each embodiment Divide mutually referring to what each embodiment stressed is the difference with other embodiment.Real especially for system For applying example, because it is substantially similar to embodiment of the method, so description is fairly simple, referring to embodiment of the method in place of correlation Part illustrate.
These are only presently preferred embodiments of the present invention, be not intended to limit protection scope of the present invention.All at this Any modification, equivalent substitution and improvement made within bright spirit and principle etc., are all contained in protection scope of the present invention.

Claims (8)

1. a kind of generation method of code file is it is characterised in that include:
Obtain and there is admittedly substantial first default file and second file with changing content, wherein, described first presets The intrinsic content of file at least includes:Multiple code statements to be found, the changing content of described second file at least includes:With The corresponding code definition of the plurality of code statement to be found code segment corresponding with described code definition;
By default programming function, read the intrinsic content of described first default file line by line, determine and reach default sentence condition First code sentence;
According to described first code sentence, from described second file, search the first generation corresponding with described first code sentence Code definition, and define corresponding first code section backup in the 3rd file by the definition of described first code and with described first code In;
All described first codes are defined and defines corresponding first code section in described 3rd file with described first code After the completion of middle backup, the final code segment in described 3rd file is generated code file, wherein, described final code segment bag Include:First code section.
2. method according to claim 1 it is characterised in that
Described by default programming function, read the intrinsic content of described first default file line by line, determine and reach default sentence The first code sentence of condition, including:
By described default programming function, the intrinsic content of described first default file is read line by line, reading State admittedly substantial multiple code statements to meet described default sentence condition is that line character length is less than preset characters length and generation When code sentence is macrodefinition sentence, the code statement being up to described default sentence condition is defined as described first code sentence; And/or
By described default programming function, the intrinsic content of described first default file is read line by line, reading State admittedly substantial multiple code statements to meet described default sentence condition is that line character length is less than described preset characters length And code statement be function interface sentence when, the code statement being up to described default sentence condition is defined as described first code Sentence;And/or
By described default programming function, the intrinsic content of described first default file is read line by line, reading State admittedly substantial multiple code statements to meet described default sentence condition is that line character length is less than described preset characters length And code statement be DPS when, the code statement being up to described default sentence condition is defined as described first code Sentence;And/or
By described default programming function, the intrinsic content of described first default file is read line by line, reading State admittedly substantial multiple code statements to meet described default sentence condition is that line character length is less than described preset characters length And code statement be front end alternate statement when, the code statement being up to described default sentence condition is defined as described first code Sentence.
3. method according to claim 1 it is characterised in that
Described first code is defined as:In described second file, and code statement identical in described first code sentence, and first The code statement of secondary appearance;
Described first code section is:In described second file, the code segment that described first code definition is located.
4. method according to claim 2 it is characterised in that
Described all described first codes defined and defines corresponding first code section the described 3rd with described first code After the completion of backing up in file, the final code segment in described 3rd file is generated code file, further includes:
Read all intrinsic content finishing in described first default file, and the priority according to multiple default sentence conditions is suitable Sequence, determines the first code sentence reaching described default sentence condition successively, and in described second file, lookup finishes all The corresponding first code definition of described first code sentence;Wherein, the multiple default sentence condition of sequencing is followed successively by:Row word Symbol length be less than described preset characters length and code statement be described macrodefinition sentence, line character length be less than described predetermined word Symbol length and code statement are described function interface sentence, line character length is less than described preset characters length and code statement and is Described DPS, line character length are less than described preset characters length and code statement is described front end alternate statement;
All described first codes are defined and defines corresponding first code section according to described default language with described first code After the completion of the order of sentence condition backs up in described 3rd file, the final code segment in described 3rd file is generated code literary composition Part;Wherein, described final code segment includes:First code section.
5. a kind of generating means of code file are it is characterised in that include:
File acquisition module, has admittedly substantial first default file and second file with changing content for obtaining, Wherein, the intrinsic content of described first default file at least includes:Multiple code statements to be found, the change of described second file Change content at least to include:Code definition corresponding with the plurality of code statement to be found is corresponding with described code definition Code segment;
First code sentence determining module, for by default programming function, reading the intrinsic of described first default file line by line Content, determines the first code sentence reaching default sentence condition;
Backup module, for according to described first code sentence, from described second file, searches and described first code sentence Corresponding first code definition, and described first code is defined and standby with the corresponding first code section of described first code definition Part is in the 3rd file;
Code file generation module, defines corresponding first for defining all described first codes and with described first code After the completion of code segment backs up in described 3rd file, the final code segment in described 3rd file is generated code file, its In, described final code segment includes:First code section.
6. device according to claim 5 it is characterised in that
Described first code sentence determining module, including:
Macrodefinition first code sentence determination sub-module, for by described default programming function, to described first default file Intrinsic content read line by line, meet described default sentence condition reading described solid substantial multiple code statements It is less than preset characters length for, line character length and when code statement is macrodefinition sentence, be up to described default sentence condition Code statement be defined as described first code sentence;And/or
Function interface first code sentence determination sub-module, for by described default programming function, to the described first default literary composition The intrinsic content of part is read line by line, meets described default sentence bar reading described solid substantial multiple code statements Part is, line character length is less than described preset characters length and when code statement is function interface sentence, is up to described default The code statement of sentence condition is defined as described first code sentence;And/or
Data processing first code sentence determination sub-module, for by described default programming function, to the described first default literary composition The intrinsic content of part is read line by line, meets described default sentence bar reading described solid substantial multiple code statements Part is, line character length is less than described preset characters length and when code statement is DPS, is up to described default The code statement of sentence condition is defined as described first code sentence;And/or
Front end interacts first code sentence determination sub-module, for by described default programming function, to the described first default literary composition The intrinsic content of part is read line by line, meets described default sentence bar reading described solid substantial multiple code statements Part is, line character length is less than described preset characters length and when code statement is front end alternate statement, is up to described default The code statement of sentence condition is defined as described first code sentence.
7. device according to claim 1 it is characterised in that
Described first code is defined as:In described second file, and code statement identical in described first code sentence, and first The code statement of secondary appearance;
Described first code section is:In described second file, the code segment that described first code definition is located.
8. device according to claim 6 it is characterised in that
Described code file generation module, further includes:
Order reads searches submodule, for reading all intrinsic content finishing in described first default file, and according to many The sequencing of individual default sentence condition, determines the first code sentence reaching described default sentence condition successively, and described In second file, search and finish the definition of all described first code sentences corresponding first code;Wherein, sequencing is multiple Default sentence condition is followed successively by:Line character length be less than described preset characters length and code statement be described macrodefinition sentence, Line character length be less than described preset characters length and code statement be described function interface sentence, line character length be less than described Preset characters length and code statement are described DPS, line character length is less than described preset characters length and code Sentence is described front end alternate statement;
Code file generates submodule, for will all described first codes definition and corresponding with the definition of described first code the After the completion of one code segment backs up in described 3rd file according to the order of described default sentence condition, by described 3rd file Final code segment generate code file;Wherein, described final code segment includes:First code section.
CN201610917151.2A 2016-10-21 2016-10-21 A kind of generation method of code file and device Pending CN106484427A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610917151.2A CN106484427A (en) 2016-10-21 2016-10-21 A kind of generation method of code file and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610917151.2A CN106484427A (en) 2016-10-21 2016-10-21 A kind of generation method of code file and device

Publications (1)

Publication Number Publication Date
CN106484427A true CN106484427A (en) 2017-03-08

Family

ID=58270394

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610917151.2A Pending CN106484427A (en) 2016-10-21 2016-10-21 A kind of generation method of code file and device

Country Status (1)

Country Link
CN (1) CN106484427A (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040261059A1 (en) * 2003-06-18 2004-12-23 Sam Spencer System and method for creating, managing and using code segments
CN103631601A (en) * 2013-12-10 2014-03-12 北京中电普华信息技术有限公司 Code generation method and code generation device
CN104156314A (en) * 2014-08-14 2014-11-19 北京航空航天大学 Code reuse method applied to test system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040261059A1 (en) * 2003-06-18 2004-12-23 Sam Spencer System and method for creating, managing and using code segments
CN103631601A (en) * 2013-12-10 2014-03-12 北京中电普华信息技术有限公司 Code generation method and code generation device
CN104156314A (en) * 2014-08-14 2014-11-19 北京航空航天大学 Code reuse method applied to test system

Similar Documents

Publication Publication Date Title
CN112818457B (en) BIM model intelligent generation method and system based on CAD drawing
CN105373541A (en) Processing method and system for data operation request of database
CN103049355A (en) Method and equipment for database system recovery
CN105373853A (en) Stock public opinion index prediction method and device
US8763905B2 (en) Data processing systems applying optical identification devices and related data processing and operation methods and computer program products thereof
WO2023108985A1 (en) Method for recognizing proportion of green asset and related product
CN110989999A (en) Code generation method and device, electronic equipment and medium
CN102207935A (en) Method and system for establishing index
CN104034492A (en) Water pressure testing curve and parameter processing method
CN111984731A (en) Method and device for synchronizing data among large data platform bins and storage medium
CN102096687A (en) Method and platform for scheduling tasks
CN106484427A (en) A kind of generation method of code file and device
CN105447114A (en) Display method and apparatus for form field
CN105573973A (en) Method for performing data correlation on EXCEL data in PPT file
CN102622359A (en) Method and device for searching character strings in database
CN112036843A (en) Flow element positioning method, device, equipment and medium based on RPA and AI
US20080033949A1 (en) Electronic apparatus and method therefor
CN106649364A (en) Positioning method and device for target column in table
CN101739432A (en) System and method for searching graphic elements
CN112181596B (en) Virtual machine cloning method, device, equipment and storage medium
CN110717576A (en) Image processing method, device and equipment
CN113806365A (en) Single data source data management method, device and storage medium
CN107229349A (en) The character displaying method and device of a kind of input method
CN113189944A (en) Production data association method and device and electronic equipment
CN104932749A (en) Coordinate calculation method and device of touch point, and touch screen equipment

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
WD01 Invention patent application deemed withdrawn after publication
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20170308