34template<
class T,
int SizeMin>
46template<
class T,
int SizeMin>
47bool Foam::DynamicList<T, SizeMin>::readBracketList(
Istream& is)
57 "DynamicList<T>::readBracketList(Istream&) : reading first token"
74 constexpr label chunkSize = 128;
75 typedef std::unique_ptr<List<T>> chunkType;
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;
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;
173template<
class T,
int SizeMin>
182 is.
fatalCheck(
"DynamicList<T>::readList(Istream&) : reading first token");
203 if constexpr (std::is_same_v<char, std::remove_cv_t<T>>)
215 "DynamicList<char>::readList(Istream&) : [binary block]"
238 "DynamicList<T>::readList(Istream&) : [binary block]"
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"
294 this->readBracketList(is);
325 <<
"incorrect first token, expected <int> or '(', found "
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
constexpr DynamicList() noexcept
Default construct, an empty list without allocation.
void transfer(List< T > &list)
Transfer contents of the argument List into this.
void resize_nocopy(const label len)
Alter addressable list size, allocating new space if required without necessarily recovering old cont...
void setCapacity_nocopy(const label len)
Alter the size of the underlying storage, without retaining old content.
void clearStorage()
Clear the list and delete storage.
label capacity() const noexcept
Size of the underlying storage.
void resize(const label len)
Alter addressable list size, allocating new space if required while recovering old content.
Istream & readList(Istream &is)
Read from Istream, discarding existing contents.
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...
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,.
bool empty() const noexcept
True if List is empty (ie, size() is zero).
iterator end() noexcept
Return an iterator to end traversing the UList.
std::streamsize size_bytes() const noexcept
Number of contiguous bytes for the List data.
T & last()
Access last element of the list, position [size()-1].
UList< T > & operator=(const UList< T > &)=delete
No copy assignment (default: shallow copy).
A token holds an item read from Istream.
bool isPunctuation() const noexcept
Token is PUNCTUATION.
@ 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.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
void readContiguous(Istream &is, char *data, std::streamsize byteCount)
Read binary block of contiguous data, possibly with conversion.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
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).