www.digitalmars.com         C & C++   DMDScript  

c++.stlsoft - problem between COMSTL and DIA SDK

reply "Jean-Marie Auville" <jauville infonie.fr> writes:
Hi,

I have a problem when I use the DIA SDK interfaces and the
comstl::collection_sequence provided by the version 1.7.

my usage of the collection_sequence is the following :
typedef comst:::collection_sequence<IDiaEnumSymbols,IDiaEnumSymbols,
IDiaSymbol*, comstl::interface_policy<IDiaSymbol>, IDiaSymbol>
com_dia_symbol_traversal;

when I run the programm, I have a problem with iterator begin() const method
and the following statement :
hr = punkEnum->QueryInterface ...

when I remove all lines and I write only return iterator(m_i) that's work
correctly.

please, could you give an explanation of this problem ?

may be I don't use correctly your class comstl::collection_sequence ?

-- 
Jean-Marie Auville
Courrier électronique : jauville infonie.fr
Mar 31 2004
next sibling parent "Matthew" <matthew stlsoft.org> writes:
Jean-Marie

Can you send me a simple VS.NET project demonstrating the problem?

Cheers

Matthew

"Jean-Marie Auville" <jauville infonie.fr> wrote in message
news:c4egbt$1kv5$1 digitaldaemon.com...
 Hi,

 I have a problem when I use the DIA SDK interfaces and the
 comstl::collection_sequence provided by the version 1.7.

 my usage of the collection_sequence is the following :
 typedef comst:::collection_sequence<IDiaEnumSymbols,IDiaEnumSymbols,
 IDiaSymbol*, comstl::interface_policy<IDiaSymbol>, IDiaSymbol>
 com_dia_symbol_traversal;

 when I run the programm, I have a problem with iterator begin() const

 and the following statement :
 hr = punkEnum->QueryInterface ...

 when I remove all lines and I write only return iterator(m_i) that's work
 correctly.

 please, could you give an explanation of this problem ?

 may be I don't use correctly your class comstl::collection_sequence ?

 --
 Jean-Marie Auville
 Courrier électronique : jauville infonie.fr

Apr 12 2004
prev sibling next sibling parent "Matthew" <matthew.hat stlsoft.dot.org> writes:
Jean-Marie

I'm still hoping you can send me a small exemplifying VS.NET project. Or have
you
found that the problem was elsewhere?

Either way, it'd be good if you could let us know what's the status.

Cheers

Matthew

"Jean-Marie Auville" <jauville infonie.fr> wrote in message
news:c4egbt$1kv5$1 digitaldaemon.com...
 Hi,

 I have a problem when I use the DIA SDK interfaces and the
 comstl::collection_sequence provided by the version 1.7.

 my usage of the collection_sequence is the following :
 typedef comst:::collection_sequence<IDiaEnumSymbols,IDiaEnumSymbols,
 IDiaSymbol*, comstl::interface_policy<IDiaSymbol>, IDiaSymbol>
 com_dia_symbol_traversal;

 when I run the programm, I have a problem with iterator begin() const method
 and the following statement :
 hr = punkEnum->QueryInterface ...

 when I remove all lines and I write only return iterator(m_i) that's work
 correctly.

 please, could you give an explanation of this problem ?

 may be I don't use correctly your class comstl::collection_sequence ?

 -- 
 Jean-Marie Auville
 Courrier électronique : jauville infonie.fr

Apr 25 2004
prev sibling parent reply "Matthew" <matthew.hat stlsoft.dot.org> writes:
Ok, first thing: there's nothing wrong with COMSTL's collection_sequence
template. Phew!

The problem is that you've specified IDiaEnumSymbols as the enumerator interface
in your collection typedef, as in:

typedef comstl::collection_sequence< IDiaEnumSymbols
                                   , IDiaEnumSymbols  // **** HERE!! ****
                                   , IDiaSymbol*
                                   , comstl::interface_policy<IDiaSymbol>
                                   , IDiaSymbol*
                                   >            dia_symbol_traversal_type;

I can see why you've done this, because IDiaEnumSymbols is also a COM Enumerator
interface, with Next(), Skip(), Clone() and Reset(). Clearly MS have done this
as
a "convenience", but it's a trap, as we can see.

The documentation for But IDiaEnumSymbols::get__NewEnum() states that it returns
an IEnumVARIANT, as we would expect from a collection. (See
http://msdn.microsoft.com/library/en-us/diasdk/html/vslrfidiaenumsymbolsget__newenum.asp.).
If you change the typedef accordingly, it all works:

typedef comstl::collection_sequence< IDiaEnumSymbols
                                   , IEnumVARIANT
                                   , VARIANT
                                   , comstl::VARIANT_policy
                                   >            dia_symbol_traversal_type;

You then need to adjust the dump_symbol() method, using the COMSTL interface
casts, which I've done in the attached code.


But there's another way to play this. Since IDiaEnumSymbols appears to be both
collection and enumeration, you could get what you want by using the COMSTL
enumerator_sequence template, as in:

typedef comstl::enumerator_sequence<IDiaEnumSymbols
                                   , IDiaSymbol*
                                   , comstl::interface_policy<IDiaSymbol>
                                   >             dia_symbol_traversal_type;

This directly uses IDiaEnumSymbols as an enumerator interface (rather than a
collection interface), and also means you can keep your original function.

I've included all three options in the attached code, and also included a
listing
of the results when run with MSDIA71.PDB.

One last thing. You specify "true" as the bAddRef parameter to the collection.
This implies that you will be releasing the enum/coll interface retrieved from
findChildren() yourself, but I don't see that. In production code you'd want to
either release it yourself, or specify "false" for bAddRef to "eat" the
reference.

btw, would it be ok with you if I used your test program as the basis for a
COMSTL sample? I will, of course, use any suitable copyright notice you wish to
provide. :)

