MCPcopy Index your code
hub / github.com/Kitware/CMake / HandleGetCommand

Function HandleGetCommand

Source/cmListCommand.cxx:113–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111}
112
113bool HandleGetCommand(std::vector<std::string> const& args,
114 cmExecutionStatus& status)
115{
116 if (args.size() < 4) {
117 status.SetError("sub-command GET requires at least three arguments.");
118 return false;
119 }
120
121 std::string const& listName = args[1];
122 std::string const& variableName = args.back();
123 // expand the variable
124 auto list = GetList(listName, status.GetMakefile());
125 if (!list) {
126 status.GetMakefile().AddDefinition(variableName, "NOTFOUND");
127 return true;
128 }
129 // FIXME: Add policy to make non-existing lists an error like empty lists.
130 if (list->empty()) {
131 status.SetError("GET given empty list");
132 return false;
133 }
134
135 std::vector<int> indexes;
136 for (std::size_t cc = 2; cc < args.size() - 1; cc++) {
137 int index;
138 if (!GetIndexArg(args[cc], &index, status.GetMakefile())) {
139 status.SetError(cmStrCat("index: ", args[cc], " is not a valid index"));
140 return false;
141 }
142 indexes.push_back(index);
143 }
144
145 try {
146 auto values = list->get_items(indexes.begin(), indexes.end());
147 status.GetMakefile().AddDefinition(variableName, values.to_string());
148 return true;
149 } catch (std::out_of_range& e) {
150 status.SetError(e.what());
151 return false;
152 }
153}
154
155bool HandleAppendCommand(std::vector<std::string> const& args,
156 cmExecutionStatus& status)

Callers

nothing calls this directly

Calls 15

GetIndexArgFunction · 0.85
push_backMethod · 0.80
get_itemsMethod · 0.80
to_stringMethod · 0.80
GetListFunction · 0.70
cmStrCatFunction · 0.70
sizeMethod · 0.45
SetErrorMethod · 0.45
backMethod · 0.45
GetMakefileMethod · 0.45
AddDefinitionMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…