Coverage Report

Created: 2026-02-09 06:05

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/CMake/Source/cmSubcommandTable.cxx
Line
Count
Source
1
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2
   file LICENSE.rst or https://cmake.org/licensing for details.  */
3
#include "cmSubcommandTable.h"
4
5
#include <algorithm>
6
7
#include "cmExecutionStatus.h"
8
#include "cmStringAlgorithms.h"
9
10
cmSubcommandTable::cmSubcommandTable(std::initializer_list<InitElem> init)
11
0
  : Impl(init.begin(), init.end())
12
0
{
13
0
  std::sort(this->Impl.begin(), this->Impl.end(),
14
0
            [](Elem const& left, Elem const& right) {
15
0
              return left.first < right.first;
16
0
            });
17
0
}
18
19
bool cmSubcommandTable::operator()(cm::string_view key,
20
                                   std::vector<std::string> const& args,
21
                                   cmExecutionStatus& status) const
22
0
{
23
0
  auto const it = std::lower_bound(
24
0
    this->Impl.begin(), this->Impl.end(), key,
25
0
    [](Elem const& elem, cm::string_view k) { return elem.first < k; });
26
0
  if (it != this->Impl.end() && it->first == key) {
27
0
    return it->second(args, status);
28
0
  }
29
0
  status.SetError(cmStrCat("does not recognize sub-command ", key));
30
0
  return false;
31
0
}