Report patch name instead of index in debug
[foam-extend-3.2.git] / src / foam / db / IOstreams / Tstreams / ITstream.C
bloba4eee801be64d8d9b05873b6cd8acdd5fe6d9133
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation, either version 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "error.H"
27 #include "ITstream.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 void Foam::ITstream::print(Ostream& os) const
33     os  << "ITstream : " << name_.c_str();
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     }
52     IOstream::print(os);
56 Foam::Istream& Foam::ITstream::read(token& t)
58     // Return the put back token if it exists
59     if (Istream::getBack(t))
60     {
61         lineNumber_ = t.lineNumber();
62         return *this;
63     }
65     if (tokenIndex_ < size())
66     {
67         t = operator[](tokenIndex_++);
68         lineNumber_ = t.lineNumber();
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);
86             setBad();
87         }
88         else
89         {
90             setEof();
91         }
93         if (size())
94         {
95             token::undefinedToken.lineNumber()
96                 = operator[](size() - 1).lineNumber();
97         }
98         else
99         {
100             token::undefinedToken.lineNumber() = lineNumber();
101         }
103         t = token::undefinedToken;
104     }
106     return *this;
110 Foam::Istream& Foam::ITstream::read(char&)
112     notImplemented("Istream& ITstream::read(char& c)");
113     return *this;
117 Foam::Istream& Foam::ITstream::read(word&)
119     notImplemented("Istream& ITstream::read(word&)");
120     return *this;
124 Foam::Istream& Foam::ITstream::read(string&)
126     notImplemented("Istream& ITstream::read(string&)");
127     return *this;
131 Foam::Istream& Foam::ITstream::read(label&)
133     notImplemented("Istream& ITstream::read(label&)");
134     return *this;
138 Foam::Istream& Foam::ITstream::read(floatScalar&)
140     notImplemented("Istream& ITstream::read(floatScalar&)");
141     return *this;
145 Foam::Istream& Foam::ITstream::read(doubleScalar&)
147     notImplemented("Istream& ITstream::read(doubleScalar&)");
148     return *this;
152 Foam::Istream& Foam::ITstream::read(longDoubleScalar&)
154     notImplemented("Istream& ITstream::read(longDoubleScalar&)");
155     return *this;
159 Foam::Istream& Foam::ITstream::read(char*, std::streamsize)
161     notImplemented("Istream& ITstream::read(char*, std::streamsize)");
162     return *this;
166 // Rewind the token stream so that it may be read again
167 Foam::Istream& Foam::ITstream::rewind()
169     tokenIndex_ = 0;
171     if (size())
172     {
173         lineNumber_ = operator[](0).lineNumber();
174     }
176     setGood();
178     return *this;
182 // ************************************************************************* //