36 template<
class T,
int SizeMin>
48 template<
class T,
int SizeMin>
59 "DynamicList<T>::readBracketList(Istream&) : reading first token" 62 if (!tok.isPunctuation(token::BEGIN_LIST))
76 constexpr label chunkSize = 128;
77 typedef std::unique_ptr<List<T>> chunkType;
82 if (tok.isPunctuation(token::END_LIST))
93 List<chunkType> chunks(16);
96 chunks[0] = chunkType(
new List<T>(chunkSize));
100 chunks[0] = chunkType(
new List<T>(std::move(list)));
104 label totalCount = 0;
105 label localIndex = 0;
107 while (!tok.isPunctuation(token::END_LIST))
111 if (chunks[nChunks-1]->size() <= localIndex)
114 if (nChunks >= chunks.size())
116 chunks.resize(2*chunks.size());
119 chunks[nChunks] = chunkType(
new List<T>(chunkSize));
124 is >> chunks[nChunks-1]->operator[](localIndex);
130 "DynamicList<T>::readBracketList(Istream&) : " 141 list = std::move(*(chunks[0]));
149 auto dest = list.
begin();
151 for (label chunki = 0; chunki < nChunks; ++chunki)
153 List<T> currChunk(std::move(*(chunks[chunki])));
154 chunks[chunki].reset(
nullptr);
156 const label localLen =
min(currChunk.size(), totalCount);
161 currChunk.begin(localLen),
165 totalCount -= localLen;
175 template<
class T,
int SizeMin>
184 is.
fatalCheck(
"DynamicList<T>::readList(Istream&) : reading first token");
205 if (is.
format() == IOstreamOption::BINARY && is_contiguous<T>::value)
211 Detail::readContiguous<T>
220 "DynamicList<T>::readList(Istream&) : " 221 "reading binary block" 228 const auto oldFmt = is.format(IOstreamOption::BINARY);
237 "DynamicList<char>::readList(Istream&) : " 238 "reading binary block" 247 const char delimiter = is.readBeginList(
"List");
251 if (delimiter == token::BEGIN_LIST)
253 auto iter = list.
begin();
254 const auto last = list.
end();
257 for (; (iter != last); (void)++iter)
263 "DynamicList<T>::readList(Istream&) : " 277 "DynamicList<T>::readList(Istream&) : " 278 "reading the single entry" 282 UList<T>::operator=(elem);
287 is.readEndList(
"List");
295 this->readBracketList(is);
326 <<
"incorrect first token, expected <int> or '(', found " bool isPunctuation() const noexcept
Token is PUNCTUATION.
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...
bool isCompound() const noexcept
Token is COMPOUND.
constexpr DynamicList() noexcept
Default construct, an empty list without allocation.
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(const label len)
Alter addressable list size, allocating new space if required while recovering old content...
char * data_bytes() noexcept
Return pointer to the underlying array serving as data storage,.
label capacity() const noexcept
Size of the underlying 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.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
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.
Istream & readList(Istream &is)
Read from Istream, discarding existing contents.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
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.
void transfer(List< T > &list)
Transfer contents of the argument List into this.
void clearStorage()
Clear the list and delete storage.
bool isLabel() const noexcept
Token is LABEL.
InfoProxy< token > info() const noexcept
Return info proxy, for printing token information to a stream.
void resize_nocopy(const label len)
Alter addressable list size, allocating new space if required without necessarily recovering old cont...
iterator end() noexcept
Return an iterator to end traversing the UList.
void setCapacity_nocopy(const label len)
Alter the size of the underlying storage, without retaining old content.
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 ...