MCPcopy Create free account
hub / github.com/Barracuda09/SATPI / getHeaderFieldParameter

Method getHeaderFieldParameter

src/StringConverter.cpp:229–261  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

227}
228
229std::string StringConverter::getHeaderFieldParameter(const std::string &msg, const std::string &header_field) {
230 std::string::size_type nextline = 0;
231 std::string parameter;
232 for (;;) {
233 const std::string line = StringConverter::getline(msg, nextline, "\r\n");
234 if (line.empty()) {
235 return "";
236 }
237 std::string::const_iterator it = line.begin();
238 std::string::const_iterator it_h = header_field.begin();
239
240 // remove any leading whitespace
241 while (std::isspace(*it)) ++it;
242
243 // check if we find header_field
244 bool found = true;
245 while (it != line.end() && it_h != header_field.end()) {
246 if (std::toupper(*it) != std::toupper(*it_h)) {
247 found = false;
248 break;
249 }
250 ++it;
251 ++it_h;
252 }
253 if (found) {
254 // copy parameter and trim whitespace
255 const std::string::size_type begin = it - line.begin();
256 const std::string::size_type end = line.size();
257 StringConverter::trimWhitespace(line.substr(begin, end - begin), parameter);
258 return parameter;
259 }
260 }
261}
262
263std::string StringConverter::getStringParameter(const std::string &msg, const std::string &header_field,
264 const std::string &delim, const std::string &parameter) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected