[omniORB] How to copy a corba struct with sequences?
Mark Johnson
mark.johnson@onfiber.com
Tue, 9 Oct 2001 10:36:57 -0500
I have built a C++ wrapper around a corba struct to carry temporary
information before passing it along, here is an excerpt of the class:
class EventInfo
{
public:
void copy( const Event & aEvent )
{
theEvent.identify = CORBA::string_dup( aEvent.identity );
theEvent.priority = aEvent.priority;
// how to copy the 'variables'?
}
const Event & getEvent() const { return theEvent; }
private:
Event theEvent; // corba struct
};
the Event IDL looks like this:
struct AttributeValue
{
string _Attribute;
string _Value;
};
typedef sequence<AttributeValue> AtrributeValueSeq;
struct Event
{
string _identity;
short _priority;
AtrributeValueSeq _variables; // Sequence a attribute values.
};
This is how I was copying the variables but the for() loop froze when I went
to add a new item to the sequence:
for( int i = 0; i < aEvent.variables.length(); ++i )
{
AttributeValue av; // Sequence a attribute values.
av.Attribute = CORBA::string_dup( aEvent.variables[i].Attribute );
av.Value = CORBA::string_dup( aEvent.variables[i].Value );
theEvent.variables[i] = av; // program freezed here.....
}
Anyway, if someone could help me with this or has a better idea as to how to
carry build the EventInfo class it would be very helpful...
thanks for your time!