Solved

streaming STL map

Posted on 2003-11-04
5
319 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_
Comment Utility
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
Comment Utility
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_
Comment Utility
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
Comment Utility
PAQ'd & 30 points refunded

Chmod
Community Support Moderator @ Experts Exchange
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

762 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

6 Experts available now in Live!

Get 1:1 Help Now