WarpX
IntervalsParser.H
Go to the documentation of this file.
1 #ifndef WARPX_INTERVALSPARSER_H_
2 #define WARPX_INTERVALSPARSER_H_
3 
4 #include <string>
5 #include <limits>
6 #include <vector>
7 
13 {
14 public:
24  SliceParser (const std::string& instr);
25 
33  bool contains (const int n) const;
34 
41  int nextContains (const int n) const;
42 
49  int previousContains (const int n) const;
50 
55  int getPeriod () const;
56 
61  int getStart () const;
62 
67  int getStop () const;
68 
69 private:
70  int m_start = 0;
71  int m_stop = std::numeric_limits<int>::max();
72  int m_period = 1;
73  std::string m_separator = ":";
74 
75 };
76 
83 {
84 public:
88  IntervalsParser () = default;
89 
97  IntervalsParser (const std::vector<std::string>& instr_vec);
98 
105  bool contains (const int n) const;
106 
113  int nextContains (const int n) const;
114 
121  int previousContains (const int n) const;
122 
129  int previousContainsInclusive (const int n) const;
130 
137  int localPeriod (const int n) const;
138 
143  bool isActivated () const;
144 
145 private:
146  std::vector<SliceParser> m_slices;
147  std::string m_separator = ",";
148  bool m_activated = false;
149 };
150 
151 #endif // WARPX_INTERVALSPARSER_H_
int previousContains(const int n) const
A method that returns the greatest integer strictly smaller than n such that contains(n) is true...
Definition: IntervalsParser.cpp:47
int getPeriod() const
A method that returns the slice period.
Definition: IntervalsParser.cpp:55
This class is a parser for multiple slices of the form x,y,z,... where x, y and z are slices of the f...
Definition: IntervalsParser.H:82
int nextContains(const int n) const
A method that returns the smallest integer strictly greater than n such that contains(n) is true...
Definition: IntervalsParser.cpp:38
SliceParser(const std::string &instr)
Constructor of the SliceParser class.
Definition: IntervalsParser.cpp:4
int getStop() const
A method that returns the slice stop.
Definition: IntervalsParser.cpp:59
int getStart() const
A method that returns the slice start.
Definition: IntervalsParser.cpp:57
int m_period
Definition: IntervalsParser.H:72
int m_start
Definition: IntervalsParser.H:70
std::string m_separator
Definition: IntervalsParser.H:73
int n
Definition: run_libensemble_on_warpx.py:68
int m_stop
Definition: IntervalsParser.H:71
std::vector< SliceParser > m_slices
Definition: IntervalsParser.H:146
bool contains(const int n) const
A method that returns true if the input integer is contained in the slice. (e.g. if the list is initi...
Definition: IntervalsParser.cpp:32
This class is a parser for slices of the form i:j:k where i, j and k are integers representing respec...
Definition: IntervalsParser.H:12