Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: zalbina 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.
-
The %FIND()% macro can be used for this purpose:
$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
-
Thanks a lot. I've not started to write the code yet but it sounds very promissing :).