@@ -558,6 +558,76 @@ StringConversion::GetKeyValueMap(const char* mapstring,
558558 return true ;
559559}
560560
561+
562+ // ------------------------------------------------------------------------------
563+ // Split a comma separated key:val list and fill it into a map with special path treatment
564+ // ------------------------------------------------------------------------------
565+ bool
566+ StringConversion::GetSpecialKeyValueMap (const char * mapstring,
567+ std::map<std::string, std::string>& map,
568+ const char * split,
569+ const char * sdelimiter,
570+ std::vector<std::string>* keyvector,
571+ const char * pathKey,
572+ const char * stopKey)
573+ {
574+ if (!mapstring || !split || !sdelimiter || !pathKey || !stopKey)
575+ return false ;
576+ std::string input (mapstring);
577+ std::string delimiter (sdelimiter);
578+ std::string splitter (split);
579+ std::string pathPrefix = std::string (pathKey) + splitter;
580+ std::string stopPrefix = std::string (stopKey) + splitter;
581+ size_t pos = 0 ;
582+ size_t start = 0 ;
583+ while (start < input.length ()) {
584+ pos = input.find (delimiter, start);
585+ std::string token;
586+ if (pos == std::string::npos) {
587+ token = input.substr (start);
588+ start = input.length ();
589+ } else {
590+ token = input.substr (start, pos - start);
591+ start = pos + delimiter.length ();
592+ }
593+ if (token.find (pathPrefix) == 0 ) {
594+ std::string key = pathKey;
595+ std::string value = token.substr (pathPrefix.length ());
596+ while (start < input.length ()) {
597+ pos = input.find (delimiter, start);
598+ std::string next_token;
599+ if (pos == std::string::npos) {
600+ next_token = input.substr (start);
601+ start = input.length ();
602+ } else {
603+ next_token = input.substr (start, pos - start);
604+ start = pos + delimiter.length ();
605+ }
606+ if (next_token.find (stopPrefix) == 0 ) {
607+ start -= (next_token.length () + delimiter.length ());
608+ break ;
609+ } else {
610+ value += delimiter + next_token;
611+ }
612+ }
613+ map[key] = value;
614+ if (keyvector)
615+ keyvector->push_back (key);
616+ } else {
617+ size_t split_pos = token.find (splitter);
618+ if (split_pos == std::string::npos)
619+ continue ;
620+ std::string key = token.substr (0 , split_pos);
621+ std::string value = token.substr (split_pos + splitter.length ());
622+ map[key] = value;
623+ if (keyvector)
624+ keyvector->push_back (key);
625+ }
626+ }
627+ return true ;
628+ }
629+
630+
561631// ------------------------------------------------------------------------------
562632// Specialized splitting function returning the host part out of a queue name
563633// ------------------------------------------------------------------------------
0 commit comments