Solved

streaming STL map

Posted on 2003-11-04
5
326 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

733 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