diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /intl/components/src/NumberPart.h | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'intl/components/src/NumberPart.h')
-rw-r--r-- | intl/components/src/NumberPart.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/intl/components/src/NumberPart.h b/intl/components/src/NumberPart.h new file mode 100644 index 0000000000..8639db5768 --- /dev/null +++ b/intl/components/src/NumberPart.h @@ -0,0 +1,53 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef intl_components_NumberPart_h_ +#define intl_components_NumberPart_h_ + +#include <cstddef> +#include <cstdint> + +#include "mozilla/Vector.h" + +namespace mozilla::intl { + +enum class NumberPartType : int16_t { + ApproximatelySign, + Compact, + Currency, + Decimal, + ExponentInteger, + ExponentMinusSign, + ExponentSeparator, + Fraction, + Group, + Infinity, + Integer, + Literal, + MinusSign, + Nan, + Percent, + PlusSign, + Unit, +}; + +enum class NumberPartSource : int16_t { Shared, Start, End }; + +// Because parts fully partition the formatted string, we only track the +// index of the end of each part -- the beginning is implicitly the last +// part's end. +struct NumberPart { + NumberPartType type; + NumberPartSource source; + size_t endIndex; + + bool operator==(const NumberPart& rhs) const { + return type == rhs.type && source == rhs.source && endIndex == rhs.endIndex; + } + bool operator!=(const NumberPart& rhs) const { return !(*this == rhs); } +}; + +using NumberPartVector = mozilla::Vector<NumberPart, 8>; + +} // namespace mozilla::intl +#endif |