Book a Demo

Author Topic: Boost, STL, and C++ code generation  (Read 3539 times)

Wowbagger

  • EA User
  • **
  • Posts: 69
  • Karma: +0/-0
    • View Profile
Boost, STL, and C++ code generation
« on: October 16, 2009, 05:18:51 am »
Does anybody have any advice on how to set EA up to use the STL and/or Boost for C++ code generation?

For example, how to make the generated code use vector<T> or map<T> for collections?

Makulik

  • EA User
  • **
  • Posts: 400
  • Karma: +0/-0
    • View Profile
Re: Boost, STL, and C++ code generation
« Reply #1 on: October 16, 2009, 08:14:25 pm »
Hi,

Reverse engineering templates with EA has it's drawbacks, and doesn't work well for all cases (e.g. when working with mixin template base classes etc.).
My actual approach when working with template frameworks like STL, is simply to specify the types in textual form. This is sufficient for correct code generation and doesn't 'overload' your models with all of the frameworks' detail information.

I personally use UML diagrams for parameterized classes only when providing them in my own models. But when it comes to use them in other packages, I'll use the textual approach again. I'm just pragmatic here  ;) ...

Template parameter binding of parameterized classes you use in your model is anyway a bit tedious to do. Code generation doesn't care about the <<bind>> stereotype dependency, but takes the parameters from the class element details dialogue. You have to create an extra class element for the concrete parameterized classes you're using in your models, I'm always confused where to place them. Namespacing says it's std:: for instance, but you need to place these in the namespace where they're used (instantiated). And then, you need to care about not having these as generated code! The compiler will do the instatiation as (intermediary) code.

Some time ago, when evaluating EA7.1 i wrote a longer study about that topic. If you're interested, I can provide it to you, if you leave your email in my message box.

WBR
Günther