umbrello API Documentation

CodeGenerationPolicy Class Reference

class CodeGenerationPolicy This class describes the code generation policy for this project. More...

#include <codegenerationpolicy.h>

List of all members.

Public Types

enum  OverwritePolicy { Ok = 0, Ask, Never, Cancel }
 OverwritePolicy can have the following values Ok: if there is a file named the same as what you want to name your output file, you can overwrite the old file. More...
enum  ModifyNamePolicy { No = 0, Underscore, Capitalise }
enum  NewLineType { UNIX = 0, DOS, MAC }
enum  IndentationType { NONE = 0, TAB, SPACE }
enum  CommentStyle { SingleLine = 0, MultiLine }
enum  ScopePolicy { Public = 200, Private, Protected, FromParent }

Signals

void modifiedCodeContent ()

Public Member Functions

OverwritePolicy defaultOverwritePolicy () const
bool defaultVerboseSectionComments () const
bool defaultVerboseDocumentComments () const
bool defaultIncludeHeadings () const
NewLineType defaultLineEndingType () const
IndentationType defaultIndentType () const
int defaultIndentAmount () const
ModifyNamePolicy defaultModifyNamePolicy () const
CommentStyle defaultCommentStyle () const
ScopePolicy defaultAttribAccessorScope () const
ScopePolicy defaultAssocFieldScope () const
bool defaultAutoGenerateConstructors () const
 CodeGenerationPolicy (CodeGenerationPolicy *clone=0)
 Constructor.
 CodeGenerationPolicy (KConfig *config)
virtual ~CodeGenerationPolicy ()
 Empty Destructor.
void setOverwritePolicy (OverwritePolicy new_var)
 Set the value of m_overwritePolicy Policy of how to deal with overwriting existing files.
OverwritePolicy getOverwritePolicy () const
 Get the value of m_overwritePolicy Policy of how to deal with overwriting existing files.
void setCodeVerboseSectionComments (bool new_var)
 Set the value of m_codeVerboseSectionComments Whether or not verbose code commenting for sections is desired.
bool getCodeVerboseSectionComments () const
 Get the value of m_codeVerboseSectionComments Whether or not verbose code commenting for sections is desired.
void setCodeVerboseDocumentComments (bool new_var)
 Set the value of m_codeVerboseDocumentComments Whether or not verbose code commenting for documentation is desired.
bool getCodeVerboseDocumentComments () const
 Get the value of m_codeVerboseDocumentComments Whether or not verbose code commenting for documentation is desired.
void setHeadingFileDir (const QString &path)
 Set the value of m_headingFileDir location of the header file template.
QString getHeadingFileDir () const
 Get the value of m_headingFileDir location of the header file template.
void setIncludeHeadings (bool new_var)
 Set the value of m_includeHeadings.
bool getIncludeHeadings () const
 Get the value of m_includeHeadings.
void setOutputDirectory (QDir new_var)
 Set the value of m_outputDirectory location of where output files will go.
QDir getOutputDirectory ()
 Get the value of m_outputDirectory location of where output files will go.
void setLineEndingType (NewLineType new_var)
 Set the value of m_lineEndingType What line ending characters to use.
NewLineType getLineEndingType ()
 Get the value of m_lineEndingType What line ending characters to use.
QString getNewLineEndingChars () const
 Utility function to get the actual characters.
void setIndentationType (IndentationType type)
 Set the value of m_indentationType The amount and type of whitespace to indent with.
IndentationType getIndentationType ()
 Get the value of m_indentationType.
void setIndentationAmount (int amount)
 How many units to indent for each indentation level.
int getIndentationAmount ()
QString getIndentation () const
 Get the string representation of each level of indentation.
void setModifyPolicy (ModifyNamePolicy new_var)
 Set the value of m_modifyPolicy.
ModifyNamePolicy getModifyPolicy () const
 Get the value of m_modifyPolicy.
void setAutoGenerateConstructors (bool var)
 Set the value of m_autoGenerateConstructors.
bool getAutoGenerateConstructors ()
 Get the value of m_autoGenerateConstructors.
void setAttributeAccessorScope (ScopePolicy var)
 Set the value of m_attributeAccessorScope.
ScopePolicy getAttributeAccessorScope ()
 Get the value of m_attributeAccessorScope.
