| 458 | }; |
| 459 | |
| 460 | double cell(double x, const std::string_view& variable, const std::weak_ptr<Payload> payload) { |
| 461 | const auto p = std::dynamic_pointer_cast<PayloadExpressionParser>(payload.lock()); |
| 462 | if (!p) { |
| 463 | assert(p); // Debug build |
| 464 | return NAN; |
| 465 | } |
| 466 | |
| 467 | const int index = (int)x - 1; |
| 468 | for (int i = 0; i < p->vars->length(); i++) { |
| 469 | if (p->vars->at(i).compare(QLatin1String(variable)) == 0) { |
| 470 | if (index >= 0 && index < p->xVectors->at(i)->length()) |
| 471 | return p->xVectors->at(i)->at(index); |
| 472 | else |
| 473 | break; |
| 474 | } |
| 475 | } |
| 476 | |
| 477 | return NAN; |
| 478 | } |
| 479 | |
| 480 | double cell_default_value(double x, double defaultValue, const std::string_view& variable, const std::weak_ptr<Payload> payload) { |
| 481 | const auto p = std::dynamic_pointer_cast<PayloadExpressionParser>(payload.lock()); |