BidiParagraph.d.hpp (3201B)
1 #ifndef icu4x_BidiParagraph_D_HPP 2 #define icu4x_BidiParagraph_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 class BidiDirection; 16 } 17 18 19 namespace icu4x { 20 namespace capi { 21 struct BidiParagraph; 22 } // namespace capi 23 } // namespace 24 25 namespace icu4x { 26 /** 27 * Bidi information for a single processed paragraph 28 */ 29 class BidiParagraph { 30 public: 31 32 /** 33 * Given a paragraph index `n` within the surrounding text, this sets this 34 * object to the paragraph at that index. Returns nothing when out of bounds. 35 * 36 * This is equivalent to calling `paragraph_at()` on `BidiInfo` but doesn't 37 * create a new object 38 */ 39 inline bool set_paragraph_in_text(size_t n); 40 41 /** 42 * The primary direction of this paragraph 43 * 44 * See the [Rust documentation for `level_at`](https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.Paragraph.html#method.level_at) for more information. 45 */ 46 inline icu4x::BidiDirection direction() const; 47 48 /** 49 * The number of bytes in this paragraph 50 * 51 * See the [Rust documentation for `len`](https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.ParagraphInfo.html#method.len) for more information. 52 */ 53 inline size_t size() const; 54 55 /** 56 * The start index of this paragraph within the source text 57 */ 58 inline size_t range_start() const; 59 60 /** 61 * The end index of this paragraph within the source text 62 */ 63 inline size_t range_end() const; 64 65 /** 66 * Reorder a line based on display order. The ranges are specified relative to the source text and must be contained 67 * within this paragraph's range. 68 * 69 * See the [Rust documentation for `level_at`](https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.Paragraph.html#method.level_at) for more information. 70 */ 71 inline std::optional<std::string> reorder_line(size_t range_start, size_t range_end) const; 72 73 /** 74 * Get the BIDI level at a particular byte index in this paragraph. 75 * This integer is conceptually a `unicode_bidi::Level`, 76 * and can be further inspected using the static methods on Bidi. 77 * 78 * Returns 0 (equivalent to `Level::ltr()`) on error 79 * 80 * See the [Rust documentation for `level_at`](https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.Paragraph.html#method.level_at) for more information. 81 */ 82 inline uint8_t level_at(size_t pos) const; 83 84 inline const icu4x::capi::BidiParagraph* AsFFI() const; 85 inline icu4x::capi::BidiParagraph* AsFFI(); 86 inline static const icu4x::BidiParagraph* FromFFI(const icu4x::capi::BidiParagraph* ptr); 87 inline static icu4x::BidiParagraph* FromFFI(icu4x::capi::BidiParagraph* ptr); 88 inline static void operator delete(void* ptr); 89 private: 90 BidiParagraph() = delete; 91 BidiParagraph(const icu4x::BidiParagraph&) = delete; 92 BidiParagraph(icu4x::BidiParagraph&&) noexcept = delete; 93 BidiParagraph operator=(const icu4x::BidiParagraph&) = delete; 94 BidiParagraph operator=(icu4x::BidiParagraph&&) noexcept = delete; 95 static void operator delete[](void*, size_t) = delete; 96 }; 97 98 } // namespace 99 #endif // icu4x_BidiParagraph_D_HPP