34 template<
class T,
int SizeMin>
46 template<
class T,
int SizeMin>
57 "DynamicList<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 "DynamicList<T>::readBracketList(Istream&) : " 139 list = std::move(*(chunks[0]));
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;
173 template<
class T,
int SizeMin>
182 is.
fatalCheck(
"DynamicList<T>::readList(Istream&) : reading first token");
203 if (is.
format() == IOstreamOption::BINARY && is_contiguous_v<T>)
209 Detail::readContiguous<T>
218 "DynamicList<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 "DynamicList<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 "DynamicList<T>::readList(Istream&) : " 275 "DynamicList<T>::readList(Istream&) : " 276 "reading the single entry" 280 UList<T>::operator=(elem);
285 is.readEndList(
"List");
293 this->readBracketList(is);
324 <<
"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 ...