d5c71e20 |
1 | // Copyright (c) 2021 OPEN CASCADE SAS |
2 | // |
3 | // This file is part of Open CASCADE Technology software library. |
4 | // |
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. |
10 | // |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
13 | |
14 | #include <BinObjMgt_Position.hxx> |
15 | |
16 | IMPLEMENT_STANDARD_RTTIEXT (BinObjMgt_Position, Standard_Transient) |
17 | |
18 | //======================================================================= |
19 | //function : BinObjMgt_Position |
20 | //purpose : |
21 | //======================================================================= |
22 | BinObjMgt_Position::BinObjMgt_Position (Standard_OStream& theStream) : |
23 | myPosition (theStream.tellp()), mySize(0) |
24 | {} |
25 | |
26 | //======================================================================= |
27 | //function : StoreSize |
28 | //purpose : |
29 | //======================================================================= |
30 | void BinObjMgt_Position::StoreSize (Standard_OStream& theStream) |
31 | { |
32 | mySize = uint64_t (theStream.tellp() - myPosition); |
33 | } |
34 | |
35 | //======================================================================= |
36 | //function : WriteSize |
37 | //purpose : |
38 | //======================================================================= |
39 | void BinObjMgt_Position::WriteSize (Standard_OStream& theStream, const Standard_Boolean theDummy) |
40 | { |
41 | if (!theDummy && theStream.tellp() != myPosition) |
42 | theStream.seekp (myPosition); |
43 | uint64_t aSize = theDummy ? 0 : mySize; |
44 | #if DO_INVERSE |
45 | aSize = FSD_BinaryFile::InverseUint64 (aSize); |
46 | #endif |
47 | theStream.write ((char*)&aSize, sizeof (uint64_t)); |
48 | } |