Solved

streaming STL map

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
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 tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

861 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