Passing a tree like structure 
Author Message
 Passing a tree like structure

Hi,
What options do I have to pass a tree like structure [registry ]  in and out
of an atl object having a dual interface [implemnts an IDispatch].
Using the information from   http://www.*-*-*.com/ ;can pass
a a struct, can I create a tree of structures and pass it using a SafeArray.

Thanx Murtuza



Mon, 27 Oct 2003 21:02:51 GMT  
 Passing a tree like structure
You can have a safearray of variants each of which may be a safearray in its
turn. Or a UDT can have a field that is a sarearray of variants containing
UDTs.
--
With best wishes,
    Igor Tandetnik


Quote:
> Hi,
> What options do I have to pass a tree like structure [registry ]  in and
out
> of an atl object having a dual interface [implemnts an IDispatch].
> Using the information from  http://www.mvps.org/vcfaq/com/4.htm I  can
pass
> a a struct, can I create a tree of structures and pass it using a
SafeArray.

> Thanx Murtuza



Mon, 27 Oct 2003 23:46:47 GMT  
 Passing a tree like structure
I have something like
typedef[uuid(C614D9B2-00F1-4714-B45D-69925CBD28BC)] struct
tagNameValueStruct
 {
 BSTR name;
 BSTR value;
 }NameValueStruct;
 typedef[uuid(536296B6-E5E7-47c1-BD29-18852E20263C)]   struct tagNodeStruct
 {
       struct tagNodeStruct ** node;
    struct tagNameValueStruct  property;
    } NodeStruct;

I think I would need to use a safearray  for the "property" variable as it
will be enumerating all name value pairs...

When I use the object viewer in Vb i can see NodeStruct,tagNodeStruct
,NameValueStruct,tagNameValueStruct.
I would like to see just NodeStruct and NameValueStruct is it possible?


Quote:
> You can have a safearray of variants each of which may be a safearray in
its
> turn. Or a UDT can have a field that is a sarearray of variants containing
> UDTs.
> --
> With best wishes,
>     Igor Tandetnik



> > Hi,
> > What options do I have to pass a tree like structure [registry ]  in and
> out
> > of an atl object having a dual interface [implemnts an IDispatch].
> > Using the information from  http://www.mvps.org/vcfaq/com/4.htm I  can
> pass
> > a a struct, can I create a tree of structures and pass it using a
> SafeArray.

> > Thanx Murtuza



Tue, 28 Oct 2003 00:00:49 GMT  
 Passing a tree like structure
I'm afraid your structures are not automation-compatible (Disclaimer: I've
never worked with UDT's myself, so take whatever I say with a grain of
salt). Maybe you need something like this:

typedef [uuid(C614D9B2-00F1-4714-B45D-69925CBD28BC)]
struct NameValueStruct
{
   BSTR name;
   BSTR value;

Quote:
} NameValueStruct;

typedef [uuid(536296B6-E5E7-47c1-BD29-18852E20263C)]
struct NodeStruct
{
    struct NameValueStruct  payload;

// maybe you will need a VARIANT here to wrap SAFEARRAY
    SAFEARRAY(struct NodeStruct) childNodes;

Quote:
} NodeStruct;

--
With best wishes,
    Igor Tandetnik


Quote:
> I have something like
> typedef[uuid(C614D9B2-00F1-4714-B45D-69925CBD28BC)] struct
> tagNameValueStruct
>  {
>  BSTR name;
>  BSTR value;
>  }NameValueStruct;
>  typedef[uuid(536296B6-E5E7-47c1-BD29-18852E20263C)]   struct
tagNodeStruct
>  {
>        struct tagNodeStruct ** node;
>     struct tagNameValueStruct  property;
>     } NodeStruct;

> I think I would need to use a safearray  for the "property" variable as it
> will be enumerating all name value pairs...

> When I use the object viewer in Vb i can see NodeStruct,tagNodeStruct
> ,NameValueStruct,tagNameValueStruct.
> I would like to see just NodeStruct and NameValueStruct is it possible?



> > You can have a safearray of variants each of which may be a safearray in
> its
> > turn. Or a UDT can have a field that is a sarearray of variants
containing
> > UDTs.
> > --
> > With best wishes,
> >     Igor Tandetnik



> > > Hi,
> > > What options do I have to pass a tree like structure [registry ]  in
and
> > out
> > > of an atl object having a dual interface [implemnts an IDispatch].
> > > Using the information from  http://www.mvps.org/vcfaq/com/4.htm I  can
> > pass
> > > a a struct, can I create a tree of structures and pass it using a
> > SafeArray.

