Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: cazo on September 29, 2004, 05:16:34 pm
-
Hi there!
I'm trying to generate the C++ code prototype from
a single class (I don't know if t's better); so, the class
is generated correctly, but I cannot see any tag that
will preserve my code. In other hand, when
regenerating my code, it repeats any time, the same
line,... like this:
char str[10]; // I change to size 20...
char str[20]; // it puts the line again...
char str[20]; // it was regenerated... and so on.
any tips?
-- Claudio
-
Hi Claudio,
I don't know this for sure, but it looks to me like you're setting the name as 'str[10]' etc. What you need to do is set the name to str and then on the Detail tab in the attributes dialog box tick 'Attribute is a Collection' and set the container type to '[10]'.
If I do that then it synchronises the changes to the container type perfectly.
Simon
-
Hi Simon, works fine after your tip; thanx! :)
So... but the same doesn't happen with the methods...
look below, please.
///////////////////////////////////////////////////////////
Hello.h
// Implementation of the Class Hello
// Created on: 26-set-2004 21:37:42
// Original author: Claudio
///////////////////////////////////////////////////////////
#if !defined(A6413818_42A5_47fe_9FDD_C8F6F19171C3__INCLUDED_)
#define A6413818_42A5_47fe_9FDD_C8F6F19171C3__INCLUDED_
#include <stdio.h>
#include <string.h>
/**
* Here should be the comments relative to the class...
*/
class Hello{
public:
void SetSomeThing(const char *str);
void SetSomeThing(const char *str); // repeats
void SetSomeThing(const char *str);
Hello();
virtual ~Hello();
void SayHello();
void SetSomeThing(char *str);
private:
/**
* string to contain a word
* It's ok; in the tab Detail I setted:
* lower bound=1 upper bound=20 and
* container type= [30] and checked
* "attribute is a collection"
*/
char str[30];
};
#endif // !defined(A6413818_42A5_47fe_9FDD_C8F6F19171C3__INCLUDED_)
-- Claudio
-
Ops, the body code, the generation repeats
each method definition... below:
///////////////////////////////////////////////////////////
// Hello.cpp
// Implementation of the Class Hello
// Created on: 26-set-2004 21:37:42
// Original author: Claudio
///////////////////////////////////////////////////////////
#include "Hello.h"
/**
* Constructor
*/
Hello::Hello(){
}
/**
* Destructor
*/
Hello::~Hello(){
}
// ATTENTION HERE!!!
// this method never is regenerated!!!
// it keeps here!
/**
* Display... may be hello... hello!
*/
void Hello::SayHello(){
}
/**
* set some thing (!?)
*/
void Hello::SetSomeThing(char *str){
}
/**
* set some thing (!?)
*/
void Hello::SetSomeThing(char *str){
}
/**
* set some thing (!?)
*/
void Hello::SetSomeThing(char *str){
}
/**
* set some thing (!?)
*/
void Hello::SetSomeThing(char *str){
}
-----------
-- Cláudio
-
I'm not sure what's going on for you there. I don't have the problem. My guess is that you have extra stuff in the type so that EA doesn't recognise that the method signature is the same and so adds a new one.
What I suggest is to try importing the code, that way you'll see how EA creates a model from that code and it expects things to be modelled in that way when it generates code again.
Simon