It looks as follows:
22 serialization::archive 3 0 0 5.5 1
-------- Original-Nachricht --------
Datum: Thu, 3 Aug 2006 08:14:41 -0700
Von: "Robert Ramey"
Is it possible that m_value is uninitialized? It is a known problem that many compilers can can write uninitialized floating/double values to a text stream and then cannot read them. This topic is currently being discussd on the developer's list - as it arises all the time.
Take a look a test_serial.txt with a text editor. What does it look like?
Robert Ramey
tkachenkok@gmx.de wrote:
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!
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- "Feel free" – 10 GB Mailbox, 100 FreeSMS/Monat ... Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail