Siarhei Vishniakou | a6a660f | 2022-03-04 15:12:16 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2022 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 | #define LOG_TAG "PrintTools" |
| 18 | |
| 19 | #include <input/PrintTools.h> |
Siarhei Vishniakou | 9f330c5 | 2022-05-17 05:03:42 -0700 | [diff] [blame^] | 20 | #include <sstream> |
Siarhei Vishniakou | a6a660f | 2022-03-04 15:12:16 -0800 | [diff] [blame] | 21 | |
| 22 | namespace android { |
| 23 | |
| 24 | const char* toString(bool value) { |
| 25 | return value ? "true" : "false"; |
| 26 | } |
| 27 | |
Siarhei Vishniakou | 9f330c5 | 2022-05-17 05:03:42 -0700 | [diff] [blame^] | 28 | std::string addLinePrefix(std::string str, const std::string& prefix) { |
| 29 | std::stringstream ss; |
| 30 | bool newLineStarted = true; |
| 31 | for (const auto& ch : str) { |
| 32 | if (newLineStarted) { |
| 33 | ss << prefix; |
| 34 | newLineStarted = false; |
| 35 | } |
| 36 | if (ch == '\n') { |
| 37 | newLineStarted = true; |
| 38 | } |
| 39 | ss << ch; |
| 40 | } |
| 41 | return ss.str(); |
| 42 | } |
| 43 | |
Siarhei Vishniakou | a6a660f | 2022-03-04 15:12:16 -0800 | [diff] [blame] | 44 | } // namespace android |