/** * Copyright (c) 2015-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #pragma once #include #include #include #include #include #include #include namespace facebook { namespace react { SharedDebugStringConvertibleList operator+(const SharedDebugStringConvertibleList &lhs, const SharedDebugStringConvertibleList &rhs); SharedDebugStringConvertible debugStringConvertibleItem(std::string name, DebugStringConvertible value, std::string defaultValue = ""); #define IS_EQUAL(a, b) ((a) == (b)) #define IS_EQUAL_FLOAT(a, b) ((isnan(a) == isnan(b)) || ((a) == (b))) #define DEBUG_STRING_CONVERTIBLE_TEMPLATE(type, converter) \ DEBUG_STRING_CONVERTIBLE_TEMPLATE_EX(type, converter, {}, IS_EQUAL) #define DEBUG_STRING_CONVERTIBLE_TEMPLATE_EX(type, converter, defaults, comparator) \ inline SharedDebugStringConvertible debugStringConvertibleItem(std::string name, type value, type defaultValue = defaults) { \ if (comparator(value, defaultValue)) { \ return nullptr; \ } \ return std::make_shared(name, converter(value)); \ } \ \ inline SharedDebugStringConvertible debugStringConvertibleItem(std::string name, folly::Optional value, type defaultValue = defaults) { \ if (value.has_value()) { \ return nullptr; \ } \ return debugStringConvertibleItem(name, value.value_or(defaultValue), defaultValue); \ } DEBUG_STRING_CONVERTIBLE_TEMPLATE(std::string, ) DEBUG_STRING_CONVERTIBLE_TEMPLATE(int, folly::to) DEBUG_STRING_CONVERTIBLE_TEMPLATE(bool, folly::to) DEBUG_STRING_CONVERTIBLE_TEMPLATE_EX(float, folly::to, std::numeric_limits::quiet_NaN(), IS_EQUAL_FLOAT) DEBUG_STRING_CONVERTIBLE_TEMPLATE_EX(double, folly::to, std::numeric_limits::quiet_NaN(), IS_EQUAL_FLOAT) } // namespace react } // namespace facebook