Saturday, October 18, 2014

Utility – Base File Name

Most of the simpler transition to using the STL classes has been completed, though there is still quite a few Qt classes in the non-GUI classes.  For example, the string member of Token class is still a QString, but the Parser class, needs significant changes to use this member as a standard string.  Since these non-GUI classes need major changes, each will be handled in separate topic branches.  Before concluding , the stl branch, some minor refactoring was done.

The base file name function was created in the Command Line class when Qt dependency was removed from the Tester class.  This function takes a standard string file path argument and returns a standard string base file name, but uses a QFileInfo function to do its work (which is the easiest platform independent way to handle file name paths, because for instance, Windows and Linux use different directory separator characters - back slash vs. forward slash).

All Qt dependency has been removed from the Command Line class except for this static function.  There was no other logical class to put this function so that it could be used by both the Command Line and Tester classes.  A new Utility class was created to hold this function.  Its header file includes the standard string header file and its source file contains the QFileInfo header, which shields the users from having to know about Qt.  This class, like the Status Message class (see post), was made so that it can't be instanced or used as a base class.  (Other similar functions can be added in the future.)

The Tester class had one remaining dependency on the Command Line class.  The instance pointer of the Command Line is passed to run function as an argument.  This instance was only used to call the copyright statement function.  This argument was changed to a standard string for the copyright statement, which is now generated in the Command Line constructor and passed to the run function.

[branch stl commit 3020cd6827]

This concludes the initial (simpler) changes transitioning non-GUI classes to STL use.  The stl branch was merged into the develop branch and deleted.  A new branch will be created for the next set of C++11/STL related changes, which will be the replacement of Qt with the STL in the Parser class.

[branch develop merge commit a8bd956bb0]

No comments:

Post a Comment

All comments and feedback welcomed, whether positive or negative.
(Anonymous comments are allowed, but comments with URL links or unrelated comments will be removed.)