34 template<
class T,
class BaseType>
39 readOpt() == IOobject::MUST_READ
40 || (isReadOptional() && headerOk())
43 Istream& is = readStream(word::null);
45 if (headerClassName() == IOList<T>::typeName)
47 is >>
static_cast<List<T>&
>(*this);
50 else if (headerClassName() == typeName)
58 <<
"Unexpected class name " << headerClassName()
59 <<
" expected " << typeName
60 <<
" or " << IOList<T>::typeName <<
endl 61 <<
" while reading object " <<
name()
72 template<
class T,
class BaseType>
75 const List<T>& lists = *
this;
78 for (
const auto& sublist : lists)
80 const label prev = total;
81 total += sublist.
size();
93 template<
class T,
class BaseType>
102 template<
class T,
class BaseType>
115 template<
class T,
class BaseType>
124 if (!readIOcontents())
131 template<
class T,
class BaseType>
135 const UList<T>& content
140 if (!readIOcontents())
147 template<
class T,
class BaseType>
156 List<T>::transfer(content);
164 template<
class T,
class BaseType>
168 const bool writeOnProc
173 streamOpt.
format() == IOstreamOption::BINARY
177 streamOpt.
format(IOstreamOption::ASCII);
180 <<
"Overall number of elements of CompactIOList of size " 181 << this->size() <<
" overflows the representation of a label" 182 <<
nl <<
" Switching to ascii writing" <<
endl;
185 if (streamOpt.
format() == IOstreamOption::ASCII)
188 const word oldTypeName(typeName);
190 const_cast<word&
>(typeName) = IOList<T>::typeName;
192 bool good = regIOobject::writeObject(streamOpt, writeOnProc);
195 const_cast<word&
>(typeName) = oldTypeName;
200 return regIOobject::writeObject(streamOpt, writeOnProc);
204 template<
class T,
class BaseType>
207 return (
os << *
this).good();
213 template<
class T,
class BaseType>
225 template<
class T,
class BaseType>
234 const List<BaseType> elems(is);
237 L.setSize(start.size()-1);
243 label index = start[i];
244 subList.setSize(start[i+1] - index);
248 subList[j] = elems[index++];
256 template<
class T,
class BaseType>
264 if (
os.format() == IOstreamOption::ASCII)
266 os << static_cast<const List<T>&>(
L);
274 for (label i = 1; i < start.size(); i++)
276 const label prev = start[i-1];
277 start[i] = prev+
L[i-1].size();
282 <<
"Overall number of elements " << start[i]
283 <<
" of CompactIOList of size " 284 <<
L.size() <<
" overflows the representation of a label" 285 <<
endl <<
"Please recompile with a larger representation" 290 List<BaseType> elems(start[start.size()-1]);
295 const T& subList =
L[i];
299 elems[elemI++] = subList[j];
302 os << start << elems;
void size(const label n)
Older name for setAddressableSize.
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.
virtual bool writeData(Ostream &os) const
Pure virtual writeData function.
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)
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 ...