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
54 <<
" or " << IOList<T>::typeName <<
endl 55 <<
" while reading object " <<
name()
61 template<
class T,
class BaseType>
66 readOpt() == IOobject::MUST_READ
67 || (isReadOptional() && headerOk())
78 template<
class T,
class BaseType>
84 const label oldSize = size;
85 size += this->operator[](i).size();
97 template<
class T,
class BaseType>
106 template<
class T,
class BaseType>
119 template<
class T,
class BaseType>
135 template<
class T,
class BaseType>
139 const UList<T>& content
151 template<
class T,
class BaseType>
160 List<T>::transfer(content);
168 template<
class T,
class BaseType>
172 const bool writeOnProc
177 streamOpt.
format() == IOstreamOption::BINARY
181 streamOpt.
format(IOstreamOption::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() == IOstreamOption::ASCII)
192 const word oldTypeName(typeName);
194 const_cast<word&
>(typeName) = IOList<T>::typeName;
196 bool good = regIOobject::writeObject(streamOpt, writeOnProc);
199 const_cast<word&
>(typeName) = oldTypeName;
204 return regIOobject::writeObject(streamOpt, writeOnProc);
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() == IOstreamOption::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;
errorManipArg< error, int > exit(error &err, const int errNo=1)
patchWriters resize(patchIds.size())
const vector L(dict.get< vector >("L"))
CompactIOList(const CompactIOList &)=default
Default copy construct.
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)...
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
A simple container for options an IOstream can normally have.
#define forAll(list, i)
Loop across all elements in list.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
virtual bool writeObject(IOstreamOption streamOpt, const bool writeOnProc) const
Write using stream options. Checks for overflow in binary.
OBJstream os(runTime.globalPath()/outputName)
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.
#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...
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
List< label > labelList
A List of labels.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
virtual bool writeData(Ostream &) const
Pure virtual writeData function.
Defines the attributes of an object for which implicit objectRegistry management is supported...
streamFormat format() const noexcept
Get the current stream format.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...