MCPcopy Create free account
hub / github.com/apache/mesos / parse

Function parse

3rdparty/libprocess/src/http.cpp:810–843  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

808namespace path {
809
810Try<hashmap<string, string>> parse(const string& pattern, const string& path)
811{
812 // Split the pattern by '/' into keys.
813 vector<string> keys = strings::tokenize(pattern, "/");
814
815 // Split the path by '/' into segments.
816 vector<string> segments = strings::tokenize(path, "/");
817
818 hashmap<string, string> result;
819
820 while (!segments.empty()) {
821 if (keys.empty()) {
822 return Error(
823 "Not expecting suffix '" + strings::join("/", segments) + "'");
824 }
825
826 string key = keys.front();
827
828 if (strings::startsWith(key, "{") &&
829 strings::endsWith(key, "}")) {
830 key = strings::remove(key, "{", strings::PREFIX);
831 key = strings::remove(key, "}", strings::SUFFIX);
832 } else if (key != segments.front()) {
833 return Error("Expecting '" + key + "' not '" + segments.front() + "'");
834 }
835
836 result[key] = segments.front();
837
838 keys.erase(keys.begin());
839 segments.erase(segments.begin());
840 }
841
842 return result;
843}
844
845} // namespace path {
846

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 9

tokenizeFunction · 0.85
startsWithFunction · 0.85
endsWithFunction · 0.85
ErrorClass · 0.50
joinFunction · 0.50
removeFunction · 0.50
emptyMethod · 0.45
eraseMethod · 0.45
beginMethod · 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