MCPcopy Create free account
hub / github.com/PDAL/PDAL / function0

Method function0

filters/private/expr/MathParser.cpp:174–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

172}
173
174bool MathParser::function0(Expression& expr)
175{
176 struct Func0
177 {
178 std::string name;
179 double value;
180 };
181
182 static const std::vector<Func0> funcs {
183 { "nan", std::numeric_limits<double>::quiet_NaN() },
184 { "lowest", std::numeric_limits<double>::lowest() },
185 { "highest", (std::numeric_limits<double>::max)() }
186 };
187
188 std::string name = curToken().sval();
189 auto it = std::find_if(funcs.begin(), funcs.end(),
190 [&name](const Func0& f){ return f.name == name; });
191
192 if (it == funcs.end())
193 {
194 if (peekToken() == TokenType::Lparen)
195 setError("Invalid function name '" + name + "'");
196 return false;
197 }
198
199 if (!match(TokenType::Lparen))
200 {
201 setError("Expecting '(' to open function invocation of '" + name + "'.");
202 return false;
203 }
204
205 if (!match(TokenType::Rparen))
206 {
207 setError("Expecting ')' to close function invocation of '" + name + "'.");
208 return false;
209 }
210
211 expr.pushNode(NodePtr(new ConstValueNode(it->value)));
212
213 return true;
214}
215
216bool MathParser::function1(Expression& expr)
217{

Callers

nothing calls this directly

Calls 4

svalMethod · 0.80
pushNodeMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected