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

Method parse

Source/cmCommandLineArgument.h:112–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110
111 template <typename T, typename... CallState>
112 bool parse(std::string const& input, T& index,
113 std::vector<std::string> const& allArgs,
114 CallState&&... state) const
115 {
116 ParseMode parseState = ParseMode::Valid;
117
118 if (this->Type == Values::Zero) {
119 if (input.size() == this->Name.size()) {
120 parseState =
121 this->StoreCall(std::string{}, std::forward<CallState>(state)...)
122 ? ParseMode::Valid
123 : ParseMode::Invalid;
124 } else {
125 parseState = ParseMode::SyntaxError;
126 }
127
128 } else if (this->Type == Values::One || this->Type == Values::ZeroOrOne) {
129 if (input.size() == this->Name.size()) {
130 auto nextValueIndex = index + 1;
131 if (nextValueIndex >= allArgs.size() ||
132 IsFlag(allArgs[nextValueIndex])) {
133 if (this->Type == Values::ZeroOrOne) {
134 parseState =
135 this->StoreCall(std::string{}, std::forward<CallState>(state)...)
136 ? ParseMode::Valid
137 : ParseMode::Invalid;
138 } else {
139 parseState = ParseMode::ValueError;
140 }
141 } else {
142 parseState = this->StoreCall(allArgs[nextValueIndex],
143 std::forward<CallState>(state)...)
144 ? ParseMode::Valid
145 : ParseMode::Invalid;
146 index = nextValueIndex;
147 }
148 } else {
149 auto value = this->extract_single_value(input, parseState);
150 if (parseState == ParseMode::Valid) {
151 parseState =
152 this->StoreCall(value, std::forward<CallState>(state)...)
153 ? ParseMode::Valid
154 : ParseMode::Invalid;
155 }
156 }
157 } else if (this->Type == Values::Two) {
158 if (input.size() == this->Name.size()) {
159 if (index + 2 >= allArgs.size() || IsFlag(allArgs[index + 1]) ||
160 IsFlag(allArgs[index + 2])) {
161 parseState = ParseMode::ValueError;
162 } else {
163 index += 2;
164 parseState =
165 this->StoreCall(cmStrCat(allArgs[index - 1], ";", allArgs[index]),
166 std::forward<CallState>(state)...)
167 ? ParseMode::Valid
168 : ParseMode::Invalid;
169 }

Callers 15

ReadJsonFunction · 0.45
cmLoadFlagTableJsonFunction · 0.45
cmJSONStateMethod · 0.45
LoadMethod · 0.45
RunMethod · 0.45
do_cmakeFunction · 0.45
do_buildFunction · 0.45
do_installFunction · 0.45
do_workflowFunction · 0.45
WriteDyndepFileMethod · 0.45
cmcmd_cmake_ninja_dyndepFunction · 0.45

Calls 4

extract_single_valueMethod · 0.95
cmStrCatFunction · 0.70
ErrorClass · 0.70
sizeMethod · 0.45

Tested by 2

RunMethod · 0.36
HandleCDashUploadFileMethod · 0.36