#ifndef RSG_TEXT_IARCHIVE_HPP #define RSG_TEXT_IARCHIVE_HPP // MS compatible compilers support #pragma once #if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 // rsg_text_iarchive.hpp // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // See http://www.boost.org for updates, documentation, and revision history. #include #include /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 // exception to be thrown if integer read from archive doesn't fit // variable being loaded class rsg_text_archive_exception : public virtual boost::archive::archive_exception { public: typedef enum { incompatible_integer_size } exception_code; rsg_text_archive_exception(exception_code c = incompatible_integer_size ) {} virtual const char *what( ) const throw( ) { const char *msg = "programmer error"; switch(code){ case incompatible_integer_size: msg = "integer cannot be represented"; default: boost::archive::archive_exception::what(); } return msg; } }; /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 // "rsg" input text archive. This is a variation of the native text // archive. it addresses integer size and endienness so that text archives can // be passed across systems. Note:floating point types not addressed here class rsg_text_iarchive : // don't derive from text_iarchive !!! public boost::archive::text_iarchive_impl { public: typedef rsg_text_iarchive derived_t; //#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS //public: //#else // friend class boost::archive::basic_text_iarchive; // friend class boost::archive::basic_text_iprimitive; // friend class boost::archive::load_access; //#endif public: rsg_text_iarchive(std::istream & is, unsigned flags = 0) : boost::archive::text_iarchive_impl( is, flags | boost::archive::no_header // skip default header checking ) { // use our own header checking if(0 == (flags & boost::archive::no_header)){ // os << "" << std::endl; char stamp[64]; is.getline(stamp, 63); // Ensure it is equal - eventually! std::cout << "Found stamp: [" << stamp << "]" << std::endl; // this->boost::archive::basic_text_iarchive::init(); // skip the following for "rsg" text archives // boost::archive::basic_text_oprimitive::init(); } } }; // explicitly instantiate for this type of text stream #include #include #include namespace boost { namespace archive { template class basic_text_iarchive ; template class basic_text_iprimitive ; template class text_iarchive_impl ; template class detail::archive_pointer_iserializer ; } // namespace archive } // namespace boost #define BOOST_ARCHIVE_CUSTOM_IARCHIVE_TYPES rsg_text_iarchive #endif // RSG_TEXT_IARCHIVE_HPP