tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

Locale.d.hpp (6355B)


      1 #ifndef icu4x_Locale_D_HPP
      2 #define icu4x_Locale_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 Locale; }
     16 class Locale;
     17 class LocaleParseError;
     18 }
     19 
     20 
     21 namespace icu4x {
     22 namespace capi {
     23    struct Locale;
     24 } // namespace capi
     25 } // namespace
     26 
     27 namespace icu4x {
     28 /**
     29 * An ICU4X Locale, capable of representing strings like `"en-US"`.
     30 *
     31 * See the [Rust documentation for `Locale`](https://docs.rs/icu/latest/icu/locale/struct.Locale.html) for more information.
     32 */
     33 class Locale {
     34 public:
     35 
     36  /**
     37   * Construct an [`Locale`] from an locale identifier.
     38   *
     39   * This will run the complete locale parsing algorithm. If code size and
     40   * performance are critical and the locale is of a known shape (such as
     41   * `aa-BB`) use `create_und`, `set_language`, `set_script`, and `set_region`.
     42   *
     43   * See the [Rust documentation for `try_from_str`](https://docs.rs/icu/latest/icu/locale/struct.Locale.html#method.try_from_str) for more information.
     44   */
     45  inline static diplomat::result<std::unique_ptr<icu4x::Locale>, icu4x::LocaleParseError> from_string(std::string_view name);
     46 
     47  /**
     48   * Construct a unknown [`Locale`] "und".
     49   *
     50   * See the [Rust documentation for `UNKNOWN`](https://docs.rs/icu/latest/icu/locale/struct.Locale.html#associatedconstant.UNKNOWN) for more information.
     51   */
     52  inline static std::unique_ptr<icu4x::Locale> unknown();
     53 
     54  /**
     55   * Clones the [`Locale`].
     56   *
     57   * See the [Rust documentation for `Locale`](https://docs.rs/icu/latest/icu/locale/struct.Locale.html) for more information.
     58   */
     59  inline std::unique_ptr<icu4x::Locale> clone() const;
     60 
     61  /**
     62   * Returns a string representation of the `LanguageIdentifier` part of
     63   * [`Locale`].
     64   *
     65   * See the [Rust documentation for `id`](https://docs.rs/icu/latest/icu/locale/struct.Locale.html#structfield.id) for more information.
     66   */
     67  inline std::string basename() const;
     68 
     69  /**
     70   * Returns a string representation of the unicode extension.
     71   *
     72   * See the [Rust documentation for `extensions`](https://docs.rs/icu/latest/icu/locale/struct.Locale.html#structfield.extensions) for more information.
     73   */
     74  inline std::optional<std::string> get_unicode_extension(std::string_view s) const;
     75 
     76  /**
     77   * Returns a string representation of [`Locale`] language.
     78   *
     79   * See the [Rust documentation for `id`](https://docs.rs/icu/latest/icu/locale/struct.Locale.html#structfield.id) for more information.
     80   */
     81  inline std::string language() const;
     82 
     83  /**
     84   * Set the language part of the [`Locale`].
     85   *
     86   * See the [Rust documentation for `try_from_str`](https://docs.rs/icu/latest/icu/locale/struct.Locale.html#method.try_from_str) for more information.
     87   */
     88  inline diplomat::result<std::monostate, icu4x::LocaleParseError> set_language(std::string_view s);
     89 
     90  /**
     91   * Returns a string representation of [`Locale`] region.
     92   *
     93   * See the [Rust documentation for `id`](https://docs.rs/icu/latest/icu/locale/struct.Locale.html#structfield.id) for more information.
     94   */
     95  inline std::optional<std::string> region() const;
     96 
     97  /**
     98   * Set the region part of the [`Locale`].
     99   *
    100   * See the [Rust documentation for `try_from_str`](https://docs.rs/icu/latest/icu/locale/struct.Locale.html#method.try_from_str) for more information.
    101   */
    102  inline diplomat::result<std::monostate, icu4x::LocaleParseError> set_region(std::string_view s);
    103 
    104  /**
    105   * Returns a string representation of [`Locale`] script.
    106   *
    107   * See the [Rust documentation for `id`](https://docs.rs/icu/latest/icu/locale/struct.Locale.html#structfield.id) for more information.
    108   */
    109  inline std::optional<std::string> script() const;
    110 
    111  /**
    112   * Set the script part of the [`Locale`]. Pass an empty string to remove the script.
    113   *
    114   * See the [Rust documentation for `try_from_str`](https://docs.rs/icu/latest/icu/locale/struct.Locale.html#method.try_from_str) for more information.
    115   */
    116  inline diplomat::result<std::monostate, icu4x::LocaleParseError> set_script(std::string_view s);
    117 
    118  /**
    119   * Normalizes a locale string.
    120   *
    121   * See the [Rust documentation for `normalize`](https://docs.rs/icu/latest/icu/locale/struct.Locale.html#method.normalize) for more information.
    122   */
    123  inline static diplomat::result<std::string, icu4x::LocaleParseError> normalize(std::string_view s);
    124 
    125  /**
    126   * Returns a string representation of [`Locale`].
    127   *
    128   * See the [Rust documentation for `write_to`](https://docs.rs/icu/latest/icu/locale/struct.Locale.html#method.write_to) for more information.
    129   */
    130  inline std::string to_string() const;
    131 
    132  /**
    133   * See the [Rust documentation for `normalizing_eq`](https://docs.rs/icu/latest/icu/locale/struct.Locale.html#method.normalizing_eq) for more information.
    134   */
    135  inline bool normalizing_eq(std::string_view other) const;
    136 
    137  /**
    138   * See the [Rust documentation for `strict_cmp`](https://docs.rs/icu/latest/icu/locale/struct.Locale.html#method.strict_cmp) for more information.
    139   */
    140  inline int8_t compare_to_string(std::string_view other) const;
    141 
    142  /**
    143   * See the [Rust documentation for `total_cmp`](https://docs.rs/icu/latest/icu/locale/struct.Locale.html#method.total_cmp) for more information.
    144   */
    145  inline int8_t compare_to(const icu4x::Locale& other) const;
    146  inline bool operator==(const icu4x::Locale& other) const;
    147  inline bool operator!=(const icu4x::Locale& other) const;
    148  inline bool operator<=(const icu4x::Locale& other) const;
    149  inline bool operator>=(const icu4x::Locale& other) const;
    150  inline bool operator<(const icu4x::Locale& other) const;
    151  inline bool operator>(const icu4x::Locale& other) const;
    152 
    153  inline const icu4x::capi::Locale* AsFFI() const;
    154  inline icu4x::capi::Locale* AsFFI();
    155  inline static const icu4x::Locale* FromFFI(const icu4x::capi::Locale* ptr);
    156  inline static icu4x::Locale* FromFFI(icu4x::capi::Locale* ptr);
    157  inline static void operator delete(void* ptr);
    158 private:
    159  Locale() = delete;
    160  Locale(const icu4x::Locale&) = delete;
    161  Locale(icu4x::Locale&&) noexcept = delete;
    162  Locale operator=(const icu4x::Locale&) = delete;
    163  Locale operator=(icu4x::Locale&&) noexcept = delete;
    164  static void operator delete[](void*, size_t) = delete;
    165 };
    166 
    167 } // namespace
    168 #endif // icu4x_Locale_D_HPP