34 template<
class T,
class BaseType>
37 Istream& is = readStream(word::null);
39 if (headerClassName() == IOList<T>::typeName)
41 is >>
static_cast<List<T>&
>(*this);
44 else if (headerClassName() == typeName)
52 <<
"unexpected class name " << headerClassName()
53 <<
" expected " << typeName <<
" or " << IOList<T>::typeName
55 <<
" while reading object " <<
name()
61 template<
class T,
class BaseType>
67 const label oldSize = size;
68 size += this->operator[](i).size();
80 template<
class T,
class BaseType>
87 io.
readOpt() == IOobject::MUST_READ
88 || (io.
readOpt() == IOobject::READ_IF_PRESENT && headerOk())
96 template<
class T,
class BaseType>
107 io.readOpt() == IOobject::MUST_READ
108 || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
120 template<
class T,
class BaseType>
124 const UList<T>& content
131 io.readOpt() == IOobject::MUST_READ
132 || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
144 template<
class T,
class BaseType>
157 io.readOpt() == IOobject::MUST_READ
158 || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
168 template<
class T,
class BaseType>
177 streamOpt.
format() == IOstream::BINARY
181 streamOpt.
format(IOstream::ASCII);
184 <<
"Overall number of elements of CompactIOList of size "
185 << this->size() <<
" overflows the representation of a label"
186 <<
nl <<
" Switching to ascii writing" <<
endl;
189 if (streamOpt.
format() == IOstream::ASCII)
192 const word oldTypeName(typeName);
194 const_cast<word&
>(typeName) = IOList<T>::typeName;
196 bool good = regIOobject::writeObject(streamOpt, valid);
199 const_cast<word&
>(typeName) = oldTypeName;
204 return regIOobject::writeObject(streamOpt, valid);
208 template<
class T,
class BaseType>
211 return (
os << *
this).good();
217 template<
class T,
class BaseType>
229 template<
class T,
class BaseType>
238 const List<BaseType> elems(is);
241 L.setSize(start.size()-1);
247 label index = start[i];
248 subList.setSize(start[i+1] - index);
252 subList[j] = elems[index++];
260 template<
class T,
class BaseType>
268 if (
os.format() == IOstream::ASCII)
270 os << static_cast<const List<T>&>(
L);
278 for (label i = 1; i < start.size(); i++)
280 const label prev = start[i-1];
281 start[i] = prev+
L[i-1].size();
286 <<
"Overall number of elements " << start[i]
287 <<
" of CompactIOList of size "
288 <<
L.size() <<
" overflows the representation of a label"
289 <<
endl <<
"Please recompile with a larger representation"
294 List<BaseType> elems(start[start.size()-1]);
299 const T& subList =
L[i];
303 elems[elemI++] = subList[j];
306 os << start << elems;