texttransformer.jpg

The author of the TextTransformer himself takes advantage of the transformation manager to update hard encoded version information of different program modules simultanously. This application also may be instructive for other users.

In each module there is a file with the following lines:

virtual int GetVersionMajor() const { return 1; }
virtual int GetVersionMinor() const { return 1; }
virtual int GetVersionRelease() const { return 3; }
virtual int GetVersionBuild() const { return 0; }

The numbers in the lines shall be changed automatically. For this you have to "creep" to the positions at first, at which the changes shall be carried out. A significant expression is "GetVersionMajor". From there the desired number is simply reached. The number is denoted here by DIGIT. DIGIT is a regular expression defined as "\d", i.e. as an arbitrary digit.

To come to DIGIT, the following sequence of tokens has to be recognized:

"GetVersionMajor" "(" ")" "const" "{" "return" DIGIT

More simply, you could have searched for:

"GetVersionMajor() const { return"

However, the token sequence has to be preferred as it is tolerant of different formattings. With the token sequence, e.g. the following text is also recognized:

GetVersionMajor() const
{
return 1;
}

The token sequence becomes a complete function for the exchange of the version number, if it is enriched with so-called semantic actions. This then looks as:

VersionMajor( int xiMajor )
(>
{{
unsigned int ui = State.Position();
}}

"GetVersionMajor" "(" ")" "const" "{" "return"
{{
cout << State.text(ui, State.Position());
}}

DIGIT
{{
cout << " " << xiMajor;
}}
<)

(The symbols "(>" and "<)" describe the beginning and the end of a rule text.)

The variable ui is used to store the position, where "GetVersionMajor" starts. After the recognition of "return" the complete token sequence is copied into the output. DIGIT, however, isn't copied but replaced by the new value xiMajor which was submitted as a parameter.

The complete value for the new version number is passed in the start rule the projects. The start rule consists in the call of a second rule to which the new version number is submitted as a parameter:

VersionUpdate( )
(>
NewVersion[1,2,0,0]
<)

The project basically consists in skipping the text and copying it at the same time, until "GetVersionMajor" is found. Then analogously is continued with "VersionMinor", "VersionRelease" and "VersionBuild". Finally the program jumpes to end of the text, whereby this rest is copied too.

NewVersion( int xiMajor, int xiMinor, int xiRelease, int xiBuild )
(>
SKIP {{cout << State.copy(); }}
(
VersionMajor[xiMajor]
SKIP {{cout << State.copy(); }}
VersionMinor[xiMinor]
SKIP {{cout << State.copy(); }}
VersionRelease[xiRelease]
SKIP {{cout << State.copy(); }}
VersionBuild[xiBuild]
SKIP {{cout << State.copy(); }}
| {{ AddWarning(SourceName() + " has no version info\n"); }}
)
<)

If "GetVersionMajor" doesn't occur in the text at all, it is copied completely without change and a warning is given which is shown in the transformation manager.

A list of the files which contain the version information can be prepared in the transformation manager now.

The list of the files and the other options are saved as a so-called "management".

backup_root = C:\Programme\TextTransformer\Backup

log_file = C:\Programme\TextTransformer\Log\transformation.log

+ D:\C_biblio\cpp_interpreter\plugin_cppinterpreter.h
+ D:\Tetra\plugin_ttimport.h
+ D:\Tetra\Gui\plugin_paramwizard.h
+ D:\Tetra\Gui\plugin_newprjwizard.h
+ D:\Tetra\Gui\plugin_nodewizard.h
+ D:\Tetra\Gui\plugin_ftwizard.h
+ D:\Tetra\Gui\plugin_pggwizard.h
+ D:\Tetra\Tgmr\plugin_tmgr.h
+ D:\Tetra\plugin_gencppcode.h

At the next update you only have to set the new numbers in the start rule:


NewVersion[1,2,1,0]

them to load the management into the transformation manager again and to press the start button.

Picture: transformation manager
Picture: setting options for a transformation
Picture: results of the transformations


   deutsch Deutsch

 

 
Latest News
10/28/24
Delphi2Cpp 2.5: Symbol names matching declaration case [more...]

08/26/24
Delphi2Cpp 2.4: Updated to RAD Studio 12.1 Athens [more...]


"...Fantastic!!!!

... You have exceeded my expectations and I love your product. We will get a lot of use out of it in the future for other projects."

Charles Finley
xformix 23-02-07


top_prize_winner.png

I was extremely impressed with your components and tools. Not only extremely powerful but very professionally done and well documented, etc. Really quality work, congratulations

mouser (First Author, Administrator)


  This website is generated from plain text with [Minimal Website ]

Minimal Website Minimal Website is made with TextTransformer

TextTransformer TextTransformer is made with Borland CBuilder

  borland