13.1.9.4 Member Functions

For a given OMG IDL sequence SEQ with base type TYPE, the member functions for the generated sequence class are described as follows:

SEQ ();
This is the default constructor for a sequence. The length is set to 0 (zero). If the sequence is unbounded, the maximum is also set to 0 (zero). If the sequence is bounded, the maximum is specified by the OMG IDL type and cannot be changed.
SEQ (CORBA::ULong Max);
This constructor is present only if the sequence is unbounded. This function sets the length of the sequence to 0 (zero) and sets the maximum of the buffer to the specified value. The Max argument specifies the maximum length of the sequence.
SEQ (CORBA::ULong Max, CORBA::ULong Length, TYPE * Value, CORBA::Boolean Release);
This constructor sets the maximum, length, and elements of the sequence. The Release flag determines whether elements are released when the sequence is destroyed. Explanations of the arguments are as follows:
Max
The maximum value of the sequence. This argument is not present in bounded sequences.
Length
The current length of the sequence. For bounded sequences, this value must be less than the maximum specified in the OMG IDL type.
Value
A pointer to the buffer containing the elements of the sequence.
Release
Determines whether elements are released. If this flag has a value of CORBA_TRUE, the sequence assumes ownership of the buffer pointed to by the Value argument. If the Release flag is CORBA_ TRUE, this buffer must be allocated using the allocbuf member function, because it will be freed using the freebuf member function when the sequence is destroyed.
SEQ(const S&From);
This copy constructor deep copies the sequence from the specified argument. The From argument specifies the sequence to be copied.
~SEQ();
This destructor frees the sequence and, depending upon the Release flag, may free the sequence elements.
SEQ&operator=(const SEQ&From);
This assignment operator deep copies the sequence from the specified sequence argument. Any existing elements in the current sequence are released if the Release flag in the current sequence is set to CORBA_TRUE. The From argument specifies the sequence to be copied.
CORBA::ULong maximum( ) const;
This function returns the maximum of the sequence. For a bounded sequence, this is the value set in the OMG IDL type. For an unbounded sequence, this is the current maximum of the sequence.
void length(CORBA::ULong Length);
This function sets the current length of the sequence. The Length argument specifies the new length of the sequence. If the sequence is unbounded and the new length is greater than the current maximum, the buffer is reallocated and the elements are copied to the new buffer. If the new length is greater than the maximum, the maximum is set to the new length.
For a bounded sequence, the length cannot be set to a value greater than the maximum.
CORBA::ULong length() const;
This function returns the current length of the sequence.
TYPE &operator[](CORBA::ULong Index); const TYPE &operator[](CORBA::ULong Index) const;
These accessor functions return a reference to the sequence element at the specified index. The Index argument specifies the index of the element to return. This index cannot be greater than the current sequence length. The length must have been set either using the TYPE * constructor or the length(CORBA::ULong) modifier. If TYPE is an object reference, TypeCode reference, or string, the return type will be a ForSeq_var class.
static TYPE * allocbuf(CORBA::ULong NumElems);
This static function allocates a buffer to be used with the TYPE * constructor. The NumElems argument specifies the number of elements in the buffer to allocate. If the buffer cannot be allocated, NULL is returned.
If this buffer is not passed to the TYPE * constructor with release set to CORBA_TRUE, it must be freed using the freebuf member function.
static void freebuf(TYPE * Value);
This static function frees a TYPE * sequence buffer allocated by the allocbuf function. The Value argument specifies the TYPE * buffer allocated by the allocbuf function. A 0 (zero) pointer is ignored.