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