|
/* ==========================================================================
File : DocumentationGenerator.cpp
Class : CDocumentationGenerator
Date : 06/16/04
Purpose : "CDocumentationGenerator" represents the documentation
for a single cpp-file.
Description : The function definitions are saved as "CFunction"-instances
in "m_functions".
Usage : Fill with info from a cpp-file, and call "Generate" to
generate the results.
========================================================================*/
#include "stdafx.h"
#include "DocumentationGenerator.h"
#include "Function.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
////////////////////////////////////////////////////////////////////
// Public functions
//
CDocumentationGenerator::CDocumentationGenerator( )
/* ============================================================
Function : CDocumentationGenerator::CDocumentationGenerator
Description : Constructor
Access : Public
Return : void
Parameters : none
Usage : Normally, create on the stack.
============================================================*/
{
}
CDocumentationGenerator::~CDocumentationGenerator( )
/* ============================================================
Function : CDocumentationGenerator::~CDocumentationGenerator
Description : Destructor
Access : Public
Return : void
Parameters : none
Usage :
============================================================*/
{
}
void CDocumentationGenerator::AddFunction( CFunction * function )
/* ============================================================
Function : CDocumentationGenerator::AddFunction
Description : Adds a function definition to this instance.
Access : Public
Return : void
Parameters : CFunction * function - Function to add.
Usage : Call to add a function definition.
============================================================*/
{
m_functions.Add( function );
}
void CDocumentationGenerator::Generate( CStringArray & stra )
/* ============================================================
Function : CDocumentationGenerator::Generate
Description : Generates the contents of the instance to
"stra".
Access : Public
Return : void
Parameters : CStringArray & stra - Array to generate
to.
Usage : Call to generate the documentation.
============================================================*/
{
CString purpose = GetPurpose();
CString description = GetDescription();
CString usage = GetUsage();
if( purpose.IsEmpty() )
purpose = _T( "-" );
if( description.IsEmpty() )
description = _T( "-" );
if( usage.IsEmpty() )
usage = _T( "-" );
purpose += _T( "<br>" );
description += _T( "<br>" );
stra.Add( _T( "<h2>" ) + GetClass() + _T( "</h2><h3>Overview</h3>" ) );
stra.Add( _T( "<blockquote>" ) );
stra.Add( _T( "<b>Purpose</b><br>" ) );
stra.Add( purpose );
stra.Add( _T( "<p><b>Description</b><br>" ) );
stra.Add( description );
stra.Add( _T( "<p><b>Usage</b><br>" ) );
stra.Add( usage );
stra.Add( _T( "<p><a class='top' href='index.html'>[back to the index page]</a>" ) );
stra.Add( _T( "</blockquote>" ) );
stra.Add( _T( "<a name='contents'></a><h3>Contents</h3>" ) );
m_functions.Generate( stra );
}
CString CDocumentationGenerator::GetPurpose( ) const
/* ============================================================
Function : CDocumentationGenerator::GetPurpose
Description : Accessor. Getter for "m_purpose"
Access : Public
Return : CString - The purpose field
Parameters : none
Usage : Call to get the Purpose-field of the header
comment block in the current cpp-file.
============================================================*/
{
return m_purpose;
}
void CDocumentationGenerator::SetPurpose( CString value )
/* ============================================================
Function : CDocumentationGenerator::SetPurpose
Description : Accessor. Setter for "m_purpose"
Access : Public
Return : void
Parameters : CString value - New value
Usage : Call to set the Purpose-field of the header
comment block in the current cpp-file.
============================================================*/
{
value.TrimLeft();
value.TrimRight();
value.Replace( _T( "<" ), _T( "<" ) );
value.Replace( _T( ">" ), _T( ">" ) );
AddCode( value );
m_purpose = value;
}
CString CDocumentationGenerator::GetDescription( ) const
/* ============================================================
Function : CDocumentationGenerator::GetDescription
Description : Accessor. Getter for "m_description"
Access : Public
Return : CString - The description field.
Parameters : none
Usage : Call to get the Description-field of the header
comment block in the current cpp-file.
============================================================*/
{
return m_description;
}
void CDocumentationGenerator::SetDescription( CString value )
/* ============================================================
Function : CDocumentationGenerator::SetDescription
Description : Accessor. Setter for "m_description"
Access : Public
Return : void
Parameters : CString value - New value
Usage : Call to set the Description-field of the header
comment block in the current cpp-file.
============================================================*/
{
value.TrimLeft();
value.TrimRight();
value.Replace( _T( "<" ), _T( "<" ) );
value.Replace( _T( ">" ), _T( ">" ) );
AddCode( value );
m_description = value;
}
CString CDocumentationGenerator::GetUsage( ) const
/* ============================================================
Function : CDocumentationGenerator::GetUsage
Description : Accessor. Getter for "m_usage"
Access : Public
Return : CString - The usage field
Parameters : none
Usage : Call to get the Usage-field of the header
comment block in the current cpp-file.
============================================================*/
{
return m_usage;
}
void CDocumentationGenerator::SetUsage( CString value )
/* ============================================================
Function : CDocumentationGenerator::SetUsage
Description : Accessor. Setter for "m_usage"
Access : Public
Return : void
Parameters : CString value - New value
Usage : Call to set the Usage-field of the header
comment block in the current cpp-file.
============================================================*/
{
value.TrimLeft();
value.TrimRight();
value.Replace( _T( "<" ), _T( "<" ) );
value.Replace( _T( ">" ), _T( ">" ) );
AddCode( value );
m_usage = value;
}
CString CDocumentationGenerator::GetClass( ) const
/* ============================================================
Function : CDocumentationGenerator::GetClass
Description : Accessor. Getter for "m_class"
Access : Public
Return : CString - The class
Parameters : none
Usage : Call to set the class in the current cpp-file.
============================================================*/
{
return m_class;
}
void CDocumentationGenerator::SetClass( CString value )
/* ============================================================
Function : CDocumentationGenerator::SetClass
Description : Accessor. Setter for "m_class"
Access : Public
Return : void
Parameters : CString value - New value
Usage : Call to set the class of the current
cpp-file.
============================================================*/
{
value.TrimLeft();
value.TrimRight();
m_class = value;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
45 years old, married, three kids.
Started with computers more than 20 years ago on a CBM-64.
Read Theoretical Philosophy at the University of Lund.
Working as a C++ consultant developer.
Science-fiction freak. Enjoy vintage punkrock.