1 // Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SMESH_BoostTxtArchive.hxx
23 // Created : Thu Aug 5 19:10:24 2021
24 // Author : Edward AGAPOV (eap)
27 #ifndef __SMESH_BoostTxtArchive_HXX__
28 #define __SMESH_BoostTxtArchive_HXX__
30 #include "SMESH_Utils.hxx"
32 #include <boost/archive/text_iarchive.hpp>
37 * \brief Load an object from a string created by boost::archive::text_oarchive.
39 * Try to workaround the issue that loading fails if the archive string
40 * is created by a newer version of boost::archive library.
42 * Usage: ObjType obj; SMESHUtils::BoostTxtArchive( arcString ) >> obj;
44 class SMESHUtils_EXPORT BoostTxtArchive
48 BoostTxtArchive( const std::string& s );
49 BoostTxtArchive( std::istream& stream );
53 BoostTxtArchive & operator>>( T & t )
55 if ( myArchiveReader )
58 (*myArchiveReader) >> t;
65 (*myArchiveReader) >> t;
79 boost::archive::text_iarchive* myArchiveReader;
80 std::string myString; // archive to read
81 bool myStringFixed; // is archive version changed
82 std::istream* myStream; // stream holding myString
83 bool myOwnStream; // is myStream created by me
85 // persistence used to create a current version archive
86 friend class boost::serialization::access;
87 template<class Archive>
88 void serialize(Archive & /*ar*/, const unsigned int /*version*/)