Thread overview | ||||||
---|---|---|---|---|---|---|
|
March 17, 2017 How to get inner most nested struct | ||||
---|---|---|---|---|
| ||||
struct VARIANT { union { struct { VARTYPE vt; WORD wReserved1; WORD wReserved2; WORD wReserved3; union { int lVal; LONGLONG llVal; ubyte bVal; short iVal; float fltVal; double dblVal; VARIANT_BOOL boolVal; SCODE scode; CY cyVal; DATE date; BSTR bstrVal; IUnknown punkVal; IDispatch pdispVal; SAFEARRAY* parray; ubyte* pbVal; short* piVal; int* plVal; float* pfltVal; double* pdblVal; VARIANT_BOOL* pboolVal; _VARIANT_BOOL* pbool; SCODE* pscode; CY* pcyVal; DATE* pdate; BSTR* pbstrVal; IUnknown* ppunkVal; IDispatch* ppdispVal; SAFEARRAY** pparray; VARIANT* pvarVal; void* byref; CHAR cVal; USHORT uiVal; ULONG ulVal; ULONGLONG ullVal; INT intVal; UINT uintVal; DECIMAL* pdecVal; CHAR* pcVal; USHORT* puiVal; ULONG* pulVal; INT* pintVal; UINT* puintVal; struct { PVOID pvRecord; IRecordInfo pRecInfo; } } } DECIMAL decVal; } } I'd like to iterate over the members of the inner most union only and only over fields(ignoring the pvRecord struct). Anyway to do this? tuple of just returns everything. I know in this case it is a simple filtering, but it would be nice to have a more general solution. |
March 17, 2017 Re: How to get inner most nested struct | ||||
---|---|---|---|---|
| ||||
Posted in reply to Hussien | On Friday, 17 March 2017 at 00:34:22 UTC, Hussien wrote:
> Anyway to do this?
I don't think you can, the inner anonymous structs are just to organize the members and group them inside the union.
|
March 17, 2017 Re: How to get inner most nested struct | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | On Friday, 17 March 2017 at 01:19:54 UTC, Adam D. Ruppe wrote:
> On Friday, 17 March 2017 at 00:34:22 UTC, Hussien wrote:
>> Anyway to do this?
>
> I don't think you can, the inner anonymous structs are just to organize the members and group them inside the union.
;/ D should retain the structure in some way and allow for one to traverse it.
|
March 17, 2017 Re: How to get inner most nested struct | ||||
---|---|---|---|---|
| ||||
Posted in reply to Hussien | On Friday, 17 March 2017 at 01:52:20 UTC, Hussien wrote:
> On Friday, 17 March 2017 at 01:19:54 UTC, Adam D. Ruppe wrote:
>> On Friday, 17 March 2017 at 00:34:22 UTC, Hussien wrote:
>>> Anyway to do this?
>>
>> I don't think you can, the inner anonymous structs are just to organize the members and group them inside the union.
>
> ;/ D should retain the structure in some way and allow for one to traverse it.
Declare them as separate structs and simply put them in there.
Ex.
struct Foo {
int bar;
int baz;
}
struct Foo2 {
union {
long bar;
Foo baz;
// Equal to:
/*
struct {
int bar;
int baz;
}
*/
}
}
Only way I could think of achieving this.
|
Copyright © 1999-2021 by the D Language Foundation