Required Result
The Solution
The Result
HandyFile Find and Replace is so flexible that it can be used in any activity. In this example we shall consider how a developer can create an HTML file to be the starting point of creating a documentation for the C++ source code.
We shall work on the C++ source files (.cpp).
We want to receive an HTML file on output, formatted as per following rules.
Class: class_name Function: function_name Parameters: list of parameters Returns: return_type Description: method_description
| Element | Style name |
|---|---|
| Entity name ("Class", "Function", etc.) | ename |
| Source code entry ("class_name", "function_name", etc.) | scname |
C:\Projects\MyLibrary*.cpp([\w\d\_]*\s@{\&|\*}?)\s@([\w\d\_]+)\:\:
({{\~?[\w\d\_]}|{operator.}}+)\(([^\)]@)\)[^\;]
where
([\w\d\_]*\s@{\&|\*}?)
matches the function return type.
The * operator indicates that
the return type specification may not exist.
The expression \s@{\&|\*}? allows any indirection.
(first stored expression);
([\w\d\_]+) matches the class name
(second stored expression);
({{\~?[\w\d\_]}|{operator.}}+)
matches the function name,
which may be the destructor \~?
or operator {operator.}
(third stored expression).
(.@) matches the function parameters
(fourth stored expression).
[^\;] disallows matching function calls.
<table>
<tr><td>
<span class="ename">Class: </span><span class="scname">\2</span><br>
<span class="ename">Function: </span><span class="scname">\3</span><br>
<span class="ename">Parameters: </span><span class="scname">\4</span><br>
<span class="ename">Returns: </span><span class="scname">\1</span><br>
</td></tr>
<tr><td>
<h1>Description</h1>
</td></tr>
</table>
where
\2 is the stored class name;
\3 is the stored function name;
\4 is the stored function parameter set;
\1 is the stored function return type.C:\Projects\MyLibrary\doc.html.The following block is a part of the generated collector file for the MFC source:
<table> <tr><td> <span class="ename">Class: </span><span class="scname">CListView</span><br> <span class="ename">Function: </span><span class="scname">DrawItem</span><br> <span class="ename">Parameters: </span><span class="scname">LPDRAWITEMSTRUCT</span><br> <span class="ename">Returns: </span><span class="scname">void</span><br> </td></tr> <tr><td> <h1>Description</h1> </td></tr> </table> <table> <tr><td> <span class="ename">Class: </span><span class="scname">CListView</span><br> <span class="ename">Function: </span><span class="scname">OnChildNotify</span><br> <span class="ename">Parameters: </span><span class="scname">UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult</span><br> <span class="ename">Returns: </span><span class="scname">BOOL</span><br> </td></tr> <tr><td> <h1>Description</h1> </td></tr> </table>