third_party/libprocess/include/stout/strings.hpp
// Returns a map of strings to strings based on calling tokenize
// twice. All non-pairs are discarded. For example:
//
//   pairs("foo=1;bar=2;baz;foo=3;bam=1=2", ";&", "=")
//
// Would return a map with the following:
//   bar: ["2"]
//   foo: ["1", "3"]
Returns a map of strings to strings based on calling tokenize
twice. All non-pairs are discarded. For example.




Returns a map of strings to strings based on calling tokenize twice . All non - pairs are discarded . For example .
inline std::map<std::string, std::vector<std::string> > pairs(
    const std::string& s,
    const std::string& delims1,
    const std::string& delims2)
{
  std::map<std::string, std::vector<std::string> > result;
  const std::vector<std::string>& tokens = tokenize(s, delims1);
  foreach (const std::string& token, tokens) {
    const std::vector<std::string>& pairs = tokenize(token, delims2);
    if (pairs.size() == 2) {
      result[pairs[0]].push_back(pairs[1]);
    }
  }
  return result;
}
inline std :: map < std :: string , std :: vector < std :: string > > pairs ( const std :: string & s , const std :: string & delims1 , const std :: string & delims2 ) { std :: map < std :: string , std :: vector < std :: string > > result ; const std :: vector < std :: string > & tokens = tokenize ( s , delims1 ) ; foreach ( const std :: string & token , tokens ) { const std :: vector < std :: string > & pairs = tokenize ( token , delims2 ) ; if ( pairs . size ( ) == 2 ) { result [ pairs [ 0 ] ] . push_back ( pairs [ 1 ] ) ; } } return result ; }
Returns a map of strings to strings based on calling tokenize
twice.
Returns a map of strings to strings based on calling tokenize twice .