Cheers

Matthew


"Jean-Marie Auville" <jauville infonie.fr> wrote in message
news:c4egbt$1kv5$1 digitaldaemon.com...
 Hi,

 I have a problem when I use the DIA SDK interfaces and the
 comstl::collection_sequence provided by the version 1.7.

 my usage of the collection_sequence is the following :
 typedef comst:::collection_sequence<IDiaEnumSymbols,IDiaEnumSymbols,
 IDiaSymbol*, comstl::interface_policy<IDiaSymbol>, IDiaSymbol>
 com_dia_symbol_traversal;

 when I run the programm, I have a problem with iterator begin() const method
 and the following statement :
 hr = punkEnum->QueryInterface ...

 when I remove all lines and I write only return iterator(m_i) that's work
 correctly.

 please, could you give an explanation of this problem ?

 may be I don't use correctly your class comstl::collection_sequence ?

 -- 
 Jean-Marie Auville
 Courrier électronique : jauville infonie.fr

May 02 2004
parent "Jean-Marie Auville" <jauville infonie.fr> writes:
Matthew

I try this solution today and provide you a feedback quickly !

no problem to use this program as a sample !

thank you


-- 
Jean-Marie Auville
Téléphone : 06 60 43 17 53
Courrier électronique : jauville infonie.fr
"Matthew" <matthew.hat stlsoft.dot.org> wrote in message
news:c7408i$2te4$1 digitaldaemon.com...
 Ok, first thing: there's nothing wrong with COMSTL's collection_sequence
 template. Phew!

 The problem is that you've specified IDiaEnumSymbols as the enumerator

 in your collection typedef, as in:

 typedef comstl::collection_sequence< IDiaEnumSymbols
                                    , IDiaEnumSymbols  // **** HERE!! ****
                                    , IDiaSymbol*
                                    , comstl::interface_policy<IDiaSymbol>
                                    , IDiaSymbol*
                                    >            dia_symbol_traversal_type;

 I can see why you've done this, because IDiaEnumSymbols is also a COM

 interface, with Next(), Skip(), Clone() and Reset(). Clearly MS have done

 a "convenience", but it's a trap, as we can see.

 The documentation for But IDiaEnumSymbols::get__NewEnum() states that it

 an IEnumVARIANT, as we would expect from a collection. (See

 If you change the typedef accordingly, it all works:

 typedef comstl::collection_sequence< IDiaEnumSymbols
                                    , IEnumVARIANT
                                    , VARIANT
                                    , comstl::VARIANT_policy
                                    >            dia_symbol_traversal_type;

 You then need to adjust the dump_symbol() method, using the COMSTL

 casts, which I've done in the attached code.


 But there's another way to play this. Since IDiaEnumSymbols appears to be

 collection and enumeration, you could get what you want by using the

 enumerator_sequence template, as in:

 typedef comstl::enumerator_sequence<IDiaEnumSymbols
                                    , IDiaSymbol*
                                    , comstl::interface_policy<IDiaSymbol>
                                    >

 This directly uses IDiaEnumSymbols as an enumerator interface (rather than

 collection interface), and also means you can keep your original function.

 I've included all three options in the attached code, and also included a

 of the results when run with MSDIA71.PDB.

 One last thing. You specify "true" as the bAddRef parameter to the

 This implies that you will be releasing the enum/coll interface retrieved

 findChildren() yourself, but I don't see that. In production code you'd

 either release it yourself, or specify "false" for bAddRef to "eat" the
 reference.

 btw, would it be ok with you if I used your test program as the basis for

 COMSTL sample? I will, of course, use any suitable copyright notice you

 provide. :)

 Cheers

 Matthew


 "Jean-Marie Auville" <jauville infonie.fr> wrote in message
 news:c4egbt$1kv5$1 digitaldaemon.com...
 Hi,

 I have a problem when I use the DIA SDK interfaces and the
 comstl::collection_sequence provided by the version 1.7.

 my usage of the collection_sequence is the following :
 typedef comst:::collection_sequence<IDiaEnumSymbols,IDiaEnumSymbols,
 IDiaSymbol*, comstl::interface_policy<IDiaSymbol>, IDiaSymbol>
 com_dia_symbol_traversal;

 when I run the programm, I have a problem with iterator begin() const


 and the following statement :
 hr = punkEnum->QueryInterface ...

 when I remove all lines and I write only return iterator(m_i) that's


 correctly.

 please, could you give an explanation of this problem ?

 may be I don't use correctly your class comstl::collection_sequence ?

 -- 
 Jean-Marie Auville
 Courrier électronique : jauville infonie.fr


May 03 2004