scalarRange Class Reference

Scalar bounds to be used as a unary predicate. More...

Collaboration diagram for scalarRange:
[legend]

Public Types

typedef scalar value_type
 Type of values the range contains. More...
 

Public Member Functions

constexpr scalarRange () noexcept
 Construct an empty (inverse, NONE) range - never matches. More...
 
constexpr scalarRange (const scalar val) noexcept
 Construct an exact value matcher. More...
 
 scalarRange (const scalar minVal, const scalar maxVal) noexcept
 Construct a range from min-value to max-value. More...
 
 scalarRange (const MinMax< label > &range) noexcept
 Copy construct from a min/max range. More...
 
 scalarRange (const MinMax< scalar > &range) noexcept
 Copy construct from a min/max range. More...
 
void clear () noexcept
 Reset to an empty (inverse, NONE) range. More...
 
bool empty () const noexcept
 True if range is empty (eg, inverted, NONE) More...
 
bool valid () const noexcept
 True if range is non-empty. More...
 
bool single () const noexcept
 True if the range bounds represent a single value. More...
 
scalar min () const noexcept
 The min value of the range. More...
 
scalar max () const noexcept
 The max value of the range. More...
 
scalar value () const
 A representative (average) value for the range. More...
 
bool match (const scalar &val) const
 True if the value matches the condition. More...
 
bool operator() (const scalar &val) const
 Identical to match(), for use as a predicate. More...
 
constexpr bool operator== (const scalarRange &rhs) const noexcept
 
constexpr bool operator!= (const scalarRange &rhs) const noexcept
 

Static Public Member Functions

static bool parse (const std::string &str, scalarRange &range)
 Construct by parsing string content. More...
 
static scalarRange parse (const std::string &str)
 Construct by parsing string content. More...
 
static constexpr scalarRange ge (const scalar minVal) noexcept
 A greater-equals bound. More...
 
static constexpr scalarRange gt (const scalar minVal) noexcept
 A greater-than bound. More...
 
static constexpr scalarRange ge0 () noexcept
 A greater-equals zero bound. More...
 
static constexpr scalarRange gt0 () noexcept
 A greater-than zero bound. More...
 
static constexpr scalarRange le (const scalar maxVal) noexcept
 A less-equals bound. More...
 
static constexpr scalarRange lt (const scalar maxVal) noexcept
 A less-than bound. More...
 
static constexpr scalarRange zero_one () noexcept
 A greater-equals 0, less-equals 1 bound. More...
 

Static Public Attributes

static const scalarRange always
 A range that always matches. More...
 

Friends

Ostreamoperator<< (Ostream &os, const scalarRange &range)
 Print information about the range. More...
 

Detailed Description

Scalar bounds to be used as a unary predicate.

The bound can be specified as an "MIN:MAX" range, as a "MIN:" or ":MAX" bound or simply as a single "VALUE".

When defined via the parse() method, the special string "none" can be used to define an empty (inverse) range.

See also
Foam::MinMax Foam::predicates::scalars
Source files

Definition at line 68 of file scalarRange.H.

Member Typedef Documentation

◆ value_type

typedef scalar value_type

Type of values the range contains.

Definition at line 109 of file scalarRange.H.

Constructor & Destructor Documentation

◆ scalarRange() [1/5]

constexpr scalarRange ( )
inlineconstexprnoexcept

Construct an empty (inverse, NONE) range - never matches.

Definition at line 43 of file scalarRangeI.H.

Referenced by scalarRange::parse().

Here is the caller graph for this function:

◆ scalarRange() [2/5]

constexpr scalarRange ( const scalar  val)
inlineexplicitconstexprnoexcept

Construct an exact value matcher.

Definition at line 49 of file scalarRangeI.H.

◆ scalarRange() [3/5]

scalarRange ( const scalar  minVal,
const scalar  maxVal 
)
inlinenoexcept

Construct a range from min-value to max-value.

Check validity of the range and sets to NONE or EQ if required.

Definition at line 56 of file scalarRangeI.H.

References clear(), and Foam::equal().

Here is the call graph for this function:

◆ scalarRange() [4/5]

scalarRange ( const MinMax< label > &  range)
explicitnoexcept

Copy construct from a min/max range.

Automatically decides if this is a GE_LE or NONE range

Definition at line 138 of file scalarRange.C.

◆ scalarRange() [5/5]

scalarRange ( const MinMax< scalar > &  range)
explicitnoexcept

Copy construct from a min/max range.

Automatically decides if this is a GE_LE or NONE range

Definition at line 146 of file scalarRange.C.

Member Function Documentation

◆ parse() [1/2]

