GithubHelp home page GithubHelp logo

nbhhcty / cpp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from staruml/staruml-cpp

0.0 2.0 0.0 2.37 MB

C++ extension for StarUML 2

License: MIT License

JavaScript 99.73% Shell 0.01% C++ 0.26%

cpp's Introduction

Cpp Extension for StarUML 2

This extension for StarUML(http://staruml.io) support to generate Cpp code from UML model.

UMLPackage

  • converted to folder.

UMLClass

  • converted to Cpp Class. (as a separate .h file)
  • visibility to one of modifiers public, protected, private. If visibility is not setted, consider as protected.
  • isFinalSpecialization and isLeaf property to final modifier.
  • Default constructor is generated.
  • All contained types (UMLClass, UMLInterface, UMLEnumeration) are generated as inner type definition.
  • TemplateParameter to Cpp Template.

UMLAttribute

  • converted to Cpp Field.
  • visibility property to one of modifiers public, protected, private. If visibility is not setted, consider as protected.
  • name property to field identifier.
  • type property to field type.
  • multiplicity property to vector type.
  • isStatic property to static modifier.
  • isLeaf property to final modifier.
  • defaultValue property to initial value.
  • Documentation property to JavaDoc comment.

UMLOperation

  • converted to Cpp Methods.
  • visibility to one of modifiers public, protected, private. If visibility is not setted, consider as protected.
  • name property to method identifier.
  • isAbstract property to virtual modifier. (TODO need options to create pure-virtual function or virtual function)
  • isStatic property to static modifier.
  • UMLParameter to Cpp Method Parameters.
  • UMLParameter's name property to parameter identifier.
  • UMLParameter's type property to type of parameter.
  • UMLParameter with direction = return to return type of method. When no return parameter, void is used.
  • UMLParameter with isReadOnly = true to const modifier of parameter.

UMLInterface

  • converted to Cpp Class. (as a separate .h file)
  • visibility property to one of modifiers public, protected, private. If visibility is not setted, consider as protected.
  • all method will treated as pure virtaul.

UMLEnumeration

Weekdays
Monday
Tuesday
Saturday

converts

/* Test header @ toori67
 * This is Test
 * also test
 * also test again
 */
#ifndef (_WEEKDAYS_H)
#define _WEEKDAYS_H

enum Weekdays { Monday,Tuesday,Saturday };

#endif //_WEEKDAYS_H
  • converted to Cpp Enum. (as a separate .h file)
  • visibility property to one of modifiers public, protected, private. If visibility is not setted, consider as protected.
  • UMLEnumerationLiteral to literals of enum.

UMLAssociationEnd

  • converted to Cpp Field.
  • visibility property to one of modifiers public, protected, private. If visibility is not setted, consider as protected.
  • name property to field identifier.
  • type property to field type.
  • If multiplicity is one of 0..*, 1..*, *, then collection type (std::vector<T> ) is used.
  • defaultValue property to initial value.

UMLGeneralization & UMLInterfaceRealization

  • converted to Cpp Inheritance (:).
  • Allowed for UMLClass to UMLClass, and UMLClass to UMLInterface.

C++ Reverse Engineering

  1. Click the menu (Tools > C++ > Reverse Code...)
  2. Select a folder containing C++ source files to be converted to UML model elements.
  3. CppReverse model will be created in the Project.

Belows are the rules to convert from C++ source code to UML model elements.

C++ Namespace

  • converted to UMLPackage.

C++ Class

  • converted to UMLClass.
  • Class name to name property.
  • Type parameters to UMLTemplateParameter.
  • Access modifier public, protected and private to visibility property.
  • abstract modifier to isAbstract property.
  • Constructors to UMLOperation with stereotype <<constructor>>.
  • All contained types (UMLClass, UMLInterface, UMLEnumeration) are generated as inner type definition.

C++ Field (to UMLAttribute)

  • converted to UMLAttribute if "Use Association" is off in Preferences.

  • Field type to type property.

    • Primitive Types : type property has the primitive type name as string.
    • T[](array) or its decendants: type property refers to T with multiplicity *.
    • T (User-Defined Types) : type property refers to the T type.
    • Otherwise : type property has the type name as string.
  • Access modifier public, protected and private to visibility property.

  • static modifier to isStatic property.

  • Initial value to defaultValue property.

C++ Field (to UMLAssociation)

  • converted to (Directed) UMLAssociation if "Use Association" is on in Preferences and there is a UML type element (UMLClass, UMLInterface, or UMLEnumeration) correspond to the field type.

  • Field type to end2.reference property.

    • T[](array) or its decendants: reference property refers to T with multiplicity *.
    • T (User-Defined Types) : reference property refers to the T type.
    • Otherwise : converted to UMLAttribute, not UMLAssociation.
  • Access modifier public, protected and private to visibility property.

C++ Method

  • converted to UMLOperation.
  • Type parameters to UMLTemplateParameter.
  • Access modifier public, protected and private to visibility property.
  • static modifier to isStatic property.
  • abstract modifier to isAbstract property.

C++ Enum

  • converted to UMLEnumeration.
  • Enum name to name property.
  • Type parameters to UMLTemplateParameter.
  • Access modifier public, protected and private to visibility property.

Licensed under the MIT license (see LICENSE file).

cpp's People

Contributors

toori67 avatar dongjoon1251 avatar niklauslee avatar jimmyberg avatar itschleemilch avatar

Watchers

James Cloos avatar Harold Bierlein avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.