convert_string_vector_to_byte_vector

 

Description

Convert string vector to byte vector

Syntax

int convert_string_vector_to_byte_vector( const vector<string> & vs, vector<byte> & vn, int nNoNumericReplace = 0 )

Parameters

vs
[input] the string vector to be converted.
vn
[output] the byte vector for the result.
nNoNumericReplace
[input] the value used to replace when a item is not a numeric. Default is 0

Return

the number of converted items

Examples

EX1

int convert_string_vector_to_byte_vector_ex1()
{
    vector<string> vs = {"255", "17", "253", "128", "--"};
    vector<byte> vn;
    int nRet = convert_string_vector_to_byte_vector(vs , vn , 0);
    if(nRet)
    { 
                printf("%d items converted :\n" , nRet);//Output as Hex: 5 items converted :
                //ff  11  fd  80  0   
                for (int ii=0; ii < nRet; ii++)
                    printf("%02x  ", vn[ii]);
        printf("\n");             
    }
    else
         printf("Convert failed");
    return 0;
}

Remark

See Also

convert_str_vector_to_num_vector, convert_string_vector_to_int_vector , convert_byte_vector_to_string_vector

header to Include

origin.h

Reference