void setAssociationFieldScope (ScopePolicy var)
 Set the value of m_associationFieldScope.
ScopePolicy getAssociationFieldScope ()
 Get the value of m_associationFieldScope.
virtual CodeGenerationPolicyPagecreatePage (QWidget *parent=0, const char *name=0)
 Create a new dialog interface for this object.
QString getHeadingFile (QString str)
 Gets the heading file (as a string) to be inserted at the beginning of the generated file.
virtual void setDefaults (CodeGenerationPolicy *defaults, bool emitUpdateSignal=true)
 set the defaults for this code generator from the passed generator.
virtual void setDefaults (KConfig *config, bool emitUpdateSignal=true)
 set the defaults from a config file for this code generator from the passed KConfig pointer.
virtual void writeConfig (KConfig *config)
 write Default params to passed KConfig pointer.
void emitModifiedCodeContentSig ()
void setCommentStyle (CommentStyle new_var)
 Set the value of m_commentStyle.
CommentStyle getCommentStyle ()
 Get the value of m_commentStyle.

Protected Member Functions

void calculateIndentation ()
void initFields ()

Protected Attributes

OverwritePolicy m_overwritePolicy
bool m_codeVerboseSectionComments
bool m_codeVerboseDocumentComments
QDir m_headingFiles
bool m_includeHeadings
QDir m_outputDirectory
NewLineType m_lineEndingType
IndentationType m_indentationType
int m_indentationAmount
ModifyNamePolicy m_modifyPolicy
bool m_autoGenerateConstructors
CommentStyle m_commentStyle
ScopePolicy m_attributeAccessorScope
ScopePolicy m_associationFieldScope
QString m_lineEndingChars
QString m_indentation


Detailed Description

class CodeGenerationPolicy This class describes the code generation policy for this project.

Definition at line 35 of file codegenerationpolicy.h.


Member Enumeration Documentation

enum CodeGenerationPolicy::OverwritePolicy
 

OverwritePolicy can have the following values Ok: if there is a file named the same as what you want to name your output file, you can overwrite the old file.

  • * - Ask:if there is a file named the same as what you want to name your output file, you should ask the User what to do, and give him the option to overwrite the file write the code to a different file, or to abort the generation of this class.
  • Never: you cannot overwrite any files. Generates a new file name like "fileName1.h", "fileName2.h" until you find an appropriate name.
  • Cancel: Do not output anything. This is only set if the user chooses Apply to All Remaining Files and clicks on Do not Output in the Ask dialog

Definition at line 51 of file codegenerationpolicy.h.


Constructor & Destructor Documentation

CodeGenerationPolicy::CodeGenerationPolicy CodeGenerationPolicy clone = 0  ) 
 

Constructor.

Definition at line 96 of file codegenerationpolicy.cpp.

References setDefaults().

CodeGenerationPolicy::~CodeGenerationPolicy  )  [virtual]
 

Empty Destructor.

Definition at line 109 of file codegenerationpolicy.cpp.


Member Function Documentation

void CodeGenerationPolicy::setOverwritePolicy OverwritePolicy  new_var  ) 
 

Set the value of m_overwritePolicy Policy of how to deal with overwriting existing files.

OverwritePolicy can have the following values

  • Ok: if there is a file named the same as what you want to name your output file, you can overwrite the old file.
  • Ask:if there is a file named the same as what you want to name your output file, you should ask the User what to do, and give him the option to overwrite the file write the code to a different file, or to abort the generation of this class.
  • Never: you cannot overwrite any files. Generates a new file name like "fileName1.h", "fileName2.h" until you find an appropriate name.
  • Cancel: Do not output anything. This is only set if the user chooses Apply to All Remaining Files and clicks on Do not Output in the Ask dialog

Parameters:
new_var the new value of m_overwritePolicy

Definition at line 129 of file codegenerationpolicy.cpp.

Referenced by CodeGenerator::overwritableName(), and setDefaults().

CodeGenerationPolicy::OverwritePolicy CodeGenerationPolicy::getOverwritePolicy  )  const
 

Get the value of m_overwritePolicy Policy of how to deal with overwriting existing files.

Allowed values are "Ok", "Ask", "Never" "Cancel".

Returns:
the value of m_overwritePolicy

Definition at line 139 of file codegenerationpolicy.cpp.

