-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
411 additions
and
282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
``properties_maps::ffi`` | ||
======================== | ||
|
||
.. cpp:class:: ICU4XUnicodeScriptMapProperty | ||
.. cpp:class:: ICU4XCodePointMapData16 | ||
|
||
An ICU4X Unicode Set Property object, capable of querying whether a code point is contained in a set based on a Unicode property. See `the Rust docs <https://unicode-org.github.io/icu4x-docs/doc/icu_properties/index.html>`__ for more information. | ||
An ICU4X Unicode Set Property object, capable of querying whether a code point is contained in a set based on a Unicode property. For properties whose values fit into 16 bits. See `the Rust docs <https://unicode-org.github.io/icu4x-docs/doc/icu_properties/index.html>`__ for more information. | ||
|
||
.. cpp:function:: static ICU4XUnicodeScriptMapPropertyResult try_get(const ICU4XDataProvider& provider) | ||
.. cpp:function:: static ICU4XCodePointMapData16Response try_get_script(const ICU4XDataProvider& provider) | ||
|
||
Gets a set for Unicode property ascii_hex_digit from a :cpp:class:`ICU4XDataProvider`. See `the Rust docs <https://unicode-org.github.io/icu4x-docs/doc/icu_properties/maps/fn.get_script.html>`__ for more information. | ||
Gets a map for Unicode property Script from a :cpp:class:`ICU4XDataProvider`. See `the Rust docs <https://unicode-org.github.io/icu4x-docs/doc/icu_properties/maps/fn.get_script.html>`__ for more information. | ||
|
||
.. cpp:function:: static ICU4XUnicodeScriptMapPropertyResult try_get_from_static(const ICU4XStaticDataProvider& provider) | ||
.. cpp:function:: static ICU4XCodePointMapData16Response try_get_script_from_static(const ICU4XStaticDataProvider& provider) | ||
|
||
Gets a set for Unicode property ascii_hex_digit from a :cpp:class:`ICU4XStaticDataProvider`. See `the Rust docs <https://unicode-org.github.io/icu4x-docs/doc/icu_properties/maps/fn.get_script.html>`__ for more information. | ||
Gets a map for Unicode property Script from a :cpp:class:`ICU4XStaticDataProvider`. See `the Rust docs <https://unicode-org.github.io/icu4x-docs/doc/icu_properties/maps/fn.get_script.html>`__ for more information. | ||
|
||
.. cpp:function:: uint32_t get(char32_t cp) const | ||
.. cpp:function:: uint16_t get(char32_t cp) const | ||
|
||
Gets the Script for a code point. See `the Rust docs <https://unicode-org.github.io/icu4x-docs/doc/icu_codepointtrie/codepointtrie/struct.CodePointTrie.html#method.get_u32>`__ for more information. | ||
Gets the value for a code point. See `the Rust docs <https://unicode-org.github.io/icu4x-docs/doc/icu_codepointtrie/codepointtrie/struct.CodePointTrie.html#method.get_u32>`__ for more information. | ||
|
||
.. cpp:struct:: ICU4XUnicodeScriptMapPropertyResult | ||
.. cpp:struct:: ICU4XCodePointMapData16Response | ||
|
||
.. cpp:member:: std::optional<ICU4XUnicodeScriptMapProperty> data | ||
.. cpp:member:: std::optional<ICU4XCodePointMapData16> data | ||
|
||
The :cpp:class:`ICU4XUnicodeScriptMapProperty`, if creation was successful. | ||
The :cpp:class:`ICU4XCodePointMapData16`, if creation was successful. | ||
|
||
.. cpp:member:: bool success | ||
|
||
Whether creating the :cpp:class:`ICU4XUnicodeScriptMapProperty` was successful. | ||
Whether creating the :cpp:class:`ICU4XCodePointMapData16` was successful. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
``properties_sets::ffi`` | ||
======================== | ||
|
||
.. cpp:class:: ICU4XUnicodeSetProperty | ||
.. cpp:class:: ICU4XCodePointSetData | ||
|
||
An ICU4X Unicode Set Property object, capable of querying whether a code point is contained in a set based on a Unicode property. See `the Rust docs <https://unicode-org.github.io/icu4x-docs/doc/icu_properties/index.html>`__ for more information. | ||
|
||
.. cpp:function:: static ICU4XUnicodeSetPropertyResult try_get_ascii_hex_digit(const ICU4XDataProvider& provider) | ||
.. cpp:function:: static ICU4XCodePointSetDataResult try_get_ascii_hex_digit(const ICU4XDataProvider& provider) | ||
|
||
Gets a set for Unicode property ascii_hex_digit from a :cpp:class:`ICU4XDataProvider`. See `the Rust docs <https://unicode-org.github.io/icu4x-docs/doc/icu_properties/sets/fn.get_ascii_hex_digit.html>`__ for more information. | ||
|
||
.. cpp:function:: static ICU4XUnicodeSetPropertyResult try_get_ascii_hex_digit_from_static(const ICU4XStaticDataProvider& provider) | ||
.. cpp:function:: static ICU4XCodePointSetDataResult try_get_ascii_hex_digit_from_static(const ICU4XStaticDataProvider& provider) | ||
|
||
Gets a set for Unicode property ascii_hex_digit from a :cpp:class:`ICU4XStaticDataProvider`. See `the Rust docs <https://unicode-org.github.io/icu4x-docs/doc/icu_properties/sets/fn.get_ascii_hex_digit.html>`__ for more information. | ||
|
||
.. cpp:function:: bool contains(char32_t cp) const | ||
|
||
Checks whether the code point is in the set. See `the Rust docs <https://unicode-org.github.io/icu4x-docs/doc/icu_uniset/struct.UnicodeSet.html#method.contains>`__ for more information. | ||
|
||
.. cpp:struct:: ICU4XUnicodeSetPropertyResult | ||
.. cpp:struct:: ICU4XCodePointSetDataResult | ||
|
||
.. cpp:member:: std::optional<ICU4XUnicodeSetProperty> data | ||
.. cpp:member:: std::optional<ICU4XCodePointSetData> data | ||
|
||
The :cpp:class:`ICU4XUnicodeSetProperty`, if creation was successful. | ||
The :cpp:class:`ICU4XCodePointSetData`, if creation was successful. | ||
|
||
.. cpp:member:: bool success | ||
|
||
Whether creating the :cpp:class:`ICU4XUnicodeSetProperty` was successful. | ||
Whether creating the :cpp:class:`ICU4XCodePointSetData` was successful. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#ifndef ICU4XCodePointMapData16_H | ||
#define ICU4XCodePointMapData16_H | ||
#include <stdio.h> | ||
#include <stdint.h> | ||
#include <stddef.h> | ||
#include <stdbool.h> | ||
#include "diplomat_runtime.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
typedef struct ICU4XCodePointMapData16 ICU4XCodePointMapData16; | ||
#include "ICU4XDataProvider.h" | ||
#include "ICU4XCodePointMapData16Response.h" | ||
#include "ICU4XStaticDataProvider.h" | ||
|
||
ICU4XCodePointMapData16Response ICU4XCodePointMapData16_try_get_script(const ICU4XDataProvider* provider); | ||
|
||
ICU4XCodePointMapData16Response ICU4XCodePointMapData16_try_get_script_from_static(const ICU4XStaticDataProvider* provider); | ||
|
||
uint16_t ICU4XCodePointMapData16_get(const ICU4XCodePointMapData16* self, char32_t cp); | ||
void ICU4XCodePointMapData16_destroy(ICU4XCodePointMapData16* self); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#ifndef ICU4XCodePointMapData16_HPP | ||
#define ICU4XCodePointMapData16_HPP | ||
#include <stdint.h> | ||
#include <stddef.h> | ||
#include <stdbool.h> | ||
#include <algorithm> | ||
#include <memory> | ||
#include <variant> | ||
#include <optional> | ||
#include <span> | ||
#include "diplomat_runtime.hpp" | ||
|
||
namespace capi { | ||
#include "ICU4XCodePointMapData16.h" | ||
} | ||
|
||
class ICU4XDataProvider; | ||
struct ICU4XCodePointMapData16Response; | ||
class ICU4XStaticDataProvider; | ||
|
||
/** | ||
* A destruction policy for using ICU4XCodePointMapData16 with std::unique_ptr. | ||
*/ | ||
struct ICU4XCodePointMapData16Deleter { | ||
void operator()(capi::ICU4XCodePointMapData16* l) const noexcept { | ||
capi::ICU4XCodePointMapData16_destroy(l); | ||
} | ||
}; | ||
class ICU4XCodePointMapData16 { | ||
public: | ||
|
||
/** | ||
* Gets a map for Unicode property Script from a [`ICU4XDataProvider`]. | ||
* See [the Rust docs](https://unicode-org.github.io/icu4x-docs/doc/icu_properties/maps/fn.get_script.html) for more information. | ||
*/ | ||
static ICU4XCodePointMapData16Response try_get_script(const ICU4XDataProvider& provider); | ||
|
||
/** | ||
* Gets a map for Unicode property Script from a [`ICU4XStaticDataProvider`]. | ||
* See [the Rust docs](https://unicode-org.github.io/icu4x-docs/doc/icu_properties/maps/fn.get_script.html) for more information. | ||
*/ | ||
static ICU4XCodePointMapData16Response try_get_script_from_static(const ICU4XStaticDataProvider& provider); | ||
|
||
/** | ||
* Gets the value for a code point. | ||
* See [the Rust docs](https://unicode-org.github.io/icu4x-docs/doc/icu_codepointtrie/codepointtrie/struct.CodePointTrie.html#method.get_u32) for more information. | ||
*/ | ||
uint16_t get(char32_t cp) const; | ||
inline const capi::ICU4XCodePointMapData16* AsFFI() const { return this->inner.get(); } | ||
inline capi::ICU4XCodePointMapData16* AsFFIMut() { return this->inner.get(); } | ||
inline ICU4XCodePointMapData16(capi::ICU4XCodePointMapData16* i) : inner(i) {} | ||
private: | ||
std::unique_ptr<capi::ICU4XCodePointMapData16, ICU4XCodePointMapData16Deleter> inner; | ||
}; | ||
|
||
#include "ICU4XDataProvider.hpp" | ||
#include "ICU4XCodePointMapData16Response.hpp" | ||
#include "ICU4XStaticDataProvider.hpp" | ||
|
||
inline ICU4XCodePointMapData16Response ICU4XCodePointMapData16::try_get_script(const ICU4XDataProvider& provider) { | ||
capi::ICU4XCodePointMapData16Response diplomat_raw_struct_out_value = capi::ICU4XCodePointMapData16_try_get_script(provider.AsFFI()); | ||
auto diplomat_optional_raw_out_value_data = diplomat_raw_struct_out_value.data; | ||
std::optional<ICU4XCodePointMapData16> diplomat_optional_out_value_data; | ||
if (diplomat_optional_raw_out_value_data != nullptr) { | ||
diplomat_optional_out_value_data = ICU4XCodePointMapData16(diplomat_optional_raw_out_value_data); | ||
} else { | ||
diplomat_optional_out_value_data = std::nullopt; | ||
} | ||
return ICU4XCodePointMapData16Response{ .data = std::move(diplomat_optional_out_value_data), .success = std::move(diplomat_raw_struct_out_value.success) }; | ||
} | ||
inline ICU4XCodePointMapData16Response ICU4XCodePointMapData16::try_get_script_from_static(const ICU4XStaticDataProvider& provider) { | ||
capi::ICU4XCodePointMapData16Response diplomat_raw_struct_out_value = capi::ICU4XCodePointMapData16_try_get_script_from_static(provider.AsFFI()); | ||
auto diplomat_optional_raw_out_value_data = diplomat_raw_struct_out_value.data; | ||
std::optional<ICU4XCodePointMapData16> diplomat_optional_out_value_data; | ||
if (diplomat_optional_raw_out_value_data != nullptr) { | ||
diplomat_optional_out_value_data = ICU4XCodePointMapData16(diplomat_optional_raw_out_value_data); | ||
} else { | ||
diplomat_optional_out_value_data = std::nullopt; | ||
} | ||
return ICU4XCodePointMapData16Response{ .data = std::move(diplomat_optional_out_value_data), .success = std::move(diplomat_raw_struct_out_value.success) }; | ||
} | ||
inline uint16_t ICU4XCodePointMapData16::get(char32_t cp) const { | ||
return capi::ICU4XCodePointMapData16_get(this->inner.get(), cp); | ||
} | ||
#endif |
24 changes: 24 additions & 0 deletions
24
ffi/diplomat/cpp/include/ICU4XCodePointMapData16Response.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#ifndef ICU4XCodePointMapData16Response_H | ||
#define ICU4XCodePointMapData16Response_H | ||
#include <stdio.h> | ||
#include <stdint.h> | ||
#include <stddef.h> | ||
#include <stdbool.h> | ||
#include "diplomat_runtime.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
typedef struct ICU4XCodePointMapData16 ICU4XCodePointMapData16; | ||
|
||
typedef struct ICU4XCodePointMapData16Response { | ||
ICU4XCodePointMapData16* data; | ||
bool success; | ||
} ICU4XCodePointMapData16Response; | ||
|
||
void ICU4XCodePointMapData16Response_destroy(ICU4XCodePointMapData16Response* self); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
#endif |
42 changes: 42 additions & 0 deletions
42
ffi/diplomat/cpp/include/ICU4XCodePointMapData16Response.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#ifndef ICU4XCodePointMapData16Response_HPP | ||
#define ICU4XCodePointMapData16Response_HPP | ||
#include <stdint.h> | ||
#include <stddef.h> | ||
#include <stdbool.h> | ||
#include <algorithm> | ||
#include <memory> | ||
#include <variant> | ||
#include <optional> | ||
#include <span> | ||
#include "diplomat_runtime.hpp" | ||
|
||
namespace capi { | ||
#include "ICU4XCodePointMapData16Response.h" | ||
} | ||
|
||
class ICU4XCodePointMapData16; | ||
|
||
/** | ||
* A destruction policy for using ICU4XCodePointMapData16Response with std::unique_ptr. | ||
*/ | ||
struct ICU4XCodePointMapData16ResponseDeleter { | ||
void operator()(capi::ICU4XCodePointMapData16Response* l) const noexcept { | ||
capi::ICU4XCodePointMapData16Response_destroy(l); | ||
} | ||
}; | ||
struct ICU4XCodePointMapData16Response { | ||
public: | ||
|
||
/** | ||
* The [`ICU4XCodePointMapData16`], if creation was successful. | ||
*/ | ||
std::optional<ICU4XCodePointMapData16> data; | ||
|
||
/** | ||
* Whether creating the [`ICU4XCodePointMapData16`] was successful. | ||
*/ | ||
bool success; | ||
}; | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#ifndef ICU4XCodePointMapDataResponse_H | ||
#define ICU4XCodePointMapDataResponse_H | ||
#include <stdio.h> | ||
#include <stdint.h> | ||
#include <stddef.h> | ||
#include <stdbool.h> | ||
#include "diplomat_runtime.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
typedef struct ICU4XCodePointMapData16 ICU4XCodePointMapData16; | ||
|
||
typedef struct ICU4XCodePointMapDataResponse { | ||
ICU4XCodePointMapData16* data; | ||
bool success; | ||
} ICU4XCodePointMapDataResponse; | ||
|
||
void ICU4XCodePointMapDataResponse_destroy(ICU4XCodePointMapDataResponse* self); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#ifndef ICU4XCodePointSetData_H | ||
#define ICU4XCodePointSetData_H | ||
#include <stdio.h> | ||
#include <stdint.h> | ||
#include <stddef.h> | ||
#include <stdbool.h> | ||
#include "diplomat_runtime.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
typedef struct ICU4XCodePointSetData ICU4XCodePointSetData; | ||
#include "ICU4XDataProvider.h" | ||
#include "ICU4XCodePointSetDataResult.h" | ||
#include "ICU4XStaticDataProvider.h" | ||
|
||
ICU4XCodePointSetDataResult ICU4XCodePointSetData_try_get_ascii_hex_digit(const ICU4XDataProvider* provider); | ||
|
||
ICU4XCodePointSetDataResult ICU4XCodePointSetData_try_get_ascii_hex_digit_from_static(const ICU4XStaticDataProvider* provider); | ||
|
||
bool ICU4XCodePointSetData_contains(const ICU4XCodePointSetData* self, char32_t cp); | ||
void ICU4XCodePointSetData_destroy(ICU4XCodePointSetData* self); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
#endif |
Oops, something went wrong.