2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								/*
  
						 
					
						
							
								
									
										
										
										
											2022-07-13 14:03:03 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								 *  Copyright  ( c )  2021 - 2022 ,  Tim  Flynn  < trflynn89 @ serenityos . org > 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  SPDX - License - Identifier :  BSD - 2 - Clause 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 10:27:46 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  "../LibUnicode/GeneratorUtil.h"   // FIXME: Move this somewhere common.
  
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								# include  <AK/AllOf.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-11-16 09:31:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <AK/Array.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								# include  <AK/CharacterTypes.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-11-16 09:31:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <AK/Find.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								# include  <AK/Format.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-12-02 19:59:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <AK/HashFunctions.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								# include  <AK/HashMap.h> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  <AK/JsonObject.h> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  <AK/JsonParser.h> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  <AK/JsonValue.h> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  <AK/LexicalPath.h> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  <AK/QuickSort.h> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  <AK/SourceGenerator.h> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  <AK/String.h> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  <AK/StringBuilder.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-12-02 19:59:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <AK/Traits.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-11-15 07:42:39 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <AK/Utf8View.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								# include  <LibCore/ArgsParser.h> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  <LibCore/DirIterator.h> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  <LibCore/File.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-02-06 16:00:13 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <LibCore/Stream.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-08-27 15:50:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <LibJS/Runtime/Intl/SingleUnitIdentifiers.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								# include  <LibUnicode/Locale.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-11-27 10:53:42 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <LibUnicode/NumberFormat.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-07-08 10:16:43 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <LibUnicode/PluralRules.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								# include  <math.h> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								using  StringIndexType  =  u16 ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								constexpr  auto  s_string_index_type  =  " u16 " sv ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 19:59:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								using  NumberFormatIndexType  =  u16 ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								constexpr  auto  s_number_format_index_type  =  " u16 " sv ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-10 16:03:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								using  NumberFormatListIndexType  =  u16 ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								constexpr  auto  s_number_format_list_index_type  =  " u16 " sv ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 00:37:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								using  NumericSymbolListIndexType  =  u8 ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								constexpr  auto  s_numeric_symbol_list_index_type  =  " u8 " sv ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 08:12:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								using  NumberSystemIndexType  =  u8 ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								constexpr  auto  s_number_system_index_type  =  " u8 " sv ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 08:30:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								using  UnitIndexType  =  u16 ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								constexpr  auto  s_unit_index_type  =  " u16 " sv ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-15 07:42:39 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								enum  class  NumberFormatType  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    Standard , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    Compact , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								struct  NumberFormat  :  public  Unicode : : NumberFormat  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    using  Base  =  Unicode : : NumberFormat ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 19:59:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    unsigned  hash ( )  const 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        auto  hash  =  pair_int_hash ( magnitude ,  exponent ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-08 10:16:43 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        hash  =  pair_int_hash ( hash ,  to_underlying ( plurality ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 19:59:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        hash  =  pair_int_hash ( hash ,  zero_format_index ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        hash  =  pair_int_hash ( hash ,  positive_format_index ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        hash  =  pair_int_hash ( hash ,  negative_format_index ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for  ( auto  index  :  identifier_indices ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            hash  =  pair_int_hash ( hash ,  index ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  hash ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    bool  operator = = ( NumberFormat  const &  other )  const 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  ( magnitude  = =  other . magnitude ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            & &  ( exponent  = =  other . exponent ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            & &  ( plurality  = =  other . plurality ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            & &  ( zero_format_index  = =  other . zero_format_index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            & &  ( positive_format_index  = =  other . positive_format_index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            & &  ( negative_format_index  = =  other . negative_format_index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            & &  ( identifier_indices  = =  other . identifier_indices ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    StringIndexType  zero_format_index  {  0  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    StringIndexType  positive_format_index  {  0  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    StringIndexType  negative_format_index  {  0  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 13:53:45 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    Vector < StringIndexType >  identifier_indices  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								} ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 19:59:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								template < >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								struct  AK : : Formatter < NumberFormat >  :  Formatter < FormatString >  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ErrorOr < void >  format ( FormatBuilder &  builder ,  NumberFormat  const &  format ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        StringBuilder  identifier_indices ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        identifier_indices . join ( " ,  " sv ,  format . identifier_indices ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  Formatter < FormatString > : : format ( builder , 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-11 17:32:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            " {{ {}, {}, {}, {}, {}, {}, {{ {} }} }} " sv , 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 19:59:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            format . magnitude , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            format . exponent , 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-08 10:16:43 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            to_underlying ( format . plurality ) , 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 19:59:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            format . zero_format_index , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            format . positive_format_index , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            format . negative_format_index , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            identifier_indices . build ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								template < >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								struct  AK : : Traits < NumberFormat >  :  public  GenericTraits < NumberFormat >  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    static  unsigned  hash ( NumberFormat  const &  f )  {  return  f . hash ( ) ;  } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-10 16:03:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								using  NumberFormatList  =  Vector < NumberFormatIndexType > ;  
						 
					
						
							
								
									
										
										
										
											2021-12-11 00:37:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								using  NumericSymbolList  =  Vector < StringIndexType > ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								struct  NumberSystem  {  
						 
					
						
							
								
									
										
										
										
											2021-12-11 08:12:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    unsigned  hash ( )  const 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-11 18:50:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        auto  hash  =  int_hash ( symbols ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 08:12:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        hash  =  pair_int_hash ( hash ,  primary_grouping_size ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        hash  =  pair_int_hash ( hash ,  secondary_grouping_size ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        hash  =  pair_int_hash ( hash ,  decimal_format ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        hash  =  pair_int_hash ( hash ,  decimal_long_formats ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        hash  =  pair_int_hash ( hash ,  decimal_short_formats ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        hash  =  pair_int_hash ( hash ,  currency_format ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        hash  =  pair_int_hash ( hash ,  accounting_format ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        hash  =  pair_int_hash ( hash ,  currency_unit_formats ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        hash  =  pair_int_hash ( hash ,  currency_short_formats ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        hash  =  pair_int_hash ( hash ,  percent_format ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        hash  =  pair_int_hash ( hash ,  scientific_format ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  hash ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    bool  operator = = ( NumberSystem  const &  other )  const 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-11 18:50:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  ( symbols  = =  other . symbols ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 08:12:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            & &  ( primary_grouping_size  = =  other . primary_grouping_size ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            & &  ( secondary_grouping_size  = =  other . secondary_grouping_size ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            & &  ( decimal_format  = =  other . decimal_format ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            & &  ( decimal_long_formats  = =  other . decimal_long_formats ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            & &  ( decimal_short_formats  = =  other . decimal_short_formats ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            & &  ( currency_format  = =  other . currency_format ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            & &  ( accounting_format  = =  other . accounting_format ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            & &  ( currency_unit_formats  = =  other . currency_unit_formats ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            & &  ( currency_short_formats  = =  other . currency_short_formats ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            & &  ( percent_format  = =  other . percent_format ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            & &  ( scientific_format  = =  other . scientific_format ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 00:37:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    NumericSymbolListIndexType  symbols  {  0  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-13 22:03:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    u8  primary_grouping_size  {  0  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    u8  secondary_grouping_size  {  0  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 19:59:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    NumberFormatIndexType  decimal_format  {  0  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-10 16:03:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    NumberFormatListIndexType  decimal_long_formats  {  0  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    NumberFormatListIndexType  decimal_short_formats  {  0  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 19:59:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    NumberFormatIndexType  currency_format  {  0  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    NumberFormatIndexType  accounting_format  {  0  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-10 16:03:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    NumberFormatListIndexType  currency_unit_formats  {  0  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    NumberFormatListIndexType  currency_short_formats  {  0  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 19:59:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    NumberFormatIndexType  percent_format  {  0  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    NumberFormatIndexType  scientific_format  {  0  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								} ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 08:12:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								template < >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								struct  AK : : Formatter < NumberSystem >  :  Formatter < FormatString >  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ErrorOr < void >  format ( FormatBuilder &  builder ,  NumberSystem  const &  system ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  Formatter < FormatString > : : format ( builder , 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-11 17:32:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            " {{ {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {} }} " sv , 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 08:12:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            system . symbols , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            system . primary_grouping_size , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            system . secondary_grouping_size , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            system . decimal_format , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            system . decimal_long_formats , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            system . decimal_short_formats , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            system . currency_format , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            system . accounting_format , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            system . currency_unit_formats , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            system . currency_short_formats , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            system . percent_format , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            system . scientific_format ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								template < >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								struct  AK : : Traits < NumberSystem >  :  public  GenericTraits < NumberSystem >  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    static  unsigned  hash ( NumberSystem  const &  s )  {  return  s . hash ( ) ;  } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 09:31:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								struct  Unit  {  
						 
					
						
							
								
									
										
										
										
											2021-12-11 08:30:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    unsigned  hash ( )  const 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        auto  hash  =  int_hash ( unit ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        hash  =  pair_int_hash ( hash ,  long_formats ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        hash  =  pair_int_hash ( hash ,  short_formats ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        hash  =  pair_int_hash ( hash ,  narrow_formats ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  hash ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    bool  operator = = ( Unit  const &  other )  const 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  ( unit  = =  other . unit ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            & &  ( long_formats  = =  other . long_formats ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            & &  ( short_formats  = =  other . short_formats ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            & &  ( narrow_formats  = =  other . narrow_formats ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 09:31:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    StringIndexType  unit  {  0  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-10 16:36:39 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    NumberFormatListIndexType  long_formats  {  0  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    NumberFormatListIndexType  short_formats  {  0  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    NumberFormatListIndexType  narrow_formats  {  0  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 09:31:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								} ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 08:30:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								template < >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								struct  AK : : Formatter < Unit >  :  Formatter < FormatString >  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ErrorOr < void >  format ( FormatBuilder &  builder ,  Unit  const &  system ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  Formatter < FormatString > : : format ( builder , 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-11 17:32:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            " {{ {}, {}, {}, {} }} " sv , 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 08:30:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            system . unit , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            system . long_formats , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            system . short_formats , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            system . narrow_formats ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								template < >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								struct  AK : : Traits < Unit >  :  public  GenericTraits < Unit >  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    static  unsigned  hash ( Unit  const &  u )  {  return  u . hash ( ) ;  } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								struct  LocaleData  {  
						 
					
						
							
								
									
										
										
										
											2022-01-11 18:50:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    Vector < NumberSystemIndexType >  number_systems ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 08:30:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    HashMap < String ,  UnitIndexType >  units  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 12:40:31 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    u8  minimum_grouping_digits  {  0  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								} ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								struct  CLDR  {  
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    UniqueStringStorage < StringIndexType >  unique_strings ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 19:59:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    UniqueStorage < NumberFormat ,  NumberFormatIndexType >  unique_formats ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-10 16:03:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    UniqueStorage < NumberFormatList ,  NumberFormatListIndexType >  unique_format_lists ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 00:37:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    UniqueStorage < NumericSymbolList ,  NumericSymbolListIndexType >  unique_symbols ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 08:12:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    UniqueStorage < NumberSystem ,  NumberSystemIndexType >  unique_systems ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 08:30:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    UniqueStorage < Unit ,  UnitIndexType >  unique_units ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-10 16:03:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-11 18:42:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    HashMap < String ,  Array < u32 ,  10 > >  number_system_digits ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    Vector < String >  number_systems ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    HashMap < String ,  LocaleData >  locales ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 13:53:45 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    size_t  max_identifier_count  {  0  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								} ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  ErrorOr < void >  parse_number_system_digits ( String  core_supplemental_path ,  CLDR &  cldr )  
						 
					
						
							
								
									
										
										
										
											2022-01-11 18:42:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    LexicalPath  number_systems_path ( move ( core_supplemental_path ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    number_systems_path  =  number_systems_path . append ( " numberingSystems.json " sv ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-06 16:00:13 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  number_systems  =  TRY ( read_json_file ( number_systems_path . string ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-11 18:42:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  const &  supplemental_object  =  number_systems . as_object ( ) . get ( " supplemental " sv ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto  const &  number_systems_object  =  supplemental_object . as_object ( ) . get ( " numberingSystems " sv ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    number_systems_object . as_object ( ) . for_each_member ( [ & ] ( auto  const &  number_system ,  auto  const &  digits_object )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        auto  type  =  digits_object . as_object ( ) . get ( " _type " sv ) . as_string ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( type  ! =  " numeric " sv ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        auto  digits  =  digits_object . as_object ( ) . get ( " _digits " sv ) . as_string ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Utf8View  utf8_digits  {  digits  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        VERIFY ( utf8_digits . length ( )  = =  10 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        auto &  number_system_digits  =  cldr . number_system_digits . ensure ( number_system ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-11 18:42:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        size_t  index  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for  ( u32  digit  :  utf8_digits ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            number_system_digits [ index + + ]  =  digit ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! cldr . number_systems . contains_slow ( number_system ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            cldr . number_systems . append ( number_system ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-11 18:42:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  String  parse_identifiers ( String  pattern ,  StringView  replacement ,  CLDR &  cldr ,  NumberFormat &  format )  
						 
					
						
							
								
									
										
										
										
											2021-11-16 10:09:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-01-16 20:34:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    static  constexpr  Utf8View  whitespace  {  " \u0020 \u00a0 \u200f " sv  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 10:09:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 13:53:45 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    while  ( true )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Utf8View  utf8_pattern  {  pattern  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Optional < size_t >  start_index ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Optional < size_t >  end_index ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        bool  inside_replacement  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 10:09:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 13:53:45 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        for  ( auto  it  =  utf8_pattern . begin ( ) ;  it  ! =  utf8_pattern . end ( ) ;  + + it )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( * it  = =  ' { ' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( start_index . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    end_index  =  utf8_pattern . byte_offset_of ( it ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 10:09:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 13:53:45 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                inside_replacement  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }  else  if  ( * it  = =  ' } ' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                inside_replacement  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }  else  if  ( ! inside_replacement  & &  ! start_index . has_value ( )  & &  ! whitespace . contains ( * it ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                start_index  =  utf8_pattern . byte_offset_of ( it ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 10:09:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 13:53:45 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! start_index . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  pattern ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        end_index  =  end_index . value_or ( pattern . length ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        utf8_pattern  =  utf8_pattern . substring_view ( * start_index ,  * end_index  -  * start_index ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        utf8_pattern  =  utf8_pattern . trim ( whitespace ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 10:09:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 22:33:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        auto  identifier  =  utf8_pattern . as_string ( ) . replace ( " '.' " sv ,  " . " sv ,  ReplaceMode : : FirstOnly ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        auto  identifier_index  =  cldr . unique_strings . ensure ( move ( identifier ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 13:53:45 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        size_t  replacement_index  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 10:09:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 13:53:45 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( auto  index  =  format . identifier_indices . find_first_index ( identifier_index ) ;  index . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            replacement_index  =  * index ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            replacement_index  =  format . identifier_indices . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            format . identifier_indices . append ( identifier_index ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 10:09:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            cldr . max_identifier_count  =  max ( cldr . max_identifier_count ,  format . identifier_indices . size ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 13:53:45 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        pattern  =  String : : formatted ( " {}{{{}:{}}}{} " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            * start_index  >  0  ?  pattern . substring_view ( 0 ,  * start_index )  :  " " sv , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            replacement , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            replacement_index , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            pattern . substring_view ( * start_index  +  utf8_pattern . byte_length ( ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 10:09:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  void  parse_number_pattern ( Vector < String >  patterns ,  CLDR &  cldr ,  NumberFormatType  type ,  NumberFormat &  format ,  NumberSystem *  number_system_for_groupings  =  nullptr )  
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // https://unicode.org/reports/tr35/tr35-numbers.html#Number_Format_Patterns
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // https://cldr.unicode.org/translation/number-currency-formats/number-and-currency-patterns
 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-15 07:56:20 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    VERIFY ( ( patterns . size ( )  = =  1 )  | |  ( patterns . size ( )  = =  2 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 17:16:30 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  replace_patterns  =  [ & ] ( String  pattern )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        static  HashMap < StringView ,  StringView >  replacements  =  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-13 10:15:33 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            {  " {0} " sv ,  " {number} " sv  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            {  " {1} " sv ,  " {currency} " sv  } , 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            {  " % " sv ,  " {percentSign} " sv  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            {  " + " sv ,  " {plusSign} " sv  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            {  " - " sv ,  " {minusSign} " sv  } , 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 23:16:37 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            {  " ¤ " sv ,  " {currency} " sv  } ,  // U+00A4 Currency Sign
 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-14 08:35:10 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            {  " E " sv ,  " {scientificSeparator} " sv  } , 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-13 10:15:33 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        for  ( auto  const &  replacement  :  replacements ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 22:33:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            pattern  =  pattern . replace ( replacement . key ,  replacement . value ,  ReplaceMode : : All ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-13 10:15:33 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 15:49:14 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( auto  start_number_index  =  pattern . find_any_of ( " #0 " sv ,  String : : SearchDirection : : Forward ) ;  start_number_index . has_value ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            auto  end_number_index  =  * start_number_index  +  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            for  ( ;  end_number_index  <  pattern . length ( ) ;  + + end_number_index )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                auto  ch  =  pattern [ end_number_index ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( ( ch  ! =  ' # ' )  & &  ( ch  ! =  ' 0 ' )  & &  ( ch  ! =  ' , ' )  & &  ( ch  ! =  ' . ' ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-13 22:03:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( number_system_for_groupings )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                auto  number_pattern  =  pattern . substring_view ( * start_number_index ,  end_number_index  -  * start_number_index ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                auto  group_separators  =  number_pattern . find_all ( " , " sv ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                VERIFY ( ( group_separators . size ( )  = =  1 )  | |  ( group_separators . size ( )  = =  2 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                auto  decimal  =  number_pattern . find ( ' . ' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                VERIFY ( decimal . has_value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( group_separators . size ( )  = =  1 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    number_system_for_groupings - > primary_grouping_size  =  * decimal  -  group_separators [ 0 ]  -  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    number_system_for_groupings - > secondary_grouping_size  =  number_system_for_groupings - > primary_grouping_size ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    number_system_for_groupings - > primary_grouping_size  =  * decimal  -  group_separators [ 1 ]  -  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    number_system_for_groupings - > secondary_grouping_size  =  group_separators [ 1 ]  -  group_separators [ 0 ]  -  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            pattern  =  String : : formatted ( " {}{{number}}{} " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                * start_number_index  >  0  ?  pattern . substring_view ( 0 ,  * start_number_index )  :  " " sv , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                pattern . substring_view ( end_number_index ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-14 08:35:10 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // This is specifically handled here rather than in the replacements HashMap above so
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // that we do not errantly replace zeroes in number patterns.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( pattern . contains ( * replacements . get ( " E " sv ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 22:33:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                pattern  =  pattern . replace ( " 0 " sv ,  " {scientificExponent} " sv ,  ReplaceMode : : FirstOnly ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 10:09:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( type  = =  NumberFormatType : : Compact ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return  parse_identifiers ( move ( pattern ) ,  " compactIdentifier " sv ,  cldr ,  format ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-15 07:42:39 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        return  pattern ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto  zero_format  =  replace_patterns ( move ( patterns [ 0 ] ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    format . positive_format_index  =  cldr . unique_strings . ensure ( String : : formatted ( " {{plusSign}}{} " ,  zero_format ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( patterns . size ( )  = =  2 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        auto  negative_format  =  replace_patterns ( move ( patterns [ 1 ] ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        format . negative_format_index  =  cldr . unique_strings . ensure ( move ( negative_format ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        format . negative_format_index  =  cldr . unique_strings . ensure ( String : : formatted ( " {{minusSign}}{} " ,  zero_format ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    format . zero_format_index  =  cldr . unique_strings . ensure ( move ( zero_format ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  void  parse_number_pattern ( Vector < String >  patterns ,  CLDR &  cldr ,  NumberFormatType  type ,  NumberFormatIndexType &  format_index ,  NumberSystem *  number_system_for_groupings  =  nullptr )  
						 
					
						
							
								
									
										
										
										
											2021-12-02 19:59:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    NumberFormat  format  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    parse_number_pattern ( move ( patterns ) ,  cldr ,  type ,  format ,  number_system_for_groupings ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 19:59:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    format_index  =  cldr . unique_formats . ensure ( move ( format ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 19:59:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  ErrorOr < void >  parse_number_systems ( String  locale_numbers_path ,  CLDR &  cldr ,  LocaleData &  locale )  
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    LexicalPath  numbers_path ( move ( locale_numbers_path ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    numbers_path  =  numbers_path . append ( " numbers.json " sv ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-06 16:00:13 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  numbers  =  TRY ( read_json_file ( numbers_path . string ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-15 01:46:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  const &  main_object  =  numbers . as_object ( ) . get ( " main " sv ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    auto  const &  locale_object  =  main_object . as_object ( ) . get ( numbers_path . parent ( ) . basename ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto  const &  locale_numbers_object  =  locale_object . as_object ( ) . get ( " numbers " sv ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 12:40:31 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  const &  minimum_grouping_digits  =  locale_numbers_object . as_object ( ) . get ( " minimumGroupingDigits " sv ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-11 18:50:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    Vector < Optional < NumberSystem > >  number_systems ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    number_systems . resize ( cldr . number_systems . size ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 08:12:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    auto  ensure_number_system  =  [ & ] ( auto  const &  system )  - >  NumberSystem &  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        auto  system_index  =  cldr . number_systems . find_first_index ( system ) . value ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-11 18:50:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        VERIFY ( system_index  <  number_systems . size ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        auto &  number_system  =  number_systems . at ( system_index ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( ! number_system . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            number_system  =  NumberSystem  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  number_system . value ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto  parse_number_format  =  [ & ] ( auto  const &  format_object )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 19:59:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        Vector < NumberFormatIndexType >  result ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        result . ensure_capacity ( format_object . size ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        format_object . for_each_member ( [ & ] ( auto  const &  key ,  JsonValue  const &  value )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            auto  split_key  =  key . split_view ( ' - ' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 17:16:30 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( split_key . size ( )  ! =  3 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-15 07:56:20 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            auto  patterns  =  value . as_string ( ) . split ( ' ; ' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            NumberFormat  format  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 17:16:30 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( auto  type  =  split_key [ 0 ] . template  to_uint < u64 > ( ) ;  type . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                VERIFY ( * type  %  10  = =  0 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                format . magnitude  =  static_cast < u8 > ( log10 ( * type ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-15 07:56:20 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( patterns [ 0 ]  ! =  " 0 " sv )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    auto  number_of_zeroes_in_pattern  =  patterns [ 0 ] . count ( " 0 " sv ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    VERIFY ( format . magnitude  > =  number_of_zeroes_in_pattern ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    format . exponent  =  format . magnitude  +  1  -  number_of_zeroes_in_pattern ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 17:16:30 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                VERIFY ( split_key [ 0 ]  = =  " unitPattern " sv ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-08 10:16:43 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            format . plurality  =  Unicode : : plural_category_from_string ( split_key [ 2 ] ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            parse_number_pattern ( move ( patterns ) ,  cldr ,  NumberFormatType : : Compact ,  format ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            auto  format_index  =  cldr . unique_formats . ensure ( move ( format ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 19:59:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            result . append ( format_index ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  cldr . unique_format_lists . ensure ( move ( result ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 00:37:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  numeric_symbol_from_string  =  [ & ] ( StringView  numeric_symbol )  - >  Optional < Unicode : : NumericSymbol >  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 13:51:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( numeric_symbol  = =  " approximatelySign " sv ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  Unicode : : NumericSymbol : : ApproximatelySign ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 00:37:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( numeric_symbol  = =  " decimal " sv ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  Unicode : : NumericSymbol : : Decimal ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( numeric_symbol  = =  " exponential " sv ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  Unicode : : NumericSymbol : : Exponential ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( numeric_symbol  = =  " group " sv ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  Unicode : : NumericSymbol : : Group ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( numeric_symbol  = =  " infinity " sv ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  Unicode : : NumericSymbol : : Infinity ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( numeric_symbol  = =  " minusSign " sv ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  Unicode : : NumericSymbol : : MinusSign ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( numeric_symbol  = =  " nan " sv ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  Unicode : : NumericSymbol : : NaN ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( numeric_symbol  = =  " percentSign " sv ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  Unicode : : NumericSymbol : : PercentSign ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( numeric_symbol  = =  " plusSign " sv ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  Unicode : : NumericSymbol : : PlusSign ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-30 13:36:11 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( numeric_symbol  = =  " timeSeparator " sv ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  Unicode : : NumericSymbol : : TimeSeparator ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 00:37:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    locale_numbers_object . as_object ( ) . for_each_member ( [ & ] ( auto  const &  key ,  JsonValue  const &  value )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        constexpr  auto  symbols_prefix  =  " symbols-numberSystem- " sv ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        constexpr  auto  decimal_formats_prefix  =  " decimalFormats-numberSystem- " sv ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        constexpr  auto  currency_formats_prefix  =  " currencyFormats-numberSystem- " sv ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        constexpr  auto  percent_formats_prefix  =  " percentFormats-numberSystem- " sv ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-14 08:35:10 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        constexpr  auto  scientific_formats_prefix  =  " scientificFormats-numberSystem- " sv ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 13:51:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        constexpr  auto  misc_patterns_prefix  =  " miscPatterns-numberSystem- " sv ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( key . starts_with ( symbols_prefix ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            auto  system  =  key . substring ( symbols_prefix . length ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            auto &  number_system  =  ensure_number_system ( system ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 00:37:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            NumericSymbolList  symbols ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            value . as_object ( ) . for_each_member ( [ & ] ( auto  const &  symbol ,  JsonValue  const &  localization )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 00:37:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                auto  numeric_symbol  =  numeric_symbol_from_string ( symbol ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( ! numeric_symbol . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( to_underlying ( * numeric_symbol )  > =  symbols . size ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    symbols . resize ( to_underlying ( * numeric_symbol )  +  1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                auto  symbol_index  =  cldr . unique_strings . ensure ( localization . as_string ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 00:37:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                symbols [ to_underlying ( * numeric_symbol ) ]  =  symbol_index ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 00:37:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 13:51:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            // The range separator does not appear in the symbols list, we have to extract it from
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // the range pattern.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            auto  misc_patterns_key  =  String : : formatted ( " {}{} " ,  misc_patterns_prefix ,  system ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            auto  misc_patterns  =  locale_numbers_object . as_object ( ) . get ( misc_patterns_key ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            auto  range_separator  =  misc_patterns . as_object ( ) . get ( " range " sv ) . as_string ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            auto  begin_index  =  range_separator . find ( " {0} " sv ) . value ( )  +  " {0} " sv . length ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            auto  end_index  =  range_separator . find ( " {1} " sv ) . value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            range_separator  =  range_separator . substring ( begin_index ,  end_index  -  begin_index ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( to_underlying ( Unicode : : NumericSymbol : : RangeSeparator )  > =  symbols . size ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                symbols . resize ( to_underlying ( Unicode : : NumericSymbol : : RangeSeparator )  +  1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            auto  symbol_index  =  cldr . unique_strings . ensure ( move ( range_separator ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 13:51:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            symbols [ to_underlying ( Unicode : : NumericSymbol : : RangeSeparator ) ]  =  symbol_index ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            number_system . symbols  =  cldr . unique_symbols . ensure ( move ( symbols ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        }  else  if  ( key . starts_with ( decimal_formats_prefix ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            auto  system  =  key . substring ( decimal_formats_prefix . length ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            auto &  number_system  =  ensure_number_system ( system ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            auto  format_object  =  value . as_object ( ) . get ( " standard " sv ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            parse_number_pattern ( format_object . as_string ( ) . split ( ' ; ' ) ,  cldr ,  NumberFormatType : : Standard ,  number_system . decimal_format ,  & number_system ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            auto  const &  long_format  =  value . as_object ( ) . get ( " long " sv ) . as_object ( ) . get ( " decimalFormat " sv ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            number_system . decimal_long_formats  =  parse_number_format ( long_format . as_object ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            auto  const &  short_format  =  value . as_object ( ) . get ( " short " sv ) . as_object ( ) . get ( " decimalFormat " sv ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            number_system . decimal_short_formats  =  parse_number_format ( short_format . as_object ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }  else  if  ( key . starts_with ( currency_formats_prefix ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            auto  system  =  key . substring ( currency_formats_prefix . length ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            auto &  number_system  =  ensure_number_system ( system ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            auto  format_object  =  value . as_object ( ) . get ( " standard " sv ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            parse_number_pattern ( format_object . as_string ( ) . split ( ' ; ' ) ,  cldr ,  NumberFormatType : : Standard ,  number_system . currency_format ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            format_object  =  value . as_object ( ) . get ( " accounting " sv ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            parse_number_pattern ( format_object . as_string ( ) . split ( ' ; ' ) ,  cldr ,  NumberFormatType : : Standard ,  number_system . accounting_format ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 17:16:30 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            number_system . currency_unit_formats  =  parse_number_format ( value . as_object ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            if  ( value . as_object ( ) . has ( " short " sv ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                auto  const &  short_format  =  value . as_object ( ) . get ( " short " sv ) . as_object ( ) . get ( " standard " sv ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                number_system . currency_short_formats  =  parse_number_format ( short_format . as_object ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }  else  if  ( key . starts_with ( percent_formats_prefix ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-14 08:09:25 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            auto  system  =  key . substring ( percent_formats_prefix . length ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            auto &  number_system  =  ensure_number_system ( system ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            auto  format_object  =  value . as_object ( ) . get ( " standard " sv ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            parse_number_pattern ( format_object . as_string ( ) . split ( ' ; ' ) ,  cldr ,  NumberFormatType : : Standard ,  number_system . percent_format ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-14 08:35:10 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        }  else  if  ( key . starts_with ( scientific_formats_prefix ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            auto  system  =  key . substring ( scientific_formats_prefix . length ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            auto &  number_system  =  ensure_number_system ( system ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            auto  format_object  =  value . as_object ( ) . get ( " standard " sv ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            parse_number_pattern ( format_object . as_string ( ) . split ( ' ; ' ) ,  cldr ,  NumberFormatType : : Standard ,  number_system . scientific_format ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-23 11:00:27 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-11 18:50:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    locale . number_systems . ensure_capacity ( number_systems . size ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 08:12:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    for  ( auto &  number_system  :  number_systems )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-11 18:50:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        NumberSystemIndexType  system_index  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( number_system . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            system_index  =  cldr . unique_systems . ensure ( number_system . release_value ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-11 18:50:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        locale . number_systems . append ( system_index ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 08:12:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 12:40:31 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    locale . minimum_grouping_digits  =  minimum_grouping_digits . as_string ( ) . template  to_uint < u8 > ( ) . value ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-23 11:00:27 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  ErrorOr < void >  parse_units ( String  locale_units_path ,  CLDR &  cldr ,  LocaleData &  locale )  
						 
					
						
							
								
									
										
										
										
											2021-11-16 09:31:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    LexicalPath  units_path ( move ( locale_units_path ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    units_path  =  units_path . append ( " units.json " sv ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-06 16:00:13 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  locale_units  =  TRY ( read_json_file ( units_path . string ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 08:30:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  const &  main_object  =  locale_units . as_object ( ) . get ( " main " sv ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 09:31:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  const &  locale_object  =  main_object . as_object ( ) . get ( units_path . parent ( ) . basename ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto  const &  locale_units_object  =  locale_object . as_object ( ) . get ( " units " sv ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto  const &  long_object  =  locale_units_object . as_object ( ) . get ( " long " sv ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto  const &  short_object  =  locale_units_object . as_object ( ) . get ( " short " sv ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto  const &  narrow_object  =  locale_units_object . as_object ( ) . get ( " narrow " sv ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 08:30:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    HashMap < String ,  Unit >  units ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 09:31:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  ensure_unit  =  [ & ] ( auto  const &  unit )  - >  Unit &  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 08:30:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  units . ensure ( unit ,  [ & ] ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            auto  unit_index  =  cldr . unique_strings . ensure ( unit ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 09:31:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return  Unit  {  . unit  =  unit_index  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto  is_sanctioned_unit  =  [ ] ( StringView  unit_name )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-28 12:05:18 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // LibUnicode generally tries to avoid being directly dependent on ECMA-402, but this rather significantly reduces the amount
 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 09:31:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // of data generated here, and ECMA-402 is currently the only consumer of this data.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-28 12:05:18 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        constexpr  auto  sanctioned_units  =  JS : : Intl : : sanctioned_single_unit_identifiers ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-30 15:44:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( find ( sanctioned_units . begin ( ) ,  sanctioned_units . end ( ) ,  unit_name )  ! =  sanctioned_units . end ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        static  constexpr  auto  extra_sanctioned_units  =  JS : : Intl : : extra_sanctioned_single_unit_identifiers ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  find ( extra_sanctioned_units . begin ( ) ,  extra_sanctioned_units . end ( ) ,  unit_name )  ! =  extra_sanctioned_units . end ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 09:31:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto  parse_units_object  =  [ & ] ( auto  const &  units_object ,  Unicode : : Style  style )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        constexpr  auto  unit_pattern_prefix  =  " unitPattern-count- " sv ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        constexpr  auto  combined_unit_separator  =  " -per- " sv ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        units_object . for_each_member ( [ & ] ( auto  const &  key ,  JsonValue  const &  value )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            auto  end_of_category  =  key . find ( ' - ' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( ! end_of_category . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            auto  unit_name  =  key . substring ( * end_of_category  +  1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( ! is_sanctioned_unit ( unit_name ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                auto  indices  =  unit_name . find_all ( combined_unit_separator ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( indices . size ( )  ! =  1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                auto  numerator  =  unit_name . substring_view ( 0 ,  indices [ 0 ] ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                auto  denominator  =  unit_name . substring_view ( indices [ 0 ]  +  combined_unit_separator . length ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( ! is_sanctioned_unit ( numerator )  | |  ! is_sanctioned_unit ( denominator ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-10 16:36:39 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            auto &  unit  =  ensure_unit ( unit_name ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            NumberFormatList  formats ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 09:31:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            value . as_object ( ) . for_each_member ( [ & ] ( auto  const &  unit_key ,  JsonValue  const &  pattern_value )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( ! unit_key . starts_with ( unit_pattern_prefix ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                NumberFormat  format  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                auto  plurality  =  unit_key . substring_view ( unit_pattern_prefix . length ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-08 10:16:43 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                format . plurality  =  Unicode : : plural_category_from_string ( plurality ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 09:31:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 22:33:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                auto  zero_format  =  pattern_value . as_string ( ) . replace ( " {0} " sv ,  " {number} " sv ,  ReplaceMode : : FirstOnly ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                zero_format  =  parse_identifiers ( zero_format ,  " unitIdentifier " sv ,  cldr ,  format ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 09:31:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                format . positive_format_index  =  cldr . unique_strings . ensure ( zero_format . replace ( " {number} " sv ,  " {plusSign}{number} " sv ,  ReplaceMode : : FirstOnly ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                format . negative_format_index  =  cldr . unique_strings . ensure ( zero_format . replace ( " {number} " sv ,  " {minusSign}{number} " sv ,  ReplaceMode : : FirstOnly ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                format . zero_format_index  =  cldr . unique_strings . ensure ( move ( zero_format ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 09:31:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                formats . append ( cldr . unique_formats . ensure ( move ( format ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 09:31:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-10 16:36:39 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            auto  number_format_list_index  =  cldr . unique_format_lists . ensure ( move ( formats ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-10 16:36:39 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            switch  ( style )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            case  Unicode : : Style : : Long : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                unit . long_formats  =  number_format_list_index ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            case  Unicode : : Style : : Short : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                unit . short_formats  =  number_format_list_index ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            case  Unicode : : Style : : Narrow : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                unit . narrow_formats  =  number_format_list_index ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                VERIFY_NOT_REACHED ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 09:31:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    parse_units_object ( long_object . as_object ( ) ,  Unicode : : Style : : Long ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    parse_units_object ( short_object . as_object ( ) ,  Unicode : : Style : : Short ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    parse_units_object ( narrow_object . as_object ( ) ,  Unicode : : Style : : Narrow ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-23 11:00:27 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 08:30:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    for  ( auto &  unit  :  units )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        auto  unit_index  =  cldr . unique_units . ensure ( move ( unit . value ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 08:30:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        locale . units . set ( unit . key ,  unit_index ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-23 11:00:27 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 09:31:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  ErrorOr < void >  parse_all_locales ( String  core_path ,  String  numbers_path ,  String  units_path ,  CLDR &  cldr )  
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2021-11-23 11:54:53 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  numbers_iterator  =  TRY ( path_to_dir_iterator ( move ( numbers_path ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto  units_iterator  =  TRY ( path_to_dir_iterator ( move ( units_path ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-11 18:42:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    LexicalPath  core_supplemental_path ( move ( core_path ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    core_supplemental_path  =  core_supplemental_path . append ( " supplemental " sv ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    VERIFY ( Core : : File : : is_directory ( core_supplemental_path . string ( ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    TRY ( parse_number_system_digits ( core_supplemental_path . string ( ) ,  cldr ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-11 18:42:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-23 11:54:53 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  remove_variants_from_path  =  [ & ] ( String  path )  - >  ErrorOr < String >  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        auto  parsed_locale  =  TRY ( CanonicalLanguageID < StringIndexType > : : parse ( cldr . unique_strings ,  LexicalPath : : basename ( path ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        StringBuilder  builder ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        builder . append ( cldr . unique_strings . get ( parsed_locale . language ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( auto  script  =  cldr . unique_strings . get ( parsed_locale . script ) ;  ! script . is_empty ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            builder . appendff ( " -{} " ,  script ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( auto  region  =  cldr . unique_strings . get ( parsed_locale . region ) ;  ! region . is_empty ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            builder . appendff ( " -{} " ,  region ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  builder . build ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    while  ( numbers_iterator . has_next ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-23 11:54:53 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        auto  numbers_path  =  TRY ( next_path_from_dir_iterator ( numbers_iterator ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        auto  language  =  TRY ( remove_variants_from_path ( numbers_path ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        auto &  locale  =  cldr . locales . ensure ( language ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        TRY ( parse_number_systems ( numbers_path ,  cldr ,  locale ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 19:10:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 09:31:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    while  ( units_iterator . has_next ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-23 11:54:53 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        auto  units_path  =  TRY ( next_path_from_dir_iterator ( units_iterator ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        auto  language  =  TRY ( remove_variants_from_path ( units_path ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 09:31:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        auto &  locale  =  cldr . locales . ensure ( language ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        TRY ( parse_units ( units_path ,  cldr ,  locale ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 09:31:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-23 11:00:27 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-11 18:42:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  String  format_identifier ( StringView ,  String  identifier )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  identifier . to_titlecase ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  ErrorOr < void >  generate_unicode_locale_header ( Core : : Stream : : BufferedFile &  file ,  CLDR &  cldr )  
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    StringBuilder  builder ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    SourceGenerator  generator  {  builder  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    generator . append ( R " ~~~( 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-11 18:42:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <AK/Types.h> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								# pragma once 
  
						 
					
						
							
								
									
										
										
										
											2022-01-11 18:42:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								namespace  Unicode  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								) ~ ~ ~ " );  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    generate_enum ( generator ,  format_identifier ,  " NumberSystem " sv ,  { } ,  cldr . number_systems ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-11 18:42:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    generator . append ( R " ~~~( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								) ~ ~ ~ " );  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-06 16:00:13 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    TRY ( file . write ( generator . as_string_view ( ) . bytes ( ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  ErrorOr < void >  generate_unicode_locale_implementation ( Core : : Stream : : BufferedFile &  file ,  CLDR &  cldr )  
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    StringBuilder  builder ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    SourceGenerator  generator  {  builder  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    generator . set ( " string_index_type " sv ,  s_string_index_type ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 19:59:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    generator . set ( " number_format_index_type " sv ,  s_number_format_index_type ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-10 16:03:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    generator . set ( " number_format_list_index_type " sv ,  s_number_format_list_index_type ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 00:37:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    generator . set ( " numeric_symbol_list_index_type " sv ,  s_numeric_symbol_list_index_type ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    generator . set ( " identifier_count " ,  String : : number ( cldr . max_identifier_count ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    generator . append ( R " ~~~( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  <AK/Array.h> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  <AK/BinarySearch.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-12-16 12:24:01 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <AK/Optional.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								# include  <AK/Span.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-12-16 12:24:01 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <AK/StringView.h> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  <AK/Vector.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:04:53 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <LibLocale/LocaleData.h> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  <LibLocale/NumberFormatData.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								# include  <LibUnicode/Locale.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-11-27 10:53:42 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <LibUnicode/NumberFormat.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-07-08 10:16:43 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <LibUnicode/PluralRules.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-04 10:57:00 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								namespace  Unicode  {  
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								) ~ ~ ~ " );  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    cldr . unique_strings . generate ( generator ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    generator . append ( R " ~~~( 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-04 10:57:00 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								struct  NumberFormatImpl  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    NumberFormat  to_unicode_number_format ( )  const  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        NumberFormat  number_format  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        number_format . magnitude  =  magnitude ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-15 07:56:20 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        number_format . exponent  =  exponent ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-08 10:16:43 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        number_format . plurality  =  static_cast < PluralCategory > ( plurality ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-15 13:01:42 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        number_format . zero_format  =  decode_string ( zero_format ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        number_format . positive_format  =  decode_string ( positive_format ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        number_format . negative_format  =  decode_string ( negative_format ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 13:53:45 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        number_format . identifiers . ensure_capacity ( identifiers . size ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for  ( @ string_index_type @  identifier  :  identifiers ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-15 13:01:42 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            number_format . identifiers . append ( decode_string ( identifier ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  number_format ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    u8  magnitude  {  0  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-15 07:56:20 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    u8  exponent  {  0  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    u8  plurality  {  0  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    @ string_index_type @  zero_format  {  0  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    @ string_index_type @  positive_format  {  0  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    @ string_index_type @  negative_format  {  0  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 13:53:45 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    Array < @ string_index_type @ ,  @ identifier_count @ >  identifiers  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								} ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-11 18:42:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								struct  NumberSystemData  {  
						 
					
						
							
								
									
										
										
										
											2021-12-11 00:37:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    @ numeric_symbol_list_index_type @  symbols  {  0  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-13 22:03:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    u8  primary_grouping_size  {  0  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    u8  secondary_grouping_size  {  0  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 19:59:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    @ number_format_index_type @  decimal_format  {  0  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-10 16:03:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    @ number_format_list_index_type @  decimal_long_formats  {  0  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    @ number_format_list_index_type @  decimal_short_formats  {  0  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 19:59:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    @ number_format_index_type @  currency_format  {  0  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    @ number_format_index_type @  accounting_format  {  0  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-10 16:03:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    @ number_format_list_index_type @  currency_unit_formats  {  0  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    @ number_format_list_index_type @  currency_short_formats  {  0  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 19:59:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    @ number_format_index_type @  percent_format  {  0  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    @ number_format_index_type @  scientific_format  {  0  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								} ;  
						 
					
						
							
								
									
										
										
										
											2021-11-16 09:31:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								struct  Unit  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    @ string_index_type @  unit  {  0  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-10 16:36:39 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    @ number_format_list_index_type @  long_formats  {  0  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    @ number_format_list_index_type @  short_formats  {  0  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    @ number_format_list_index_type @  narrow_formats  {  0  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 09:31:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								} ;  
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								) ~ ~ ~ " );  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    cldr . unique_formats . generate ( generator ,  " NumberFormatImpl " sv ,  " s_number_formats " sv ,  10 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    cldr . unique_format_lists . generate ( generator ,  s_number_format_index_type ,  " s_number_format_lists " sv ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    cldr . unique_symbols . generate ( generator ,  s_string_index_type ,  " s_numeric_symbol_lists " sv ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    cldr . unique_systems . generate ( generator ,  " NumberSystemData " sv ,  " s_number_systems " sv ,  10 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    cldr . unique_units . generate ( generator ,  " Unit " sv ,  " s_units " sv ,  10 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  locales  =  cldr . locales . keys ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 12:40:31 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    quick_sort ( locales ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    generator . set ( " size " ,  String : : number ( locales . size ( ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    generator . append ( R " ~~~( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								static  constexpr  Array < u8 ,  @ size @ >  s_minimum_grouping_digits  {  {  ) ~ ~ ~ " );  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    bool  first  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    for  ( auto  const &  locale  :  locales )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-11 17:32:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        generator . append ( first  ?  "   " sv  :  " ,  " sv ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        generator . append ( String : : number ( cldr . locales . find ( locale ) - > value . minimum_grouping_digits ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 12:40:31 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        first  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    generator . append ( "  } }; \n " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 08:12:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  append_map  =  [ & ] ( String  name ,  auto  type ,  auto  const &  map )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        generator . set ( " name " ,  name ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 08:12:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        generator . set ( " type " ,  type ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        generator . set ( " size " ,  String : : number ( map . size ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        generator . append ( R " ~~~( 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 08:12:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  constexpr  Array < @ type @ ,  @ size @ >  @ name @  {  { ) ~ ~ ~ " );  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        bool  first  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for  ( auto  const &  item  :  map )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-11 17:32:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            generator . append ( first  ?  "   " sv  :  " ,  " sv ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-11 18:42:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  constexpr  ( requires  {  item . value ;  } ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                generator . append ( String : : number ( item . value ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                generator . append ( String : : number ( item ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 08:12:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            first  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 08:12:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        generator . append ( "  } }; " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    generate_mapping ( generator ,  cldr . number_system_digits ,  " u32 " sv ,  " s_number_systems_digits " sv ,  " s_number_systems_digits_{} " sv ,  nullptr ,  [ & ] ( auto  const &  name ,  auto  const &  value )  {  append_map ( name ,  " u32 " sv ,  value ) ;  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    generate_mapping ( generator ,  cldr . locales ,  s_number_system_index_type ,  " s_locale_number_systems " sv ,  " s_number_systems_{} " sv ,  nullptr ,  [ & ] ( auto  const &  name ,  auto  const &  value )  {  append_map ( name ,  s_number_system_index_type ,  value . number_systems ) ;  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    generate_mapping ( generator ,  cldr . locales ,  s_unit_index_type ,  " s_locale_units " sv ,  " s_units_{} " sv ,  nullptr ,  [ & ] ( auto  const &  name ,  auto  const &  value )  {  append_map ( name ,  s_unit_index_type ,  value . units ) ;  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 14:31:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    generator . append ( R " ~~~( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								static  Optional < NumberSystem >  keyword_to_number_system ( KeywordNumbers  keyword )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    switch  ( keyword )  { ) ~ ~ ~ " ); 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-11 18:42:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    for  ( auto  const &  number_system  :  cldr . number_systems )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 14:31:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        generator . set ( " name " sv ,  format_identifier ( { } ,  number_system ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        generator . append ( R " ~~~( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    case  KeywordNumbers : : @ name @ : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  NumberSystem : : @ name @ ; ) ~ ~ ~ " ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-11 18:42:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    generator . append ( R " ~~~( 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 14:31:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-11 18:42:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Optional < Span < u32  const > >  get_digits_for_number_system ( StringView  system )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-02-15 14:31:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  number_system_keyword  =  keyword_nu_from_string ( system ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( ! number_system_keyword . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto  number_system_value  =  keyword_to_number_system ( * number_system_keyword ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-11 18:42:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( ! number_system_value . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto  number_system_index  =  to_underlying ( * number_system_value ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  s_number_systems_digits [ number_system_index ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								static  NumberSystemData  const *  find_number_system ( StringView  locale ,  StringView  system )  
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto  locale_value  =  locale_from_string ( locale ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( ! locale_value . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-13 14:03:03 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  locale_index  =  to_underlying ( * locale_value )  -  1 ;  // Subtract 1 because 0 == Locale::None.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto  const &  number_systems  =  s_locale_number_systems . at ( locale_index ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 14:31:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-13 14:03:03 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  lookup_number_system  =  [ & ] ( auto  number_system )  - >  NumberSystemData  const *  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        auto  number_system_keyword  =  keyword_nu_from_string ( number_system ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( ! number_system_keyword . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-11 18:50:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-13 14:03:03 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        auto  number_system_value  =  keyword_to_number_system ( * number_system_keyword ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( ! number_system_value . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 08:12:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-13 14:03:03 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        auto  number_system_index  =  to_underlying ( * number_system_value ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        number_system_index  =  number_systems . at ( number_system_index ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( number_system_index  = =  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  & s_number_systems . at ( number_system_index ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( auto  const *  number_system  =  lookup_number_system ( system ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  number_system ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-13 14:03:03 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  default_number_system  =  get_preferred_keyword_value_for_locale ( locale ,  " nu " sv ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( ! default_number_system . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-11 18:50:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-13 14:03:03 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    return  lookup_number_system ( * default_number_system ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-04 10:57:00 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Optional < StringView >  get_number_system_symbol ( StringView  locale ,  StringView  system ,  NumericSymbol  symbol )  
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( auto  const *  number_system  =  find_number_system ( locale ,  system ) ;  number_system  ! =  nullptr )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 00:37:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        auto  symbols  =  s_numeric_symbol_lists . at ( number_system - > symbols ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        auto  symbol_index  =  to_underlying ( symbol ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( symbol_index  > =  symbols . size ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-15 13:01:42 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  decode_string ( symbols [ symbol_index ] ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-13 22:03:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Optional < NumberGroupings >  get_number_system_groupings ( StringView  locale ,  StringView  system )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-01-27 12:40:31 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  locale_value  =  locale_from_string ( locale ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( ! locale_value . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    u8  minimum_grouping_digits  =  s_minimum_grouping_digits [ to_underlying ( * locale_value )  -  1 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-13 22:03:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( auto  const *  number_system  =  find_number_system ( locale ,  system ) ;  number_system  ! =  nullptr ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 12:40:31 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  NumberGroupings  {  minimum_grouping_digits ,  number_system - > primary_grouping_size ,  number_system - > secondary_grouping_size  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-13 22:03:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-04 10:57:00 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Optional < NumberFormat >  get_standard_number_system_format ( StringView  locale ,  StringView  system ,  StandardNumberFormatType  type )  
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( auto  const *  number_system  =  find_number_system ( locale ,  system ) ;  number_system  ! =  nullptr )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 19:59:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        @ number_format_index_type @  format_index  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        switch  ( type )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        case  StandardNumberFormatType : : Decimal : 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 19:59:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            format_index  =  number_system - > decimal_format ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            break ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        case  StandardNumberFormatType : : Currency : 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 19:59:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            format_index  =  number_system - > currency_format ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            break ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        case  StandardNumberFormatType : : Accounting : 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 19:59:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            format_index  =  number_system - > accounting_format ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            break ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        case  StandardNumberFormatType : : Percent : 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 19:59:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            format_index  =  number_system - > percent_format ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            break ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-14 08:35:10 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        case  StandardNumberFormatType : : Scientific : 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 19:59:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            format_index  =  number_system - > scientific_format ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            break ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 19:59:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  s_number_formats [ format_index ] . to_unicode_number_format ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-04 10:57:00 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Vector < NumberFormat >  get_compact_number_system_formats ( StringView  locale ,  StringView  system ,  CompactNumberFormatType  type )  
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-01-04 10:57:00 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    Vector < NumberFormat >  formats ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( auto  const *  number_system  =  find_number_system ( locale ,  system ) ;  number_system  ! =  nullptr )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-10 16:03:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        @ number_format_list_index_type @  number_format_list_index  {  0  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        switch  ( type )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        case  CompactNumberFormatType : : DecimalLong : 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-10 16:03:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            number_format_list_index  =  number_system - > decimal_long_formats ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        case  CompactNumberFormatType : : DecimalShort : 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-10 16:03:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            number_format_list_index  =  number_system - > decimal_short_formats ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            break ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 17:16:30 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        case  CompactNumberFormatType : : CurrencyUnit : 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-10 16:03:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            number_format_list_index  =  number_system - > currency_unit_formats ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 17:16:30 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            break ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        case  CompactNumberFormatType : : CurrencyShort : 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-10 16:03:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            number_format_list_index  =  number_system - > currency_short_formats ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-10 16:03:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        auto  number_formats  =  s_number_format_lists . at ( number_format_list_index ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        formats . ensure_capacity ( number_formats . size ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 19:59:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        for  ( auto  number_format  :  number_formats ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            formats . append ( s_number_formats [ number_format ] . to_unicode_number_format ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  formats ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 09:31:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  Unit  const *  find_units ( StringView  locale ,  StringView  unit )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto  locale_value  =  locale_from_string ( locale ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( ! locale_value . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto  locale_index  =  to_underlying ( * locale_value )  -  1 ;  // Subtract 1 because 0 == Locale::None.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-11 08:30:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  const &  locale_units  =  s_locale_units . at ( locale_index ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    for  ( auto  unit_index  :  locale_units )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        auto  const &  units  =  s_units . at ( unit_index ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 09:31:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-15 13:01:42 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( unit  = =  decode_string ( units . unit ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 09:31:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return  & units ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-04 10:57:00 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Vector < NumberFormat >  get_unit_formats ( StringView  locale ,  StringView  unit ,  Style  style )  
						 
					
						
							
								
									
										
										
										
											2021-11-16 09:31:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-01-04 10:57:00 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    Vector < NumberFormat >  formats ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 09:31:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( auto  const *  units  =  find_units ( locale ,  unit ) ;  units  ! =  nullptr )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-10 16:36:39 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        @ number_format_list_index_type @  number_format_list_index  {  0  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 09:31:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        switch  ( style )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        case  Style : : Long : 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-10 16:36:39 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            number_format_list_index  =  units - > long_formats ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 09:31:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        case  Style : : Short : 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-10 16:36:39 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            number_format_list_index  =  units - > short_formats ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 09:31:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        case  Style : : Narrow : 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-10 16:36:39 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            number_format_list_index  =  units - > narrow_formats ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 09:31:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            VERIFY_NOT_REACHED ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-10 16:36:39 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        auto  number_formats  =  s_number_format_lists . at ( number_format_list_index ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 09:31:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        formats . ensure_capacity ( number_formats . size ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 19:59:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        for  ( auto  number_format  :  number_formats ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            formats . append ( s_number_formats [ number_format ] . to_unicode_number_format ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 09:31:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  formats ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								) ~ ~ ~ " );  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-06 16:00:13 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    TRY ( file . write ( generator . as_string_view ( ) . bytes ( ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-23 11:00:27 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								ErrorOr < int >  serenity_main ( Main : : Arguments  arguments )  
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-01-11 18:42:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    StringView  generated_header_path ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    StringView  generated_implementation_path ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    StringView  core_path ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    StringView  numbers_path ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    StringView  units_path ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    Core : : ArgsParser  args_parser ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args_parser . add_option ( generated_header_path ,  " Path to the Unicode locale header file to generate " ,  " generated-header-path " ,  ' h ' ,  " generated-header-path " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args_parser . add_option ( generated_implementation_path ,  " Path to the Unicode locale implementation file to generate " ,  " generated-implementation-path " ,  ' c ' ,  " generated-implementation-path " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-11 18:42:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    args_parser . add_option ( core_path ,  " Path to cldr-core directory " ,  " core-path " ,  ' r ' ,  " core-path " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    args_parser . add_option ( numbers_path ,  " Path to cldr-numbers directory " ,  " numbers-path " ,  ' n ' ,  " numbers-path " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 09:31:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    args_parser . add_option ( units_path ,  " Path to cldr-units directory " ,  " units-path " ,  ' u ' ,  " units-path " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-23 11:00:27 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    args_parser . parse ( arguments ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-06 16:00:13 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  generated_header_file  =  TRY ( open_file ( generated_header_path ,  Core : : Stream : : OpenMode : : Write ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto  generated_implementation_file  =  TRY ( open_file ( generated_implementation_path ,  Core : : Stream : : OpenMode : : Write ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    CLDR  cldr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    TRY ( parse_all_locales ( core_path ,  numbers_path ,  units_path ,  cldr ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 11:48:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    TRY ( generate_unicode_locale_header ( * generated_header_file ,  cldr ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    TRY ( generate_unicode_locale_implementation ( * generated_implementation_file ,  cldr ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 09:09:48 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}