Referenced by CodeGenerator::overwritableName(), and writeConfig().

void CodeGenerationPolicy::setCodeVerboseSectionComments bool  new_var  ) 
 

Set the value of m_codeVerboseSectionComments Whether or not verbose code commenting for sections is desired.

If true, comments for sections will be written even if the section is empty.

Parameters:
new_var the new value of m_codeVerboseSectionComments

Definition at line 166 of file codegenerationpolicy.cpp.

Referenced by setDefaults().

bool CodeGenerationPolicy::getCodeVerboseSectionComments  )  const
 

Get the value of m_codeVerboseSectionComments Whether or not verbose code commenting for sections is desired.

If true, comments for sections will be written even if the section is empty.

Returns:
the value of m_codeVerboseSectionComments

Definition at line 177 of file codegenerationpolicy.cpp.

Referenced by writeConfig().

void CodeGenerationPolicy::setCodeVerboseDocumentComments bool  new_var  ) 
 

Set the value of m_codeVerboseDocumentComments Whether or not verbose code commenting for documentation is desired.

If true, documentation for various code will be written even if no code would normally be created at that point in the file.

Parameters:
new_var the new value of m_codeVerboseDocumentComments

Definition at line 188 of file codegenerationpolicy.cpp.

Referenced by setDefaults().

bool CodeGenerationPolicy::getCodeVerboseDocumentComments  )  const
 

Get the value of m_codeVerboseDocumentComments Whether or not verbose code commenting for documentation is desired.

If true, documentation for various code will be written even if no code would normally be created at that point in the file.

Returns:
the value of m_codeVerboseDocumentComments

Definition at line 200 of file codegenerationpolicy.cpp.

Referenced by JavaClassifierCodeDocument::forceDoc(), CPPHeaderCodeDocument::updateContent(), and writeConfig().

void CodeGenerationPolicy::setHeadingFileDir const QString &  path  ) 
 

Set the value of m_headingFileDir location of the header file template.

Parameters:
path the new path of m_headingFileDir

Definition at line 209 of file codegenerationpolicy.cpp.

Referenced by setDefaults().

QString CodeGenerationPolicy::getHeadingFileDir  )  const
 

Get the value of m_headingFileDir location of the header file template.

Returns:
the value of m_headingFileDir

Definition at line 218 of file codegenerationpolicy.cpp.

Referenced by writeConfig().

void CodeGenerationPolicy::setIncludeHeadings bool  new_var  ) 
 

Set the value of m_includeHeadings.

Parameters:
new_var the new value of m_includeHeadings

Definition at line 226 of file codegenerationpolicy.cpp.

Referenced by setDefaults().

bool CodeGenerationPolicy::getIncludeHeadings  )  const
 

Get the value of m_includeHeadings.

Returns:
the value of m_includeHeadings

Definition at line 235 of file codegenerationpolicy.cpp.

Referenced by getHeadingFile(), and writeConfig().

void CodeGenerationPolicy::setOutputDirectory QDir  new_var  ) 
 

Set the value of m_outputDirectory location of where output files will go.

Parameters:
new_var the new value of m_outputDirectory

Definition at line 244 of file codegenerationpolicy.cpp.

Referenced by setDefaults(), and PerlWriter::writeClass().

QDir CodeGenerationPolicy::getOutputDirectory  ) 
 

Get the value of m_outputDirectory location of where output files will go.

Returns:
the value of m_outputDirectory

Definition at line 253 of file codegenerationpolicy.cpp.

Referenced by CodeGenerator::findFileName(), CodeGenerator::openFile(), CodeGenerator::overwritableName(), PerlWriter::writeClass(), and writeConfig().

void CodeGenerationPolicy::setLineEndingType NewLineType  new_var  ) 
 

Set the value of m_lineEndingType What line ending characters to use.

Parameters:
new_var the new value of m_lineEndingType

Definition at line 262 of file codegenerationpolicy.cpp.

Referenced by setDefaults().

CodeGenerationPolicy::NewLineType CodeGenerationPolicy::getLineEndingType  ) 
 

Get the value of m_lineEndingType What line ending characters to use.

Returns:
the value of m_lineEndingType

Definition at line 284 of file codegenerationpolicy.cpp.

Referenced by writeConfig().

QString CodeGenerationPolicy::getNewLineEndingChars  )  const
 

Utility function to get the actual characters.

Definition at line 290 of file codegenerationpolicy.cpp.

Referenced by CodeGenerator::formatDoc(), getHeadingFile(), TextBlock::setAttributesFromNode(), CodeMethodBlock::setAttributesFromNode(), TextBlock::setAttributesOnNode(), CodeMethodBlock::setAttributesOnNode(), SimpleCodeGenerator::syncCodeToDocument(), TextBlock::toString(), CodeMethodBlock::toString(), and CPPHeaderCodeDocument::updateContent().

void CodeGenerationPolicy::setIndentationType IndentationType  type  ) 
 

Set the value of m_indentationType The amount and type of whitespace to indent with.

Parameters:
type the new value of m_indentationType

Definition at line 299 of file codegenerationpolicy.cpp.

Referenced by setDefaults().

CodeGenerationPolicy::IndentationType CodeGenerationPolicy::getIndentationType  ) 
 

Get the value of m_indentationType.

Definition at line 305 of file codegenerationpolicy.cpp.

Referenced by writeConfig().

void CodeGenerationPolicy::setIndentationAmount int  amount  ) 
 

How many units to indent for each indentation level.

Definition at line 309 of file codegenerationpolicy.cpp.

Referenced by setDefaults().

QString CodeGenerationPolicy::getIndentation  )  const
 

Get the string representation of each level of indentation.

The amount and type of whitespace to indent with.

Returns:
the value of m_indentationType

Definition at line 326 of file codegenerationpolicy.cpp.

Referenced by TextBlock::getIndentation(), SimpleCodeGenerator::syncCodeToDocument(), and CPPHeaderCodeDocument::updateContent().

void CodeGenerationPolicy::setModifyPolicy ModifyNamePolicy  new_var  ) 
 

Set the value of m_modifyPolicy.

Parameters:
new_var the new value of m_modifyPolicy

Definition at line 353 of file codegenerationpolicy.cpp.

Referenced by setDefaults().

CodeGenerationPolicy::ModifyNamePolicy CodeGenerationPolicy::getModifyPolicy  )  const
 

Get the value of m_modifyPolicy.

Returns:
the value of m_modifyPolicy

Definition at line 361 of file codegenerationpolicy.cpp.

Referenced by writeConfig().

void CodeGenerationPolicy::setAutoGenerateConstructors bool  var  ) 
 

Set the value of m_autoGenerateConstructors.

Parameters:
var the new value

Definition at line 369 of file codegenerationpolicy.cpp.

Referenced by JavaCodeGenerationPolicyPage::apply(), and setDefaults().

bool CodeGenerationPolicy::getAutoGenerateConstructors  ) 
 

Get the value of m_autoGenerateConstructors.

Returns:
value the boolean value of m_autoGenerateConstructors

Definition at line 378 of file codegenerationpolicy.cpp.

Referenced by JavaCodeGenerationPolicyPage::JavaCodeGenerationPolicyPage(), CPPHeaderCodeDocument::updateContent(), and writeConfig().

void CodeGenerationPolicy::setAttributeAccessorScope ScopePolicy  var  ) 
 

Set the value of m_attributeAccessorScope.

Parameters:
var the new value

Definition at line 382 of file codegenerationpolicy.cpp.

Referenced by JavaCodeGenerationPolicyPage::apply(), and setDefaults().

CodeGenerationPolicy::ScopePolicy CodeGenerationPolicy::getAttributeAccessorScope  ) 
 

Get the value of m_attributeAccessorScope.

Returns:
the ScopePolicy value of m_attributeAccessorScope

Definition at line 387 of file codegenerationpolicy.cpp.

Referenced by JavaCodeGenerationPolicyPage::JavaCodeGenerationPolicyPage(), and writeConfig().

void CodeGenerationPolicy::setAssociationFieldScope ScopePolicy  var  ) 
 

Set the value of m_associationFieldScope.

Parameters:
var the new value

Definition at line 391 of file codegenerationpolicy.cpp.

Referenced by JavaCodeGenerationPolicyPage::apply(), and setDefaults().

CodeGenerationPolicy::ScopePolicy CodeGenerationPolicy::getAssociationFieldScope  ) 
 

Get the value of m_associationFieldScope.

Returns:
the ScopePolicy value of m_associationFieldScope

