C++ Builder 5.0 Project
| TFAbout | About-Dialog with a few lines of text, two hyperlinks and an animated icon playing pinball with the dialog’s frame. Shows how to move an icon without flickering and how to open an URL. Derived from TForm. |
| TCpp2Html | Class which encapsulates the conversions routines. You provide the keywords as a TKeyword object and the syntax-highlighting style as a TItemStyle object in the constructor. Additionally you’ve got to pass parameters like the tab stop position or the language as a TBasicSettings object. |
| ThreadFunc | TThread derivate: does the conversion process in its Execute-function using TCpp2Html::convert() |
| fileutils | A few utility functions to read values and strings from an ifstream tracking the current line number. You can realize format sensitive reading without the “always read a whoole line” concept. |
| TItemStyles | The two classes TItemStyle which represents a syntax-highlightning style and TItemStyles which encapsulates several TItemStyle objects and holds them in a list. |
| TKeywords | Simple class which loads the keywords from a text file and stores them in a keyword array (char**). |
| TFMain | Application main form: Manages the user interface and creates the overview file. |
TFAbout
| header | source |
The class is quite simple. It’s a form containing some TLabel objects to display some text and a TPanel in which a TImage with a TIcon inside is displayed. The panel doesn’t have any borders and thus you only see the icon inside. This construction prevents flickering cause you can move the panel without causing the icon to be repainted. There are two TLabel‘s which open an URL in your browser when they are clicked with the mouse.
TCpp2Html
| header | source |
You provide the keywords as a TKeyword object and the syntax-highlighting style as a TItemStyle object in the constructor. Additionally you’ve got to pass parameters like the tab stop position or the language as a TBasicSettings object. Then you just call the function
Convert(ifstream& inFile, ofstream& outFile, bool& stop, int& progress, const char* filename)
The two io-streams are the opended in- and output files. The stop-flag is checked periodically and the conversion process is breaked when it is set. progress is a counter which count’s the processed bytes of the input file. Note: The programm executes the conversion process in an additionally thread. Therefore it doesn’t calls convert() directly but uses the class ThreadFunc which calls convert() in its Execute() function.
ThreadFunc
| header | source |
The class is a derivate of TThread. It does the conversion process in its Execute function using TCpp2Html::convert().
fileutils
| header | source |
Their are two different kinds of functions. First the read functions which try to read a string or another streamable type from the ifstream. They throw an exception if an error occurs. The second kind are the skipws functions which can skip whitespaces and comments returning the number of encountered linefeeds (‘\n’). The mechanism is simple but however you’ve got to be careful with your implementation:
- Skip all whitespaces using one of the skipws functions. Maybe evaluate the information about the encountered linefeeds which is provided as return value.
- Try to read the value you expect or read a string and interpret it. Then continue with step one.
TItemStyle / TItemStyles
| header | source |
The class TItemStyle is rather a struct than a class. It keeps the information about color, bold and italic style of the different item types in three public arrays. The known item types are: comment, keyword, identifier, symbol, string, number, character, preprocessor, illegal_char, bkgnd. Color, bold and italic styles should be defined for each item except for identifier and bkgnd for which only the color should be set. These restrictions are fullfilled in the main program in which the functionality to edit a style is implemented.
The class TItemStyles provides functionality to load, save, insert, delete and retrieve an TItemStyle object from the style list.
TKeywords
| header | source |
The name of the keyword file is passed in the constructor. This file has got to contain the keywords in ASCII-format one word each line. Maximum length of a keyword is defined in MAX_KEYWORD_LEN in the header file and is actually set to 32. Hard coded default keywords are used if the specified keyword file cannot be opened. Use the function bool IsKeyword(const char* word) to determine if a string is a keyword or not.
TFMain
| header | source |
This class manages the user interface. It contains a TPageControl with the three TTabSheet objects named “Options”, “Convert” and “About”. The class loads the keyword-objects (TKeyword) and the syntax-highlighting styles (TItemStyles). It provides the functionality to select, display, edit, save and delete the current style and it manages the file selection and conversion process.