1/*
2 * Copyright (C) 2016 The Qt Company Ltd.
3 * Copyright (c) Meta Platforms, Inc. and affiliates.
4 *
5 * SPDX-License-Identifier: MIT
6 */
7
8#pragma once
9
10#include <yoga/YGEnums.h>
11#include <yoga/YGMacros.h>
12
13QT_YOGA_NAMESPACE_BEGIN
14
15YG_EXTERN_C_BEGIN
16
17typedef struct YGValue {
18 float value;
19 YGUnit unit;
20} YGValue;
21
22YOGA_EXPORT extern const YGValue YGValueAuto;
23YOGA_EXPORT extern const YGValue YGValueUndefined;
24YOGA_EXPORT extern const YGValue YGValueZero;
25
26YG_EXTERN_C_END
27
28QT_YOGA_NAMESPACE_END
29
30#ifdef __cplusplus
31#include <limits>
32QT_YOGA_NAMESPACE_BEGIN
33constexpr float YGUndefined = std::numeric_limits<float>::quiet_NaN();
34#else
35#include <math.h>
36QT_YOGA_NAMESPACE_BEGIN
37#define YGUndefined NAN
38#endif
39
40#ifdef __cplusplus
41inline bool operator==(const YGValue& lhs, const YGValue& rhs) {
42 if (lhs.unit != rhs.unit) {
43 return false;
44 }
45
46 switch (lhs.unit) {
47 case YGUnitUndefined:
48 case YGUnitAuto:
49 return true;
50 case YGUnitPoint:
51 case YGUnitPercent:
52 return lhs.value == rhs.value;
53 }
54
55 return false;
56}
57
58inline bool operator!=(const YGValue& lhs, const YGValue& rhs) {
59 return !(lhs == rhs);
60}
61
62inline YGValue operator-(const YGValue& value) {
63 return {.value: -value.value, .unit: value.unit};
64}
65#endif
66
67QT_YOGA_NAMESPACE_END
68

source code of qtdeclarative/src/3rdparty/yoga/YGValue.h