umbrello 2.34.70-5524f40e1
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:
Collaboration 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)
 
CodeDocumentListgetCodeDocumentList ()
 
QString getUniqueID (CodeDocument *codeDoc)
 
virtual void saveToXMI (QXmlStreamWriter &writer)
 
CodeDocumentfindCodeDocumentByID (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 setForceSections (bool f)
 
bool forceSections () const
 
virtual QString getHeadingFile (const QString &file)
 
QString findFileName (CodeDocument *codeDocument)
 
virtual void loadFromXMI (QDomElement &element)
 
CodeDocumentfindCodeDocumentByClassifier (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 More...
 
bool isInterface
 whether or not this concept is an interface More...
 

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 *concept, bool generated)
 
void codeGenerated (UMLClassifier *concept, 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=QLatin1String(" *"), 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 *concept, const QString &ext)
 
QString overwritableName (UMLPackage *concept, 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
 
UMLDocm_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
op1first operation to be compared
op2second operation to be compared
Here is the call graph for this function:

◆ 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
umlOpoperation to be searched
opllist of operations
Here is the call graph for this function:

◆ 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
cthe class for which we are generating code
oplthe list of operations used to append the operations
Here is the call graph for this function:

◆ 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
cthe class for which we are generating code
yetImplementedOpListthe list of yet implemented operations
toBeImplementedOpListthe list of to be implemented operations
noClassInPathtells if there is a class between the base class and the current interface
Here is the call graph for this function:

◆ getUMLObjectName()

QString DWriter::getUMLObjectName ( UMLObject obj)
private

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

Here is the call graph for this function:

◆ 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.

Here is the call graph for this function:

◆ writeAssociationMethods()

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

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

Here is the call graph for this function:

◆ 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.

Here is the call graph for this function:

◆ 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.

Here is the call graph for this function:

◆ writeAttributeDecl()

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

Writes attribute declarations with a specific protection modifier.

Parameters
visibilitythe protection modifier
atlistattribute list
dtext stream
Here is the call graph for this function:

◆ writeAttributeDecls()

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

Writes the Attribute declarations.

Parameters
atpubList of public attributes
atprotlist of protected attributes
atprivlist of private attributes
dtext stream
Here is the call graph for this function:

◆ writeAttributeMethods()

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

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

Here is the call graph for this function:

◆ writeAttributes()

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

Write all attributes for a given class.

Parameters
cthe class for which we are generating code
jthe 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
cthe class to generate code for

Implements SimpleCodeGenerator.

Here is the call graph for this function:

◆ writeClassDecl()

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

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

Here is the call graph for this function:

◆ 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.

Here is the call graph for this function:

◆ writeDocumentation()

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

Writes a documentation comment.

Here is the call graph for this function:

◆ writeModuleDecl()

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

Writes the module declaration.

Here is the call graph for this function:

◆ writeModuleImports()

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

Writes the module imports.

Here is the call graph for this function:

◆ writeOperations() [1/2]

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

Write all operations for a given class.

Parameters
cthe class for which we are generating code
jthe stream associated with the output file
Here is the call graph for this function:

◆ writeOperations() [2/2]

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

Write a list of operations for a given class.

Parameters
listthe list of operations you want to write
jthe stream associated with the output file
Here is the call graph for this function:

◆ writeProtectionMod()

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

Writes the protection modifier line.

Parameters
visibilityprotection modifier
dtext stream
Here is the call graph for this function:

◆ 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.

Here is the call graph for this function:

◆ 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.

Here is the call graph for this function:

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: