umbrello: DWriter Class Reference

umbrello 25.04.0 Umbrello UML Modeller is a Unified Modelling Language (UML) diagram program based on KDE Technology

Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
DWriter Class Reference

`#include <dwriter.h>`

Inheritance diagram for DWriter:

## Public Member Functions
| DWriter ()
virtual | ~DWriter ()
virtual void | writeClass (UMLClassifier *c)
virtual Uml::ProgrammingLanguage::Enum | language () const
QStringList | defaultDatatypes () const
Public Member Functions inherited from SimpleCodeGenerator
| SimpleCodeGenerator (bool createDirHierarchyForPackages=true)
virtual | ~SimpleCodeGenerator ()
void | writeCodeToFile (UMLClassifierList &concepts)
void | writeCodeToFile ()
Public Member Functions inherited from CodeGenerator
| CodeGenerator ()
virtual | ~CodeGenerator ()
bool | addCodeDocument (CodeDocument *add_object)
bool | removeCodeDocument (CodeDocument *remove_object)
CodeDocumentList * | getCodeDocumentList ()
QString | getUniqueID (CodeDocument *codeDoc)
virtual void | saveToXMI (QXmlStreamWriter &writer)
CodeDocument * | findCodeDocumentByID (const QString &id)
void | setIncludeHeadings (bool i)
bool | includeHeadings () const
void | setHeadingFileDir (const QString &)
QString | headingFileDir () const
void | setForceDoc (bool f)
bool | forceDoc () const
void | setSectionCommentPolicy (CodeGenerationPolicy::WriteSectionCommentsPolicy f)
bool | forceSections () const
virtual QString | getHeadingFile (const QString &file)
QString | findFileName (CodeDocument *codeDocument)
virtual void | loadFromXMI (QDomElement &element)
CodeDocument * | findCodeDocumentByClassifier (UMLClassifier *classifier)
virtual bool | isReservedKeyword (const QString &keyword)
virtual QStringList | reservedKeywords () const
virtual void | createDefaultStereotypes ()

## Private Member Functions
void | writeModuleDecl (UMLClassifier *c, QTextStream &d)
void | writeModuleImports (UMLClassifier *c, QTextStream &d)
void | writeClassDecl (UMLClassifier *c, QTextStream &d)
void | writeConstructor (UMLClassifier *c, QTextStream &d)
void | getSuperImplementedOperations (UMLClassifier *c, UMLOperationList &yetImplementedOpList, UMLOperationList &toBeImplementedOpList, bool noClassInPath=true)
void | getInterfacesOperationsToBeImplemented (UMLClassifier *c, UMLOperationList &opl)
void | writeOperations (UMLClassifier *c, QTextStream &j)
void | writeOperations (UMLOperationList &list, QTextStream &j)
void | writeAttributes (UMLClassifier *c, QTextStream &j)
void | writeProtectionMod (Uml::Visibility::Enum visibility, QTextStream &d)
void | writeAttributeDecl (Uml::Visibility::Enum visibility, UMLAttributeList &atlist, QTextStream &d)
void | writeAttributeDecls (UMLAttributeList &atpub, UMLAttributeList &atprot, UMLAttributeList &atpriv, QTextStream &d)
void | writeAssociationDecls (UMLAssociationList associations, Uml::ID::Type id, QTextStream &d)
void | writeAssociationRoleDecl (QString fieldClassName, QString roleName, QString multi, QString doc, Uml::Visibility::Enum visib, QTextStream &d)
void | writeAttributeMethods (UMLAttributeList &atpub, Uml::Visibility::Enum visibility, QTextStream &d)
void | writeAssociationMethods (UMLAssociationList associations, UMLClassifier *thisClass, QTextStream &d)
void | writeAssociationRoleMethod (QString fieldClassName, QString roleName, QString multi, QString description, Uml::Visibility::Enum visib, Uml::Changeability::Enum change, QTextStream &d)
void | writeSingleAttributeAccessorMethods (QString fieldClassName, QString fieldVarName, QString fieldName, QString description, Uml::Visibility::Enum visibility, Uml::Changeability::Enum change, bool isFinal, QTextStream &d)
void | writeVectorAttributeAccessorMethods (QString fieldClassName, QString fieldVarName, QString fieldName, QString description, Uml::Visibility::Enum visibility, Uml::Changeability::Enum change, QTextStream &d)
void | writeComment (const QString &text, const QString &indent, QTextStream &d, bool dDocStyle=false)
void | writeDocumentation (QString header, QString body, QString end, QString indent, QTextStream &d)
QString | getUMLObjectName (UMLObject *obj)
QString | deCapitaliseFirstLetter (const QString &str)
QString | pluralize (const QString &string)
QString | unPluralize (const QString &str)
QString | fixTypeName (const QString &string)
QString | fixInitialStringDeclValue (const QString &val, const QString &type)
void | writeBlankLine (QTextStream &d)

