C++ code generation questions

General discussions about code engineering

Moderator: Moderators

C++ code generation questions

Postby Jedzia » Sat Mar 26, 2011 12:30 am

I have some questions related to ansi c++ code generation.

Lets take this class in Selection.h as example:

/**
* @(#) Selection.h
*/

#ifndef SELECTION_H_H
#define SELECTION_H_H

namespace QUtil
{
namespace Textprocessing
{
class Selection
{

public:
Selection( int position, int length );
~Selection( );

private:
int length;

int line;

int position;

void opi( );

};

}
}

#endif

---------

I want it a little different:

/**
* @(#) Selection.h
*/

#ifndef TEXTPROCESSING_SELECTION_H_H
#define TEXTPROCESSING_SELECTION_H_H // <- (1)

#define USE_SOME_DEFINE TRUE // <- (2)
#include <platform.h> // <- (3)

namespace QUtil
{
namespace Textprocessing
{
class PLATFORM_DECL Selection // <- (4)
{

public:
Selection( int position, int length );
~Selection( );

private:
int length;

int line;

int position;

void opi( );

};

}
}

#endif // TEXTPROCESSING_SELECTION_H_H <- (1)

Done:
3. The extra file include can be done with a file component and the include stereotype
set to system include, like described in the manual.

My questions are:

1. How to output a different header file guard / Can the codegenerator be changed to
spit out the guard name as comment at the #endif define?
2. How to put some #define statements into the c++ code?
4. How to use a #define'd statement as declspec identifier?
Generating this as VC-Storage-Class spits out the __declspec(identifier). Changing this after
codegeneration and with "#define PLATFORM_DECL __declspec(identifier)"
in the MagicDraw c++ reverse preprocessor settings does the job. But i want this symbol
put in my code from the first code generation on.

Can this all be done (easy:)) and when, how?

Thank you in advance.
Jedzia
Forum Newbie
Forum Newbie
 
Posts: 1
Posts Rating:0
Joined: Sat Mar 26, 2011 12:21 am

Re: C++ code generation questions

Postby bhoomchai » Mon Mar 28, 2011 3:39 am

Dear Jedzia,

1. The header file guard cannot be customize for code generation. The part that you can customize is the file header.

/**
* @(#) Selection.h
*/

2,4 They cannot be done using C++ code generation. The idea behind this is that the macro part is not handled by model. Macro is considered as a separate layer. When you reverse code to model, macros are not reversed to the model. Vise-versa, you cannot put information about macros to the model and generate them to code. (When you reverse your source code, C++ code engineer reverses the code that all macros already get expanded instead of the original source code.)

We apologize for any inconvenience.

Best regards,
No Magic Customer Support
bhoomchai
Customer Support
Customer Support
 
Posts: 36
Posts Rating:5
Joined: Thu Jan 21, 2010 12:38 am


Return to Code engineering

Who is online

Users browsing this forum: No registered users and 0 guests