blob: 01f6bf514b6b20783a23fbfe7becdd9900f506f6 [file] [log] [blame]
Siarhei Vishniakoua6a660f2022-03-04 15:12:16 -08001/*
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 Vishniakou9f330c52022-05-17 05:03:42 -070020#include <sstream>
Siarhei Vishniakoua6a660f2022-03-04 15:12:16 -080021
22namespace android {
23
24const char* toString(bool value) {
25 return value ? "true" : "false";
26}
27
Siarhei Vishniakou9f330c52022-05-17 05:03:42 -070028std::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 Vishniakoua6a660f2022-03-04 15:12:16 -080044} // namespace android