39#ifndef Foam_primitives_label_H
40#define Foam_primitives_label_H
47#define INT_ADD_SIZE(x,s,y) x ## s ## y
48#define INT_ADD_DEF_SIZE(x,s,y) INT_ADD_SIZE(x,s,y)
49#define INT_SIZE(x,y) INT_ADD_DEF_SIZE(x,WM_LABEL_SIZE,y)
82inline bool readLabel(
const char* buf, label& val)
90inline bool readLabel(
const std::string& str, label& val)
106void readRawLabel(Istream& is, label* data,
size_t nElem = 1);
130label
pow(label a, label
b);
152inline bool equal(
const T& a,
const T&
b)
161inline T clamp(
const T& val,
const T& lower,
const T& upper)
163 return min(
max(val, lower), upper);
179 constexpr label operator()(
const int32_t& val)
const noexcept
190 constexpr label operator()(
const int64_t& val)
const noexcept
192 #if WM_LABEL_SIZE == 32
194 #elif WM_LABEL_SIZE == 64
211 (val <= INT32_MIN) ? INT32_MIN
212 : (val >= INT32_MAX) ? INT32_MAX
213 :
static_cast<int32_t
>(val)
227#undef INT_ADD_DEF_SIZE
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Typedefs for label/uLabel without requiring label.H.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
void readRawLabel(Istream &is, label *data, size_t nElem=1)
Read raw label(s) from binary stream.
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
bool equal(const T &a, const T &b)
Compare two values for equality.
label & setComponent(label &val, const direction) noexcept
Non-const access to integer-type (has no components).
label readLabel(const char *buf)
Parse entire buffer as a label, skipping leading/trailing whitespace.
dimensionSet clamp(const dimensionSet &a, const dimensionSet &range)
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
int readInt(Istream &is)
Read int from stream.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
constexpr int32_t narrowInt32(const int64_t val) noexcept
Type narrowing from int64_t to int32_t.
label factorial(label n)
Evaluate n! : 0 < n <= 12.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
constexpr label operator()(const int32_t &val) const noexcept
constexpr label operator()(const int64_t &val) const noexcept
Conversion/extraction to label operation.