Created
January 25, 2021 01:07
-
-
Save zbraniecki/518423d03b17a0b17e385f74b62f305d to your computer and use it in GitHub Desktop.
FFI for ICU4X example
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
class DateTimeFormat { | |
public: | |
Result<DateTimeFormat, ()> tryNew(string aLocale, options aOptions); | |
string format(date aDate); | |
protected: | |
DateTimeFormat(string aLocale, ffi::DateTimeFormatData aData); | |
UniquePtr<ffi::DateTimeFormatData> mData; | |
}; | |
Result<DateTimeFormat, ()> | |
DateTimeFormat::tryNew(string aLocale, options aOptions) { | |
ffi::RequestData request = ffi::DateTimeFormat::Request(aLocale, aOptions); | |
mData = ffi::DataProvider::GetData(request); // fallible? async? | |
return new DateTimeFormat(aLocale, mData); | |
} | |
string | |
DateTimeFormat::Format(date aDate) { | |
return ffi::DateTimeFormat::Format(aDate, mData); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment