Debian Codegraph @

intl/components/src/NumberPart.h

raw
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 #ifndef intl_components_NumberPart_h_
5 #define intl_components_NumberPart_h_
6
7 #include <cstddef>
8 #include <cstdint>
9
10 #include "mozilla/Vector.h"
11
12 namespace mozilla::intl {
13
14 enum class NumberPartType : int16_t {
15 ApproximatelySign,
16 Compact,
17 Currency,
18 Decimal,
19 ExponentInteger,
20 ExponentMinusSign,
21 ExponentSeparator,
22 Fraction,
23 Group,
24 Infinity,
25 Integer,
26 Literal,
27 MinusSign,
28 Nan,
29 Percent,
30 PlusSign,
31 Unit,
32 };
33
34 enum class NumberPartSource : int16_t { Shared, Start, End };
35
36 // Because parts fully partition the formatted string, we only track the
37 // index of the end of each part -- the beginning is implicitly the last
38 // part's end.
39 struct NumberPart {
40 NumberPartType type;
41 NumberPartSource source;
42 size_t endIndex;
43
44 bool operator==(const NumberPart& rhs) const {
45 return type == rhs.type && source == rhs.source && endIndex == rhs.endIndex;
46 }
47 bool operator!=(const NumberPart& rhs) const { return !(*this == rhs); }
48 };
49
50 using NumberPartVector = mozilla::Vector<NumberPart, 8>;
51
52 } // namespace mozilla::intl
53 #endif