MCPcopy Create free account
hub / github.com/3rdparty/libprocess / parse

Function parse

src/http.cpp:739–772  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

737namespace path {
738
739Try<hashmap<string, string>> parse(const string& pattern, const string& path)
740{
741 // Split the pattern by '/' into keys.
742 vector<string> keys = strings::tokenize(pattern, "/");
743
744 // Split the path by '/' into segments.
745 vector<string> segments = strings::tokenize(path, "/");
746
747 hashmap<string, string> result;
748
749 while (!segments.empty()) {
750 if (keys.empty()) {
751 return Error(
752 "Not expecting suffix '" + strings::join("/", segments) + "'");
753 }
754
755 string key = keys.front();
756
757 if (strings::startsWith(key, "{") &&
758 strings::endsWith(key, "}")) {
759 key = strings::remove(key, "{", strings::PREFIX);
760 key = strings::remove(key, "}", strings::SUFFIX);
761 } else if (key != segments.front()) {
762 return Error("Expecting '" + key + "' not '" + segments.front() + "'");
763 }
764
765 result[key] = segments.front();
766
767 keys.erase(keys.begin());
768 segments.erase(segments.begin());
769 }
770
771 return result;
772}
773
774} // namespace path {
775

Callers 12

toggleMethod · 0.70
pid.cppFile · 0.70
authenticateMethod · 0.70
startMethod · 0.70
createMethod · 0.50
_snapshotMethod · 0.50
runMethod · 0.50
foreachFunction · 0.50
TEST_FFunction · 0.50
TEST_PFunction · 0.50
TESTFunction · 0.50
TESTFunction · 0.50

Calls 2

removeFunction · 0.85
emptyMethod · 0.45

Tested by 6

runMethod · 0.40
foreachFunction · 0.40
TEST_FFunction · 0.40
TEST_PFunction · 0.40
TESTFunction · 0.40
TESTFunction · 0.40