Loading...
Searching...
No Matches
scalarRanges.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2018-2023 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::scalarRanges
28
29Description
30 A collection of scalar bounds to be used as a unary predicate.
31
32SeeAlso
33 Foam::predicates::scalars
34
35SourceFiles
36 scalarRanges.cxx
37 scalarRangesI.H
38
39\*---------------------------------------------------------------------------*/
40
41#ifndef Foam_scalarRanges_H
42#define Foam_scalarRanges_H
43
44#include "scalarRange.H"
45#include "List.H"
46
47// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48
49namespace Foam
50{
52/*---------------------------------------------------------------------------*\
53 Class scalarRanges Declaration
54\*---------------------------------------------------------------------------*/
55
56class scalarRanges
57:
58 public List<scalarRange>
59{
60public:
61
62 // Constructors
63
64 //- Inherit constructors from List of scalarRange
65 using List<scalarRange>::List;
66
67 //- Default construct
68 constexpr scalarRanges() noexcept = default;
69
70 //- Construct by parsing string using the parse() static method
71 //- with optional reporting if any range fails to parse
72 explicit scalarRanges(const std::string& str, bool report = true)
73 :
74 List<scalarRange>(scalarRanges::parse(str, report))
75 {}
76
77
78 // Static Constructors
79
80 //- Construct by parsing string for scalar ranges
81 //- with optional reporting if any range fails to parse.
82 // The individual items are space, comma or semicolon delimited.
83 static scalarRanges parse(const std::string& str, bool report = true);
84
85
86 // Member Functions
88 //- True if the value is contained by any of the sub-ranges
89 bool contains(const scalar value) const
90 {
91 for (const scalarRange& range : *this)
92 {
93 if (range.contains(value))
94 {
95 return true;
96 }
97 }
98 return false;
99 }
100
101 //- True if the value is matched by any of the sub-ranges
102 bool match(const scalar value) const { return contains(value); }
103
104
105 // Member Operators
106
107 //- For use as a predicate, same as contains()
108 bool operator()(const scalar value) const { return contains(value); }
109};
111
112// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
113
114} // End namespace Foam
115
116// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
117
118#endif
119
120// ************************************************************************* //
scalar range
Scalar bounds to be used as a unary predicate.
Definition scalarRange.H:65
A collection of scalar bounds to be used as a unary predicate.
constexpr scalarRanges() noexcept=default
Default construct.
bool operator()(const scalar value) const
For use as a predicate, same as contains().
bool contains(const scalar value) const
True if the value is contained by any of the sub-ranges.
static scalarRanges parse(const std::string &str, bool report=true)
Construct by parsing string for scalar ranges with optional reporting if any range fails to parse.
bool match(const scalar value) const
True if the value is matched by any of the sub-ranges.
Namespace for OpenFOAM.
const direction noexcept
Definition scalarImpl.H:265