op_vvec_create()
Abstract
Creates a new vector that contains no elements and can hold elements of a specified type.
Syntax
op_vvec_create (type)
| Argument | Type | Description |
|---|---|---|
type |
OpT_Value_Type |
Data type of the values that the vector will contain. Must be one of the values given in Table 98 “Value Vector Type Symbolic Constants“ on page 35. |
Return Type
Vvec_Vector
New, empty value vector.
Example
/* Create a new value vector to maintain error strings. */
error_vector = op_vvec_create (OpC_Type_String);
/* insert several packet pointers into the vector. */
op_vvec_value_set (packet_vector, OPC_VVEC_VECTOR_END, "Timeout expired");
op_vvec_value_set (packet_vector, OPC_VVEC_VECTOR_END, "Packet is corrupt");
op_vvec_value_set (packet_vector, OPC_VVEC_VECTOR_END,
"Unknown packet header format");
Details
Unlike an array, a vector’s length does not need to be specified, and the length can change as the result of other operations. All elements placed into the vector, however, must be of the type specified by the type argument.
Purpose
Provide a mechanism for creating vectors, which may then receive values.
Errors
- No errors are trapped.
Reference
- Use the KP op_vvec_copy() to create a new value vector that is a copy of an existing vector
- Use the KP op_vvec_destroy() to deallocate memory assigned to a vector
- Use the KP op_vvec_remove() to create a new vector consisting of elements removed from another vector
- Use the KP op_vvec_value_get() to copy a value from a specific element in a value vector to a variable
- Use the KP op_vvec_value_set() to assign a value to a specific element in a value vector