bool parse ( const std::string &  str,
scalarRange range 
)
static

Construct by parsing string content.

A colon (:) is used as a range marker or when specifying greater-than or less-than bounds.

Note
The special string "none" can be used define an empty (inverse) range
Returns
True if no parse problems were encountered.

Definition at line 46 of file scalarRange.C.

References scalarRange::always, Switch::find(), scalarRange::ge(), Switch::good(), scalarRange::le(), range, and scalarRange::scalarRange().

Here is the call graph for this function:

◆ parse() [2/2]

Foam::scalarRange parse ( const std::string &  str)
static

Construct by parsing string content.

Any parse problems are emitted as information and the returned range is of type empty().

Returns
The parsed range, which is empty() on any problems

Definition at line 123 of file scalarRange.C.

References Foam::endl(), Foam::Info, and range.

Here is the call graph for this function:

◆ ge()

constexpr Foam::scalarRange ge ( const scalar  minVal)
inlinestaticconstexprnoexcept

A greater-equals bound.

Definition at line 75 of file scalarRangeI.H.

Referenced by scalarRange::parse().

Here is the caller graph for this function:

◆ gt()

constexpr Foam::scalarRange gt ( const scalar  minVal)
inlinestaticconstexprnoexcept

A greater-than bound.

Definition at line 82 of file scalarRangeI.H.

◆ ge0()

constexpr Foam::scalarRange ge0 ( )
inlinestaticconstexprnoexcept

A greater-equals zero bound.

Definition at line 89 of file scalarRangeI.H.

◆ gt0()

constexpr Foam::scalarRange gt0 ( )
inlinestaticconstexprnoexcept

A greater-than zero bound.

Definition at line 96 of file scalarRangeI.H.

◆ le()

constexpr Foam::scalarRange le ( const scalar  maxVal)
inlinestaticconstexprnoexcept

A less-equals bound.

Definition at line 103 of file scalarRangeI.H.

Referenced by scalarRange::parse().

Here is the caller graph for this function:

◆ lt()

constexpr Foam::scalarRange lt ( const scalar  maxVal)
inlinestaticconstexprnoexcept

A less-than bound.

Definition at line 109 of file scalarRangeI.H.

◆ zero_one()

constexpr Foam::scalarRange zero_one ( )
inlinestaticconstexprnoexcept

A greater-equals 0, less-equals 1 bound.

Definition at line 116 of file scalarRangeI.H.

◆ clear()

void clear ( )
inlinenoexcept

Reset to an empty (inverse, NONE) range.

Definition at line 124 of file scalarRangeI.H.

◆ empty()

bool empty ( ) const
inlinenoexcept

True if range is empty (eg, inverted, NONE)

Definition at line 132 of file scalarRangeI.H.

◆ valid()

bool valid ( ) const
inlinenoexcept

True if range is non-empty.

Definition at line 138 of file scalarRangeI.H.

References bool.

◆ single()

bool single ( ) const
inlinenoexcept

True if the range bounds represent a single value.

Definition at line 144 of file scalarRangeI.H.

◆ min()

Foam::scalar min ( ) const
inlinenoexcept

The min value of the range.

Definition at line 150 of file scalarRangeI.H.

◆ max()

Foam::scalar max ( ) const
inlinenoexcept

The max value of the range.

Definition at line 156 of file scalarRangeI.H.

◆ value()

Foam::scalar value ( ) const
inline

A representative (average) value for the range.

For GE, LE bounds it is the min/max value, respectively.

Definition at line 162 of file scalarRangeI.H.

◆ match()

bool match ( const scalar &  val) const
inline

True if the value matches the condition.

Definition at line 185 of file scalarRangeI.H.

References Foam::equal().

Here is the call graph for this function:

◆ operator()()

bool operator() ( const scalar &  val) const
inline

Identical to match(), for use as a predicate.

Definition at line 203 of file scalarRangeI.H.

References Foam::stringOps::match().

Here is the call graph for this function:

◆ operator==()

constexpr bool operator== ( const scalarRange rhs) const
inlineconstexprnoexcept

Definition at line 211 of file scalarRangeI.H.

◆ operator!=()

constexpr bool operator!= ( const scalarRange rhs) const
inlineconstexprnoexcept

Definition at line 221 of file scalarRangeI.H.

Friends And Related Function Documentation

◆ operator<<

Ostream& operator<< ( Ostream os,
const scalarRange range 
)
friend

Print information about the range.

Member Data Documentation

◆ always

const Foam::scalarRange always
static

A range that always matches.

Definition at line 115 of file scalarRange.H.

Referenced by scalarRange::parse().


The documentation for this class was generated from the following files: