Salome HOME
Synchronize adm files
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_TMPFile_i.cxx
1 // Copyright (C) 2007-2014  CEA/DEN, EDF R&D, 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
23 //  SALOME SALOMEDS : data structure of SALOME and sources of Salome data server 
24 //  File   : SALOMEDSImpl_SObject.cxx
25 //  Author : Sergey RUIN
26 //  Module : SALOME
27 //
28 #include "SALOMEDS_TMPFile_i.hxx"
29
30 #include <stdexcept>
31
32 SALOMEDS_TMPFile_i
33 ::SALOMEDS_TMPFile_i(SALOMEDS::TMPFile* theStream):
34   myStream(theStream)
35 {}
36
37 size_t
38 SALOMEDS_TMPFile_i
39 ::Size()
40 {
41   if(!&myStream.in())
42     return 0;
43
44   return myStream->length();
45 }
46
47 SALOMEDSImpl_TMPFile::TOctet&
48 SALOMEDS_TMPFile_i
49 ::Get(size_t theIndex)
50 {
51   if(!&myStream.in())
52     throw std::out_of_range("SALOMEDS_TMPFile_i::Get(size_t) const - !&myStream.in()");
53
54   if(theIndex < 0 || theIndex >= myStream->length())
55     throw std::out_of_range("SALOMEDS_TMPFile_i::Get(size_t) const - theIndex < 0 || theIndex >= myStream->length()");
56
57   return myStream[theIndex];
58 }
59
60
61 //-----------------------------------------------------------------------------
62 Engines_TMPFile_i
63 ::Engines_TMPFile_i(Engines::TMPFile* theStream):
64   myStream(theStream)
65 {}
66
67 size_t
68 Engines_TMPFile_i
69 ::Size()
70 {
71   if(!&myStream.in())
72     return 0;
73
74   return myStream->length();
75 }
76
77 SALOMEDSImpl_TMPFile::TOctet&
78 Engines_TMPFile_i
79 ::Get(size_t theIndex)
80 {
81   if(!&myStream.in())
82     throw std::out_of_range("Engines_TMPFile_i::Get(size_t) const - !&myStream.in()");
83
84   if(theIndex < 0 || theIndex >= myStream->length())
85     throw std::out_of_range("Engines_TMPFile_i::Get(size_t) const - theIndex < 0 || theIndex >= myStream->length()");
86
87   return myStream[theIndex];
88 }