Bug 1746711 Part 2: Ensure the enqueued surface has a color space. r=gfx-reviewers...
[gecko.git] / intl / components / src / NumberParser.h
blob97efec083679b5928eee6c146e3ab916dab49423
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_NumberParser_h_
5 #define intl_components_NumberParser_h_
7 #include "mozilla/intl/ICUError.h"
8 #include "mozilla/intl/ICU4CGlue.h"
9 #include "mozilla/Span.h"
10 #include "mozilla/UniquePtr.h"
12 #include "unicode/unum.h"
14 namespace mozilla::intl {
16 class NumberParser {
17 public:
18 /**
19 * Initialize a new NumberParser for the provided locale and using the
20 * provided options.
22 static Result<UniquePtr<NumberParser>, ICUError> TryCreate(
23 const char* aLocale, bool aUseGrouping);
25 NumberParser() : mNumberFormat(nullptr){};
26 NumberParser(const NumberParser&) = delete;
27 NumberParser& operator=(const NumberParser&) = delete;
28 ~NumberParser();
30 /**
31 * Attempts to parse a string representing a double, returning the parsed
32 * double and the parse position if successful, or an error.
34 * The parse position is the index into the input string where parsing
35 * stopped because an non-numeric character was encountered.
37 Result<std::pair<double, int32_t>, ICUError> ParseDouble(
38 Span<const char16_t> aDouble) const;
40 private:
41 ICUPointer<UNumberFormat> mNumberFormat;
44 } // namespace mozilla::intl
46 #endif