Author Topic: Code Generation Template  (Read 3063 times)

zalbina

  • EA User
  • **
  • Posts: 149
  • Karma: +0/-0
    • View Profile
Code Generation Template
« on: December 09, 2012, 10:10:57 pm »
Hello,

I have question regarding string operations in code generation template. I'm looking something like C# String.Contains("substring"). I need to find if class name contains some specific word expression.

Another one question is to get all "Parent Classes" of a class. I can get only one base class from whom derived, but I need to get the parent of this base class and so on. Is it possible get all "generations" of a class?

Thank you in advance.

g.makulik

  • EA User
  • **
  • Posts: 355
  • Karma: +0/-0
    • View Profile
Re: Code Generation Template
« Reply #1 on: December 10, 2012, 12:58:13 am »
The %FIND()% macro can be used for this purpose:

Code: [Select]
$qualName = %classQualName%
$resPos = %FIND($qualName, "::")%

%if $resPos == "-1"%
...

I'm afraid you cannot achieve your 2nd need with plain code template language. You could though write an AddIn that gets the inheritance hierarchy and provides methods that can be called via the %EXEC_ADDI_N()% macro.

HTH
Günther
Using EA9.3, UML2.3, C++, linux, my brain, http://makulik.github.com/sttcl/

zalbina

  • EA User
  • **
  • Posts: 149
  • Karma: +0/-0
    • View Profile
Re: Code Generation Template
« Reply #2 on: December 10, 2012, 06:10:30 pm »
Thanks a lot. I've not started to write the code yet but it sounds very promissing :).