1 /*
2 * Copyright (C) 2017 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 /*******************************************************************************
18 * AUTOGENERATED - DO NOT EDIT
19 *******************************************************************************
20 * This file has been generated from the protobuf message
21 * perfetto/config/android/android_log_config.proto
22 * by
23 * ../../tools/proto_to_cpp/proto_to_cpp.cc.
24 * If you need to make changes here, change the .proto file and then run
25 * ./tools/gen_tracing_cpp_headers_from_protos
26 */
27
28 #include "perfetto/tracing/core/android_log_config.h"
29
30 #include "perfetto/common/android_log_constants.pb.h"
31 #include "perfetto/config/android/android_log_config.pb.h"
32
33 namespace perfetto {
34
35 AndroidLogConfig::AndroidLogConfig() = default;
36 AndroidLogConfig::~AndroidLogConfig() = default;
37 AndroidLogConfig::AndroidLogConfig(const AndroidLogConfig&) = default;
38 AndroidLogConfig& AndroidLogConfig::operator=(const AndroidLogConfig&) =
39 default;
40 AndroidLogConfig::AndroidLogConfig(AndroidLogConfig&&) noexcept = default;
41 AndroidLogConfig& AndroidLogConfig::operator=(AndroidLogConfig&&) = default;
42
43 #pragma GCC diagnostic push
44 #pragma GCC diagnostic ignored "-Wfloat-equal"
operator ==(const AndroidLogConfig & other) const45 bool AndroidLogConfig::operator==(const AndroidLogConfig& other) const {
46 return (log_ids_ == other.log_ids_) && (min_prio_ == other.min_prio_) &&
47 (filter_tags_ == other.filter_tags_);
48 }
49 #pragma GCC diagnostic pop
50
FromProto(const perfetto::protos::AndroidLogConfig & proto)51 void AndroidLogConfig::FromProto(
52 const perfetto::protos::AndroidLogConfig& proto) {
53 log_ids_.clear();
54 for (const auto& field : proto.log_ids()) {
55 log_ids_.emplace_back();
56 static_assert(sizeof(log_ids_.back()) == sizeof(proto.log_ids(0)),
57 "size mismatch");
58 log_ids_.back() = static_cast<decltype(log_ids_)::value_type>(field);
59 }
60
61 static_assert(sizeof(min_prio_) == sizeof(proto.min_prio()), "size mismatch");
62 min_prio_ = static_cast<decltype(min_prio_)>(proto.min_prio());
63
64 filter_tags_.clear();
65 for (const auto& field : proto.filter_tags()) {
66 filter_tags_.emplace_back();
67 static_assert(sizeof(filter_tags_.back()) == sizeof(proto.filter_tags(0)),
68 "size mismatch");
69 filter_tags_.back() =
70 static_cast<decltype(filter_tags_)::value_type>(field);
71 }
72 unknown_fields_ = proto.unknown_fields();
73 }
74
ToProto(perfetto::protos::AndroidLogConfig * proto) const75 void AndroidLogConfig::ToProto(
76 perfetto::protos::AndroidLogConfig* proto) const {
77 proto->Clear();
78
79 for (const auto& it : log_ids_) {
80 proto->add_log_ids(static_cast<decltype(proto->log_ids(0))>(it));
81 static_assert(sizeof(it) == sizeof(proto->log_ids(0)), "size mismatch");
82 }
83
84 static_assert(sizeof(min_prio_) == sizeof(proto->min_prio()),
85 "size mismatch");
86 proto->set_min_prio(static_cast<decltype(proto->min_prio())>(min_prio_));
87
88 for (const auto& it : filter_tags_) {
89 proto->add_filter_tags(static_cast<decltype(proto->filter_tags(0))>(it));
90 static_assert(sizeof(it) == sizeof(proto->filter_tags(0)), "size mismatch");
91 }
92 *(proto->mutable_unknown_fields()) = unknown_fields_;
93 }
94
95 } // namespace perfetto
96