Cheney Ni | aef115f | 2018-11-07 08:41:55 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #pragma once |
| 18 | |
| 19 | #include <string> |
| 20 | #include <unordered_map> |
| 21 | |
| 22 | namespace android { |
| 23 | namespace bluetooth { |
| 24 | namespace audio { |
| 25 | namespace utils { |
| 26 | |
| 27 | // Creates a hash map based on the |params| string containing key and value |
| 28 | // pairs. Pairs are expected in the form "key=value" separated by the ';' |
| 29 | // character. Both ';' and '=' characters are invalid in keys or values. |
| 30 | // Examples: |
| 31 | // "key0" -> map: [key0]="" |
| 32 | // "key0=value0;key1=value1;" -> map: [key0]="value0" [key1]="value1" |
| 33 | // "key0=;key1=value1;" -> map: [key0]="" [key1]="value1" |
| 34 | // "=value0;key1=value1;" -> map: [key1]="value1" |
| 35 | std::unordered_map<std::string, std::string> ParseAudioParams( |
| 36 | const std::string& params); |
| 37 | |
| 38 | // Dumps the contents of the hash_map to the log for debugging purposes. |
| 39 | // If |map| is not NULL, all entries of |map| will be dumped, otherwise |
| 40 | // nothing will be dumped. Note that this function does not take the ownership |
| 41 | // of the |map|. |
| 42 | std::string GetAudioParamString( |
| 43 | std::unordered_map<std::string, std::string>& params_map); |
| 44 | |
| 45 | } // namespace utils |
| 46 | } // namespace audio |
| 47 | } // namespace bluetooth |
| 48 | } // namespace android |