MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / next

Method next

Libraries/Http/HttpURLParser.cpp:21–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19}
20
21bool SC::HttpURLQueryIterator::next(HttpURLQueryItem& item)
22{
23 item = {};
24 if (cursor >= search.sizeInBytes())
25 {
26 return false;
27 }
28
29 const char* data = search.bytesWithoutTerminator();
30 const size_t nameStart = cursor;
31 while (cursor < search.sizeInBytes() and data[cursor] != '=' and data[cursor] != '&')
32 {
33 cursor++;
34 }
35 const size_t nameEnd = cursor;
36
37 const bool hasValue = cursor < search.sizeInBytes() and data[cursor] == '=';
38 if (hasValue)
39 {
40 cursor++;
41 }
42
43 const size_t valueStart = cursor;
44 while (cursor < search.sizeInBytes() and data[cursor] != '&')
45 {
46 cursor++;
47 }
48 const size_t valueEnd = cursor;
49 if (cursor < search.sizeInBytes() and data[cursor] == '&')
50 {
51 cursor++;
52 }
53
54 item.name = {{data + nameStart, nameEnd - nameStart}, false, search.getEncoding()};
55 item.value = {{data + valueStart, valueEnd - valueStart}, false, search.getEncoding()};
56 item.hasValue = hasValue;
57 return true;
58}
59
60SC::HttpFormUrlEncodedIterator::HttpFormUrlEncodedIterator(StringSpan formBody) : body(formBody) {}
61

Callers 2

getValueMethod · 0.45
getQueryValueMethod · 0.45

Calls 1

sizeInBytesMethod · 0.45

Tested by

no test coverage detected