## Static Private Member Functions
static bool | compareDMethod (UMLOperation *op1, UMLOperation *op2)
static bool | dMethodInList (UMLOperation *umlOp, UMLOperationList &opl)

## Private Attributes
QString | startline
| a , used at the end of each line
bool | isInterface
| whether or not this concept is an interface

## Additional Inherited Members
Public Types inherited from CodeGenerator
enum | GenerationState { Generated , Failed , Skipped }
Public Slots inherited from SimpleCodeGenerator
virtual void | syncCodeToDocument ()
Public Slots inherited from CodeGenerator
virtual void | syncCodeToDocument ()
Signals inherited from CodeGenerator
void | codeGenerated (UMLClassifier *classifier, bool generated)
void | codeGenerated (UMLClassifier *classifier, CodeGenerator::GenerationState result)
void | showGeneratedFile (const QString &filename)
Static Public Member Functions inherited from CodeGenerator
static QString | cleanName (const QString &name)
static QString | formatDoc (const QString &text, const QString &linePrefix=QStringLiteral(" *"), int lineWidth=80)
static QString | formatFullDocBlock (const QString &text, const QString &blockHeader=QStringLiteral("/* "), const QString &blockFooter=QStringLiteral(" */"), const QString &linePrefix=QStringLiteral(" *"), int lineWidth=80)
static QString | formatSourceCode (const QString &code, const QString &indentation)
static void | findObjectsRelated (UMLClassifier *c, UMLPackageList &cList)
Protected Member Functions inherited from SimpleCodeGenerator
QString | findFileName (UMLPackage *classifier, const QString &ext)
QString | overwritableName (UMLPackage *classifier, const QString &name, const QString &ext)
bool | hasDefaultValueAttr (UMLClassifier *c)
bool | hasAbstractOps (UMLClassifier *c)
QString | indent ()
virtual void | initFromParentDocument ()
Protected Member Functions inherited from CodeGenerator
QString | overwritableName (const QString &name, const QString &extension)
bool | openFile (QFile &file, const QString &name)
void | writeListedCodeDocsToFile (CodeDocumentList *docs)
virtual void | finalizeRun ()
Protected Attributes inherited from SimpleCodeGenerator
QString | className_
QString | fileName_
QMap< UMLPackage *, QString > | m_fileMap
bool | m_createDirHierarchyForPackages
QString | m_indentation
int | m_indentLevel
QString | m_endl
Protected Attributes inherited from CodeGenerator
QHash< QString, CodeDocument * > | m_codeDocumentDictionary
bool | m_applyToAllRemaining
UMLDoc * | m_document

## Detailed Description

Class DWriter is a code generator for UMLClassifier objects. Create an instance of this class, and feed it a UMLClassifier when calling writeClass and it will generate a d source file for that concept. Note: This is the "old" code generator that does not support code editing in the Modeller but uses significantly less file space because the source code is not replicated in the XMI file.

## Constructor & Destructor Documentation

## ◆ DWriter()

DWriter::DWriter | ( |  | ) |

Constructor, initialises a couple of variables.

## ◆ ~DWriter()

DWriter::~DWriter | ( |  | ) |
| virtual

Destructor, empty.

## Member Function Documentation

## ◆ compareDMethod()

bool DWriter::compareDMethod | ( | UMLOperation * | op1,
|  | UMLOperation * | op2 )
| staticprivate

Return true if the two operations have the same name and the same parameters.

Parameters

  op1 | first operation to be compared
  op2 | second operation to be compared

## ◆ deCapitaliseFirstLetter()

QString DWriter::deCapitaliseFirstLetter | ( | const QString & | str | ) |
| private

Lowers the case of the first letter in the given string.

## ◆ defaultDatatypes()

QStringList DWriter::defaultDatatypes | ( |  | ) | const
| virtual

Return the default datatypes. (Overrides method from class CodeGenerator.)

Returns
  list of default datatypes

Reimplemented from CodeGenerator.

## ◆ dMethodInList()

bool DWriter::dMethodInList | ( | UMLOperation * | umlOp,
|  | UMLOperationList & | opl )
| staticprivate

Return true if the operation is in the list.

Parameters

  umlOp | operation to be searched
  opl | list of operations

## ◆ fixInitialStringDeclValue()

QString DWriter::fixInitialStringDeclValue | ( | const QString & | val,
|  | const QString & | type )
| private

Check that initial values of strings have quotes around them.

## ◆ fixTypeName()

QString DWriter::fixTypeName | ( | const QString & | string | ) |
| private

Replaces `string' with `String' and `bool' with `boolean'.

## ◆ getInterfacesOperationsToBeImplemented()

void DWriter::getInterfacesOperationsToBeImplemented | ( | UMLClassifier * | c,
|  | UMLOperationList & | opl )
| private

Get all operations which a given class inherit from all its super interfaces and that should be implemented.

Parameters

  c | the class for which we are generating code
  opl | the list of operations used to append the operations

## ◆ getSuperImplementedOperations()

void DWriter::getSuperImplementedOperations | ( | UMLClassifier * | c,
|  | UMLOperationList & | yetImplementedOpList,
|  | UMLOperationList & | toBeImplementedOpList,
|  | bool | noClassInPath = true )
| private

Get all operations which a given class inherit from all its super interfaces and get all operations which this given class inherit from all its super classes.

Parameters

  c | the class for which we are generating code
  yetImplementedOpList | the list of yet implemented operations
  toBeImplementedOpList | the list of to be implemented operations
  noClassInPath | tells if there is a class between the base class and the current interface

## ◆ getUMLObjectName()

QString DWriter::getUMLObjectName | ( | UMLObject * | obj | ) |
| private

Returns the name of the given object (if it exists).

## ◆ language()

Uml::ProgrammingLanguage::Enum DWriter::language | ( |  | ) | const
| virtual

Returns "D".

Returns
  the programming language identifier

Implements CodeGenerator.

## ◆ pluralize()

QString DWriter::pluralize | ( | const QString & | string | ) |
| private

Returns the plural form of a subject.

## ◆ unPluralize()

QString DWriter::unPluralize | ( | const QString & | str | ) |
| private

Returns the non-plural form of a subject.

## ◆ writeAssociationDecls()

void DWriter::writeAssociationDecls | ( | UMLAssociationList | associations,
|  | Uml::ID::Type | id,
|  | QTextStream & | d )
| private

Searches a list of associations for appropriate ones to write out as attributes.

## ◆ writeAssociationMethods()

void DWriter::writeAssociationMethods | ( | UMLAssociationList | associations,
|  | UMLClassifier * | thisClass,
|  | QTextStream & | d )
| private

Calls writeAssociationRoleMethod() on each of the associations in the given list.

## ◆ writeAssociationRoleDecl()

void DWriter::writeAssociationRoleDecl | ( | QString | fieldClassName,
|  | QString | roleName,
|  | QString | multi,
|  | QString | doc,
|  | Uml::Visibility::Enum | visib,
|  | QTextStream & | d )
| private

Writes out an association as an attribute using Vector.

## ◆ writeAssociationRoleMethod()

void DWriter::writeAssociationRoleMethod | ( | QString | fieldClassName,
|  | QString | roleName,
|  | QString | multi,
|  | QString | description,
|  | Uml::Visibility::Enum | visib,
|  | Uml::Changeability::Enum | change,
|  | QTextStream & | d )
| private

Calls writeSingleAttributeAccessorMethods() or writeVectorAttributeAccessorMethods() on the association role.

## ◆ writeAttributeDecl()

void DWriter::writeAttributeDecl | ( | Uml::Visibility::Enum | visibility,
|  | UMLAttributeList & | atlist,
|  | QTextStream & | d )
| private

Writes attribute declarations with a specific protection modifier.

Parameters

  visibility | the protection modifier
  atlist | attribute list
  d | text stream

## ◆ writeAttributeDecls()

void DWriter::writeAttributeDecls | ( | UMLAttributeList & | atpub,
|  | UMLAttributeList & | atprot,
|  | UMLAttributeList & | atpriv,
|  | QTextStream & | d )
| private

Writes the Attribute declarations.

Parameters

  atpub | List of public attributes
  atprot | list of protected attributes
  atpriv | list of private attributes
  d | text stream

## ◆ writeAttributeMethods()

void DWriter::writeAttributeMethods | ( | UMLAttributeList & | atpub,
|  | Uml::Visibility::Enum | visibility,
|  | QTextStream & | d )
| private

Calls writeSingleAttributeAccessorMethods() on each of the attributes in atpub.

## ◆ writeAttributes()

void DWriter::writeAttributes | ( | UMLClassifier * | c,
|  | QTextStream & | j )
| private

Write all attributes for a given class.

Parameters

  c | the class for which we are generating code
  j | the stream associated with the output file

## ◆ writeBlankLine()

void DWriter::writeBlankLine | ( | QTextStream & | d | ) |
| private

Write a blank line.

## ◆ writeClass()

void DWriter::writeClass | ( | UMLClassifier * | c | ) |
| virtual

Call this method to generate d code for a UMLClassifier.

Parameters

  c | the class to generate code for

Implements SimpleCodeGenerator.

## ◆ writeClassDecl()

void DWriter::writeClassDecl | ( | UMLClassifier * | c,
|  | QTextStream & | d )
| private

Writes class's documentation then the class header "public abstract class Foo extents {".

## ◆ writeComment()

void DWriter::writeComment | ( | const QString & | text,
|  | const QString & | indent,
|  | QTextStream & | d,
|  | bool | dDocStyle = false )
| private

Writes a // style comment.

## ◆ writeConstructor()

void DWriter::writeConstructor | ( | UMLClassifier * | c,
|  | QTextStream & | d )
| private

Writes the comment and class constructor.

## ◆ writeDocumentation()

void DWriter::writeDocumentation | ( | QString | header,
|  | QString | body,
|  | QString | end,
|  | QString | indent,
|  | QTextStream & | d )
| private

Writes a documentation comment.

## ◆ writeModuleDecl()

void DWriter::writeModuleDecl | ( | UMLClassifier * | c,
|  | QTextStream & | d )
| private

Writes the module declaration.

## ◆ writeModuleImports()

void DWriter::writeModuleImports | ( | UMLClassifier * | c,
|  | QTextStream & | d )
| private

Writes the module imports.

## ◆ writeOperations() [1/2]

void DWriter::writeOperations | ( | UMLClassifier * | c,
|  | QTextStream & | j )
| private

Write all operations for a given class.

Parameters

  c | the class for which we are generating code
  j | the stream associated with the output file

## ◆ writeOperations() [2/2]

void DWriter::writeOperations | ( | UMLOperationList & | list,
|  | QTextStream & | j )
| private

Write a list of operations for a given class.

Parameters

  list | the list of operations you want to write
  j | the stream associated with the output file

## ◆ writeProtectionMod()

void DWriter::writeProtectionMod | ( | Uml::Visibility::Enum | visibility,
|  | QTextStream & | d )
| private

Writes the protection modifier line.

Parameters

  visibility | protection modifier
  d | text stream

## ◆ writeSingleAttributeAccessorMethods()

void DWriter::writeSingleAttributeAccessorMethods | ( | QString | fieldClassName,
|  | QString | fieldVarName,
|  | QString | fieldName,
|  | QString | description,
|  | Uml::Visibility::Enum | visibility,
|  | Uml::Changeability::Enum | change,
|  | bool | isFinal,
|  | QTextStream & | d )
| private

Writes getFoo() and setFoo() accessor methods for the attribute.

## ◆ writeVectorAttributeAccessorMethods()

void DWriter::writeVectorAttributeAccessorMethods | ( | QString | fieldClassName,
|  | QString | fieldVarName,
|  | QString | fieldName,
|  | QString | description,
|  | Uml::Visibility::Enum | visibility,
|  | Uml::Changeability::Enum | change,
|  | QTextStream & | d )
| private

Writes addFoo() and removeFoo() accessor methods for the Vector attribute.

## Member Data Documentation

## ◆ isInterface

bool DWriter::isInterface
| private

whether or not this concept is an interface

## ◆ startline

QString DWriter::startline
| private

a
, used at the end of each line

The documentation for this class was generated from the following files:

- umbrello/codegenerators/d/dwriter.h
- umbrello/codegenerators/d/dwriter.cpp