Loading...
Searching...
No Matches
scalarRange Class Reference

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

#include <scalarRange.H>

Collaboration diagram for scalarRange:

Public Types

typedef scalar value_type
 Type of values the range contains.

Public Member Functions

constexpr scalarRange () noexcept
 Construct an empty (inverse, NONE) range - never matches.
constexpr scalarRange (const scalar val) noexcept
 Construct an exact value matcher.
 scalarRange (const scalar minVal, const scalar maxVal) noexcept
 Construct a range from min-value to max-value.
 scalarRange (const MinMax< label > &range) noexcept
 Copy construct from a min/max range.
 scalarRange (const MinMax< scalar > &range) noexcept
 Copy construct from a min/max range.
bool empty () const noexcept
 True if range is empty (eg, inverted, NONE).
bool good () const noexcept
 True if range is non-empty.
bool single () const noexcept
 True if the range bounds represent a single value.
scalar min () const noexcept
 The min value of the range.
scalar max () const noexcept
 The max value of the range.
void reset () noexcept
 Reset to an empty (inverse, NONE) range.
void clear () noexcept
 Same as reset() - reset to an empty (inverse, NONE) range.
scalar value () const
 A representative (average) value for the range.
bool contains (const scalar val) const
 True if the value is matched by the condition.
bool match (const scalar value) const
 True if the value is matched by the condition.
bool operator() (const scalar value) const
 For use as a predicate, same as contains(), match().
constexpr bool operator== (const scalarRange &rhs) const noexcept
constexpr bool operator!= (const scalarRange &rhs) const noexcept
void print (Ostream &os) const
 Print information about the range.
bool valid () const noexcept
 Same as good() or !empty().

Static Public Member Functions

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

Static Public Attributes

static const scalarRange always
 A range that always matches.

Friends

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

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 64 of file scalarRange.H.

Member Typedef Documentation

◆ value_type

typedef scalar value_type

Type of values the range contains.

Definition at line 117 of file scalarRange.H.

Constructor & Destructor Documentation

◆ scalarRange() [1/5]

scalarRange ( )
inlineconstexprnoexcept

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

Definition at line 36 of file scalarRangeI.H.

References Foam::noexcept.

◆ scalarRange() [2/5]

scalarRange ( const scalar val)
inlineexplicitconstexprnoexcept

Construct an exact value matcher.

Definition at line 42 of file scalarRangeI.H.

References Foam::noexcept.

◆ 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 48 of file scalarRangeI.H.

References Foam::equal(), Foam::noexcept, and reset().

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

References Foam::noexcept, and range.

◆ 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

References Foam::noexcept, and range.

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.

References parse(), and range.

Referenced by parse(), and parse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse() [2/2]

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

References empty(), ge(), ge0(), good(), gt(), gt0(), le(), lt(), Foam::noexcept, parse(), single(), and zero_one().

Here is the call graph for this function:

◆ ge()

Foam::scalarRange ge ( const scalar minVal)
inlinestaticconstexprnoexcept

A greater-equals bound.

Definition at line 68 of file scalarRangeI.H.

Referenced by parse().

Here is the caller graph for this function:

◆ gt()

Foam::scalarRange gt ( const scalar minVal)
inlinestaticconstexprnoexcept

A greater-than bound.

Definition at line 75 of file scalarRangeI.H.

Referenced by parse().

Here is the caller graph for this function:

◆ ge0()

Foam::scalarRange ge0 ( )
inlinestaticconstexprnoexcept

A greater-equals zero bound.

Definition at line 82 of file scalarRangeI.H.

References Foam::noexcept.

Referenced by parse().

Here is the caller graph for this function:

◆ gt0()

Foam::scalarRange gt0 ( )
inlinestaticconstexprnoexcept

A greater-than zero bound.

Definition at line 89 of file scalarRangeI.H.

References Foam::noexcept.

Referenced by parse().

Here is the caller graph for this function:

◆ le()

Foam::scalarRange le ( const scalar maxVal)
inlinestaticconstexprnoexcept

A less-equals bound.

Definition at line 96 of file scalarRangeI.H.

Referenced by parse().

Here is the caller graph for this function:

◆ lt()

Foam::scalarRange lt ( const scalar maxVal)
inlinestaticconstexprnoexcept

A less-than bound.

Definition at line 102 of file scalarRangeI.H.

Referenced by parse().

Here is the caller graph for this function:

◆ zero_one()

Foam::scalarRange zero_one ( )
inlinestaticconstexprnoexcept

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

Definition at line 109 of file scalarRangeI.H.

References Foam::noexcept.

Referenced by parse().

Here is the caller graph for this function:

◆ empty()

bool empty ( ) const
inlinenoexcept

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

Definition at line 125 of file scalarRangeI.H.

References Foam::noexcept.

Referenced by parse().

Here is the caller graph for this function:

◆ good()

bool good ( ) const
inlinenoexcept

True if range is non-empty.

Definition at line 131 of file scalarRangeI.H.

References Foam::noexcept.

Referenced by parse(), and valid().

Here is the caller graph for this function:

◆ single()

bool single ( ) const
inlinenoexcept

True if the range bounds represent a single value.

Definition at line 137 of file scalarRangeI.H.

References Foam::noexcept.

Referenced by parse().

Here is the caller graph for this function:

◆ min()

scalar min ( ) const
inlinenoexcept

The min value of the range.

Definition at line 243 of file scalarRange.H.

References min(), and Foam::noexcept.

Referenced by min().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ max()

scalar max ( ) const
inlinenoexcept

The max value of the range.

Definition at line 248 of file scalarRange.H.

References Foam::noexcept.

◆ reset()

void reset ( )
inlinenoexcept

Reset to an empty (inverse, NONE) range.

Definition at line 117 of file scalarRangeI.H.

References Foam::noexcept.

Referenced by clear().

Here is the caller graph for this function:

◆ clear()

void clear ( )
inlinenoexcept

Same as reset() - reset to an empty (inverse, NONE) range.

Definition at line 258 of file scalarRange.H.

References clear(), Foam::noexcept, and reset().

Referenced by clear().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 143 of file scalarRangeI.H.

Referenced by match(), and operator()().

Here is the caller graph for this function:

◆ contains()

bool contains ( const scalar val) const
inline

True if the value is matched by the condition.

Definition at line 166 of file scalarRangeI.H.

References Foam::equal().

Referenced by match(), and operator()().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ match()

bool match ( const scalar value) const
inline

True if the value is matched by the condition.

Definition at line 276 of file scalarRange.H.

References contains(), and value().

Here is the call graph for this function:

◆ operator()()

bool operator() ( const scalar value) const
inline

For use as a predicate, same as contains(), match().

Definition at line 284 of file scalarRange.H.

References contains(), and value().

Here is the call graph for this function:

◆ operator==()

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

Definition at line 185 of file scalarRangeI.H.

References Foam::rhs().

Here is the call graph for this function:

◆ operator!=()

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

Definition at line 192 of file scalarRangeI.H.

References Foam::rhs().

Here is the call graph for this function:

◆ print()

void print ( Ostream & os) const

Print information about the range.

References os().

Here is the call graph for this function:

◆ valid()

bool valid ( ) const
inlinenoexcept

Same as good() or !empty().

Definition at line 308 of file scalarRange.H.

References good(), and Foam::noexcept.

Here is the call graph for this function:

◆ operator<<

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

Print information about the range.

References os(), and range.

Member Data Documentation

◆ always

const scalarRange always
static

A range that always matches.

Definition at line 125 of file scalarRange.H.


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