Version: 9.16.0
SMESH_BoostTxtArchive.hxx
Go to the documentation of this file.
1// Copyright (C) 2007-2026 CEA, EDF, OPEN CASCADE
2//
3// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5//
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.
10//
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.
15//
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
19//
20// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21//
22// File : SMESH_BoostTxtArchive.hxx
23// Created : Thu Aug 5 19:10:24 2021
24// Author : Edward AGAPOV (eap)
25
26
27#ifndef __SMESH_BoostTxtArchive_HXX__
28#define __SMESH_BoostTxtArchive_HXX__
29
30#include "SMESH_Utils.hxx"
31
32#include <boost/archive/text_iarchive.hpp>
33
34namespace SMESHUtils
35{
45 {
46 public:
47
48 BoostTxtArchive( const std::string& s );
49 BoostTxtArchive( std::istream& stream );
51
52 template< class T >
54 {
55 if ( myArchiveReader )
56 try
57 {
58 (*myArchiveReader) >> t;
59 }
60 catch (...)
61 {
62 if ( fixString() )
63 try
64 {
65 (*myArchiveReader) >> t;
66 }
67 catch(...)
68 {
69 }
70 }
71 return *this;
72 }
73
74 private:
75
76 void makeReader();
77 bool fixString();
78
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
84
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*/)
89 {
90 }
91 };
92}
93
94
95#endif
#define SMESHUtils_EXPORT
Definition: SMESH_Utils.hxx:37
Load an object from a string created by boost::archive::text_oarchive.
Definition: SMESH_BoostTxtArchive.hxx:45
bool myOwnStream
Definition: SMESH_BoostTxtArchive.hxx:83
void serialize(Archive &, const unsigned int)
Definition: SMESH_BoostTxtArchive.hxx:88
std::string myString
Definition: SMESH_BoostTxtArchive.hxx:80
std::istream * myStream
Definition: SMESH_BoostTxtArchive.hxx:82
bool myStringFixed
Definition: SMESH_BoostTxtArchive.hxx:81
BoostTxtArchive & operator>>(T &t)
Definition: SMESH_BoostTxtArchive.hxx:53
boost::archive::text_iarchive * myArchiveReader
Definition: SMESH_BoostTxtArchive.hxx:79
Definition: SMESH_BoostTxtArchive.hxx:35