0026961: Recover possibility to read files in old persistence format
[occt.git] / src / StdLPersistent / StdLPersistent_HArray2.cxx
CommitLineData
ff205346 1// Copyright (c) 2015 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 <StdLPersistent_HArray2.hxx>
15#include <StdObjMgt_ReadData.hxx>
16
17#include <TColStd_HArray2OfInteger.hxx>
18#include <TColStd_HArray2OfReal.hxx>
19
20
21//=======================================================================
22//function : Read
23//purpose : Read persistent data from a file
24//=======================================================================
25void StdLPersistent_HArray2::commonBase::Read (StdObjMgt_ReadData& theReadData)
26{
27 Value<Standard_Integer> aLowerRow, aLowerCol, anUpperRow, anUpperCol;
28 theReadData >> aLowerRow >> aLowerCol >> anUpperRow >> anUpperCol;
29 createArray (aLowerRow, aLowerCol, anUpperRow, anUpperCol);
30
31 theReadData.Driver().BeginReadObjectData();
32
33 Standard_Integer aSize;
34 theReadData.ReadValue (aSize);
35
36 for (Standard_Integer aRow = aLowerRow; aRow <= anUpperRow; aRow++)
37 for (Standard_Integer aCol = aLowerCol; aCol <= anUpperCol; aCol++)
38 readValue (theReadData, aRow, aCol);
39
40 theReadData.Driver().EndReadObjectData();
41}
42
43template <class ArrayClass>
44void StdLPersistent_HArray2::instance<ArrayClass>::readValue (
45 StdObjMgt_ReadData& theReadData,
46 const Standard_Integer theRow,
47 const Standard_Integer theCol)
48{
49 typename ArrayClass::value_type aValue;
50 theReadData.ReadValue (aValue);
51 this->myArray->SetValue (theRow, theCol, aValue);
52}
53
54
55template class StdLPersistent_HArray2::instance<TColStd_HArray2OfInteger>;
56template class StdLPersistent_HArray2::instance<TColStd_HArray2OfReal>;