xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

HB_StructureToArray()

Converts values contained in a binary C structure string to an array.

Syntax

HB_StructureToArray( <cBinary>  , ;
                     <aTypes>   , ;
                    [<nAlign>]  , ;
                    [<lRecurse>], ;
                     <aStructure> ) -->  aStructure

Arguments

<cBinary>
This is a character string holding the values of structure members in binary form. It is returned from HB_ArrayToStructure().
<aTypes>
The C-data types for each structure member must be specified as a one dimensional array of the same number of elements as there are structure members. #define constants must be used for <aTypes>. The following constants are available in the Cstruct.ch file:

Constants for C-data types
ConstantC-data type
CTYPE_CHARchar
CTYPE_UNSIGNED_CHARunsigned char
CTYPE_CHAR_PTRchar *
CTYPE_UNSIGNED_CHAR_PTRunsigned char*
CTYPE_SHORTshort
CTYPE_UNSIGNED_SHORTunsigned short
CTYPE_SHORT_PTRshort *
CTYPE_UNSIGNED_SHORT_PTRunsigned short *
CTYPE_INTint
CTYPE_UNSIGNED_INTunsigned int
CTYPE_INT_PTRint *
CTYPE_UNSIGNED_INT_PTRunsigned int *
CTYPE_LONGlong
CTYPE_UNSIGNED_LONGunsigned long
CTYPE_LONG_PTRlong *
CTYPE_UNSIGNED_LONG_PTRunsigned long *
CTYPE_FLOATfloat
CTYPE_FLOAT_PTRfloat *
CTYPE_DOUBLEdouble
CTYPE_DOUBLE_PTRdouble *
CTYPE_VOID_PTRvoid *
CTYPE_STRUCTUREstruct
CTYPE_STRUCTURE_PTRstruct *

<nAlign>
Optionally, the byte alignment for C-structure members can be specified. By default, the members are aligned at an eight byte boundary. Note that Windows API functions require a four byte alignment for structures.
<lRecurse>
This parameter defaults to .F. (false). When set to .T. (true) nested structures are decoded as well.
<aStructure>
An array of Len(<aTypes>) elements must be passed to receive in its elements the decoded values of memober variables.

Return

The function returns the array <aStructure>.

Description

HB_StructureToArray() is the reverse function of HB_ArrayToStructure(). It accepts a binary character string holding structure members and decodes them from their binary representation into native xHarbour data types. The resulting values are assigned to the elements of <aStructure>.

Note:  conversion of structure data to/from binary is most comfortly done with declaring a C structure class using typedef struct and using the resulting C structure objects.

Info

See also:C Structure class, HB_ArrayToStructure(), pragma pack(), (struct), typedef struct
Category: C Structure support , xHarbour extensions
Header:cstruct.ch
Source:vm\arrayshb.c
LIB:xhb.lib
DLL:xhbdll.dll


Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe