/* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @addtogroup NdkBinder * @{ */ /** * @file binder_to_string.h * @brief Helper for parcelable. */ #pragma once #include #include #include #include #include #include #include #if __has_include() #include #define HAS_STRONG_POINTER #endif #if __has_include() #include #define HAS_STRING16 #endif #if __has_include() #include #include #include #define HAS_NDK_INTERFACE #else #include #include #include #include #endif //_has_include namespace android { namespace internal { // ToString is a utility to generate string representation for various AIDL-supported types. template std::string ToString(const _T& t); namespace details { // Truthy if _T has toString() method. template class HasToStringMethod { template static auto _test(int) -> decltype(std::declval<_U>().toString(), std::true_type()); template static std::false_type _test(...); public: enum { value = decltype(_test<_T>(0))::value }; }; // Truthy if _T has a overloaded toString(T) template class HasToStringFunction { template static auto _test(int) -> decltype(toString(std::declval<_U>()), std::true_type()); template static std::false_type _test(...); public: enum { value = decltype(_test<_T>(0))::value }; }; template typename U> struct IsInstantiationOf : std::false_type {}; template