Problems with CATLMap
I'm trying to use CAtl map to store a map of string-based keys to a
VARIANT value, storing basically a key=value property bag.
My CAtlMap is declared as follows:
typedef CAtlMap< CComBSTR, VARIANT,CElementTraits<CComBSTR>>
PropertyBagMap;
....
PropertyBagMap m_propbag_map ;
I'm adding the values as follows:
CComBSTR key = bstrPropertyName ;
CComVariant cvar( varValue ) ;
this->Lock() ;
this->m_propbag_map[ key ] = cvar ;
this->Unlock() ;
Later, when I am trying to copt the contents of this property bag to
another by iterating through, my values are mixed up.
If I originally set
"Output Dir", "C:\Test"
"OutputFormat", "Multipage"
"Append", FALSE
Iterating through I get "Append" as the value for my key
"OutputFormat".
Here is my iteration code:
POSITION pos = NULL ;
CComVariant v ;
CComBSTR key ;
pos = m_propbag_map.GetStartPosition() ;
while ( pos != NULL ) {
m_propbag_map.GetAt( pos, key, v ); //** values are WRONG!
(*propBag).SetAt( key, v ) ;
m_propbag_map.GetNext( pos ) ;
}
What am I doing wrong?
Thanks.