Shaka Packager SDK
kv_pairs.cc
1 // Copyright 2022 Google LLC. All rights reserved.
2 //
3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file or at
5 // https://developers.google.com/open-source/licenses/bsd
6 
7 #include <packager/kv_pairs/kv_pairs.h>
8 
9 #include <absl/strings/str_split.h>
10 
11 namespace shaka {
12 
13 std::vector<KVPair> SplitStringIntoKeyValuePairs(std::string_view str,
14  char kv_separator,
15  char list_separator) {
16  std::vector<KVPair> kv_pairs;
17 
18  // Edge case: 0 pairs.
19  if (str.size() == 0) {
20  return kv_pairs;
21  }
22 
23  std::vector<std::string> kv_strings = absl::StrSplit(str, list_separator);
24  for (const auto& kv_string : kv_strings) {
25  KVPair pair = absl::StrSplit(kv_string, absl::MaxSplits(kv_separator, 1));
26  kv_pairs.push_back(pair);
27  }
28 
29  return kv_pairs;
30 }
31 
32 } // namespace shaka
All the methods that are virtual are virtual for mocking.
Definition: crypto_flags.cc:66