1 // Generated by the protocol buffer compiler.  DO NOT EDIT!
2 // source: protos/perfetto/trace/power/battery_counters.proto
3 
4 #include "protos/perfetto/trace/power/battery_counters.pb.h"
5 
6 #include <algorithm>
7 #include <cstdint>
8 
9 #include <google/protobuf/io/coded_stream.h>
10 #include <google/protobuf/extension_set.h>
11 #include <google/protobuf/wire_format_lite.h>
12 #include <google/protobuf/io/zero_copy_stream_impl_lite.h>
13 // @@protoc_insertion_point(includes)
14 #include <google/protobuf/port_def.inc>
15 
16 PROTOBUF_PRAGMA_INIT_SEG
17 
18 namespace _pb = ::PROTOBUF_NAMESPACE_ID;
19 namespace _pbi = _pb::internal;
20 
21 namespace perfetto {
22 namespace protos {
BatteryCounters(::_pbi::ConstantInitialized)23 PROTOBUF_CONSTEXPR BatteryCounters::BatteryCounters(
24     ::_pbi::ConstantInitialized): _impl_{
25     /*decltype(_impl_._has_bits_)*/{}
26   , /*decltype(_impl_._cached_size_)*/{}
27   , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
28   , /*decltype(_impl_.charge_counter_uah_)*/::int64_t{0}
29   , /*decltype(_impl_.current_ua_)*/::int64_t{0}
30   , /*decltype(_impl_.current_avg_ua_)*/::int64_t{0}
31   , /*decltype(_impl_.energy_counter_uwh_)*/::int64_t{0}
32   , /*decltype(_impl_.voltage_uv_)*/::int64_t{0}
33   , /*decltype(_impl_.capacity_percent_)*/0} {}
34 struct BatteryCountersDefaultTypeInternal {
BatteryCountersDefaultTypeInternalperfetto::protos::BatteryCountersDefaultTypeInternal35   PROTOBUF_CONSTEXPR BatteryCountersDefaultTypeInternal()
36       : _instance(::_pbi::ConstantInitialized{}) {}
~BatteryCountersDefaultTypeInternalperfetto::protos::BatteryCountersDefaultTypeInternal37   ~BatteryCountersDefaultTypeInternal() {}
38   union {  // NOLINT(misc-non-private-member-variables-in-classes)
39     BatteryCounters _instance;
40   };
41 };
42 PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 BatteryCountersDefaultTypeInternal _BatteryCounters_default_instance_;
43 }  // namespace protos
44 }  // namespace perfetto
45 namespace perfetto {
46 namespace protos {
47 
48 // ===================================================================
49 
50 class BatteryCounters::_Internal {
51  public:
52   using HasBits = decltype(std::declval<BatteryCounters>()._impl_._has_bits_);
set_has_charge_counter_uah(HasBits * has_bits)53   static void set_has_charge_counter_uah(HasBits* has_bits) {
54     (*has_bits)[0] |= 2u;
55   }
set_has_capacity_percent(HasBits * has_bits)56   static void set_has_capacity_percent(HasBits* has_bits) {
57     (*has_bits)[0] |= 64u;
58   }
set_has_current_ua(HasBits * has_bits)59   static void set_has_current_ua(HasBits* has_bits) {
60     (*has_bits)[0] |= 4u;
61   }
set_has_current_avg_ua(HasBits * has_bits)62   static void set_has_current_avg_ua(HasBits* has_bits) {
63     (*has_bits)[0] |= 8u;
64   }
set_has_name(HasBits * has_bits)65   static void set_has_name(HasBits* has_bits) {
66     (*has_bits)[0] |= 1u;
67   }
set_has_energy_counter_uwh(HasBits * has_bits)68   static void set_has_energy_counter_uwh(HasBits* has_bits) {
69     (*has_bits)[0] |= 16u;
70   }
set_has_voltage_uv(HasBits * has_bits)71   static void set_has_voltage_uv(HasBits* has_bits) {
72     (*has_bits)[0] |= 32u;
73   }
74 };
75 
BatteryCounters(::PROTOBUF_NAMESPACE_ID::Arena * arena,bool is_message_owned)76 BatteryCounters::BatteryCounters(::PROTOBUF_NAMESPACE_ID::Arena* arena,
77                          bool is_message_owned)
78   : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) {
79   SharedCtor(arena, is_message_owned);
80   // @@protoc_insertion_point(arena_constructor:perfetto.protos.BatteryCounters)
81 }
BatteryCounters(const BatteryCounters & from)82 BatteryCounters::BatteryCounters(const BatteryCounters& from)
83   : ::PROTOBUF_NAMESPACE_ID::MessageLite() {
84   BatteryCounters* const _this = this; (void)_this;
85   new (&_impl_) Impl_{
86       decltype(_impl_._has_bits_){from._impl_._has_bits_}
87     , /*decltype(_impl_._cached_size_)*/{}
88     , decltype(_impl_.name_){}
89     , decltype(_impl_.charge_counter_uah_){}
90     , decltype(_impl_.current_ua_){}
91     , decltype(_impl_.current_avg_ua_){}
92     , decltype(_impl_.energy_counter_uwh_){}
93     , decltype(_impl_.voltage_uv_){}
94     , decltype(_impl_.capacity_percent_){}};
95 
96   _internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
97   _impl_.name_.InitDefault();
98   #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
99     _impl_.name_.Set("", GetArenaForAllocation());
100   #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
101   if (from._internal_has_name()) {
102     _this->_impl_.name_.Set(from._internal_name(),
103       _this->GetArenaForAllocation());
104   }
105   ::memcpy(&_impl_.charge_counter_uah_, &from._impl_.charge_counter_uah_,
106     static_cast<size_t>(reinterpret_cast<char*>(&_impl_.capacity_percent_) -
107     reinterpret_cast<char*>(&_impl_.charge_counter_uah_)) + sizeof(_impl_.capacity_percent_));
108   // @@protoc_insertion_point(copy_constructor:perfetto.protos.BatteryCounters)
109 }
110 
SharedCtor(::_pb::Arena * arena,bool is_message_owned)111 inline void BatteryCounters::SharedCtor(
112     ::_pb::Arena* arena, bool is_message_owned) {
113   (void)arena;
114   (void)is_message_owned;
115   new (&_impl_) Impl_{
116       decltype(_impl_._has_bits_){}
117     , /*decltype(_impl_._cached_size_)*/{}
118     , decltype(_impl_.name_){}
119     , decltype(_impl_.charge_counter_uah_){::int64_t{0}}
120     , decltype(_impl_.current_ua_){::int64_t{0}}
121     , decltype(_impl_.current_avg_ua_){::int64_t{0}}
122     , decltype(_impl_.energy_counter_uwh_){::int64_t{0}}
123     , decltype(_impl_.voltage_uv_){::int64_t{0}}
124     , decltype(_impl_.capacity_percent_){0}
125   };
126   _impl_.name_.InitDefault();
127   #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
128     _impl_.name_.Set("", GetArenaForAllocation());
129   #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
130 }
131 
~BatteryCounters()132 BatteryCounters::~BatteryCounters() {
133   // @@protoc_insertion_point(destructor:perfetto.protos.BatteryCounters)
134   if (auto *arena = _internal_metadata_.DeleteReturnArena<std::string>()) {
135   (void)arena;
136     return;
137   }
138   SharedDtor();
139 }
140 
SharedDtor()141 inline void BatteryCounters::SharedDtor() {
142   GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
143   _impl_.name_.Destroy();
144 }
145 
SetCachedSize(int size) const146 void BatteryCounters::SetCachedSize(int size) const {
147   _impl_._cached_size_.Set(size);
148 }
149 
Clear()150 void BatteryCounters::Clear() {
151 // @@protoc_insertion_point(message_clear_start:perfetto.protos.BatteryCounters)
152   ::uint32_t cached_has_bits = 0;
153   // Prevent compiler warnings about cached_has_bits being unused
154   (void) cached_has_bits;
155 
156   cached_has_bits = _impl_._has_bits_[0];
157   if (cached_has_bits & 0x00000001u) {
158     _impl_.name_.ClearNonDefaultToEmpty();
159   }
160   if (cached_has_bits & 0x0000007eu) {
161     ::memset(&_impl_.charge_counter_uah_, 0, static_cast<size_t>(
162         reinterpret_cast<char*>(&_impl_.capacity_percent_) -
163         reinterpret_cast<char*>(&_impl_.charge_counter_uah_)) + sizeof(_impl_.capacity_percent_));
164   }
165   _impl_._has_bits_.Clear();
166   _internal_metadata_.Clear<std::string>();
167 }
168 
_InternalParse(const char * ptr,::_pbi::ParseContext * ctx)169 const char* BatteryCounters::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
170 #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
171   _Internal::HasBits has_bits{};
172   while (!ctx->Done(&ptr)) {
173     ::uint32_t tag;
174     ptr = ::_pbi::ReadTag(ptr, &tag);
175     switch (tag >> 3) {
176       // optional int64 charge_counter_uah = 1;
177       case 1:
178         if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 8)) {
179           _Internal::set_has_charge_counter_uah(&has_bits);
180           _impl_.charge_counter_uah_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
181           CHK_(ptr);
182         } else {
183           goto handle_unusual;
184         }
185         continue;
186       // optional float capacity_percent = 2;
187       case 2:
188         if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 21)) {
189           _Internal::set_has_capacity_percent(&has_bits);
190           _impl_.capacity_percent_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<float>(ptr);
191           ptr += sizeof(float);
192         } else {
193           goto handle_unusual;
194         }
195         continue;
196       // optional int64 current_ua = 3;
197       case 3:
198         if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 24)) {
199           _Internal::set_has_current_ua(&has_bits);
200           _impl_.current_ua_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
201           CHK_(ptr);
202         } else {
203           goto handle_unusual;
204         }
205         continue;
206       // optional int64 current_avg_ua = 4;
207       case 4:
208         if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 32)) {
209           _Internal::set_has_current_avg_ua(&has_bits);
210           _impl_.current_avg_ua_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
211           CHK_(ptr);
212         } else {
213           goto handle_unusual;
214         }
215         continue;
216       // optional string name = 5;
217       case 5:
218         if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 42)) {
219           auto str = _internal_mutable_name();
220           ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
221           CHK_(ptr);
222         } else {
223           goto handle_unusual;
224         }
225         continue;
226       // optional int64 energy_counter_uwh = 6;
227       case 6:
228         if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 48)) {
229           _Internal::set_has_energy_counter_uwh(&has_bits);
230           _impl_.energy_counter_uwh_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
231           CHK_(ptr);
232         } else {
233           goto handle_unusual;
234         }
235         continue;
236       // optional int64 voltage_uv = 7;
237       case 7:
238         if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 56)) {
239           _Internal::set_has_voltage_uv(&has_bits);
240           _impl_.voltage_uv_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
241           CHK_(ptr);
242         } else {
243           goto handle_unusual;
244         }
245         continue;
246       default:
247         goto handle_unusual;
248     }  // switch
249   handle_unusual:
250     if ((tag == 0) || ((tag & 7) == 4)) {
251       CHK_(ptr);
252       ctx->SetLastTag(tag);
253       goto message_done;
254     }
255     ptr = UnknownFieldParse(
256         tag,
257         _internal_metadata_.mutable_unknown_fields<std::string>(),
258         ptr, ctx);
259     CHK_(ptr != nullptr);
260   }  // while
261 message_done:
262   _impl_._has_bits_.Or(has_bits);
263   return ptr;
264 failure:
265   ptr = nullptr;
266   goto message_done;
267 #undef CHK_
268 }
269 
_InternalSerialize(::uint8_t * target,::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream * stream) const270 ::uint8_t* BatteryCounters::_InternalSerialize(
271     ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
272   // @@protoc_insertion_point(serialize_to_array_start:perfetto.protos.BatteryCounters)
273   ::uint32_t cached_has_bits = 0;
274   (void) cached_has_bits;
275 
276   cached_has_bits = _impl_._has_bits_[0];
277   // optional int64 charge_counter_uah = 1;
278   if (cached_has_bits & 0x00000002u) {
279     target = stream->EnsureSpace(target);
280     target = ::_pbi::WireFormatLite::WriteInt64ToArray(1, this->_internal_charge_counter_uah(), target);
281   }
282 
283   // optional float capacity_percent = 2;
284   if (cached_has_bits & 0x00000040u) {
285     target = stream->EnsureSpace(target);
286     target = ::_pbi::WireFormatLite::WriteFloatToArray(2, this->_internal_capacity_percent(), target);
287   }
288 
289   // optional int64 current_ua = 3;
290   if (cached_has_bits & 0x00000004u) {
291     target = stream->EnsureSpace(target);
292     target = ::_pbi::WireFormatLite::WriteInt64ToArray(3, this->_internal_current_ua(), target);
293   }
294 
295   // optional int64 current_avg_ua = 4;
296   if (cached_has_bits & 0x00000008u) {
297     target = stream->EnsureSpace(target);
298     target = ::_pbi::WireFormatLite::WriteInt64ToArray(4, this->_internal_current_avg_ua(), target);
299   }
300 
301   // optional string name = 5;
302   if (cached_has_bits & 0x00000001u) {
303     target = stream->WriteStringMaybeAliased(
304         5, this->_internal_name(), target);
305   }
306 
307   // optional int64 energy_counter_uwh = 6;
308   if (cached_has_bits & 0x00000010u) {
309     target = stream->EnsureSpace(target);
310     target = ::_pbi::WireFormatLite::WriteInt64ToArray(6, this->_internal_energy_counter_uwh(), target);
311   }
312 
313   // optional int64 voltage_uv = 7;
314   if (cached_has_bits & 0x00000020u) {
315     target = stream->EnsureSpace(target);
316     target = ::_pbi::WireFormatLite::WriteInt64ToArray(7, this->_internal_voltage_uv(), target);
317   }
318 
319   if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
320     target = stream->WriteRaw(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(),
321         static_cast<int>(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target);
322   }
323   // @@protoc_insertion_point(serialize_to_array_end:perfetto.protos.BatteryCounters)
324   return target;
325 }
326 
ByteSizeLong() const327 size_t BatteryCounters::ByteSizeLong() const {
328 // @@protoc_insertion_point(message_byte_size_start:perfetto.protos.BatteryCounters)
329   size_t total_size = 0;
330 
331   ::uint32_t cached_has_bits = 0;
332   // Prevent compiler warnings about cached_has_bits being unused
333   (void) cached_has_bits;
334 
335   cached_has_bits = _impl_._has_bits_[0];
336   if (cached_has_bits & 0x0000007fu) {
337     // optional string name = 5;
338     if (cached_has_bits & 0x00000001u) {
339       total_size += 1 +
340         ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
341           this->_internal_name());
342     }
343 
344     // optional int64 charge_counter_uah = 1;
345     if (cached_has_bits & 0x00000002u) {
346       total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_charge_counter_uah());
347     }
348 
349     // optional int64 current_ua = 3;
350     if (cached_has_bits & 0x00000004u) {
351       total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_current_ua());
352     }
353 
354     // optional int64 current_avg_ua = 4;
355     if (cached_has_bits & 0x00000008u) {
356       total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_current_avg_ua());
357     }
358 
359     // optional int64 energy_counter_uwh = 6;
360     if (cached_has_bits & 0x00000010u) {
361       total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_energy_counter_uwh());
362     }
363 
364     // optional int64 voltage_uv = 7;
365     if (cached_has_bits & 0x00000020u) {
366       total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_voltage_uv());
367     }
368 
369     // optional float capacity_percent = 2;
370     if (cached_has_bits & 0x00000040u) {
371       total_size += 1 + 4;
372     }
373 
374   }
375   if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
376     total_size += _internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size();
377   }
378   int cached_size = ::_pbi::ToCachedSize(total_size);
379   SetCachedSize(cached_size);
380   return total_size;
381 }
382 
CheckTypeAndMergeFrom(const::PROTOBUF_NAMESPACE_ID::MessageLite & from)383 void BatteryCounters::CheckTypeAndMergeFrom(
384     const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) {
385   MergeFrom(*::_pbi::DownCast<const BatteryCounters*>(
386       &from));
387 }
388 
MergeFrom(const BatteryCounters & from)389 void BatteryCounters::MergeFrom(const BatteryCounters& from) {
390   BatteryCounters* const _this = this;
391   // @@protoc_insertion_point(class_specific_merge_from_start:perfetto.protos.BatteryCounters)
392   GOOGLE_DCHECK_NE(&from, _this);
393   ::uint32_t cached_has_bits = 0;
394   (void) cached_has_bits;
395 
396   cached_has_bits = from._impl_._has_bits_[0];
397   if (cached_has_bits & 0x0000007fu) {
398     if (cached_has_bits & 0x00000001u) {
399       _this->_internal_set_name(from._internal_name());
400     }
401     if (cached_has_bits & 0x00000002u) {
402       _this->_impl_.charge_counter_uah_ = from._impl_.charge_counter_uah_;
403     }
404     if (cached_has_bits & 0x00000004u) {
405       _this->_impl_.current_ua_ = from._impl_.current_ua_;
406     }
407     if (cached_has_bits & 0x00000008u) {
408       _this->_impl_.current_avg_ua_ = from._impl_.current_avg_ua_;
409     }
410     if (cached_has_bits & 0x00000010u) {
411       _this->_impl_.energy_counter_uwh_ = from._impl_.energy_counter_uwh_;
412     }
413     if (cached_has_bits & 0x00000020u) {
414       _this->_impl_.voltage_uv_ = from._impl_.voltage_uv_;
415     }
416     if (cached_has_bits & 0x00000040u) {
417       _this->_impl_.capacity_percent_ = from._impl_.capacity_percent_;
418     }
419     _this->_impl_._has_bits_[0] |= cached_has_bits;
420   }
421   _this->_internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
422 }
423 
CopyFrom(const BatteryCounters & from)424 void BatteryCounters::CopyFrom(const BatteryCounters& from) {
425 // @@protoc_insertion_point(class_specific_copy_from_start:perfetto.protos.BatteryCounters)
426   if (&from == this) return;
427   Clear();
428   MergeFrom(from);
429 }
430 
IsInitialized() const431 bool BatteryCounters::IsInitialized() const {
432   return true;
433 }
434 
InternalSwap(BatteryCounters * other)435 void BatteryCounters::InternalSwap(BatteryCounters* other) {
436   using std::swap;
437   auto* lhs_arena = GetArenaForAllocation();
438   auto* rhs_arena = other->GetArenaForAllocation();
439   _internal_metadata_.InternalSwap(&other->_internal_metadata_);
440   swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
441   ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
442       &_impl_.name_, lhs_arena,
443       &other->_impl_.name_, rhs_arena
444   );
445   ::PROTOBUF_NAMESPACE_ID::internal::memswap<
446       PROTOBUF_FIELD_OFFSET(BatteryCounters, _impl_.capacity_percent_)
447       + sizeof(BatteryCounters::_impl_.capacity_percent_)  // NOLINT
448       - PROTOBUF_FIELD_OFFSET(BatteryCounters, _impl_.charge_counter_uah_)>(
449           reinterpret_cast<char*>(&_impl_.charge_counter_uah_),
450           reinterpret_cast<char*>(&other->_impl_.charge_counter_uah_));
451 }
452 
GetTypeName() const453 std::string BatteryCounters::GetTypeName() const {
454   return "perfetto.protos.BatteryCounters";
455 }
456 
457 
458 // @@protoc_insertion_point(namespace_scope)
459 }  // namespace protos
460 }  // namespace perfetto
461 PROTOBUF_NAMESPACE_OPEN
462 template<> PROTOBUF_NOINLINE ::perfetto::protos::BatteryCounters*
CreateMaybeMessage(Arena * arena)463 Arena::CreateMaybeMessage< ::perfetto::protos::BatteryCounters >(Arena* arena) {
464   return Arena::CreateMessageInternal< ::perfetto::protos::BatteryCounters >(arena);
465 }
466 PROTOBUF_NAMESPACE_CLOSE
467 
468 // @@protoc_insertion_point(global_scope)
469 #include <google/protobuf/port_undef.inc>
470