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
PythonWriter Class Reference

#include <pythonwriter.h>

Inheritance diagram for PythonWriter:
Collaboration diagram for PythonWriter:

Public Member Functions

 PythonWriter ()
 
virtual ~PythonWriter ()
 
virtual void writeClass (UMLClassifier *c)
 
virtual Uml::ProgrammingLanguage::Enum language () const
 
virtual QStringList reservedKeywords () 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 void createDefaultStereotypes ()
 

Private Member Functions

void writeAttributes (UMLAttributeList atList, QTextStream &py)
 
void writeOperations (UMLClassifier *c, QTextStream &h)
 
void writeOperations (const QString &classname, UMLOperationList &opList, QTextStream &h, Uml::Visibility::Enum access)
 
QString findIncludeFromType (const QString &string)
 

Static Private Member Functions

static bool hasContainer (const QString &string)
 
static QString fixTypeName (const QString &string)
 

Private Attributes

bool m_bNeedPass
 True as long as no "pass" has been written. 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 PythonWriter is a python code generator for UMLClassifier objects Just call writeClass and feed it a UMLClassifier.

NOTE: There is a unit test available for this class. Please, use and adapt it when necessary.

Constructor & Destructor Documentation

◆ PythonWriter()

PythonWriter::PythonWriter ( )

◆ ~PythonWriter()

PythonWriter::~PythonWriter ( )
virtual

Member Function Documentation

◆ defaultDatatypes()

QStringList PythonWriter::defaultDatatypes ( ) const
virtual

Reimplementation of method from class CodeGenerator

Reimplemented from CodeGenerator.

◆ findIncludeFromType()

QString PythonWriter::findIncludeFromType ( const QString &  string)
private
Here is the call graph for this function:

◆ fixTypeName()

QString PythonWriter::fixTypeName ( const QString &  string)
staticprivate

Fix types to be compatible with Python

Parameters
stringtype as defined in model
Returns
fixed type
Here is the call graph for this function:

◆ hasContainer()

bool PythonWriter::hasContainer ( const QString &  string)
staticprivate

Check if type is a container

Parameters
stringtype that will be used
Returns
true if is a container

◆ language()

Uml::ProgrammingLanguage::Enum PythonWriter::language ( ) const
virtual

Return the programming language identifier.

Returns
programming language id

Implements CodeGenerator.

◆ reservedKeywords()

QStringList PythonWriter::reservedKeywords ( ) const
virtual

Get list of reserved keywords.

Returns
the list of reserved keywords

Reimplemented from CodeGenerator.

◆ writeAttributes()

void PythonWriter::writeAttributes ( UMLAttributeList  atList,
QTextStream &  py 
)
private

Write all attributes for a given class.

Parameters
atListthe attribute list we are generating code for
pyoutput stream for the header file
Here is the call graph for this function:

◆ writeClass()

void PythonWriter::writeClass ( UMLClassifier c)
virtual

Call this method to generate C++ code for a UMLClassifier.

Parameters
cthe class you want to generate code for

Implements SimpleCodeGenerator.

Here is the call graph for this function:

◆ writeOperations() [1/2]

void PythonWriter::writeOperations ( const QString &  classname,
UMLOperationList opList,
QTextStream &  h,
Uml::Visibility::Enum  access 
)
private

Write a list of class operations.

Parameters
classnamethe name of the class
opListthe list of operations
houtput stream for the header file
accessvisibility identifier
Here is the call graph for this function:

◆ writeOperations() [2/2]

void PythonWriter::writeOperations ( UMLClassifier c,
QTextStream &  h 
)
private

Write all operations for a given class.

Parameters
cthe concept we are generating code for
houtput stream for the header file
Here is the call graph for this function:

Member Data Documentation

◆ m_bNeedPass

bool PythonWriter::m_bNeedPass
private

True as long as no "pass" has been written.


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