Boost logo

Boost Users :

From: tkachenkok_at_[hidden]
Date: 2006-08-03 08:14:35


I've tried to write my first application with Boost.Serialization library.

Here is the part of code, where the boost::text_iarchive throws an exception "boost::archive::archive_exception" "what(): stream error":

[code]
enum Origin {
    UNKNOWN=0,
    MEASURED,
    AVERAGE };

class OTCValue
{
        friend class boost::serialization::access;
        template<class Archive>
                void serialize(Archive & ar, const unsigned int version)
        {
                ar & m_value;
                ar & m_orig;
        }
        double m_value;
        Origin m_orig;
        ...
};
         ...
        const OTCValue val1=(*loaded.second.begin())->get_row(0)[0];
        {
                std::ofstream ofs("test_serial.txt");
                boost::archive::text_oarchive oa(ofs);
                oa << val1;
        }
        OTCValue val;
        {
                std::ifstream ifs("test_serial.txt");
                boost::archive::text_iarchive ia(ifs);
                ia >> val; // here is this exceptions thrown
        }
        ...
[/code]

And here is a little bit different code, which works great:

[code]
enum Origin {
    UNKNOWN=0,
    MEASURED,
    AVERAGE };

class OTCValue
{
        friend class boost::serialization::access;
        template<class Archive>
                void serialize(Archive & ar, const unsigned int version)
        {
                ar & m_value;
                ar & m_orig;
        }
        double m_value;
        Origin m_orig;
        ...
};
         ...
        const OTCValue val1(5.5, MEASURED);
        {
                std::ofstream ofs("test_serial.txt");
                boost::archive::text_oarchive oa(ofs);
                oa << val1;
        }
        OTCValue val;
        {
                std::ifstream ifs("test_serial.txt");
                boost::archive::text_iarchive ia(ifs);
                ia >> val;
        }
        ...
[/code]

What is the problem? The construction (*loaded.second.begin())->get_row(0)[0] returns an OTCValue .

I have compiled the boost-1.33.1 from the sources (www.boost.org).
The project I've made is under KDevelop 3.2.2 (initially consol "Hello World" application)

Operating System: SuSe Linux 10.0
Compiler: gcc version 4.0.2

I hope, that I've gave enouph information. If not, ask what aou need, you are welcome.

Best regards,
and thanks to all!

-- 
Echte DSL-Flatrate dauerhaft für 0,- Euro*. Nur noch kurze Zeit!
"Feel free" mit GMX DSL: http://www.gmx.net/de/go/dsl

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