Solved

streaming STL map

Posted on 2003-11-04
5
328 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
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 be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

734 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