• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 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 #ifndef SRC_TRACE_PROCESSOR_UTIL_PROTOZERO_TO_TEXT_H_
18 #define SRC_TRACE_PROCESSOR_UTIL_PROTOZERO_TO_TEXT_H_
19 
20 #include <cstdint>
21 #include <string>
22 #include <vector>
23 
24 #include "perfetto/protozero/field.h"
25 
26 namespace perfetto::trace_processor {
27 
28 class DescriptorPool;
29 
30 namespace protozero_to_text {
31 
32 // If |new_lines_modes| == kIncludeNewLines, new lines will be used between
33 // fields, otherwise only a space will be used.
34 enum NewLinesMode {
35   kIncludeNewLines = 0,
36   kSkipNewLines,
37 };
38 
39 // Given a protozero message |protobytes| which is of fully qualified name
40 // |type|, convert this into a text proto format string. All types used in
41 // message definition of |type| must be available in |pool|.
42 std::string ProtozeroToText(
43     const DescriptorPool& pool,
44     const std::string& type,
45     protozero::ConstBytes protobytes,
46     NewLinesMode new_lines_mode = NewLinesMode::kIncludeNewLines,
47     uint32_t initial_indent_depth = 0);
48 
49 std::string ProtozeroToText(const DescriptorPool& pool,
50                             const std::string& type,
51                             const std::vector<uint8_t>& protobytes,
52                             NewLinesMode new_lines_mode);
53 
54 }  // namespace protozero_to_text
55 }  // namespace perfetto::trace_processor
56 
57 #endif  // SRC_TRACE_PROCESSOR_UTIL_PROTOZERO_TO_TEXT_H_
58