UnitsConverterFactory.d.hpp (3380B)
1 #ifndef icu4x_UnitsConverterFactory_D_HPP 2 #define icu4x_UnitsConverterFactory_D_HPP 3 4 #include <stdio.h> 5 #include <stdint.h> 6 #include <stddef.h> 7 #include <stdbool.h> 8 #include <memory> 9 #include <functional> 10 #include <optional> 11 #include <cstdlib> 12 #include "../diplomat_runtime.hpp" 13 14 namespace icu4x { 15 namespace capi { struct DataProvider; } 16 class DataProvider; 17 namespace capi { struct MeasureUnit; } 18 class MeasureUnit; 19 namespace capi { struct UnitsConverter; } 20 class UnitsConverter; 21 namespace capi { struct UnitsConverterFactory; } 22 class UnitsConverterFactory; 23 class DataError; 24 } 25 26 27 namespace icu4x { 28 namespace capi { 29 struct UnitsConverterFactory; 30 } // namespace capi 31 } // namespace 32 33 namespace icu4x { 34 /** 35 * An ICU4X Units Converter Factory object, capable of creating converters a [`UnitsConverter`] 36 * for converting between two [`MeasureUnit`]s. 37 * 38 * Also, it can parse the CLDR unit identifier (e.g. `meter-per-square-second`) and get the [`MeasureUnit`]. 39 * 40 * See the [Rust documentation for `ConverterFactory`](https://docs.rs/icu/latest/icu/experimental/units/converter_factory/struct.ConverterFactory.html) for more information. 41 */ 42 class UnitsConverterFactory { 43 public: 44 45 /** 46 * Construct a new [`UnitsConverterFactory`] instance using compiled data. 47 * 48 * See the [Rust documentation for `new`](https://docs.rs/icu/latest/icu/experimental/units/converter_factory/struct.ConverterFactory.html#method.new) for more information. 49 */ 50 inline static std::unique_ptr<icu4x::UnitsConverterFactory> create(); 51 52 /** 53 * Construct a new [`UnitsConverterFactory`] instance using a particular data source. 54 * 55 * See the [Rust documentation for `new`](https://docs.rs/icu/latest/icu/experimental/units/converter_factory/struct.ConverterFactory.html#method.new) for more information. 56 */ 57 inline static diplomat::result<std::unique_ptr<icu4x::UnitsConverterFactory>, icu4x::DataError> create_with_provider(const icu4x::DataProvider& provider); 58 59 /** 60 * Creates a new [`UnitsConverter`] from the input and output [`MeasureUnit`]s. 61 * Returns nothing if the conversion between the two units is not possible. 62 * For example, conversion between `meter` and `second` is not possible. 63 * 64 * See the [Rust documentation for `converter`](https://docs.rs/icu/latest/icu/experimental/units/converter_factory/struct.ConverterFactory.html#method.converter) for more information. 65 */ 66 inline std::unique_ptr<icu4x::UnitsConverter> converter(const icu4x::MeasureUnit& from, const icu4x::MeasureUnit& to) const; 67 68 inline const icu4x::capi::UnitsConverterFactory* AsFFI() const; 69 inline icu4x::capi::UnitsConverterFactory* AsFFI(); 70 inline static const icu4x::UnitsConverterFactory* FromFFI(const icu4x::capi::UnitsConverterFactory* ptr); 71 inline static icu4x::UnitsConverterFactory* FromFFI(icu4x::capi::UnitsConverterFactory* ptr); 72 inline static void operator delete(void* ptr); 73 private: 74 UnitsConverterFactory() = delete; 75 UnitsConverterFactory(const icu4x::UnitsConverterFactory&) = delete; 76 UnitsConverterFactory(icu4x::UnitsConverterFactory&&) noexcept = delete; 77 UnitsConverterFactory operator=(const icu4x::UnitsConverterFactory&) = delete; 78 UnitsConverterFactory operator=(icu4x::UnitsConverterFactory&&) noexcept = delete; 79 static void operator delete[](void*, size_t) = delete; 80 }; 81 82 } // namespace 83 #endif // icu4x_UnitsConverterFactory_D_HPP