1 #ifndef icu4x_DataError_D_HPP 2 #define icu4x_DataError_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 "../diplomat_runtime.hpp" 12 13 14 namespace icu4x { 15 namespace capi { 16 enum DataError { 17 DataError_Unknown = 0, 18 DataError_MarkerNotFound = 1, 19 DataError_IdentifierNotFound = 2, 20 DataError_InvalidRequest = 3, 21 DataError_InconsistentData = 4, 22 DataError_Downcast = 5, 23 DataError_Deserialize = 6, 24 DataError_Custom = 7, 25 DataError_Io = 8, 26 }; 27 28 typedef struct DataError_option {union { DataError ok; }; bool is_ok; } DataError_option; 29 } // namespace capi 30 } // namespace 31 32 namespace icu4x { 33 class DataError { 34 public: 35 enum Value { 36 Unknown = 0, 37 MarkerNotFound = 1, 38 IdentifierNotFound = 2, 39 InvalidRequest = 3, 40 InconsistentData = 4, 41 Downcast = 5, 42 Deserialize = 6, 43 Custom = 7, 44 Io = 8, 45 }; 46 47 DataError() = default; 48 // Implicit conversions between enum and ::Value DataError(Value v)49 constexpr DataError(Value v) : value(v) {} operator Value() const50 constexpr operator Value() const { return value; } 51 // Prevent usage as boolean value 52 explicit operator bool() const = delete; 53 54 inline icu4x::capi::DataError AsFFI() const; 55 inline static icu4x::DataError FromFFI(icu4x::capi::DataError c_enum); 56 private: 57 Value value; 58 }; 59 60 } // namespace 61 #endif // icu4x_DataError_D_HPP 62