Definition at line 396 of file codegenerationpolicy.cpp.

Referenced by JavaCodeGenerationPolicyPage::JavaCodeGenerationPolicyPage(), and writeConfig().

CodeGenerationPolicyPage * CodeGenerationPolicy::createPage QWidget *  parent = 0,
const char *  name = 0
[virtual]
 

Create a new dialog interface for this object.

Returns:
dialog object

Definition at line 404 of file codegenerationpolicy.cpp.

QString CodeGenerationPolicy::getHeadingFile QString  str  ) 
 

Gets the heading file (as a string) to be inserted at the beginning of the generated file.

you give the file type as parameter and get the string. if fileName starts with a period (.) then fileName is the extension (.cpp, .h, .java) if fileName starts with another character you are requesting a specific file (mylicensefile.txt). The files can have parameters which are denoted by parameter%.

current parameters are author% date% time% filepath%

Definition at line 513 of file codegenerationpolicy.cpp.

References getIncludeHeadings(), and getNewLineEndingChars().

Referenced by CodeGenerator::getHeadingFile().

void CodeGenerationPolicy::setDefaults CodeGenerationPolicy defaults,
bool  emitUpdateSignal = true
[virtual]
 

set the defaults for this code generator from the passed generator.

Definition at line 416 of file codegenerationpolicy.cpp.

References setCodeVerboseDocumentComments(), setCodeVerboseSectionComments(), setHeadingFileDir(), setIncludeHeadings(), setIndentationAmount(), setIndentationType(), setLineEndingType(), setModifyPolicy(), setOutputDirectory(), and setOverwritePolicy().

Referenced by CodeGenerationPolicy().

void CodeGenerationPolicy::setDefaults KConfig *  config,
bool  emitUpdateSignal = true
[virtual]
 

set the defaults from a config file for this code generator from the passed KConfig pointer.

Definition at line 444 of file codegenerationpolicy.cpp.

References setAssociationFieldScope(), setAttributeAccessorScope(), setAutoGenerateConstructors(), setCodeVerboseDocumentComments(), setCodeVerboseSectionComments(), setCommentStyle(), setHeadingFileDir(), setIncludeHeadings(), setIndentationAmount(), setIndentationType(), setLineEndingType(), setModifyPolicy(), setOutputDirectory(), and setOverwritePolicy().

void CodeGenerationPolicy::writeConfig KConfig *  config  )  [virtual]
 

write Default params to passed KConfig pointer.

Definition at line 488 of file codegenerationpolicy.cpp.

References getAssociationFieldScope(), getAttributeAccessorScope(), getAutoGenerateConstructors(), getCodeVerboseDocumentComments(), getCodeVerboseSectionComments(), getCommentStyle(), getHeadingFileDir(), getIncludeHeadings(), getIndentationType(), getLineEndingType(), getModifyPolicy(), getOutputDirectory(), and getOverwritePolicy().

Referenced by UMLApp::saveOptions().

void CodeGenerationPolicy::setCommentStyle CommentStyle  new_var  ) 
 

Set the value of m_commentStyle.

Parameters:
new_var the new value of m_commentStyle

Definition at line 147 of file codegenerationpolicy.cpp.

Referenced by JavaCodeGenerationPolicyPage::apply(), and setDefaults().

CodeGenerationPolicy::CommentStyle CodeGenerationPolicy::getCommentStyle  ) 
 

Get the value of m_commentStyle.

Returns:
the value of m_commentStyle

Definition at line 156 of file codegenerationpolicy.cpp.

Referenced by RubyCodeDocumentation::firstEditableLine(), JavaCodeDocumentation::firstEditableLine(), CPPCodeDocumentation::firstEditableLine(), RubyCodeDocumentation::getNewEditorLine(), JavaCodeDocumentation::getNewEditorLine(), CPPCodeDocumentation::getNewEditorLine(), JavaCodeGenerationPolicyPage::JavaCodeGenerationPolicyPage(), RubyCodeDocumentation::toString(), JavaCodeDocumentation::toString(), CPPCodeDocumentation::toString(), RubyCodeDocumentation::unformatText(), JavaCodeDocumentation::unformatText(), CPPCodeDocumentation::unformatText(), and writeConfig().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for umbrello Version 3.1.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Jun 26 08:08:04 2007 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003