Book a Demo

Author Topic: C++ namespace  (Read 3130 times)

benoitkm

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
C++ namespace
« on: February 28, 2006, 01:28:15 pm »
I wish to define a namespace in C++ using EA.  If I am writing the source directly this is not a problem.  However, in EA things are not working for me.

This is what I am doing in EA.

In Project View create a new Package.

Right click the package and click Set as Namespace root.

Add a new class to the package.

Generate the source code.

When I do this the source code does not contain the namespace that I am expecting.

I am expecting the following...

namespace MyNameSpace
{
        class MyClass
        {

             // some code.
         };

}

But I am getting...


class MyClass
{

       // some code.
};


Is there more to the process?



Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: C++ namespace
« Reply #1 on: February 28, 2006, 01:30:52 pm »
By setting the package as a namespace root you're telling EA to not generate a namespace for that package.  Instead set the parent package as a namespace root.

See http://www.sparxsystems.com.au/EAUserGuide/index.html?namespaces.htm for more information.

benoitkm

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: C++ namespace
« Reply #2 on: March 01, 2006, 05:18:39 am »
Thanks,
One more thing, in Project View, you can right click a package and provide a note for the package (a.k.a. namespace), I would like the comment to show up in the source code when I generate the code, and I would like changes to the note from the source updated in EA when I synchronize.  Is this possible?

Notes for classes, operations, and attributes, function in the manner described above, however, namespace notes are not working for me.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: C++ namespace
« Reply #3 on: March 01, 2006, 02:01:49 pm »
Currently it's not supported, but we will add a packageNotes macro into our next build.  This won't enable full synchronisation of the namespace note, but will allow you to generate it when initially generating the file.  Just add the following to your namespace declaration template immediately before the last line.

Code: [Select]

%WRAP_LINES(packageNotes, genOptWrapComment, "// ")%\n

Full synchronisation is a bit more difficult to get going so I can't make any promises on that.
« Last Edit: March 01, 2006, 08:23:42 pm by simonm »

benoitkm

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: C++ namespace
« Reply #4 on: March 03, 2006, 06:25:26 am »
I added the line as suggested but nothing different happens.  That is to say the comments are not included in the source.  The following is the way my namespace declaration template now looks.

%if packagePath == "" or genOptCPPGenNamespace != "T"%
%endTemplate%
%WRAP_LINES(packageNotes, genOptWrapComment, "// ")%\n
namespace %packageName%

Is there something else I need to do?

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: C++ namespace
« Reply #5 on: March 05, 2006, 01:12:31 pm »
No.  There is nothing else you can do at the moment.

As I said in my previous post.  Currently it's not supported.  The packageNotes macro will be added into our next build.  At that time your template should generate namespace notes when initially generating a file.