Boost logo

Boost Users :

From: Mike Lapshin (rewinder_at_[hidden])
Date: 2005-03-04 06:50:11


Hello Boost-users,

I'm trying to save a simple class to xml_woarchive:

class StringContainer
{
        std::map<std::string, std::wstring> mStrings;
        
        friend class boost::serialization::access;
        template<class TArchive>
        void serialize(TArchive& ar, const unsigned int version)
        {
                ar & BOOST_SERIALIZATION_NVP(mStrings);
        }
public:
        typedef std::map<std::string, std::wstring> StringMap;
        StringContainer() {}
        ~StringContainer() {}

        void addString (const std::string& id, const std::wstring& str);
        bool isStringExists (const std::string& id) const;
        const std::wstring& getString(const std::string& id) const;
        void removeString (const std::string& id);
};

// somewhere in main code:

StringContainer sc;
sc.addString("fps.profilerfl", L"FPS: ");
sc.addString("triangles.profilerfl", L"Triangles: ");
std::wofstream outfs("strings.xml");
assert(outfs.good());
boost::archive::xml_woarchive oa(outfs);
oa << BOOST_SERIALIZATION_NVP(sc);

But somewhere after it (i think it is in xml_woarchive destructor) my
program falls with "Debug Assertion Failed" (I'm using VC7.1) message:
HEAP[test.exe]: Invalid Address specified to RtlValidateHeap( 011B0000, 011F29E8 )
Unhandled exception at 0x77f767cd in test.exe: User breakpoint.

By the way, xml file writes as expected:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE boost_serialization>
<boost_serialization signature="serialization::archive" version="3">
<sc class_id="0" tracking_level="0" version="0">
        <mStrings class_id="1" tracking_level="0" version="0">
                <count>2</count>
                <item class_id="2" tracking_level="0" version="0">
                        <first>fps.profilerfl</first>
                        <second>FPS: </second>
                </item>
                <item>
                        <first>triangles.profilerfl</first>
                        <second>Triangles: </second>
                </item>
        </mStrings>
</sc>
</boost_serialization>

What i'm doing incorrectly?

-- 
Mike Lapshin

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net