umbrello: CodeBlock Class Reference

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

Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | Friends | List of all members
CodeBlock Class Reference

`#include <codeblock.h>`

Inheritance diagram for CodeBlock:

## Public Types
enum | ContentType { AutoGenerated =0 , UserGenerated }

## Public Member Functions
| CodeBlock (CodeDocument *parent, const QString &body=QString())
virtual | ~CodeBlock ()
void | setContentType (ContentType new_var)
ContentType | contentType () const
virtual void | saveToXMI (QXmlStreamWriter &writer)
virtual void | loadFromXMI (QDomElement &root)
virtual void | setAttributesFromObject (TextBlock *obj)
Public Member Functions inherited from TextBlock
| TextBlock (CodeDocument *parent, const QString &text=QString())
virtual | ~TextBlock ()
void | setText (const QString &text)
QString | getText () const
void | appendText (const QString &text)
void | setTag (const QString &value)
QString | getTag () const
CodeDocument * | getParentDocument () const
void | setWriteOutText (bool write)
bool | getWriteOutText () const
void | setIndentationLevel (int level)
int | getIndentationLevel () const
QString | getIndentationString (int level=0) const
virtual QString | unformatText (const QString &text, const QString &indent=QString())
virtual QString | toString () const
bool | canDelete () const
virtual QString | getNewEditorLine (int amount=0)
virtual int | firstEditableLine ()
virtual int | lastEditableLine ()

## Static Public Member Functions
static QString | enumToString (const ContentType &val)
Static Public Member Functions inherited from TextBlock
static QString | getIndentation ()
static QString | getNewLineEndingChars ()
static QString | formatMultiLineText (const QString &work, const QString &linePrefix, const QString &breakStr, bool addBreak=true, bool lastLineHasBreak=true)
static QString | encodeText (const QString &text, const QString &endLine)
static QString | decodeText (const QString &text, const QString &endLine)

## Protected Member Functions
virtual void | setAttributesOnNode (QXmlStreamWriter &writer)
virtual void | setAttributesFromNode (QDomElement &element)
Protected Member Functions inherited from TextBlock
void | setCanDelete (bool canDelete)
virtual void | release ()

## Private Attributes
ContentType | m_contentType

## Friends
QDebug | operator<< (QDebug str, const CodeBlock &obj)

## Detailed Description

A "chunk" of code within the code document.

## Member Enumeration Documentation

## ◆ ContentType

enum CodeBlock::ContentType

Describes the creation of the content.

Enumerator
AutoGenerated | the content was generated by code generation itself
UserGenerated | the content was entered by the user

## Constructor & Destructor Documentation

## ◆ CodeBlock()

CodeBlock::CodeBlock | ( | CodeDocument * | doc,
|  | const QString & | body = QString() )
| explicit

Constructor.

Parameters

  doc | the documentation text
  body | the body text

## ◆ ~CodeBlock()

CodeBlock::~CodeBlock | ( |  | ) |
| virtual

Empty Destructor.

## Member Function Documentation

## ◆ contentType()

CodeBlock::ContentType CodeBlock::contentType | ( |  | ) | const

Get the value of m_contentType specifies whether the content (text) of this object was generated by the code generator or was supplied by the user.

Returns
  the value of m_contentType

## ◆ enumToString()

QString CodeBlock::enumToString | ( | const ContentType & | val | ) |
| static

Return a string representation of ContentType.

Parameters

  val | the enum value of the ContentType

Returns
  the string representation of the enum

## ◆ loadFromXMI()

void CodeBlock::loadFromXMI | ( | QDomElement & | root | ) |
| virtual

Load params from the appropriate XMI element node.

Parameters

  root | the starting point to load from

Implements TextBlock.

Reimplemented in CodeAccessorMethod, CodeBlockWithComments, CodeClassFieldDeclarationBlock, CodeOperation, CPPHeaderClassDeclarationBlock, DClassDeclarationBlock, HierarchicalCodeBlock, JavaClassDeclarationBlock, OwnedHierarchicalCodeBlock, RubyClassDeclarationBlock, and XMLElementCodeBlock.

## ◆ saveToXMI()

void CodeBlock::saveToXMI | ( | QXmlStreamWriter & | writer | ) |
| virtual

Save the XMI representation of this object.

Parameters

  writer | QXmlStreamWriter serialization target

Implements TextBlock.

Reimplemented in CodeAccessorMethod, CodeBlockWithComments, CodeClassFieldDeclarationBlock, CodeOperation, CPPHeaderClassDeclarationBlock, DClassDeclarationBlock, HierarchicalCodeBlock, JavaClassDeclarationBlock, OwnedHierarchicalCodeBlock, RubyClassDeclarationBlock, and XMLElementCodeBlock.

## ◆ setAttributesFromNode()

void CodeBlock::setAttributesFromNode | ( | QDomElement & | elem | ) |
| protectedvirtual

Set the class attributes of this object from the passed element node.

Parameters

  elem | the xmi element from which to load

Reimplemented from TextBlock.

Reimplemented in CodeAccessorMethod, CodeBlockWithComments, CodeClassFieldDeclarationBlock, CodeMethodBlock, CodeOperation, DCodeAccessorMethod, HierarchicalCodeBlock, JavaCodeAccessorMethod, OwnedHierarchicalCodeBlock, RubyCodeAccessorMethod, and XMLElementCodeBlock.

## ◆ setAttributesFromObject()

void CodeBlock::setAttributesFromObject | ( | TextBlock * | obj | ) |
| virtual

Set the class attributes from a passed object.

Parameters

  obj | text block from which the attributes are taken

Reimplemented from TextBlock.

Reimplemented in CodeAccessorMethod, CodeBlockWithComments, CodeClassFieldDeclarationBlock, CodeMethodBlock, CodeOperation, CPPHeaderClassDeclarationBlock, DClassDeclarationBlock, HierarchicalCodeBlock, and OwnedHierarchicalCodeBlock.

## ◆ setAttributesOnNode()

void CodeBlock::setAttributesOnNode | ( | QXmlStreamWriter & | writer | ) |
| protectedvirtual

Set attributes of the node that represents this class in the XMI document.

Parameters

  writer | QXmlStreamWriter serialization target

Reimplemented from TextBlock.

Reimplemented in CodeAccessorMethod, CodeBlockWithComments, CodeClassFieldDeclarationBlock, CodeMethodBlock, CodeOperation, DCodeAccessorMethod, HierarchicalCodeBlock, JavaCodeAccessorMethod, OwnedHierarchicalCodeBlock, RubyCodeAccessorMethod, and XMLElementCodeBlock.

## ◆ setContentType()

void CodeBlock::setContentType | ( | ContentType | new_var | ) |

Set the value of m_contentType specifies whether the content (text) of this object was generated by the code generator or was supplied by the user.

Parameters

  new_var | the new value of m_contentType

## Friends And Related Symbol Documentation

## ◆ operator<<

QDebug operator<< | ( | QDebug | str,
|  | const CodeBlock & | obj )
| friend

## Member Data Documentation

## ◆ m_contentType

ContentType CodeBlock::m_contentType
| private

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

- umbrello/codegenerators/codeblock.h
- umbrello/codegenerators/codeblock.cpp