| // services/network/public/mojom/ip_address.mojom.h is auto generated by mojom_bindings_generator.py, do not edit |
| |
| // Copyright 2013 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #ifndef SERVICES_NETWORK_PUBLIC_MOJOM_IP_ADDRESS_MOJOM_H_ |
| #define SERVICES_NETWORK_PUBLIC_MOJOM_IP_ADDRESS_MOJOM_H_ |
| |
| #include <stdint.h> |
| |
| #include <limits> |
| #include <type_traits> |
| #include <utility> |
| |
| #include "third_party/abseil-cpp/absl/types/optional.h" |
| #include "mojo/public/cpp/bindings/clone_traits.h" |
| #include "mojo/public/cpp/bindings/equals_traits.h" |
| #include "mojo/public/cpp/bindings/lib/serialization.h" |
| #include "mojo/public/cpp/bindings/struct_ptr.h" |
| #include "mojo/public/cpp/bindings/struct_traits.h" |
| #include "mojo/public/cpp/bindings/union_traits.h" |
| |
| #include "third_party/perfetto/include/perfetto/tracing/traced_value_forward.h" |
| |
| #include "services/network/public/mojom/ip_address.mojom-shared.h" |
| #include "services/network/public/mojom/ip_address.mojom-forward.h" |
| #include <string> |
| #include <vector> |
| |
| |
| |
| |
| #include "services/network/public/cpp/ip_address_mojom_traits.h" |
| |
| #ifdef KYTHE_IS_RUNNING |
| #pragma kythe_inline_metadata "Metadata comment" |
| #endif |
| |
| |
| namespace network { |
| namespace mojom { |
| |
| |
| |
| |
| |
| |
| |
| |
| // @generated_from: network.mojom.IPAddress |
| class IPAddress { |
| public: |
| template <typename T> |
| using EnableIfSame = std::enable_if_t<std::is_same<IPAddress, T>::value>; |
| using DataView = IPAddressDataView; |
| using Data_ = internal::IPAddress_Data; |
| |
| template <typename... Args> |
| static IPAddressPtr New(Args&&... args) { |
| return IPAddressPtr( |
| absl::in_place, std::forward<Args>(args)...); |
| } |
| |
| template <typename U> |
| static IPAddressPtr From(const U& u) { |
| return mojo::TypeConverter<IPAddressPtr, U>::Convert(u); |
| } |
| |
| template <typename U> |
| U To() const { |
| return mojo::TypeConverter<U, IPAddress>::Convert(*this); |
| } |
| |
| |
| IPAddress(); |
| |
| explicit IPAddress( |
| std::vector<uint8_t> address_bytes); |
| |
| |
| ~IPAddress(); |
| |
| // Clone() is a template so it is only instantiated if it is used. Thus, the |
| // bindings generator does not need to know whether Clone() or copy |
| // constructor/assignment are available for members. |
| template <typename StructPtrType = IPAddressPtr> |
| IPAddressPtr Clone() const; |
| |
| // Equals() is a template so it is only instantiated if it is used. Thus, the |
| // bindings generator does not need to know whether Equals() or == operator |
| // are available for members. |
| template <typename T, IPAddress::EnableIfSame<T>* = nullptr> |
| bool Equals(const T& other) const; |
| |
| template <typename T, IPAddress::EnableIfSame<T>* = nullptr> |
| bool operator==(const T& rhs) const { return Equals(rhs); } |
| template <typename UserType> |
| static std::vector<uint8_t> Serialize(UserType* input) { |
| return mojo::internal::SerializeImpl< |
| IPAddress::DataView, std::vector<uint8_t>>(input); |
| } |
| |
| template <typename UserType> |
| static mojo::Message SerializeAsMessage(UserType* input) { |
| return mojo::internal::SerializeAsMessageImpl< |
| IPAddress::DataView>(input); |
| } |
| |
| // The returned Message is serialized only if the message is moved |
| // cross-process or cross-language. Otherwise if the message is Deserialized |
| // as the same UserType |input| will just be moved to |output| in |
| // DeserializeFromMessage. |
| template <typename UserType> |
| static mojo::Message WrapAsMessage(UserType input) { |
| return mojo::Message(std::make_unique< |
| internal::IPAddress_UnserializedMessageContext< |
| UserType, IPAddress::DataView>>(0, 0, std::move(input)), |
| MOJO_CREATE_MESSAGE_FLAG_NONE); |
| } |
| |
| template <typename UserType> |
| static bool Deserialize(const void* data, |
| size_t data_num_bytes, |
| UserType* output) { |
| mojo::Message message; |
| return mojo::internal::DeserializeImpl<IPAddress::DataView>( |
| message, data, data_num_bytes, output, Validate); |
| } |
| |
| template <typename UserType> |
| static bool Deserialize(const std::vector<uint8_t>& input, |
| UserType* output) { |
| return IPAddress::Deserialize( |
| input.size() == 0 ? nullptr : &input.front(), input.size(), output); |
| } |
| |
| template <typename UserType> |
| static bool DeserializeFromMessage(mojo::Message input, |
| UserType* output) { |
| auto context = input.TakeUnserializedContext< |
| internal::IPAddress_UnserializedMessageContext< |
| UserType, IPAddress::DataView>>(); |
| if (context) { |
| *output = std::move(context->TakeData()); |
| return true; |
| } |
| input.SerializeIfNecessary(); |
| return mojo::internal::DeserializeImpl<IPAddress::DataView>( |
| input, input.payload(), input.payload_num_bytes(), output, Validate); |
| } |
| |
| |
| // @generated_from: network.mojom.IPAddress.address_bytes |
| std::vector<uint8_t> address_bytes; |
| |
| // Serialise this struct into a trace. |
| void WriteIntoTrace(perfetto::TracedValue traced_context) const; |
| |
| private: |
| static bool Validate(const void* data, |
| mojo::internal::ValidationContext* validation_context); |
| }; |
| |
| // The comparison operators are templates, so they are only instantiated if they |
| // are used. Thus, the bindings generator does not need to know whether |
| // comparison operators are available for members. |
| template <typename T, IPAddress::EnableIfSame<T>* = nullptr> |
| bool operator<(const T& lhs, const T& rhs); |
| |
| template <typename T, IPAddress::EnableIfSame<T>* = nullptr> |
| bool operator<=(const T& lhs, const T& rhs) { |
| return !(rhs < lhs); |
| } |
| |
| template <typename T, IPAddress::EnableIfSame<T>* = nullptr> |
| bool operator>(const T& lhs, const T& rhs) { |
| return rhs < lhs; |
| } |
| |
| template <typename T, IPAddress::EnableIfSame<T>* = nullptr> |
| bool operator>=(const T& lhs, const T& rhs) { |
| return !(lhs < rhs); |
| } |
| |
| template <typename StructPtrType> |
| IPAddressPtr IPAddress::Clone() const { |
| return New( |
| mojo::Clone(address_bytes) |
| ); |
| } |
| |
| template <typename T, IPAddress::EnableIfSame<T>*> |
| bool IPAddress::Equals(const T& other_struct) const { |
| if (!mojo::Equals(this->address_bytes, other_struct.address_bytes)) |
| return false; |
| return true; |
| } |
| |
| template <typename T, IPAddress::EnableIfSame<T>*> |
| bool operator<(const T& lhs, const T& rhs) { |
| if (lhs.address_bytes < rhs.address_bytes) |
| return true; |
| if (rhs.address_bytes < lhs.address_bytes) |
| return false; |
| return false; |
| } |
| |
| |
| } // namespace mojom |
| } // namespace network |
| |
| namespace mojo { |
| |
| |
| template <> |
| struct StructTraits<::network::mojom::IPAddress::DataView, |
| ::network::mojom::IPAddressPtr> { |
| static bool IsNull(const ::network::mojom::IPAddressPtr& input) { return !input; } |
| static void SetToNull(::network::mojom::IPAddressPtr* output) { output->reset(); } |
| |
| static const decltype(::network::mojom::IPAddress::address_bytes)& address_bytes( |
| const ::network::mojom::IPAddressPtr& input) { |
| return input->address_bytes; |
| } |
| |
| static bool Read(::network::mojom::IPAddress::DataView input, ::network::mojom::IPAddressPtr* output); |
| }; |
| |
| } // namespace mojo |
| |
| #endif // SERVICES_NETWORK_PUBLIC_MOJOM_IP_ADDRESS_MOJOM_H_ |
| |
| /* Metadata comment |
| eyJtZXRhIjogW3siZW5kIjogMTM1OCwgImJlZ2luIjogMTM0OSwgImVkZ2UiOiAiJS9reXRoZS9l |
| ZGdlL2dlbmVyYXRlcyIsICJ0eXBlIjogImFuY2hvcl9kZWZpbmVzIiwgInZuYW1lIjogeyJjb3Jw |
| dXMiOiAiY2hyb21pdW0uZ29vZ2xlc291cmNlLmNvbS9jaHJvbWl1bS9zcmMiLCAibGFuZ3VhZ2Ui |
| OiAibW9qb20iLCAic2lnbmF0dXJlIjogIm5ldHdvcmsubW9qb20uSVBBZGRyZXNzIn19LCB7ImVu |
| ZCI6IDQ5MjYsICJiZWdpbiI6IDQ5MTMsICJlZGdlIjogIiUva3l0aGUvZWRnZS9nZW5lcmF0ZXMi |
| LCAidHlwZSI6ICJhbmNob3JfZGVmaW5lcyIsICJ2bmFtZSI6IHsiY29ycHVzIjogImNocm9taXVt |
| Lmdvb2dsZXNvdXJjZS5jb20vY2hyb21pdW0vc3JjIiwgImxhbmd1YWdlIjogIm1vam9tIiwgInNp |
| Z25hdHVyZSI6ICJuZXR3b3JrLm1vam9tLklQQWRkcmVzcy5hZGRyZXNzX2J5dGVzIn19XSwgInR5 |
| cGUiOiAia3l0aGUwIn0= |
| */ |