| 1483 | } |
| 1484 | |
| 1485 | static bool generateFirstLast(Node const& n, size_t idx, size_t size, std::ostream& out) { |
| 1486 | ANKERL_NANOBENCH_LOG("n.type=" << static_cast<int>(n.type)); |
| 1487 | bool matchFirst = n == "-first"; |
| 1488 | bool matchLast = n == "-last"; |
| 1489 | if (!matchFirst && !matchLast) { |
| 1490 | return false; |
| 1491 | } |
| 1492 | |
| 1493 | bool doWrite = false; |
| 1494 | if (n.type == Node::Type::section) { |
| 1495 | doWrite = (matchFirst && idx == 0) || (matchLast && idx == size - 1); |
| 1496 | } else if (n.type == Node::Type::inverted_section) { |
| 1497 | doWrite = (matchFirst && idx != 0) || (matchLast && idx != size - 1); |
| 1498 | } |
| 1499 | |
| 1500 | if (doWrite) { |
| 1501 | for (auto const& child : n.children) { |
| 1502 | if (child.type == Node::Type::content) { |
| 1503 | out.write(child.begin, std::distance(child.begin, child.end)); |
| 1504 | } |
| 1505 | } |
| 1506 | } |
| 1507 | return true; |
| 1508 | } |
| 1509 | |
| 1510 | static bool matchCmdArgs(std::string const& str, std::vector<std::string>& matchResult) { |
| 1511 | matchResult.clear(); |
no test coverage detected