Book a Demo

Author Topic: generating namespaces in c++  (Read 4043 times)

sm

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
generating namespaces in c++
« on: June 01, 2005, 01:31:45 am »
Iam trying to generate namespace in c++. I have set the package to "name space root". I have turned on the "Generate namespace" option for c++. Still I could not generate namespace in code. The reason seems to be the "package path" is empty. How to solve this problem?.

-sm

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: generating namespaces in c++
« Reply #1 on: June 01, 2005, 03:22:02 pm »
You're very close.

Namespace root specifies 'This package corresponds to the root namespace in code'.  From there, any packages below that point will correspond to a namespace.

Hope that helps.

Simon

sm

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: generating namespaces in c++
« Reply #2 on: June 01, 2005, 11:55:50 pm »
Thankyou. Now i can see the namespace body in header file. But I have another problem.

I have a namspace "compname". In UML "compname" is a package. I have set the logical model as namespace root and "compname" is below the logical model

In header file i can see the name space body like this

namespace compname
{

   class A
    {

    }

 .....
}

But in cpp file the syntax of the generated "using" statement is wrong

it is like this

using  compname::A;

but in c++ it should be

using namespace compname::A;

What could be the problem?.

Thanks in Advance.

sm

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: generating namespaces in c++
« Reply #3 on: June 02, 2005, 12:39:59 am »
Sorry...

I need the using statement in this way...

using namespace compname;

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: generating namespaces in c++
« Reply #4 on: June 02, 2005, 03:39:38 pm »
You've now entered the realm of editing code templates (or you will if you want to generate that enough to enter)

The %fileHeaders% macro generates the using statements.  If you don't want them, remove it.  Then you can create an Import template to generate the using statements that you like.

Look at the Import generation for Java, C# or PHP for guide on how to get what you want.

sm

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: generating namespaces in c++
« Reply #5 on: June 03, 2005, 04:36:21 am »
Thanks for the info.