primitiveEntry.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "primitiveEntry.H"
00028 #include "dictionary.H"
00029
00030
00031
00032 Foam::primitiveEntry::primitiveEntry(const keyType& key, const ITstream& tokens)
00033 :
00034 entry(key),
00035 ITstream(tokens)
00036 {
00037 name() += "::" + keyword();
00038 }
00039
00040
00041 Foam::primitiveEntry::primitiveEntry(const keyType& keyword, const token& t)
00042 :
00043 entry(keyword),
00044 ITstream(keyword, tokenList(1, t))
00045 {}
00046
00047
00048 Foam::primitiveEntry::primitiveEntry
00049 (
00050 const keyType& keyword,
00051 const tokenList& tokens
00052 )
00053 :
00054 entry(keyword),
00055 ITstream(keyword, tokens)
00056 {}
00057
00058
00059
00060
00061 Foam::label Foam::primitiveEntry::startLineNumber() const
00062 {
00063 if (size())
00064 {
00065 return operator[](0).lineNumber();
00066 }
00067 else
00068 {
00069 return -1;
00070 }
00071 }
00072
00073 Foam::label Foam::primitiveEntry::endLineNumber() const
00074 {
00075 if (size())
00076 {
00077 return operator[](size()-1).lineNumber();
00078 }
00079 else
00080 {
00081 return -1;
00082 }
00083 }
00084
00085
00086 Foam::ITstream& Foam::primitiveEntry::stream() const
00087 {
00088 ITstream& dataStream = const_cast<primitiveEntry&>(*this);
00089 dataStream.rewind();
00090 return dataStream;
00091 }
00092
00093
00094 const Foam::dictionary& Foam::primitiveEntry::dict() const
00095 {
00096 FatalErrorIn("const dictionary& primitiveEntry::dict() const")
00097 << "Attempt to return primitive entry " << info()
00098 << " as a sub-dictionary"
00099 << abort(FatalError);
00100
00101 return dictionary::null;
00102 }
00103
00104
00105 Foam::dictionary& Foam::primitiveEntry::dict()
00106 {
00107 FatalErrorIn("const dictionary& primitiveEntry::dict()")
00108 << "Attempt to return primitive entry " << info()
00109 << " as a sub-dictionary"
00110 << abort(FatalError);
00111
00112 return const_cast<dictionary&>(dictionary::null);
00113 }
00114
00115
00116 void Foam::primitiveEntry::insert
00117 (
00118 const tokenList& varTokens,
00119 const label posI
00120 )
00121 {
00122 tokenList& tokens = *this;
00123
00124 if (varTokens.empty())
00125 {
00126 label end = tokens.size() - 1;
00127
00128 for (label j=posI; j<end; j++)
00129 {
00130 tokens[j] = tokens[j+1];
00131 }
00132
00133 tokens.setSize(tokens.size() - 1);
00134 }
00135 else if (varTokens.size() > 1)
00136 {
00137 tokens.setSize(tokens.size() + varTokens.size() - 1);
00138
00139 label end = tokens.size() - 1;
00140 label offset = varTokens.size() - 1;
00141
00142 for (label j=end; j>posI; j--)
00143 {
00144 tokens[j] = tokens[j-offset];
00145 }
00146 }
00147
00148 forAll(varTokens, j)
00149 {
00150 tokens[posI + j] = varTokens[j];
00151 }
00152 }
00153
00154
00155
Copyright © 2000-2009 OpenCFD Ltd