ClasHStamP: Draw One, Generate Natives Everywhere

Code File

Header/Footer

Just draw a class

  You can specify must-include/must-import file/package with this syntax template tags:
  file.begin
  file.end
  /* header file */
  #ifndef __Context_H__
  #define __Context_H__
  ...
  #endif//__Context_INTERNAL__

  /* implementation file */
  #define __Context_INTERNAL__
  #include "CommonInclude.h"
  #include "Context.h"
  #pragma once
  #include "Generic/CommonInclude.h"
  using System;                                                   
  using System.Collections.Generic;
  using boolean = System.Boolean;
  package model;

  import java.io.*;
  import java.util.*;

Dependencies’ References

Supported Dependencies

  file.ext1st
  file.extnxt
  friend.name
  friend.ext1st
  friend.extnxt
  friend.begin
  friend.end
  /* header file */
  #include "UsedDependency.h"     // Used (or strong) Dependency is included in header file, so that other module which includes this header won't need to care about this dependency 
  ...                             // Public content
  #endif//__Context_H__
  #if !defined( Context_Init ) && ( defined( __Context_INTERNAL__ )  || defined( __AFriend_INTERNAL__ )  )
  ...                             // Protected content, and a friend declarated like above will be allowed to view protected content
  #endif//__Context_INTERNAL__
  /* source file */
  #include "CalledDependency.h"   // Called (or normal/weak) Dependency is included in source file
  #include "Model/CalledDependency.hpp" // This C++ generator is inline type (almost source code is laid in header file) so that all dependencies are placed in header file
  #include "Model/UsedDependency.hpp"                             
  ...
  friend class Main;
  using Model;                    // In this sample , CalledDependency and UsedDependency are belong to the same package so that a delcaration of package are enough 
  import model.*;                 // In this sample , CalledDependency and UsedDependency are belong to the same package so that a delcaration of package are enough 

Super Class, Implemented Interface and Attribute Type References

Supported BaseReferences

  file.ext1st
  file.extnxt
  /* header file */
  #include "BaseClass.h"
  #include "Interface2.h"
  #include "Interface1.h"
  #include "Composition.h"        // aProtectedComposition member has Composition type so that Composition header file will automatically included here.
                                  // publicAttribute member has String type but marked by <<stdtype>> stereotype so that include declaration is omitted.
  #include "Abstracts/BaseClass.hpp"                              
  #include "Interfaces/Interface2.hpp"                            
  #include "Interfaces/Interface1.hpp"                            
  #include "Model/Composition.hpp"                                
  using Abstracts;
  using Interfaces;
  using Model;
  import abstracts.*;
  import interfaces.*;
  import model.*;

Class Stereotype

Standard Type

Object Type

Class Definition

Nested Items

Internal Structures

Internal Enumerations

Template, Generalization and Realization

Supported ClassDefinition Supported ClassDefinition

  name ext1st extnxt begin end
template          
inheritance          
class          
  /** @class BaseClass
   * @extends 
   */
  #define BaseClass_CLASS                                                                         \
      const BaseClassVtbl* const vTbl;                                                            \

  typedef struct tagBaseClass{
      BaseClass_CLASS    
  }BaseClass;

  // There is no explicitly template and implemented interface realization in C language
  /** @class Context
   * @extends BaseClass
   */
  #define Context_CLASS                                                                           \
      BaseClass_CLASS                                                                             \
      ...
  typedef struct tagContext{
      Context_CLASS    
  }Context;

  /** @class AFriend
   * @extends 
   */
  #define AFriend_CLASS                                                                           \
      size_t cbSize;                                                                              \
      ...
  typedef struct tagAFriend{
      AFriend_CLASS    
  }AFriend;

  class BaseClass{
      ...
  }

  class Context: public BaseClass, public Interface2, public Interface1{
      ... 
  }

  template<typename T0 , Composition* T1 , typename T2  = T0, Aggregration* T3  = Aggregration*>
  class AFriend{
      ...
  };
  namespace Abstracts {
      public  abstract class BaseClass
      {
          ...
      }
  }

  namespace Model {
      public  class Context: BaseClass, Interface2, Interface1
      {
          ...
      }
  }

  namespace Model {
      public  class AFriend<T0, T1, T2, T3>
          where T1: Composition
          where T3: Aggregration
      {
          ...
      }
  }
  public  abstract class BaseClass
  {
      ...
  }

  public  class Context extends BaseClass implements Interface2, Interface1
  {
      ...
  }

  public  class AFriend<T0, T1 extends Composition, T2, T3 extends Aggregration>
  {
      ...
  }

Attributes

Supported ClassAttributes

  Attention: Attribute's Constraint field also can be used for initialization routine, 
  if this field is specified, the Initial Value in Base tab will be ignored.
  This trick will be useful when you need language-specific or multi-line initialization code, 
  name ext1st extnxt begin end comments
__s_attr           attribute of standard type
__o_attr           attribute of object type
__r_attr           attribute of referenced/pointer type
_ms_attr           attribute with multiplicity of standard type
_mo_attr           attribute with multiplicity of object type
_mr_attr           attribute with multiplicity of referenced/pointer type
c_s_attr           constant of standard type
c_o_attr           constant of object type
c_r_attr           constant of referenced/pointer type
cms_attr           constant with multiplicity of standard type
cmo_attr           constant with multiplicity of object type
cmr_attr           constant with multiplicity of referenced/pointer type
s_s_attr           static attribute or constant of standard type
s_o_attr           static attribute or constant of object type
s_r_attr           static attribute or constant of referenced/pointer type
sms_attr           static attribute or constant with multiplicity of standard type
smo_attr           static attribute or constant with multiplicity of object type
smr_attr           static attribute or constant with multiplicity of referenced/pointer type
  /* header file *//* Attention: in C language, all attributes have only protected visibility */
  #define Context_CLASS                                                                           \
      BaseClass_CLASS                                                                             \
      String publicAttribute;                                                                     \
      int privateAttribute;                                                                       \
      int internalAttribute;                                                                      \
      boolean isInitializedAttribute;                                                             \
      const int readOnlyAttribute;                                                                \
      Aggregration* anAggregation[ 3 ];                                                           \
      Composition aProtectedComposition[ 10 ];                                                    \

  typedef struct tagContext{
      Context_CLASS    
  }Context;

  /* source file */
  /** @private @static @memberof Context */
  static int classOrStaticAttribute;                              
  /** @private @static @memberof Context */
  static int initializedStaticArray[   ] = { 1, 2, 3 };           
  /** @private @static @memberof Context */
  static const int finalConstantAttribute = 5;                    
  /* header file */
  class Context: public BaseClass, public Interface2, public Interface1{
      private: static int classOrStaticAttribute;                 
      private: static std::vector<int> initializedStaticArray;    
      private: static const int finalConstantAttribute = 5;       
      public:  static void classOrStaticMethod(
      public: String publicAttribute;                             
      private: int privateAttribute;                              
      public: int internalAttribute;                              
      private: boolean isInitializedAttribute;                    
      private: const int readOnlyAttribute;                       
      private: std::vector<Aggregration*> anAggregation;          
      protected: std::vector<Composition*> aProtectedComposition; 
  }

  /* source file */
  int Context::classOrStaticAttribute;                            
  std::vector<int> Context::initializedStaticArray = { 1, 2, 3 }; 
  public  class Context: BaseClass, Interface2, Interface1
  {
      private static int classOrStaticAttribute;              
      private static int[] initializedStaticArray = { 1, 2, 3 };
      private const int finalConstantAttribute = 5;           
      public String publicAttribute;                          
      private int privateAttribute;                           
      internal int internalAttribute;                         
      private boolean isInitializedAttribute;                 
      private readonly int readOnlyAttribute;                 
      private   List<Aggregration> anAggregation;             
      protected   List<Composition> aProtectedComposition;    
  }
  public  class Context extends BaseClass implements Interface2, Interface1
  {
      private static int classOrStaticAttribute;                  
      private static int[] initializedStaticArray = { 1, 2, 3 };  
      private static final int finalConstantAttribute = 5;        
      public String publicAttribute;                              
      private int privateAttribute;                               
      int internalAttribute;                                      
      private boolean isInitializedAttribute;                     
      private final int readOnlyAttribute;                        
      private ArrayList<Aggregration> anAggregation;                 
      protected ArrayList<Composition> aProtectedComposition;        
  }

Getter/Setter (Accessor/Mutator)

Default Getter/Setter

Supported AbstractGetterSetter

  Attention: An Attribute with Constraint defined as "language.get" or "language.set" will have geter or setter correspondingly."
  name ext1st extnxt begin end comments
p_s_attr           getter/setter integrated attribute of standard type
p_o_attr           getter/setter integrated attribute of object type
p_r_attr           getter/setter integrated attribute of referenced/pointer type
pms_attr           getter/setter integrated attribute with multiplicity of standard type
pmo_attr           getter/setter integrated attribute with multiplicity of object type
pmr_attr           getter/setter integrated attribute with multiplicity of referenced/pointer type
  /* Attention: Right now, generated C language does not support polymorphism Getter/Setter */
  #define Beverage_CLASS                                                                          \
      const BeverageVtbl* const vTbl;                                                             \
      size_t cbSize;                                                                              \
      String description;                                                                         \

  typedef struct tagBeverage{
      Beverage_CLASS    
  }Beverage;

  String Beverage_GetDescription( const Beverage* pBeverage ){
      return pBeverage->description;
  }
  void Beverage_SetDescription( Beverage* pBeverage, String value ){
      pBeverage->description = value;
  }
  /* Attention: Cpp supports polymophism, operator type Getter/Setter (C# style), 
     you can edit Syntax file to have function type (Java style) Getter/Setter if you want */
  class Beverage{
      protected: String description;
      public: struct { Beverage* pContainer; friend Beverage;
          operator String () const { return pContainer->getDescription(); }
          String& operator = (const String& value) { pContainer->setDescription(value); }
      } m_description;
      protected: virtual String getDescription() const { return description; }
      protected: virtual String& setDescription(const String& value) { return description = value; }
      friend class Main;
      public:  Beverage(
          String _description
      ): description( _description )
      {
          m_description.pContainer = this;    /* Use Class's Constraint to add this code (see Auto-generated Constructor section below for more details) */
      }                                                                                           
  };
  public  abstract class Beverage
  {
      public virtual String description {
          get;
          set;
      }
      public  Beverage(
          String _description
      ){
          description = _description;
      }                                                                                       
  }
  public  abstract class Beverage
  {
      public String getDescription(){
          return description;
      }
      public void setDescription(String value){
          description = value;
      }
      public  Beverage(
          String _description
      ){
          description = _description;
      }                                                                                           
      public String description;                                  
  }

Customized Getter/Setter

Supported ConcreteGetterSetter

  Attention: An Attribute with Constraint defined as "language.get" or "language.set" will have geter or setter correspondingly."
  name ext1st extnxt begin end comments
p_s_attr leave         getter/setter integrated attribute of standard type
p_o_attr this         getter/setter integrated attribute of object type
p_r_attr column         getter/setter integrated attribute of referenced/pointer type
pms_attr blank         getter/setter integrated attribute with multiplicity of standard type
pmo_attr           getter/setter integrated attribute with multiplicity of object type
pmr_attr           getter/setter integrated attribute with multiplicity of referenced/pointer type
  /* Attention: you can see the "description" attribute is omitted here (because it was declared already in super class) */

  /** @class Mocha
   * @extends CondimentDecorator (which even more extended from Beverage class)
   */
  #define Mocha_CLASS                                                                             \
      CondimentDecorator_CLASS                                                                    \

  typedef struct tagMocha{
      Mocha_CLASS    
  }Mocha;

  String Mocha_GetDescription( const Mocha* pMocha ){
      return MakeString( "This sample does not use this as polymorphism property. Instead, it uses constructor code to do it." );
  }

  class Mocha: public CondimentDecorator{
      protected: virtual String getDescription() const {
          String sTemp = beverage->m_description;
          return sTemp + ", Mocha";
      };
  };
  public  class Mocha: CondimentDecorator
  {
      public override String description {
          get{ return beverage.description + ", Mocha"; }

      }
  }
  public  class Mocha extends CondimentDecorator
  {
      public String getDescription(){
          return beverage.getDescription() + ", Mocha";

      }
  }

Auto-generated Constructor

Supported AutoConstructor

  - Attributes having Initial Value will be initialized by that value in constructor
  - Attributes having Constraint defined (ex: c.init, cpp, init, java.init ...) will be initialized 
    to the next-line-value in constructor, and the Initial Value if have will be ignored.
  - Attributes without any above initialization code will receive auto-generated input of 
    constructor as initialization value.
  name ext1st extnxt begin end comments
constructor           constructor related declaration
ctor_call           super class7s constructor calling related declaration
__s_attr           attribute of standard type
__o_attr           attribute of object type
__r_attr           attribute of referenced/pointer type
_ms_attr           attribute with multiplicity of standard type
_mo_attr           attribute with multiplicity of object type
_mr_attr           attribute with multiplicity of referenced/pointer type
c_s_attr           constant of standard type
c_o_attr           constant of object type
c_r_attr           constant of referenced/pointer type
cms_attr           constant with multiplicity of standard type
cmo_attr           constant with multiplicity of object type
cmr_attr           constant with multiplicity of referenced/pointer type
  /** @memberof Context
   * @brief Context auto-generated constructor
   */
  #define Context_Init(_derivableAttribute, _publicAttribute, _privateAttribute, _internalAttribute, _readOnlyAttribute, _anAggregation, _aProtectedComposition)\
      BaseClass_Init( P( _derivableAttribute ) )\
      .vTbl = &gContextVtbl,\
      .publicAttribute = _publicAttribute,\
      .privateAttribute = _privateAttribute,\
      .internalAttribute = _internalAttribute,\
      .isInitializedAttribute = true,\
      .readOnlyAttribute = _readOnlyAttribute,\
      .anAggregation = P( _anAggregation ),\
      .aProtectedComposition = P( _aProtectedComposition ),\

  #define Context_Ctor( InitFunc, optionParams )    ( Context ){\
      InitFunc\
  \
  }
  /* Calling code: Context context = Context_Ctor( Context_Init( ... ), ... ); */
  class Context: public BaseClass, public Interface2, public Interface1{
      ...
      public:  Context(
          int _derivableAttribute,
          String _publicAttribute,
          int _privateAttribute,
          int _internalAttribute,
          int _readOnlyAttribute,
          std::vector<Composition*> &_aProtectedComposition
      ):  BaseClass( _derivableAttribute ),
          publicAttribute( _publicAttribute ),
          privateAttribute( _privateAttribute ),
          internalAttribute( _internalAttribute ),
          isInitializedAttribute( true ),
          readOnlyAttribute( _readOnlyAttribute ),
          anAggregation(   ),
          aProtectedComposition( _aProtectedComposition )
      {
      }                                                                                           
  };
  public  class Context: BaseClass, Interface2, Interface1
  {   ...
      public  Context(
          int _derivableAttribute,
          String _publicAttribute,
          int _privateAttribute,
          int _internalAttribute,
          int _readOnlyAttribute,
          List<Aggregration> _anAggregation,
          List<Composition> _aProtectedComposition
      ):  base( _derivableAttribute )
      {
          publicAttribute = _publicAttribute;
          privateAttribute = _privateAttribute;
          internalAttribute = _internalAttribute;
          isInitializedAttribute = true;
          readOnlyAttribute = _readOnlyAttribute;
          anAggregation = _anAggregation;
          aProtectedComposition = _aProtectedComposition;
      }                                                                                       
  }
  public  class Context extends BaseClass implements Interface2, Interface1
  {   ...
      public  Context(
          int _derivableAttribute,
          String _publicAttribute,
          int _privateAttribute,
          int _internalAttribute,
          int _readOnlyAttribute,
          ArrayList<Aggregration> _anAggregation,
          ArrayList<Composition> _aProtectedComposition
      ) {
          super( _derivableAttribute );

          publicAttribute = _publicAttribute;
          privateAttribute = _privateAttribute;
          internalAttribute = _internalAttribute;
          isInitializedAttribute = true;
          readOnlyAttribute = _readOnlyAttribute;
          anAggregation = _anAggregation;
          aProtectedComposition = _aProtectedComposition;
      }                                                                                           
  }

