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

Method Consume

Source/cmArgumentParser.cxx:142–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140}
141
142void Instance::Consume(cm::string_view arg)
143{
144 ParserState& state = this->GetState();
145
146 auto const it = state.Bindings.Keywords.Find(arg);
147 if (it != state.Bindings.Keywords.end()) {
148 this->FinishKeyword();
149 state.Keyword = it->first;
150 state.KeywordValuesSeen = 0;
151 state.DoneWithPositional = true;
152 if (state.Bindings.ParsedKeyword) {
153 state.Bindings.ParsedKeyword(*this, it->first);
154 }
155 it->second(*this);
156 return;
157 }
158
159 if (!state.DoneWithPositional) {
160 auto const pit = state.Bindings.Positions.Find(state.Pos);
161 if (pit != state.Bindings.Positions.end()) {
162 pit->second(*this, state.Pos, arg);
163 return;
164 }
165
166 if (state.Bindings.TrailingArgs) {
167 state.Keyword = ""_s;
168 state.KeywordValuesSeen = 0;
169 state.DoneWithPositional = true;
170 state.Bindings.TrailingArgs(*this);
171 if (!state.KeywordValueFunc) {
172 return;
173 }
174 }
175 }
176
177 if (state.KeywordValueFunc) {
178 switch (state.KeywordValueFunc(arg)) {
179 case Continue::Yes:
180 break;
181 case Continue::No:
182 state.KeywordValueFunc = nullptr;
183 break;
184 }
185 ++state.KeywordValuesSeen;
186 return;
187 }
188
189 if (this->UnparsedArguments) {
190 this->UnparsedArguments->emplace_back(arg);
191 }
192}
193
194void Instance::FinishKeyword()
195{

Callers 3

ParseMethod · 0.95
cmArgumentParserClass · 0.80

Calls 5

FinishKeywordMethod · 0.95
emplace_backMethod · 0.80
GetStateMethod · 0.45
FindMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected