tor-browser

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

Bidi.d.hpp (4191B)


      1 #ifndef icu4x_Bidi_D_HPP
      2 #define icu4x_Bidi_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 Bidi; }
     16 class Bidi;
     17 namespace capi { struct BidiInfo; }
     18 class BidiInfo;
     19 namespace capi { struct DataProvider; }
     20 class DataProvider;
     21 namespace capi { struct ReorderedIndexMap; }
     22 class ReorderedIndexMap;
     23 class DataError;
     24 }
     25 
     26 
     27 namespace icu4x {
     28 namespace capi {
     29    struct Bidi;
     30 } // namespace capi
     31 } // namespace
     32 
     33 namespace icu4x {
     34 /**
     35 * An ICU4X Bidi object, containing loaded bidi data
     36 *
     37 * See the [Rust documentation for `BidiClass`](https://docs.rs/icu/latest/icu/properties/props/struct.BidiClass.html) for more information.
     38 */
     39 class Bidi {
     40 public:
     41 
     42  /**
     43   * Creates a new [`Bidi`] from locale data using compiled data.
     44   */
     45  inline static std::unique_ptr<icu4x::Bidi> create();
     46 
     47  /**
     48   * Creates a new [`Bidi`] from locale data, and a particular data source.
     49   */
     50  inline static diplomat::result<std::unique_ptr<icu4x::Bidi>, icu4x::DataError> create_with_provider(const icu4x::DataProvider& provider);
     51 
     52  /**
     53   * Use the data loaded in this object to process a string and calculate bidi information
     54   *
     55   * Takes in a Level for the default level, if it is an invalid value or None it will default to Auto.
     56   *
     57   * Returns nothing if `text` is invalid UTF-8.
     58   *
     59   * See the [Rust documentation for `new_with_data_source`](https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.BidiInfo.html#method.new_with_data_source) for more information.
     60   */
     61  inline std::unique_ptr<icu4x::BidiInfo> for_text(std::string_view text, std::optional<uint8_t> default_level) const;
     62 
     63  /**
     64   * Utility function for producing reorderings given a list of levels
     65   *
     66   * Produces a map saying which visual index maps to which source index.
     67   *
     68   * The levels array must not have values greater than 126 (this is the
     69   * Bidi maximum explicit depth plus one).
     70   * Failure to follow this invariant may lead to incorrect results,
     71   * but is still safe.
     72   *
     73   * See the [Rust documentation for `reorder_visual`](https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.BidiInfo.html#method.reorder_visual) for more information.
     74   */
     75  inline std::unique_ptr<icu4x::ReorderedIndexMap> reorder_visual(diplomat::span<const uint8_t> levels) const;
     76 
     77  /**
     78   * Check if a Level returned by level_at is an RTL level.
     79   *
     80   * Invalid levels (numbers greater than 125) will be assumed LTR
     81   *
     82   * See the [Rust documentation for `is_rtl`](https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.Level.html#method.is_rtl) for more information.
     83   */
     84  inline static bool level_is_rtl(uint8_t level);
     85 
     86  /**
     87   * Check if a Level returned by level_at is an LTR level.
     88   *
     89   * Invalid levels (numbers greater than 125) will be assumed LTR
     90   *
     91   * See the [Rust documentation for `is_ltr`](https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.Level.html#method.is_ltr) for more information.
     92   */
     93  inline static bool level_is_ltr(uint8_t level);
     94 
     95  /**
     96   * Get a basic RTL Level value
     97   *
     98   * See the [Rust documentation for `rtl`](https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.Level.html#method.rtl) for more information.
     99   */
    100  inline static uint8_t level_rtl();
    101 
    102  /**
    103   * Get a simple LTR Level value
    104   *
    105   * See the [Rust documentation for `ltr`](https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.Level.html#method.ltr) for more information.
    106   */
    107  inline static uint8_t level_ltr();
    108 
    109  inline const icu4x::capi::Bidi* AsFFI() const;
    110  inline icu4x::capi::Bidi* AsFFI();
    111  inline static const icu4x::Bidi* FromFFI(const icu4x::capi::Bidi* ptr);
    112  inline static icu4x::Bidi* FromFFI(icu4x::capi::Bidi* ptr);
    113  inline static void operator delete(void* ptr);
    114 private:
    115  Bidi() = delete;
    116  Bidi(const icu4x::Bidi&) = delete;
    117  Bidi(icu4x::Bidi&&) noexcept = delete;
    118  Bidi operator=(const icu4x::Bidi&) = delete;
    119  Bidi operator=(icu4x::Bidi&&) noexcept = delete;
    120  static void operator delete[](void*, size_t) = delete;
    121 };
    122 
    123 } // namespace
    124 #endif // icu4x_Bidi_D_HPP