2.2.3.19.13 vectorbase::GetBytes

Description

Copy the elements of this vector into a byte type buffer.

Syntax

int GetBytes( vector<byte> & vStream )

Parameters

vStream
[output]vector containing bytes copied from the source vector

Return

Returns 0 on success or a non-zero error code on failure.

Examples

EX1

void vectorbase_GetBytes_ex1()
{    
    // Decalare a vector of type int and fill with some data
    vector<int> vecData = {1,2,3,4,5};
 
    // Declare a vector of type byte
    vector<byte> vecBytes;
    // Copy vecData into vecBytes
    vecData.GetBytes(vecBytes);
 
    // Check size of vecBytes - it should be "size of int" * "size of vecData"
    int iSize = vecBytes.GetSize();
    if (iSize == sizeof(int) * vecData.GetSize())
    	printf("iSize is %d", iSize);
    else
    	printf("Should NOT come here");    
    //Result: iSize is 20
}

Remark

Copy elements of the vector to an internal byte type buffer.

See Also

vectorbase::SetBytes

Header to Include

origin.h