Super Class Constructor Call

Initialization Code

Operations

Supported ClassOperations

  Attention: Attribute's Constraint field also can be used for initialization routine, 
  if this field is specified, the Initial Value in Base tab will be ignored.
  This trick will be useful when you need language-specific or multi-line initialization code, 
  name ext1st extnxt begin end comments
vptr_impl           virtual function table implementation (used for none OOP language like C)
__c_oper           virtual operation with protected visibility
__b_oper           virtual operation with public visibility
vptr_decl           virtual function table declaration (used for none OOP language like C)
_ac_oper           abstract operation with protected visibility
_ab_oper           abstract operation with public visibility
l_i_oper           leaf operation with private visibility
l_c_oper           leaf operation with protected visibility
l_b_oper           leaf operation with public visibility
lai_oper           leaf abstract operation with private visibility (used for C language as leaf function prototype)
vptr_call           used in abstract operations (used for none OOP language like C)
s_i_oper           static operation with private visibility
s_c_oper           static operation with protected visibility
s_b_oper           static operation with public visibility
sai_oper           static abstract operation with protected visibility(used for C language as leaf function prototype)
sab_oper           static abstract operation with public visibility (used for C language as leaf function prototype)

The belows are in proposal (intented to use for Pascal and Basic language families)

__f_oper           virtual function
_af_oper           abstract function
l_f_oper           leaf function
s_f_oper           static function
  /* -------------------------------- Abstract class's header file -------------------------------- */
  #ifndef __BaseClass_H__
  #define __BaseClass_H__                                                   // public area
  typedef struct tagBaseClass BaseClass;
  void BaseClass_publicMethod( BaseClass* pBaseClass );
  void BaseClass_packageVisibleMethod( BaseClass* pBaseClass );
  #endif//__BaseClass_H__
  #if !defined( BaseClass_Init ) && ( defined( __BaseClass_INTERNAL__ )  )  // protected area
  void BaseClass_protectedMethod( BaseClass* pBaseClass );
  ...
  typedef struct tagBaseClassVtbl{                                          // virtual function table
      void ( * const ppublicMethod )( BaseClass* );
      void ( * const pprotectedMethod )( BaseClass* );
      void ( * const ppackageVisibleMethod )( BaseClass* );
  }BaseClassVtbl;
  /** @class BaseClass
   * @extends 
   */
  #define BaseClass_CLASS                                                                         \
      const BaseClassVtbl* const vTbl;                                                            \

  typedef struct tagBaseClass{
      BaseClass_CLASS    
  }BaseClass;
  #endif//__BaseClass_INTERNAL__
  /* --------------------------- Abstract class's source file is ommited--------------------------- */
  /* --------------------------- Concrete class's source file is ommited--------------------------- */
  /* -------------------------------- Concrete class's source file -------------------------------- */
  void Context_classOrStaticMethod( void ){
  } /* Context_classOrStaticMethod */

  /** @public @memberof Context */
  static void Context_publicMethod( Context* pContext ){
  } /* Context_publicMethod */

  /** @private @memberof Context */
  static void Context_privateLeafMethod( Context* pContext ){
  } /* Context_privateLeafMethod */

  /** @public @memberof Context */
  Context_Context( Context* pContext ){
  } /* Context_Context */

  /** @public @memberof Context */
  void Context_methodWithParams( Context* pContext, String parm1, float parm2 ){
  } /* Context_methodWithParams */

  /** @public @memberof Context */
  UsedDependency* Context_methodReturnsSomething( Context* pContext ){
      return NULL;
  } /* Context_methodReturnsSomething */

  /** @public @memberof Context */
  void Context_methodThrowsException( Context* pContext ){
  } /* Context_methodThrowsException */

  /** @public @memberof Context */
  void Context_finalMethod( Context* pContext ){
  } /* Context_finalMethod */

  /** @protected @memberof Context */
  static void Context_protectedMethod( Context* pContext ){
  } /* Context_protectedMethod */

  /** @protected @memberof Context */
  static void Context_packageVisibleMethod( Context* pContext ){
  } /* Context_packageVisibleMethod */
  /* -------------------------------- Abstract class -------------------------------- */
  class BaseClass{
      public: virtual void publicMethod() = 0;
      protected: virtual void protectedMethod() = 0;
      protected: virtual void packageVisibleMethod() = 0;
  };
  /* -------------------------------- Concrete class -------------------------------- */
  class Context: public BaseClass, public Interface2, public Interface1{
      public:  static void classOrStaticMethod(
      ){
      } /* Context.classOrStaticMethod */
      public: virtual void publicMethod(
      ){
      } /* Context.publicMethod */
      private: void privateLeafMethod(
      ){
      } /* Context.privateLeafMethod */
      public:  Context(
      ): BaseClass(3), readOnlyAttribute(5){
          std::cout << "Manual Constructor" << std::endl;
      } /* Context.Context */
      public: void methodWithParams(
          String parm1,
          float parm2
      ){
      } /* Context.methodWithParams */
      public: UsedDependency methodReturnsSomething(
      ){
      } /* Context.methodReturnsSomething */
      public: void methodThrowsException(
      ){
      } /* Context.methodThrowsException */
      public: void finalMethod(
      ){
      } /* Context.finalMethod */
      protected: virtual int& setDerivableAttribute(const int& value) {
          return privateAttribute = value;
      };
      friend class Main;
      protected: virtual void protectedMethod(
      ){
      } /* Context.protectedMethod */

      protected: virtual void packageVisibleMethod(
      ){
      } /* Context.packageVisibleMethod */
      ...
  };
  /* -------------------------------- Abstract class -------------------------------- */
  public  abstract class BaseClass
  {
      public abstract void publicMethod(
      );
      protected abstract void protectedMethod(
      );
      protected abstract void packageVisibleMethod(
      );
  }
  /* -------------------------------- Concrete class -------------------------------- */
  public  class Context: BaseClass, Interface2, Interface1
  {
      public  static void classOrStaticMethod(
      ){
      } /* Context.classOrStaticMethod */
      public override void publicMethod(
      ){
      } /* Context.publicMethod */

      private void privateLeafMethod(
      ){
      } /* Context.privateLeafMethod */
      public  Context(
      ): base(3){
      } /* Context.Context */
      public void methodWithParams(
          String parm1,
          out float parm2
      ){
          parm2 = 3f;
      } /* Context.methodWithParams */
      public UsedDependency methodReturnsSomething(
      ){
          return null;
      } /* Context.methodReturnsSomething */
      public void methodThrowsException(
      ){
      } /* Context.methodThrowsException */
      public void finalMethod(
      ){
      } /* Context.finalMethod */
      public override int derivableAttribute {
          set{ privateAttribute = value; }

      }
      protected override void protectedMethod(
      ){
      } /* Context.protectedMethod */

      protected override void packageVisibleMethod(
      ){
      } /* Context.packageVisibleMethod */
      ...
  }
  /* -------------------------------- Abstract class -------------------------------- */
  public  abstract class BaseClass
  {
      public abstract void publicMethod(
      );
      protected abstract void protectedMethod(
      );
      protected abstract void packageVisibleMethod(
      );
  }
  /* -------------------------------- Concrete class -------------------------------- */
  public  class Context extends BaseClass implements Interface2, Interface1
  {
      public static void classOrStaticMethod(
      ){
      } /* Context.classOrStaticMethod */
      public void publicMethod(
      ){
      } /* Context.publicMethod */

      private void privateLeafMethod(
      ){
      } /* Context.privateLeafMethod */
      public  Context(
      ){
    	  super(3);
    	  readOnlyAttribute = 7;
      } /* Context.Context */
      public void methodWithParams(
          String parm1,
          float parm2
      ){
      } /* Context.methodWithParams */
      public UsedDependency methodReturnsSomething(
      ){
    	  return null;
      } /* Context.methodReturnsSomething */
      public void methodThrowsException(
      )throws IOException{
      } /* Context.methodThrowsException */
      public void finalMethod(
      ){
      } /* Context.finalMethod */
      void setDerivableAttribute(int value){
          privateAttribute = value;

      }
      protected void protectedMethod(
      ){
      } /* Context.protectedMethod */

      protected void packageVisibleMethod(
      ){
      } /* Context.packageVisibleMethod */
      ...
  }

Code Parsing

Code Comments

Single-line

Multi-line

Debug Code

Share this on → Twitter Facebook Google+
www.easy-hit-counter.com
www.easy-hit-counter.com