I am using Atomineer 7.31 to format my C++ files, but I'm having trouble creating separate behaviour for different file types. As an example, I'd like to populate my .cpp files with certain information such as including the .h file with the same name as this file, and including my memory tracker, and I'd like the .h file to have a define guard and the basics of a class.
Example of .h file I desire:
//! \file ExampleFile.h
//! \brief Declares an ExampleFile
//! Company legal information etc.
#ifndef EXAMPLEFILE_H
#define EXAMPLEFILE_H
class ExampleFile
{
};
#endif // EXAMPLEFILE_H
And an example of a .cpp file I desire:
//! \file ExampleFile.cpp
//! \brief Implements ExampleFile
//! Company legal information etc.
#include <ExampleFile.h>
// Memory tracking. Do not include anything beneath this!
#include <debug_new.h>
I'd like each of the above behaviours to appear (based on the file-type being used) when at the top of a blank file 3 forward-slashes are inserted (I believe this is default Atomineer behaviour). I've looked through http://www.atomineerutils.com/rulesguide.php, as well as the .xml files included with Atomineer (File.xml, Namespace.xml, DoxygenTemplates.xml, UserVariables.xml etc.), but I can't find any indication of whether I can do what I need.
There is a small example in File.xml where different information is used in the comments at the top of the file (e.g. header files will say "Declares class xxx" whereas .cpp/.c files will say "Implements class xxx"); but I'm unable to mimic that behaviour.
I'm aware of the %extension% variable that can be used, and the < If /> command, but I don't seem to be able to get what I desire. I've also tried using the Namespace.xml file in a similar way to the File.xml (File.xml declares the %fileDescription% variable to use, which is the one which handles whether the file says "Declares class xxx" or "Implements class xxx"), but I'm unable to get Namespace.xml to display anything at all.
Example of File.xml:
<File>
<!-- Rules for generating auto-documentation for file header comments. The results of executing this rule are placed in %fileDescription% when adding file comments. -->
<If extension=".c" desc="" />
<If sNameRaw="I #" desc="Declares the %name% interface" />
<If extension=".h,.hpp" continue="y" desc="Declares the " />
<If extension=".cs,.cpp,.java" continue="y" desc="Implements the " />
<If sName="# dialog,# dialogue" desc="%match:noPrefix:LCase% Dialog" />
<If sName="# form,# window" desc="%match:noPrefix:LCase% Windows Form" />
<Set desc="%sname:noPrefix:LCase% class" />
</File>
That information is then used in DoxygenTemplates.xml:
<file>
//! \file %projectpathname%
//! \brief %fileDescription%
//!
//----------------------------------------------------------------------------------------------------------------------
// (c) Copyright 2015 by %company%
//----------------------------------------------------------------------------------------------------------------------
%ip%
</file>
I've tried inserting several things above the %ip% (input position: where the mouse cursor will appear) but to no avail. I feel that perhaps part of the problem is that I can't get Namespace.xml to display anything. For instance, above the %ip% I've put %namespaceDescription% and I have a simple < Set desc="Hi" /> in Namespace.xml, but it doesn't display. I'd appreciate any help in solving this, thanks!
Yes, it is possible to do this with Atomineer! Proper functionality was added in a later version which I'll talk about, but to answer your question, you could change your DoxygenTemplate.xml to:
And then add everything in your File.xml, like so:
That being said, proper support was added for this kind of functionality in Atomineer 7.36.
The information necessary to achieve this is in the documentation:
If you have Atomineer 7.36 or higher, in your DoxygenTemplates.xml file you can write the following (If you have Atomineer 7.36 or higher it looks as if the default template comes with an example for an include guard):
For the header files:
For the cpp files:
Ensure that they both appear above any generic
because the Atomineer documentation states that
Regarding your problem with Namespace.xml and %namespaceDescription% not working, you were putting it in the wrong place. File.xml contains < File >: a means of creating a template for Atomineer to use when adding a file comment (that is, a comment created at the top of a file). Namespace.xml contains < Namespace > which is a template for Atomineer to use when adding a namespace comment (that is, a comment above a namespace).