The next effort is to replace the Qt classes and Qt dependencies with STL classes in the lower level non-GUI related classes (Token, Parser, Translator, Recreator, RPN List, Error List, Table, and Dictionary). Besides using Qt classes for some of their members, the Token and Parser classes also use the locale translate function. These are used for error messages. (The Table class also uses the translate function for error messages, but this class will be handled separately, and may not be necessary when this class is redesigned.)
In order to remove the dependency on the translate function, the Token, Parser, RPN List, and Error List classes will be modified to only use status codes instead of holding error messages. It will be the responsibility of the user of these classes to convert the status code to an error message when needed. The Translator class is the user or the Token and Parser classes and it will pass the status code along in the RPN list that it returns.
Currently, the Token class contains a static member function for converting a status code to an error message. There is no reason that this function along with the status enumeration to be part of the Token class (which doesn't have a status member variable).
The Parser class does not currently use status codes to return errors. Instead, it sets the token type to Error and the string member to the error message. This mechanism needs to be changed so that the Parser uses status codes. This will remove the dependency on the translate function.
The first step was to move the Status enumeration from the Token class to the main application header file, since the Status enumeration shouldn't be part of the Token class. This main header file does not have any dependencies on Qt. The error status and error message refactoring will take place on the new err-msgs branch. The goal of this branch is to remove direct handling of error messages by these lower classes.
[branch err-msgs commit 837f085074]
Saturday, September 20, 2014
Subscribe to:
Post Comments (Atom)
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.)