ILListIO.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
00028
00029 #include "ILList.H"
00030 #include "Istream.H"
00031 #include "INew.H"
00032
00033
00034
00035 template<class LListBase, class T>
00036 template<class INew>
00037 void Foam::ILList<LListBase, T>::read(Istream& is, const INew& iNew)
00038 {
00039 is.fatalCheck("operator>>(Istream&, ILList<LListBase, T>&)");
00040
00041 token firstToken(is);
00042
00043 is.fatalCheck
00044 (
00045 "operator>>(Istream&, ILList<LListBase, T>&) : reading first token"
00046 );
00047
00048 if (firstToken.isLabel())
00049 {
00050 label s = firstToken.labelToken();
00051
00052
00053 char delimiter = is.readBeginList("ILList<LListBase, T>");
00054
00055 if (s)
00056 {
00057 if (delimiter == token::BEGIN_LIST)
00058 {
00059 for (label i=0; i<s; i++)
00060 {
00061 append(iNew(is).ptr());
00062
00063 is.fatalCheck
00064 (
00065 "operator>>(Istream&, ILList<LListBase, T>&) : "
00066 "reading entry"
00067 );
00068 }
00069 }
00070 else
00071 {
00072 T* tPtr = iNew(is).ptr();
00073 append(tPtr);
00074
00075 is.fatalCheck
00076 (
00077 "operator>>(Istream&, ILList<LListBase, T>&) : "
00078 "reading entry"
00079 );
00080
00081 for (label i=1; i<s; i++)
00082 {
00083 append(new T(*tPtr));
00084 }
00085 }
00086 }
00087
00088
00089 is.readEndList("ILList<LListBase, T>");
00090 }
00091 else if (firstToken.isPunctuation())
00092 {
00093 if (firstToken.pToken() != token::BEGIN_LIST)
00094 {
00095 FatalIOErrorIn
00096 (
00097 "operator>>(Istream&, ILList<LListBase, T>&)",
00098 is
00099 ) << "incorrect first token, '(', found " << firstToken.info()
00100 << exit(FatalIOError);
00101 }
00102
00103 token lastToken(is);
00104 is.fatalCheck("operator>>(Istream&, ILList<LListBase, T>&)");
00105
00106 while
00107 (
00108 !(
00109 lastToken.isPunctuation()
00110 && lastToken.pToken() == token::END_LIST
00111 )
00112 )
00113 {
00114 is.putBack(lastToken);
00115 append(iNew(is).ptr());
00116
00117 is >> lastToken;
00118 is.fatalCheck("operator>>(Istream&, ILList<LListBase, T>&)");
00119 }
00120 }
00121 else
00122 {
00123 FatalIOErrorIn("operator>>(Istream&, ILList<LListBase, T>&)", is)
00124 << "incorrect first token, expected <int> or '(', found "
00125 << firstToken.info()
00126 << exit(FatalIOError);
00127 }
00128
00129 is.fatalCheck("operator>>(Istream&, ILList<LListBase, T>&)");
00130 }
00131
00132
00133 template<class LListBase, class T>
00134 template<class INew>
00135 Foam::ILList<LListBase, T>::ILList(Istream& is, const INew& iNew)
00136 {
00137 read(is, iNew);
00138 }
00139
00140
00141 template<class LListBase, class T>
00142 Foam::ILList<LListBase, T>::ILList(Istream& is)
00143 {
00144 read(is, INew<T>());
00145 }
00146
00147
00148
00149
00150 template<class LListBase, class T>
00151 Foam::Istream& Foam::operator>>(Istream& is, ILList<LListBase, T>& L)
00152 {
00153 L.clear();
00154 L.read(is, INew<T>());
00155
00156 return is;
00157 }
00158
00159
00160
00161
00162
Copyright © 2000-2009 OpenCFD Ltd