38 if constexpr (std::is_same_v<char, std::remove_cv_t<T>>)
88 os.writeKeyword(keyword);
102 const UList<T>& list = *
this;
104 const label len = list.
size();
106 if constexpr (std::is_same_v<char, std::remove_cv_t<T>>)
110 const auto oldFmt =
os.format(IOstreamOption::BINARY);
111 os << nl << len << nl;
116 os.write(list.cdata_bytes(), list.size_bytes());
132 os.write(list.cdata_bytes(), list.size_bytes());
142 (len <= 1 || !shortLen)
153 os << len << token::BEGIN_LIST;
155 auto iter = list.cbegin();
156 const auto last = list.cend();
163 for (++iter; (iter != last); (void)++iter)
165 os << token::SPACE << *iter;
170 os << token::END_LIST;
177 os <<
nl << len <<
nl << token::BEGIN_LIST;
179 auto iter = list.cbegin();
180 const auto last = list.cend();
183 for (; (iter != last); (void)++iter)
189 os <<
nl << token::END_LIST <<
nl;
204 const label len = list.
size();
210 is.
fatalCheck(
"UList<T>::readList(Istream&) : reading first token");
222 const label inputLen = elems.
size();
228 <<
"incorrect length for UList. Read "
229 << inputLen <<
" expected " << len
245 <<
"incorrect length for UList. Read "
246 << inputLen <<
" expected " << len
247 << exit(FatalIOError);
250 else if constexpr (std::is_same_v<char, std::remove_cv_t<T>>)
253 const auto oldFmt = is.
format(IOstreamOption::BINARY);
262 "UList<char>::readList(Istream&) : [binary block]"
270 if (is.
format() == IOstreamOption::BINARY && is_contiguous_v<T>)
276 Detail::readContiguous<T>
285 "UList<T>::readList(Istream&) : [binary block]"
296 if (delimiter == token::BEGIN_LIST)
298 for (label i=0; i<len; ++i)
304 "UList<T>::readList(Istream&) : "
318 "UList<T>::readList(Istream&) : "
319 "reading the single entry"
323 this->fill_uniform(elem);
341 while (!tok.isPunctuation(token::END_LIST))
346 is >> list[inputLen];
358 "UList<T>::readList(Istream&) : "
370 <<
"incorrect length for UList. Read "
371 << inputLen <<
" expected " << len
372 <<
exit(FatalIOError);
378 <<
"incorrect first token, expected <int> or '(', found "
380 <<
exit(FatalIOError);
streamFormat format() const noexcept
Get the current stream format.
bool fatalCheck(const char *operation) const
Check IOstream status for given operation.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
char readEndList(const char *funcName)
End read of list data, ends with ')' or '}'.
char readBeginList(const char *funcName)
Begin read of list data, starts with '(' or '{'.
void putBack(const token &tok)
Put back a token (copy). Only a single put back is permitted.
virtual Istream & read(token &)=0
Return next token from stream.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void fill_uniform(const T &val)
Assign all entries to the given value.
iterator begin() noexcept
Return an iterator to begin traversing the UList.
char * data_bytes() noexcept
Return pointer to the underlying array serving as data storage,.
UList(const UList< T > &) noexcept=default
Copy construct, shallow copy.
iterator end() noexcept
Return an iterator to end traversing the UList.
const_iterator cend() const noexcept
Return const_iterator to end traversing the constant UList.
const_iterator cbegin() const noexcept
Return const_iterator to begin traversing the constant UList.
bool uniform() const
True if all entries have identical values, and list is non-empty.
const char * cdata_bytes() const noexcept
Return pointer to the underlying array serving as data storage,.
void writeEntry(Ostream &os) const
Write the UList with its compound type.
void size(const label n)
Older name for setAddressableSize.
Ostream & writeList(Ostream &os, const label shortLen=0) const
Write List, with line-breaks in ASCII when length exceeds shortLen.
Istream & readList(Istream &is)
Read List contents from Istream.
std::streamsize size_bytes() const noexcept
Number of contiguous bytes for the List data.
A traits class, which is primarily used for primitives and vector-space.
static bool isCompound(const word &compoundType)
True if a known (registered) compound type.
A token holds an item read from Istream.
bool isPunctuation() const noexcept
Token is PUNCTUATION.
@ BEGIN_BLOCK
Begin block [isseparator].
@ END_BLOCK
End block [isseparator].
@ BEGIN_LIST
Begin list [isseparator].
@ END_LIST
End list [isseparator].
bool isLabel() const noexcept
Integral token is convertible to Foam::label.
label labelToken() const
Return integer type as label value or Error.
compound & transferCompoundToken(const Istream *is=nullptr)
Return reference to compound and mark internally as released.
bool isCompound() const noexcept
Token is COMPOUND.
InfoProxy< token > info() const noexcept
Return info proxy, for printing token information to a stream.
A class for handling words, derived from Foam::string.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
OBJstream os(runTime.globalPath()/outputName)
void readContiguous(Istream &is, char *data, std::streamsize byteCount)
Read binary block of contiguous data, possibly with conversion.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
constexpr bool is_contiguous_v
The is_contiguous value of Type (after stripping of qualifiers).
errorManipArg< error, int > exit(error &err, const int errNo=1)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
constexpr char nl
The newline '\n' character (0x0a).
Can suppress additional line breaks separate ASCII data content when the data elements are primitives...