1 // Created on: 2004-05-18
2 // Created by: Sergey ZARITCHNY
3 // Copyright (c) 2004-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and / or modify it
8 // under the terms of the GNU Lesser General Public version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <BinTools.ixx>
17 #include <FSD_FileHeader.hxx>
18 #include <Storage_StreamTypeMismatchError.hxx>
20 //=======================================================================
23 //=======================================================================
25 Standard_OStream& BinTools::PutBool(Standard_OStream& OS, const Standard_Boolean aValue)
27 OS.put((Standard_Byte)aValue);
32 //=======================================================================
33 //function : PutInteger
35 //=======================================================================
37 Standard_OStream& BinTools::PutInteger(Standard_OStream& OS, const Standard_Integer aValue)
39 Standard_Integer anIntValue = aValue;
41 anIntValue = InverseInt (aValue);
43 OS.write((char*)&anIntValue, sizeof(Standard_Integer));
48 //=======================================================================
51 //=======================================================================
53 Standard_OStream& BinTools::PutReal(Standard_OStream& OS, const Standard_Real aValue)
55 Standard_Real aRValue = aValue;
57 aRValue = InverseReal (aValue);
59 OS.write((char*)&aRValue, sizeof(Standard_Real));
63 //=======================================================================
64 //function : PutExtChar
66 //=======================================================================
68 Standard_OStream& BinTools::PutExtChar(Standard_OStream& OS, const Standard_ExtCharacter aValue)
70 Standard_ExtCharacter aSValue = aValue;
72 aSValue = InverseExtChar (aValue);
74 OS.write((char*)&aSValue, sizeof(Standard_ExtCharacter));
77 //=======================================================================
80 //=======================================================================
82 Standard_IStream& BinTools::GetReal(Standard_IStream& IS, Standard_Real& aValue)
84 if(!IS.read ((char*)&aValue, sizeof(Standard_Real)))
85 Storage_StreamTypeMismatchError::Raise();
87 aValue = InverseReal (aValue);
92 //=======================================================================
93 //function : GetInteger
95 //=======================================================================
97 Standard_IStream& BinTools::GetInteger(Standard_IStream& IS, Standard_Integer& aValue)
99 if(!IS.read ((char*)&aValue, sizeof(Standard_Integer)))
100 Storage_StreamTypeMismatchError::Raise();;
102 aValue = InverseInt (aValue);
107 //=======================================================================
108 //function : GetExtChar
110 //=======================================================================
112 Standard_IStream& BinTools::GetExtChar(Standard_IStream& IS, Standard_ExtCharacter& theValue)
114 if(!IS.read ((char*)&theValue, sizeof(Standard_ExtCharacter)))
115 Storage_StreamTypeMismatchError::Raise();;
117 theValue = InverseExtChar (theValue);
122 //=======================================================================
125 //=======================================================================
127 Standard_IStream& BinTools::GetBool(Standard_IStream& IS, Standard_Boolean& aValue)
129 aValue = (Standard_Boolean)IS.get();