31 template<
class T,
class BaseType>
34 Istream& is = readStream(word::null);
36 if (headerClassName() == IOList<T>::typeName)
38 is >>
static_cast<List<T>&
>(*this);
41 else if (headerClassName() == typeName)
51 ) <<
"unexpected class name " << headerClassName()
52 <<
" expected " << typeName <<
" or " << IOList<T>::typeName
54 <<
" while reading object " <<
name()
60 template<
class T,
class BaseType>
67 size += this->operator[](i).size();
79 template<
class T,
class BaseType>
86 io.
readOpt() == IOobject::MUST_READ
87 || (io.
readOpt() == IOobject::READ_IF_PRESENT && headerOk())
95 template<
class T,
class BaseType>
106 io.
readOpt() == IOobject::MUST_READ
107 || (io.
readOpt() == IOobject::READ_IF_PRESENT && headerOk())
119 template<
class T,
class BaseType>
130 io.
readOpt() == IOobject::MUST_READ
131 || (io.
readOpt() == IOobject::READ_IF_PRESENT && headerOk())
143 template<
class T,
class BaseType>
156 io.
readOpt() == IOobject::MUST_READ
157 || (io.
readOpt() == IOobject::READ_IF_PRESENT && headerOk())
167 template<
class T,
class BaseType>
175 template<
class T,
class BaseType>
184 if (fmt == IOstream::ASCII)
187 const word oldTypeName = typeName;
191 bool good = regIOobject::writeObject(fmt, ver, cmp, valid);
194 const_cast<word&
>(typeName) = oldTypeName;
198 else if (overflows())
201 <<
"Overall number of elements of CompactIOList of size " 202 << this->size() <<
" overflows the representation of a label" 203 <<
endl <<
" Switching to ascii writing" <<
endl;
206 const word oldTypeName = typeName;
210 bool good = regIOobject::writeObject(IOstream::ASCII, ver, cmp, valid);
213 const_cast<word&
>(typeName) = oldTypeName;
219 return regIOobject::writeObject(fmt, ver, cmp, valid);
224 template<
class T,
class BaseType>
227 return (os << *
this).good();
233 template<
class T,
class BaseType>
234 void Foam::CompactIOList<T, BaseType>::operator=
243 template<
class T,
class BaseType>
252 template<
class T,
class BaseType>
264 L.setSize(start.
size()-1);
270 label index = start[i];
271 subList.
setSize(start[i+1] - index);
275 subList[j] = elems[index++];
283 template<
class T,
class BaseType>
291 if (os.format() == IOstream::ASCII)
293 os << static_cast<const List<T>&>(L);
301 for (
label i = 1; i < start.size(); i++)
303 label prev = start[i-1];
304 start[i] = prev+L[i-1].
size();
309 <<
"Overall number of elements " << start[i]
310 <<
" of CompactIOList of size " 311 << L.size() <<
" overflows the representation of a label" 312 <<
endl <<
"Please recompile with a larger representation" 326 elems[elemI++] = subList[j];
329 os << start << elems;
A simple container for copying or transferring objects of type <T>.
virtual bool writeObject(IOstream::streamFormat, IOstream::versionNumber, IOstream::compressionType, const bool valid) const
Write using given format, version and compression.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
void size(const label)
Override size to be inconsistent with allocated storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
A List of objects of type <T> with automated input and output.
points setSize(newPointi)
A List obtained as a section of another List.
A class for handling words, derived from string.
CompactIOList(const IOobject &)
Construct from IOobject.
streamFormat
Enumeration for the format of data in the stream.
compressionType
Enumeration for the format of data in the stream.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
A List of objects of type <T> with automated input and output using a compact storage. Behaves like IOList except when binary output in case it writes a CompactListList.
word name(const complex &)
Return a string representation of a complex.
void setSize(const label)
Reset size of List.
#define WarningInFunction
Report a warning using Foam::Warning.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
void operator=(const CompactIOList< T, BaseType > &)
readOption readOpt() const
virtual bool writeData(Ostream &) const
Pure virtual writaData function.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...