Solved

streaming STL map

Posted on 2003-11-04
5
322 Views
Last Modified: 2010-04-01
I need to stream a STL map via the MarshalInterface method on IMarshal .How do we give the size specifications for STL map?
e.g typedef map<string,string> MAPSTRTOSTR
MAPSTRTOSTR mSTLString;

somewhere later on,

mSTLString.insert(MAPSTRTOSTR::value_type("unity","is strength");

Now to pass this map into the Write method of IStream interface what do i give the size of the map as ?

0
Comment
Question by:ranadhir
  • 2
5 Comments
 
LVL 9

Expert Comment

by:_ys_
ID: 9677788
Sorry, but I do have to question your motives here. COM is supposed to be platform and language independant.

If you want to return a collection the standard IEnumXxxx style implementation would suit better.
0
 

Author Comment

by:ranadhir
ID: 9683397
There is an exisitng  class which reads data from a data storage(in this case  , a set of files ) and stores it into a map.
Now the idea is add custom marshalling support to this class,to stream the stored map to the client.The objective was to prevent any round network  trips when the client retrieves records from the map.
This idea was tested fine with a normal data-type like long etc. - but to implement this with a map;we needed to determine how to caclculate the size of the data to be streamed in.
0
 
LVL 9

Expert Comment

by:_ys_
ID: 9686347
From what I gather, you're trying to serialise an entire std::map into the stream as void*, and deserialise it on the other side into an std::map instance.

Only problem is ... is the entire map contiguous in memory ?

Wouldn't
mSTLString.insert(MAPSTRTOSTR::value_type("unity","is strength");
just insert two pointers to the strings directly into the memory space ?

My recommendation would be to pass a UDT back to the client. They're automatically marshalled (support added with DCOM 1.2).

I have seen std objects being passed around within COM. Just can't remember where or when.
0
 

Accepted Solution

by:
Chmod earned 0 total points
ID: 9768320
PAQ'd & 30 points refunded

Chmod
Community Support Moderator @ Experts Exchange
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now