git.iko.soy/typeable/libphonenumber
on main help sign in
Support libphonenumber 7.1.0
dad2ec7mniip
cxxbits/c_phonenumber.cpp+13−1
@@ -9,6 +9,18 @@ extern "C" {
9
9
10using i18n::phonenumbers::PhoneNumber;
10using i18n::phonenumbers::PhoneNumber;
11
11
12+// libphonenumber versions < 8.6.0 do not define CountryCodeSource::UNSPECIFIED
13+// The value PN_UNSPECIFIED contains CountryCodeSource::UNSPECIFIED if it is
14+// defined, otherwise 0 (the value used in the newer versions).
15+template<typename T, typename = void>
16+struct check_UNSPECIFIED: std::integral_constant<T, static_cast<T>(0)>
17+{};
18+template<typename T>
19+struct check_UNSPECIFIED<T, void_t<decltype(T::UNSPECIFIED)>>:
20+ std::integral_constant<T, T::UNSPECIFIED>
21+{};
22+static constexpr auto PN_UNSPECIFIED = check_UNSPECIFIED<PhoneNumber::CountryCodeSource>::value;
23+
12static PhoneNumber::CountryCodeSource marshal_country_code_source(country_code_source value)
24static PhoneNumber::CountryCodeSource marshal_country_code_source(country_code_source value)
13{
25{
14 static_assert(is_same_enum<
26 static_assert(is_same_enum<
@@ -20,7 +32,7 @@ static PhoneNumber::CountryCodeSource marshal_country_code_source(country_code_s
20 FROM_DEFAULT_COUNTRY
32 FROM_DEFAULT_COUNTRY
21 >,
33 >,
22 enum_values<PhoneNumber::CountryCodeSource,
34 enum_values<PhoneNumber::CountryCodeSource,
23− PhoneNumber::UNSPECIFIED,
35+ PN_UNSPECIFIED,
24 PhoneNumber::FROM_NUMBER_WITH_PLUS_SIGN,
36 PhoneNumber::FROM_NUMBER_WITH_PLUS_SIGN,
25 PhoneNumber::FROM_NUMBER_WITH_IDD,
37 PhoneNumber::FROM_NUMBER_WITH_IDD,
26 PhoneNumber::FROM_NUMBER_WITHOUT_PLUS_SIGN,
38 PhoneNumber::FROM_NUMBER_WITHOUT_PLUS_SIGN,
include/common.h+7
@@ -50,6 +50,13 @@ struct is_same_enum<enum_values<T, TVals...>, enum_values<S, SVals...>>:
50 >::value>
50 >::value>
51{};
51{};
52
52
53+// std::void_t for compilers that don't have it
54+template<typename T>
55+struct make_void { using type = void; };
56+
57+template<typename T>
58+using void_t = typename make_void<T>::type;
59+
53inline void unmarshal_string_size(std::string const &string, char *&c_string, size_t &c_string_size)
60inline void unmarshal_string_size(std::string const &string, char *&c_string, size_t &c_string_size)
54{
61{
55 c_string_size = string.size();
62 c_string_size = string.size();