> > > Thanx Murtuza



Tue, 28 Oct 2003 00:30:50 GMT  
 Passing a tree like structure
Structs cannot be nested, but you can store a safe array in a struct.
You need a VARIANT to store the nested struct though.

As for Murtuza's name question - I always advise against using
typedefs. Typing struct in the IDL before the name of the struct
is not a big deal...

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================


Quote:
> I'm afraid your structures are not automation-compatible (Disclaimer: I've
> never worked with UDT's myself, so take whatever I say with a grain of
> salt). Maybe you need something like this:

> typedef [uuid(C614D9B2-00F1-4714-B45D-69925CBD28BC)]
> struct NameValueStruct
> {
>    BSTR name;
>    BSTR value;
> } NameValueStruct;

> typedef [uuid(536296B6-E5E7-47c1-BD29-18852E20263C)]
> struct NodeStruct
> {
>     struct NameValueStruct  payload;

> // maybe you will need a VARIANT here to wrap SAFEARRAY
>     SAFEARRAY(struct NodeStruct) childNodes;
> } NodeStruct;

> --
> With best wishes,
>     Igor Tandetnik



> > I have something like
> > typedef[uuid(C614D9B2-00F1-4714-B45D-69925CBD28BC)] struct
> > tagNameValueStruct
> >  {
> >  BSTR name;
> >  BSTR value;
> >  }NameValueStruct;
> >  typedef[uuid(536296B6-E5E7-47c1-BD29-18852E20263C)]   struct
> tagNodeStruct
> >  {
> >        struct tagNodeStruct ** node;
> >     struct tagNameValueStruct  property;
> >     } NodeStruct;

> > I think I would need to use a safearray  for the "property" variable as
it
> > will be enumerating all name value pairs...

> > When I use the object viewer in Vb i can see NodeStruct,tagNodeStruct
> > ,NameValueStruct,tagNameValueStruct.
> > I would like to see just NodeStruct and NameValueStruct is it possible?



> > > You can have a safearray of variants each of which may be a safearray
in
> > its
> > > turn. Or a UDT can have a field that is a sarearray of variants
> containing
> > > UDTs.
> > > --
> > > With best wishes,
> > >     Igor Tandetnik



> > > > Hi,
> > > > What options do I have to pass a tree like structure [registry ]  in
> and
> > > out
> > > > of an atl object having a dual interface [implemnts an IDispatch].
> > > > Using the information from  http://www.mvps.org/vcfaq/com/4.htm I
can
> > > pass
> > > > a a struct, can I create a tree of structures and pass it using a
> > > SafeArray.

> > > > Thanx Murtuza



Tue, 28 Oct 2003 02:20:41 GMT  
 Passing a tree like structure
Remind me:  Why is this?  And, which book is this in?

--
Reginald Blue                   | Opinions expressed here do not
Natural Language Understanding  | necessarily represent those of
Unisys Corporation              | my employer.
--------------------------------+-------------------------------

NL technology,speech application| My email address is wrong, you
development training, see:      | need to remove the obvious.
http://www.speechdepot.com/     +-------------------------------


Quote:
> As for Murtuza's name question - I always advise against using
> typedefs. Typing struct in the IDL before the name of the struct
> is not a big deal...



Tue, 28 Oct 2003 23:42:11 GMT  
 Passing a tree like structure
No book, just painful experience... I know it can be done with the
typedef too - I've seen others use the same name for the struct
and the typedef. But it looks kind of wrong to me - you cannot
write that in a C++ header... Besides, you create two entries
in the type library completely redundantly! One suffices...

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================


Quote:
> Remind me:  Why is this?  And, which book is this in?

> --
> Reginald Blue                   | Opinions expressed here do not
> Natural Language Understanding  | necessarily represent those of
> Unisys Corporation              | my employer.
> --------------------------------+-------------------------------

> NL technology,speech application| My email address is wrong, you
> development training, see:      | need to remove the obvious.
> http://www.speechdepot.com/     +-------------------------------



> > As for Murtuza's name question - I always advise against using
> > typedefs. Typing struct in the IDL before the name of the struct
> > is not a big deal...



Wed, 29 Oct 2003 01:32:52 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Linked list/ Tree structure

2. Tree Data Structure on Disk?

3. tree data structure

4. tree structures in C

5. Directory Tree Structure

6. searching for a structure in a binary tree

7. structures and binary tree?!

8. "tree" data structure of GCC

9. Directory tree structure

10. About Tree Structure

11. inverted structure & B+ tree

12. Homework Question about tree structures.

 

 
Powered by phpBB® Forum Software