Click here to Skip to main content
15,890,882 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralATL in .NET Studio... Pin
CherezZaboro10-Nov-04 7:45
CherezZaboro10-Nov-04 7:45 
GeneralRe: ATL in .NET Studio... Pin
De Nardis Andrea10-Nov-04 8:33
De Nardis Andrea10-Nov-04 8:33 
GeneralATL web server and smart pointers Pin
De Nardis Andrea9-Nov-04 4:14
De Nardis Andrea9-Nov-04 4:14 
GeneralRe: ATL web server and smart pointers Pin
Igor Vigdorchik9-Nov-04 14:53
Igor Vigdorchik9-Nov-04 14:53 
GeneralRe: ATL web server and smart pointers Pin
De Nardis Andrea9-Nov-04 22:33
De Nardis Andrea9-Nov-04 22:33 
GeneralSreaming maps and vectors to a file Pin
Malcolm Smart8-Nov-04 23:31
Malcolm Smart8-Nov-04 23:31 
GeneralRe: Sreaming maps and vectors to a file Pin
Steve S9-Nov-04 0:07
Steve S9-Nov-04 0:07 
GeneralRe: Sreaming maps and vectors to a file Pin
Andrew Walker9-Nov-04 2:06
Andrew Walker9-Nov-04 2:06 
Yes, there's a trick to it. The iostreams library breaks input on any whitespace (sounds a bit silly at first but in some situations it can be helpful). To get around this you need to save each element of the pair with spaces in it to a separate line. To make things easy for yourself, save the size of the container as well.

You can see the basic idea from the snippet below

#include <iostream>
#include <map>
#include <string>
#include <sstream>

using std::cout;
using std::endl;

typedef std::map<std::string,std::string> PairContainer;

void writeMap(std::ostream& os, PairContainer& v)
{
    os << static_cast<unsigned int>(v.size()) << "\n";
    PairContainer::const_iterator end(v.end());
    for(PairContainer::iterator cur(v.begin()); cur != end; ++cur)
    {
        os << (*cur).first << "\n";
        os << (*cur).second << "\n";
    }
}

void readMap(std::istream& is, PairContainer& v)
{
    unsigned int npairs = 0;
    std::string tmp;
    std::getline(is,tmp);
    std::istringstream iss(tmp);
    iss >> npairs;
    for(unsigned int i = 0; i < npairs; i++)
    {
        std::pair<std::string,std::string> p;
        std::getline(is,p.first);
        std::getline(is,p.second);
        v.insert(p);
    }
}


I agree with the last poster that serializing data in this way is not a long term solution - it won't scale and can be hard to maintain and read, although I would recommend going with an XML api with a high level of abstraction if you head down that road, and even then it can be frustrating in some situations.

At times scripting languages like python and lua can be godsends for loading complex or heirarchical data, mainly because they are based on full parsers that do all the work for you, rather than SAX and DOM and many of the current XML API's which seem to only partially solve the problem.



If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts your aim;
Yours is the Earth and everything that's in it.

Rudyard Kipling

GeneralRe: Sreaming maps and vectors to a file Pin
Malcolm Smart9-Nov-04 4:37
Malcolm Smart9-Nov-04 4:37 
QuestionHow to import MFC DLL into WTL project Pin
humbird8-Nov-04 2:33
humbird8-Nov-04 2:33 
AnswerRe: How to import MFC DLL into WTL project Pin
Michael Dunn8-Nov-04 6:52
sitebuilderMichael Dunn8-Nov-04 6:52 
QuestionATL DLL? Pin
dSolariuM5-Nov-04 17:49
dSolariuM5-Nov-04 17:49 
AnswerRe: ATL DLL? Pin
ThatsAlok8-Nov-04 18:47
ThatsAlok8-Nov-04 18:47 
GeneralATL Server: Catch all resources Pin
Diep-Virezer5-Nov-04 4:14
Diep-Virezer5-Nov-04 4:14 
GeneralAbout Runtime and Developer Component Pin
ThatsAlok3-Nov-04 20:26
ThatsAlok3-Nov-04 20:26 
GeneralATL property page can't get WM_HELP message Pin
CodewithJoe2-Nov-04 21:26
CodewithJoe2-Nov-04 21:26 
GeneralRe: ATL property page can't get WM_HELP message Pin
CodewithJoe2-Nov-04 21:34
CodewithJoe2-Nov-04 21:34 
GeneralCAxDialogImpl Pin
atabac1-Nov-04 9:34
atabac1-Nov-04 9:34 
GeneralRe: CAxDialogImpl Pin
Michael Dunn2-Nov-04 10:57
sitebuilderMichael Dunn2-Nov-04 10:57 
Generalexport attribute with struct / enum Pin
DrGreen1-Nov-04 4:04
DrGreen1-Nov-04 4:04 
GeneralRe: export attribute with struct / enum Pin
RChin3-Nov-04 6:38
RChin3-Nov-04 6:38 
GeneralRe: export attribute with struct / enum Pin
User 21559716-Nov-04 0:20
User 21559716-Nov-04 0:20 
GeneralWTL resource leak Pin
nm_11431-Oct-04 7:08
nm_11431-Oct-04 7:08 
QuestionWhat is RPC Pin
Ranjish29-Oct-04 3:14
Ranjish29-Oct-04 3:14 
AnswerRe: What is RPC Pin
Nicholas Cardi10-Nov-04 4:30
Nicholas Cardi10-Nov-04 4:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.