57 "List<T>::readBracketList(Istream&) : reading first token" 60 if (!tok.isPunctuation(token::BEGIN_LIST))
74 constexpr label chunkSize = 128;
75 typedef std::unique_ptr<List<T>> chunkType;
80 if (tok.isPunctuation(token::END_LIST))
91 List<chunkType> chunks(16);
94 chunks[0] = chunkType(
new List<T>(chunkSize));
98 chunks[0] = chunkType(
new List<T>(std::move(list)));
102 label totalCount = 0;
103 label localIndex = 0;
105 while (!tok.isPunctuation(token::END_LIST))
109 if (chunks[nChunks-1]->size() <= localIndex)
112 if (nChunks >= chunks.size())
114 chunks.resize(2*chunks.size());
117 chunks[nChunks] = chunkType(
new List<T>(chunkSize));
122 is >> chunks[nChunks-1]->operator[](localIndex);
128 "List<T>::readBracketList(Istream&) : " 139 list = std::move(*(chunks[0]));
145 list.setCapacity_nocopy(totalCount);
147 auto dest = list.
begin();
149 for (label chunki = 0; chunki < nChunks; ++chunki)
151 List<T> currChunk(std::move(*(chunks[chunki])));
152 chunks[chunki].reset(
nullptr);
154 const label localLen =
Foam::min(currChunk.size(), totalCount);
159 currChunk.begin(localLen),
163 totalCount -= localLen;
182 is.
fatalCheck(
"List<T>::readList(Istream&) : reading first token");
203 if (is.
format() == IOstreamOption::BINARY && is_contiguous_v<T>)
209 Detail::readContiguous<T>
218 "List<T>::readList(Istream&) : " 219 "reading binary block" 223 else if constexpr (std::is_same_v<
char, std::remove_cv_t<T>>)
226 const auto oldFmt = is.format(IOstreamOption::BINARY);
235 "List<char>::readList(Istream&) : " 236 "reading binary block" 245 const char delimiter = is.readBeginList(
"List");
249 if (delimiter == token::BEGIN_LIST)
251 auto iter = list.
begin();
252 const auto last = list.
end();
255 for (; (iter != last); (void)++iter)
261 "List<T>::readList(Istream&) : " 275 "List<T>::readList(Istream&) : " 276 "reading the single entry" 280 UList<T>::operator=(elem);
285 is.readEndList(
"List");
292 this->readBracketList(is);
299 <<
"incorrect first token, expected <int> or '(', found " bool isPunctuation() const noexcept
Token is PUNCTUATION.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void resize(const label len)
Adjust allocated size of list.
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
bool isCompound() const noexcept
Token is COMPOUND.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
constexpr char nl
The newline '\n' character (0x0a)
bool empty() const noexcept
True if List is empty (ie, size() is zero)
A token holds an item read from Istream.
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
char * data_bytes() noexcept
Return pointer to the underlying array serving as data storage,.
void putBack(const token &tok)
Put back a token (copy). Only a single put back is permitted.
compound & transferCompoundToken(const Istream *is=nullptr)
Return reference to compound and mark internally as released.
label capacity() const noexcept
Size of the underlying storage.
void clear()
Clear the list, i.e. set size to zero.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
iterator begin() noexcept
Return an iterator to begin traversing the UList.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Istream & readList(Istream &is)
Read List from Istream, discarding contents of existing List.
bool fatalCheck(const char *operation) const
Check IOstream status for given operation.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
label labelToken() const
Return label value.
bool isLabel() const noexcept
Token is LABEL.
InfoProxy< token > info() const noexcept
Return info proxy, for printing token information to a stream.
iterator end() noexcept
Return an iterator to end traversing the UList.
constexpr List() noexcept
Default construct.
streamFormat format() const noexcept
Get the current stream format.
std::streamsize size_bytes() const noexcept
Number of contiguous bytes for the List data.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...