1 /*---------------------------------------------------------------------------*\
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 -------------------------------------------------------------------------------
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 "primitiveEntry.H"
27 #include "dictionary.H"
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 Foam::primitiveEntry::primitiveEntry(const keyType& key, const ITstream& tokens)
36 name() += "::" + keyword();
40 Foam::primitiveEntry::primitiveEntry(const keyType& keyword, const token& t)
43 ITstream(keyword, tokenList(1, t))
47 Foam::primitiveEntry::primitiveEntry
49 const keyType& keyword,
50 const tokenList& tokens
54 ITstream(keyword, tokens)
58 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
60 Foam::label Foam::primitiveEntry::startLineNumber() const
64 return operator[](0).lineNumber();
72 Foam::label Foam::primitiveEntry::endLineNumber() const
76 return operator[](size()-1).lineNumber();
85 Foam::ITstream& Foam::primitiveEntry::stream() const
87 ITstream& dataStream = const_cast<primitiveEntry&>(*this);
93 const Foam::dictionary& Foam::primitiveEntry::dict() const
95 FatalErrorIn("const dictionary& primitiveEntry::dict() const")
96 << "Attempt to return primitive entry " << info()
97 << " as a sub-dictionary"
100 return dictionary::null;
104 Foam::dictionary& Foam::primitiveEntry::dict()
106 FatalErrorIn("const dictionary& primitiveEntry::dict()")
107 << "Attempt to return primitive entry " << info()
108 << " as a sub-dictionary"
109 << abort(FatalError);
111 return const_cast<dictionary&>(dictionary::null);
115 void Foam::primitiveEntry::insert
117 const tokenList& varTokens,
121 tokenList& tokens = *this;
123 if (varTokens.empty())
125 label end = tokens.size() - 1;
127 for (label j=posI; j<end; j++)
129 tokens[j] = tokens[j+1];
132 tokens.setSize(tokens.size() - 1);
134 else if (varTokens.size() > 1)
136 tokens.setSize(tokens.size() + varTokens.size() - 1);
138 label end = tokens.size() - 1;
139 label offset = varTokens.size() - 1;
141 for (label j=end; j>posI; j--)
143 tokens[j] = tokens[j-offset];
149 tokens[posI + j] = varTokens[j];
154 // ************************************************************************* //