27 [[nodiscard]]
const std::string&
getName()
const {
return theName; }
31 [[nodiscard]]
virtual std::string
help(std::span<const TclObject> tokens)
const = 0;
42 template<
typename ITER>
45 bool caseSensitive =
true);
46 template<
typename RANGE>
48 RANGE&& possibleValues,
49 bool caseSensitive =
true);
50 template<
typename RANGE>
58 std::span<const std::string_view> input);
64 void checkNumArgs(std::span<const TclObject> tokens,
unsigned exactly,
const char* errMessage)
const;
65 void checkNumArgs(std::span<const TclObject> tokens,
AtLeast atLeast,
const char* errMessage)
const;
66 void checkNumArgs(std::span<const TclObject> tokens,
Between between,
const char* errMessage)
const;
67 void checkNumArgs(std::span<const TclObject> tokens,
unsigned exactly,
Prefix prefix,
const char* errMessage)
const;
75 template<
typename String>
76 requires(!std::same_as<Completer, std::remove_cvref_t<String>>)
78 : theName(std::forward<String>(name_))
85 static bool equalHead(std::string_view s1, std::string_view s2,
bool caseSensitive);
86 template<
typename ITER>
87 static std::vector<std::string_view> filter(
88 std::string_view str, ITER
begin, ITER
end,
bool caseSensitive);
89 template<
typename RANGE>
90 static std::vector<std::string_view> filter(
91 std::string_view str, RANGE&& range,
bool caseSensitive);
92 static bool completeImpl(std::string& str, std::vector<std::string_view>
matches,
94 static void completeFileNameImpl(std::vector<std::string>& tokens,
96 std::vector<std::string_view>
matches);
98 const std::string theName;
105 std::string_view str, ITER
begin, ITER
end,
bool caseSensitive)
107 std::vector<std::string_view> result;
108 for (
auto it =
begin; it !=
end; ++it) {
109 if (equalHead(str, *it, caseSensitive)) {
110 result.push_back(*it);
120 return filter(str, std::begin(range), std::end(range), caseSensitive);