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 theValue
argument. If theRelease
flag isCORBA_ TRUE
, this buffer must be allocated using theallocbuf
member function, because it will be freed using thefreebuf
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 toCORBA_TRUE
. TheFrom
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. -
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 theTYPE *
constructor or thelength(CORBA::ULong)
modifier. IfTYPE
is an object reference, TypeCode reference, or string, the return type will be aForSeq_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. -
static void freebuf(TYPE * Value);
- This static function frees a
TYPE
*
sequence buffer allocated by theallocbuf
function. TheValue
argument specifies theTYPE
*
buffer allocated by theallocbuf
function. A 0 (zero) pointer is ignored.
Parent topic: Sequences