MCPcopy Create free account
hub / github.com/Kitware/CMake / HandleRemoveAtCommand

Function HandleRemoveAtCommand

Source/cmListCommand.cxx:860–907  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

858}
859
860bool HandleRemoveAtCommand(std::vector<std::string> const& args,
861 cmExecutionStatus& status)
862{
863 if (args.size() < 3) {
864 status.SetError("sub-command REMOVE_AT requires at least "
865 "two arguments.");
866 return false;
867 }
868
869 std::string const& listName = args[1];
870 // expand the variable
871 auto list = GetList(listName, status.GetMakefile());
872
873 if (!list || list->empty()) {
874 std::ostringstream str;
875 str << "index: ";
876 for (size_t i = 1; i < args.size(); ++i) {
877 str << args[i];
878 if (i != args.size() - 1) {
879 str << ", ";
880 }
881 }
882 str << " out of range (0, 0)";
883 status.SetError(str.str());
884 return false;
885 }
886
887 size_t cc;
888 std::vector<cmList::index_type> removed;
889 for (cc = 2; cc < args.size(); ++cc) {
890 int index;
891 if (!GetIndexArg(args[cc], &index, status.GetMakefile())) {
892 status.SetError(cmStrCat("index: ", args[cc], " is not a valid index"));
893 return false;
894 }
895 removed.push_back(index);
896 }
897
898 try {
899 status.GetMakefile().AddDefinition(
900 listName,
901 list->remove_items(removed.begin(), removed.end()).to_string());
902 return true;
903 } catch (std::out_of_range& e) {
904 status.SetError(e.what());
905 return false;
906 }
907}
908
909bool HandleFilterCommand(std::vector<std::string> const& args,
910 cmExecutionStatus& status)

Callers

nothing calls this directly

Calls 14

GetIndexArgFunction · 0.85
strMethod · 0.80
push_backMethod · 0.80
to_stringMethod · 0.80
GetListFunction · 0.70
cmStrCatFunction · 0.70
sizeMethod · 0.45
SetErrorMethod · 0.45
GetMakefileMethod · 0.45
emptyMethod · 0.45
AddDefinitionMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…