Home
Downloads
Documentation
Installation
User Guide
man-pages
API Documentation
README
Release Notes
Changes
License
Support
SourceForge Project
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
OpenFOAM
db
IOstreams
Tstreams
ITstream.C
Go to the documentation of this file.
1
/*---------------------------------------------------------------------------*\
2
========= |
3
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4
\\ / O peration |
5
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6
\\/ M anipulation |
7
-------------------------------------------------------------------------------
8
License
9
This file is part of OpenFOAM.
10
11
OpenFOAM is free software: you can redistribute it and/or modify it
12
under the terms of the GNU General Public License as published by
13
the Free Software Foundation, either version 3 of the License, or
14
(at your option) any later version.
15
16
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19
for more details.
20
21
You should have received a copy of the GNU General Public License
22
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23
24
\*---------------------------------------------------------------------------*/
25
26
#include <
OpenFOAM/error.H
>
27
#include "
ITstream.H
"
28
29
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30
31
void
Foam::ITstream::print
(
Ostream
& os)
const
32
{
33
os <<
"ITstream : "
<< name_.c_str();
34
35
if
(
size
())
36
{
37
if
(
begin
()->
lineNumber
() ==
rbegin
()->
lineNumber
())
38
{
39
os <<
", line "
<<
begin
()->lineNumber() <<
", "
;
40
}
41
else
42
{
43
os <<
", lines "
<<
begin
()->lineNumber()
44
<<
'-'
<<
rbegin
()->lineNumber() <<
", "
;
45
}
46
}
47
else
48
{
49
os <<
", line "
<<
lineNumber
() <<
", "
;
50
}
51
52
IOstream::print
(os);
53
}
54
55
56
Foam::Istream
&
Foam::ITstream::read
(
token
& t)
57
{
58
// Return the put back token if it exists
59
if
(
Istream::getBack
(t))
60
{
61
lineNumber_ = t.
lineNumber
();
62
return
*
this
;
63
}
64
65
if
(tokenIndex_ < size())
66
{
67
t = operator[](tokenIndex_++);
68
lineNumber_ = t.
lineNumber
();
69
70
if
(tokenIndex_ == size())
71
{
72
setEof();
73
}
74
}
75
else
76
{
77
if
(eof())
78
{
79
FatalIOErrorIn
80
(
81
"ITstream::read(token& t)"
,
82
*
this
83
) <<
"attempt to read beyond EOF"
84
<<
exit
(
FatalIOError
);
85
86
setBad();
87
}
88
else
89
{
90
setEof();
91
}
92
93
if
(size())
94
{
95
token::undefinedToken
.
lineNumber
()
96
= operator[](size() - 1).lineNumber();
97
}
98
else
99
{
100
token::undefinedToken
.
lineNumber
() = lineNumber();
101
}
102
103
t =
token::undefinedToken
;
104
}
105
106
return
*
this
;
107
}
108
109
110
Foam::Istream
&
Foam::ITstream::read
(
char
&)
111
{
112
notImplemented
(
"Istream& ITstream::read(char& c)"
);
113
return
*
this
;
114
}
115
116
117
Foam::Istream
&
Foam::ITstream::read
(
word
&)
118
{
119
notImplemented
(
"Istream& ITstream::read(word&)"
);
120
return
*
this
;
121
}
122
123
124
Foam::Istream
&
Foam::ITstream::read
(
string
&)
125
{
126
notImplemented
(
"Istream& ITstream::read(string&)"
);
127
return
*
this
;
128
}
129
130
131
Foam::Istream
&
Foam::ITstream::read
(label&)
132
{
133
notImplemented
(
"Istream& ITstream::read(label&)"
);
134
return
*
this
;
135
}
136
137
138
Foam::Istream
&
Foam::ITstream::read
(
floatScalar
&)
139
{
140
notImplemented
(
"Istream& ITstream::read(floatScalar&)"
);
141
return
*
this
;
142
}
143
144
145
Foam::Istream
&
Foam::ITstream::read
(
doubleScalar
&)
146
{
147
notImplemented
(
"Istream& ITstream::read(doubleScalar&)"
);
148
return
*
this
;
149
}
150
151
152
Foam::Istream
&
Foam::ITstream::read
(
char
*, std::streamsize)
153
{
154
notImplemented
(
"Istream& ITstream::read(char*, std::streamsize)"
);
155
return
*
this
;
156
}
157
158
159
// Rewind the token stream so that it may be read again
160
Foam::Istream
&
Foam::ITstream::rewind
()
161
{
162
tokenIndex_ = 0;
163
164
if
(size())
165
{
166
lineNumber_ = operator[](0).
lineNumber
();
167
}
168
169
setGood();
170
171
return
*
this
;
172
}
173
174
175
// ************************ vim: set sw=4 sts=4 et: ************************ //