33template<
unsigned W
idth>
42template<
unsigned W
idth>
51 const label nblocks = debugOutput ? blocks_.size() : num_blocks(size());
52 for (label blocki = 0; blocki < nblocks; ++blocki)
63template<
unsigned W
idth>
75 is.
fatalCheck(
"PackedList::readList(Istream&) : reading first token");
95 "PackedList::readList(Istream&) : "
96 "reading the binary block"
109 for (label i=0; i<len; ++i)
115 "PackedList::readList(Istream&) : "
127 "PackedList::readList(Istream&) : "
128 "reading the single entry"
142 while (!tok.isPunctuation(token::END_LIST))
151 else if (tok.isPunctuation(token::BEGIN_BLOCK))
156 while (!tok.isPunctuation(token::END_BLOCK))
168 <<
"incorrect first token, expected <int>, '(' or '{', found "
170 <<
exit(FatalIOError);
177template<
unsigned W
idth>
184 const PackedList<Width>& list = *
this;
185 const label len = list.
size();
187 if (shortLen < 0) shortLen = 1;
189 if (
os.format() == IOstreamOption::BINARY)
193 os << nl << len << nl;
198 os.write(list.cdata_bytes(), list.size_bytes());
201 else if (len > 1 && list.uniform())
204 os << len << token::BEGIN_BLOCK << list[0] << token::END_BLOCK;
206 else if (!shortLen || len <= shortLen)
211 os << len << token::BEGIN_LIST;
214 for (label i = 0; i < len; ++i)
216 if (i)
os << token::SPACE;
217 os << label(list.get(i));
221 os << token::END_LIST;
228 os <<
nl << len <<
nl << token::BEGIN_LIST <<
nl;
234 for (label i = 0; i < len; ++i)
236 os << label(list.get(i)) <<
nl;
244 for (label i = 0; i < len; ++i, ++line)
246 if (line == shortLen)
255 os << label(list.get(i));
261 os << token::END_LIST <<
nl;
268template<
unsigned W
idth>
277 os.writeKeyword(keyword);
286template<
unsigned W
idth>
293template<
unsigned W
idth>
297 const InfoProxy<PackedList<Width>>& iproxy
300 const auto& list = *iproxy;
302 os <<
"PackedList<" << Width
304 <<
" (limits: max=" << PackedList<Width>::max_value
305 <<
", elem_per_block=" << PackedList<Width>::elem_per_block
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
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.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A dynamic list of packed unsigned integers, with the number of bits per item specified by the <Width>...
static unsigned int readValue(Istream &is)
Read a list entry (allows for specialization).
char * data_bytes() noexcept
A pointer to the raw storage, reinterpreted as byte data.
block_container blocks_
The blocks of raw data.
void push_back(const unsigned int val)
Append a value at the end of the list.
void resize(const label numElem, const unsigned int val=0u)
Reset addressable list size, does not shrink the allocated size.
Ostream & printBits(Ostream &os, bool debugOutput=false) const
Print bit patterns, optionally with extra debug.
label capacity() const noexcept
Number of elements that can be stored without reallocating.
bool set(const label i, unsigned int val=~0u)
Set value at index i, default value set is the max_value.
Ostream & writeList(Ostream &os, label shortLen=0) const
Write List, with line-breaks in ASCII when length exceeds shortLen.
bool uniform() const
True if all entries have identical values (and list is non-empty).
unsigned int get(const label i) const
Get value at index i or 0 for out-of-range.
constexpr PackedList() noexcept
Default construct, zero-sized and no allocation.
const char * cdata_bytes() const noexcept
A const pointer to the raw storage, reinterpreted as byte data.
void writeEntry(Ostream &os) const
Write as a dictionary entry.
static constexpr label num_blocks(label numElem) noexcept
Calculate the number of blocks required to _address_ the requested number of elements.
void setPair(Istream &is)
Read an index/value pair and set accordingly.
label size() const noexcept
Number of entries.
void clear()
Clear the list, i.e. set addressable size to zero.
Istream & readList(Istream &is)
Clear list and read from stream.
std::streamsize size_bytes() const noexcept
The number of bytes addressed in the raw storage including any padding.
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.
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)
Ostream & print(Ostream &os, UIntType value, char off='0', char on='1')
Print 0/1 bits in the (unsigned) integral type.
Istream & operator>>(Istream &, directionInfo &)
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a).