1 // Copyright (c) 2017 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #ifndef _StdObjMgt_WriteData_HeaderFile
15 #define _StdObjMgt_WriteData_HeaderFile
17 #include <Standard.hxx>
18 #include <Storage_BaseDriver.hxx>
20 class StdObjMgt_Persistent;
23 //! Auxiliary data used to write persistent objects to a file.
24 class StdObjMgt_WriteData
28 //! Auxiliary class used to automate begin and end of
29 //! writing object (adding opening and closing parenthesis)
30 //! at constructor and destructor
34 explicit ObjectSentry (StdObjMgt_WriteData& theData) : myWriteData(&theData)
35 { myWriteData->myDriver->BeginWriteObjectData(); }
38 { myWriteData->myDriver->EndWriteObjectData(); }
41 StdObjMgt_WriteData* myWriteData;
43 ObjectSentry (const ObjectSentry&);
44 ObjectSentry& operator = (const ObjectSentry&);
47 Standard_EXPORT StdObjMgt_WriteData
48 (Storage_BaseDriver& theDriver);
50 Standard_EXPORT void WritePersistentObject
51 (const Handle(StdObjMgt_Persistent)& thePersistent);
53 template <class Persistent>
54 StdObjMgt_WriteData& operator << (const Handle(Persistent)& thePersistent)
56 myDriver->PutReference(thePersistent ? thePersistent->RefNum() : 0);
60 Standard_EXPORT StdObjMgt_WriteData& operator << (const Handle(StdObjMgt_Persistent)& thePersistent);
63 StdObjMgt_WriteData& WriteValue(const Type& theValue)
65 *myDriver << theValue;
69 StdObjMgt_WriteData& operator << (const Standard_Character& theValue)
70 { return WriteValue(theValue); }
72 StdObjMgt_WriteData& operator << (const Standard_ExtCharacter& theValue)
73 { return WriteValue(theValue); }
75 StdObjMgt_WriteData& operator << (const Standard_Integer& theValue)
76 { return WriteValue(theValue); }
78 StdObjMgt_WriteData& operator << (const Standard_Boolean& theValue)
79 { return WriteValue(theValue); }
81 StdObjMgt_WriteData& operator << (const Standard_Real& theValue)
82 { return WriteValue(theValue); }
84 StdObjMgt_WriteData& operator << (const Standard_ShortReal& theValue)
85 { return WriteValue(theValue); }
88 Storage_BaseDriver* myDriver;
91 Standard_EXPORT StdObjMgt_WriteData& operator <<
92 (StdObjMgt_WriteData& theWriteData, const Standard_GUID& theGUID);
94 #endif // _StdObjMgt_WriteData_HeaderFile