// generated by insrcdata version 0.2.0 #include "insrcdata.h" #include #include #include static unsigned const REGION_TABLE_COUNT = 5; static const region_t REGION_TABLE[REGION_TABLE_COUNT] = { {"Asia", 142, }, {"Europe", 150, }, {"Africa", 2, }, {"Oceania", 9, }, {"Americas", 19, }, }; const region_t* region_next(region_iter_t* idx) { return idx->ptrend ? ®ION_TABLE[*idx->ptr++] : NULL; } static unsigned const SUBREGION_TABLE_COUNT = 17; static const subregion_t SUBREGION_TABLE[SUBREGION_TABLE_COUNT] = { {"Southern Asia", 34, 0, }, {"Northern Europe", 154, 1, }, {"Southern Europe", 39, 1, }, {"Northern Africa", 15, 2, }, {"Polynesia", 61, 3, }, {"Sub-Saharan Africa", 202, 2, }, {"Latin America and the Caribbean", 419, 4, }, {"Western Asia", 145, 0, }, {"Australia and New Zealand", 53, 3, }, {"Western Europe", 155, 1, }, {"Eastern Europe", 151, 1, }, {"Northern America", 21, 4, }, {"South-eastern Asia", 35, 0, }, {"Eastern Asia", 30, 0, }, {"Melanesia", 54, 3, }, {"Micronesia", 57, 3, }, {"Central Asia", 143, 0, }, }; const subregion_t* subregion_next(subregion_iter_t* idx) { return idx->ptrend ? &SUBREGION_TABLE[*idx->ptr++] : NULL; } static unsigned const SUBREGION_REGION_INDEX_COUNT = 17; static uint8_t SUBREGION_REGION_INDEX [SUBREGION_REGION_INDEX_COUNT] = { 0, 7, 12, 13, 16, 1, 2, 9, 10, 3, 5, 4, 8, 14, 15, 6, 11, }; const country_t COUNTRY_TABLE[COUNTRY_TABLE_COUNT] = { {"Afghanistan", "AF", "AFG", 4, 1, }, {"Åland Islands", "AX", "ALA", 248, 2, }, {"Albania", "AL", "ALB", 8, 3, }, {"Algeria", "DZ", "DZA", 12, 4, }, {"American Samoa", "AS", "ASM", 16, 5, }, {"Andorra", "AD", "AND", 20, 3, }, {"Angola", "AO", "AGO", 24, 6, }, {"Anguilla", "AI", "AIA", 660, 7, }, {"Antarctica", "AQ", "ATA", 10, 0, }, {"Antigua and Barbuda", "AG", "ATG", 28, 7, }, {"Argentina", "AR", "ARG", 32, 7, }, {"Armenia", "AM", "ARM", 51, 8, }, {"Aruba", "AW", "ABW", 533, 7, }, {"Australia", "AU", "AUS", 36, 9, }, {"Austria", "AT", "AUT", 40, 10, }, {"Azerbaijan", "AZ", "AZE", 31, 8, }, {"Bahamas", "BS", "BHS", 44, 7, }, {"Bahrain", "BH", "BHR", 48, 8, }, {"Bangladesh", "BD", "BGD", 50, 1, }, {"Barbados", "BB", "BRB", 52, 7, }, {"Belarus", "BY", "BLR", 112, 11, }, {"Belgium", "BE", "BEL", 56, 10, }, {"Belize", "BZ", "BLZ", 84, 7, }, {"Benin", "BJ", "BEN", 204, 6, }, {"Bermuda", "BM", "BMU", 60, 12, }, {"Bhutan", "BT", "BTN", 64, 1, }, {"Bolivia (Plurinational State of)", "BO", "BOL", 68, 7, }, {"Bonaire, Sint Eustatius and Saba", "BQ", "BES", 535, 7, }, {"Bosnia and Herzegovina", "BA", "BIH", 70, 3, }, {"Botswana", "BW", "BWA", 72, 6, }, {"Bouvet Island", "BV", "BVT", 74, 7, }, {"Brazil", "BR", "BRA", 76, 7, }, {"British Indian Ocean Territory", "IO", "IOT", 86, 6, }, {"Brunei Darussalam", "BN", "BRN", 96, 13, }, {"Bulgaria", "BG", "BGR", 100, 11, }, {"Burkina Faso", "BF", "BFA", 854, 6, }, {"Burundi", "BI", "BDI", 108, 6, }, {"Cabo Verde", "CV", "CPV", 132, 6, }, {"Cambodia", "KH", "KHM", 116, 13, }, {"Cameroon", "CM", "CMR", 120, 6, }, {"Canada", "CA", "CAN", 124, 12, }, {"Cayman Islands", "KY", "CYM", 136, 7, }, {"Central African Republic", "CF", "CAF", 140, 6, }, {"Chad", "TD", "TCD", 148, 6, }, {"Chile", "CL", "CHL", 152, 7, }, {"China", "CN", "CHN", 156, 14, }, {"Christmas Island", "CX", "CXR", 162, 9, }, {"Cocos (Keeling) Islands", "CC", "CCK", 166, 9, }, {"Colombia", "CO", "COL", 170, 7, }, {"Comoros", "KM", "COM", 174, 6, }, {"Congo", "CG", "COG", 178, 6, }, {"Congo, Democratic Republic of the", "CD", "COD", 180, 6, }, {"Cook Islands", "CK", "COK", 184, 5, }, {"Costa Rica", "CR", "CRI", 188, 7, }, {"Côte d'Ivoire", "CI", "CIV", 384, 6, }, {"Croatia", "HR", "HRV", 191, 3, }, {"Cuba", "CU", "CUB", 192, 7, }, {"Curaçao", "CW", "CUW", 531, 7, }, {"Cyprus", "CY", "CYP", 196, 8, }, {"Czechia", "CZ", "CZE", 203, 11, }, {"Denmark", "DK", "DNK", 208, 2, }, {"Djibouti", "DJ", "DJI", 262, 6, }, {"Dominica", "DM", "DMA", 212, 7, }, {"Dominican Republic", "DO", "DOM", 214, 7, }, {"Ecuador", "EC", "ECU", 218, 7, }, {"Egypt", "EG", "EGY", 818, 4, }, {"El Salvador", "SV", "SLV", 222, 7, }, {"Equatorial Guinea", "GQ", "GNQ", 226, 6, }, {"Eritrea", "ER", "ERI", 232, 6, }, {"Estonia", "EE", "EST", 233, 2, }, {"Eswatini", "SZ", "SWZ", 748, 6, }, {"Ethiopia", "ET", "ETH", 231, 6, }, {"Falkland Islands (Malvinas)", "FK", "FLK", 238, 7, }, {"Faroe Islands", "FO", "FRO", 234, 2, }, {"Fiji", "FJ", "FJI", 242, 15, }, {"Finland", "FI", "FIN", 246, 2, }, {"France", "FR", "FRA", 250, 10, }, {"French Guiana", "GF", "GUF", 254, 7, }, {"French Polynesia", "PF", "PYF", 258, 5, }, {"French Southern Territories", "TF", "ATF", 260, 6, }, {"Gabon", "GA", "GAB", 266, 6, }, {"Gambia", "GM", "GMB", 270, 6, }, {"Georgia", "GE", "GEO", 268, 8, }, {"Germany", "DE", "DEU", 276, 10, }, {"Ghana", "GH", "GHA", 288, 6, }, {"Gibraltar", "GI", "GIB", 292, 3, }, {"Greece", "GR", "GRC", 300, 3, }, {"Greenland", "GL", "GRL", 304, 12, }, {"Grenada", "GD", "GRD", 308, 7, }, {"Guadeloupe", "GP", "GLP", 312, 7, }, {"Guam", "GU", "GUM", 316, 16, }, {"Guatemala", "GT", "GTM", 320, 7, }, {"Guernsey", "GG", "GGY", 831, 2, }, {"Guinea", "GN", "GIN", 324, 6, }, {"Guinea-Bissau", "GW", "GNB", 624, 6, }, {"Guyana", "GY", "GUY", 328, 7, }, {"Haiti", "HT", "HTI", 332, 7, }, {"Heard Island and McDonald Islands", "HM", "HMD", 334, 9, }, {"Holy See", "VA", "VAT", 336, 3, }, {"Honduras", "HN", "HND", 340, 7, }, {"Hong Kong", "HK", "HKG", 344, 14, }, {"Hungary", "HU", "HUN", 348, 11, }, {"Iceland", "IS", "ISL", 352, 2, }, {"India", "IN", "IND", 356, 1, }, {"Indonesia", "ID", "IDN", 360, 13, }, {"Iran (Islamic Republic of)", "IR", "IRN", 364, 1, }, {"Iraq", "IQ", "IRQ", 368, 8, }, {"Ireland", "IE", "IRL", 372, 2, }, {"Isle of Man", "IM", "IMN", 833, 2, }, {"Israel", "IL", "ISR", 376, 8, }, {"Italy", "IT", "ITA", 380, 3, }, {"Jamaica", "JM", "JAM", 388, 7, }, {"Japan", "JP", "JPN", 392, 14, }, {"Jersey", "JE", "JEY", 832, 2, }, {"Jordan", "JO", "JOR", 400, 8, }, {"Kazakhstan", "KZ", "KAZ", 398, 17, }, {"Kenya", "KE", "KEN", 404, 6, }, {"Kiribati", "KI", "KIR", 296, 16, }, {"Korea (Democratic People's Republic of)", "KP", "PRK", 408, 14, }, {"Korea, Republic of", "KR", "KOR", 410, 14, }, {"Kuwait", "KW", "KWT", 414, 8, }, {"Kyrgyzstan", "KG", "KGZ", 417, 17, }, {"Lao People's Democratic Republic", "LA", "LAO", 418, 13, }, {"Latvia", "LV", "LVA", 428, 2, }, {"Lebanon", "LB", "LBN", 422, 8, }, {"Lesotho", "LS", "LSO", 426, 6, }, {"Liberia", "LR", "LBR", 430, 6, }, {"Libya", "LY", "LBY", 434, 4, }, {"Liechtenstein", "LI", "LIE", 438, 10, }, {"Lithuania", "LT", "LTU", 440, 2, }, {"Luxembourg", "LU", "LUX", 442, 10, }, {"Macao", "MO", "MAC", 446, 14, }, {"Madagascar", "MG", "MDG", 450, 6, }, {"Malawi", "MW", "MWI", 454, 6, }, {"Malaysia", "MY", "MYS", 458, 13, }, {"Maldives", "MV", "MDV", 462, 1, }, {"Mali", "ML", "MLI", 466, 6, }, {"Malta", "MT", "MLT", 470, 3, }, {"Marshall Islands", "MH", "MHL", 584, 16, }, {"Martinique", "MQ", "MTQ", 474, 7, }, {"Mauritania", "MR", "MRT", 478, 6, }, {"Mauritius", "MU", "MUS", 480, 6, }, {"Mayotte", "YT", "MYT", 175, 6, }, {"Mexico", "MX", "MEX", 484, 7, }, {"Micronesia (Federated States of)", "FM", "FSM", 583, 16, }, {"Moldova, Republic of", "MD", "MDA", 498, 11, }, {"Monaco", "MC", "MCO", 492, 10, }, {"Mongolia", "MN", "MNG", 496, 14, }, {"Montenegro", "ME", "MNE", 499, 3, }, {"Montserrat", "MS", "MSR", 500, 7, }, {"Morocco", "MA", "MAR", 504, 4, }, {"Mozambique", "MZ", "MOZ", 508, 6, }, {"Myanmar", "MM", "MMR", 104, 13, }, {"Namibia", "NA", "NAM", 516, 6, }, {"Nauru", "NR", "NRU", 520, 16, }, {"Nepal", "NP", "NPL", 524, 1, }, {"Netherlands", "NL", "NLD", 528, 10, }, {"New Caledonia", "NC", "NCL", 540, 15, }, {"New Zealand", "NZ", "NZL", 554, 9, }, {"Nicaragua", "NI", "NIC", 558, 7, }, {"Niger", "NE", "NER", 562, 6, }, {"Nigeria", "NG", "NGA", 566, 6, }, {"Niue", "NU", "NIU", 570, 5, }, {"Norfolk Island", "NF", "NFK", 574, 9, }, {"North Macedonia", "MK", "MKD", 807, 3, }, {"Northern Mariana Islands", "MP", "MNP", 580, 16, }, {"Norway", "NO", "NOR", 578, 2, }, {"Oman", "OM", "OMN", 512, 8, }, {"Pakistan", "PK", "PAK", 586, 1, }, {"Palau", "PW", "PLW", 585, 16, }, {"Palestine, State of", "PS", "PSE", 275, 8, }, {"Panama", "PA", "PAN", 591, 7, }, {"Papua New Guinea", "PG", "PNG", 598, 15, }, {"Paraguay", "PY", "PRY", 600, 7, }, {"Peru", "PE", "PER", 604, 7, }, {"Philippines", "PH", "PHL", 608, 13, }, {"Pitcairn", "PN", "PCN", 612, 5, }, {"Poland", "PL", "POL", 616, 11, }, {"Portugal", "PT", "PRT", 620, 3, }, {"Puerto Rico", "PR", "PRI", 630, 7, }, {"Qatar", "QA", "QAT", 634, 8, }, {"Réunion", "RE", "REU", 638, 6, }, {"Romania", "RO", "ROU", 642, 11, }, {"Russian Federation", "RU", "RUS", 643, 11, }, {"Rwanda", "RW", "RWA", 646, 6, }, {"Saint Barthélemy", "BL", "BLM", 652, 7, }, {"Saint Helena, Ascension and Tristan da Cunha", "SH", "SHN", 654, 6, }, {"Saint Kitts and Nevis", "KN", "KNA", 659, 7, }, {"Saint Lucia", "LC", "LCA", 662, 7, }, {"Saint Martin (French part)", "MF", "MAF", 663, 7, }, {"Saint Pierre and Miquelon", "PM", "SPM", 666, 12, }, {"Saint Vincent and the Grenadines", "VC", "VCT", 670, 7, }, {"Samoa", "WS", "WSM", 882, 5, }, {"San Marino", "SM", "SMR", 674, 3, }, {"Sao Tome and Principe", "ST", "STP", 678, 6, }, {"Saudi Arabia", "SA", "SAU", 682, 8, }, {"Senegal", "SN", "SEN", 686, 6, }, {"Serbia", "RS", "SRB", 688, 3, }, {"Seychelles", "SC", "SYC", 690, 6, }, {"Sierra Leone", "SL", "SLE", 694, 6, }, {"Singapore", "SG", "SGP", 702, 13, }, {"Sint Maarten (Dutch part)", "SX", "SXM", 534, 7, }, {"Slovakia", "SK", "SVK", 703, 11, }, {"Slovenia", "SI", "SVN", 705, 3, }, {"Solomon Islands", "SB", "SLB", 90, 15, }, {"Somalia", "SO", "SOM", 706, 6, }, {"South Africa", "ZA", "ZAF", 710, 6, }, {"South Georgia and the South Sandwich Islands", "GS", "SGS", 239, 7, }, {"South Sudan", "SS", "SSD", 728, 6, }, {"Spain", "ES", "ESP", 724, 3, }, {"Sri Lanka", "LK", "LKA", 144, 1, }, {"Sudan", "SD", "SDN", 729, 4, }, {"Suriname", "SR", "SUR", 740, 7, }, {"Svalbard and Jan Mayen", "SJ", "SJM", 744, 2, }, {"Sweden", "SE", "SWE", 752, 2, }, {"Switzerland", "CH", "CHE", 756, 10, }, {"Syrian Arab Republic", "SY", "SYR", 760, 8, }, {"Taiwan, Province of China", "TW", "TWN", 158, 14, }, {"Tajikistan", "TJ", "TJK", 762, 17, }, {"Tanzania, United Republic of", "TZ", "TZA", 834, 6, }, {"Thailand", "TH", "THA", 764, 13, }, {"Timor-Leste", "TL", "TLS", 626, 13, }, {"Togo", "TG", "TGO", 768, 6, }, {"Tokelau", "TK", "TKL", 772, 5, }, {"Tonga", "TO", "TON", 776, 5, }, {"Trinidad and Tobago", "TT", "TTO", 780, 7, }, {"Tunisia", "TN", "TUN", 788, 4, }, {"Turkey", "TR", "TUR", 792, 8, }, {"Turkmenistan", "TM", "TKM", 795, 17, }, {"Turks and Caicos Islands", "TC", "TCA", 796, 7, }, {"Tuvalu", "TV", "TUV", 798, 5, }, {"Uganda", "UG", "UGA", 800, 6, }, {"Ukraine", "UA", "UKR", 804, 11, }, {"United Arab Emirates", "AE", "ARE", 784, 8, }, {"United Kingdom of Great Britain and Northern Ireland", "GB", "GBR", 826, 2, }, {"United States of America", "US", "USA", 840, 12, }, {"United States Minor Outlying Islands", "UM", "UMI", 581, 16, }, {"Uruguay", "UY", "URY", 858, 7, }, {"Uzbekistan", "UZ", "UZB", 860, 17, }, {"Vanuatu", "VU", "VUT", 548, 15, }, {"Venezuela (Bolivarian Republic of)", "VE", "VEN", 862, 7, }, {"Viet Nam", "VN", "VNM", 704, 13, }, {"Virgin Islands (British)", "VG", "VGB", 92, 7, }, {"Virgin Islands (U.S.)", "VI", "VIR", 850, 7, }, {"Wallis and Futuna", "WF", "WLF", 876, 5, }, {"Western Sahara", "EH", "ESH", 732, 4, }, {"Yemen", "YE", "YEM", 887, 8, }, {"Zambia", "ZM", "ZMB", 894, 6, }, {"Zimbabwe", "ZW", "ZWE", 716, 6, }, }; const country_t* country_next(country_iter_t* idx) { return idx->ptrend ? &COUNTRY_TABLE[*idx->ptr++] : NULL; } static unsigned const COUNTRY_ALPHA3_INDEX_COUNT = 249; static uint8_t COUNTRY_ALPHA3_INDEX [COUNTRY_ALPHA3_INDEX_COUNT] = { 12, 0, 6, 7, 1, 2, 5, 233, 10, 11, 4, 8, 79, 9, 13, 14, 15, 36, 21, 23, 27, 35, 18, 34, 17, 16, 28, 185, 20, 22, 24, 26, 31, 19, 33, 25, 30, 29, 42, 40, 47, 215, 44, 45, 54, 39, 51, 50, 52, 48, 49, 37, 53, 56, 57, 46, 41, 58, 59, 83, 61, 62, 60, 63, 3, 64, 65, 68, 245, 209, 69, 71, 75, 74, 72, 76, 73, 144, 80, 234, 82, 92, 84, 85, 93, 89, 81, 94, 67, 86, 88, 87, 91, 77, 90, 95, 100, 97, 99, 55, 96, 101, 104, 108, 103, 32, 107, 105, 106, 102, 109, 110, 111, 113, 114, 112, 115, 116, 121, 38, 117, 187, 119, 120, 122, 124, 126, 127, 188, 128, 210, 125, 129, 130, 123, 131, 189, 150, 146, 145, 132, 135, 143, 138, 164, 136, 137, 152, 148, 147, 165, 151, 140, 149, 139, 141, 133, 134, 142, 153, 157, 160, 163, 161, 159, 162, 156, 166, 155, 154, 158, 167, 168, 171, 176, 174, 175, 169, 172, 177, 179, 118, 178, 173, 170, 78, 180, 181, 182, 183, 184, 195, 211, 196, 200, 207, 186, 213, 204, 199, 66, 193, 205, 190, 197, 208, 194, 212, 202, 203, 214, 70, 201, 198, 216, 229, 43, 222, 220, 218, 223, 228, 221, 224, 225, 226, 227, 230, 217, 219, 231, 232, 236, 237, 235, 238, 98, 191, 240, 242, 243, 241, 239, 244, 192, 246, 206, 247, 248, }; static unsigned const COUNTRY_CODE_INDEX_COUNT = 249; static uint8_t COUNTRY_CODE_INDEX [COUNTRY_CODE_INDEX_COUNT] = { 0, 2, 8, 3, 4, 5, 6, 9, 15, 10, 13, 14, 16, 17, 18, 11, 19, 21, 24, 25, 26, 28, 29, 30, 31, 22, 32, 204, 242, 33, 34, 152, 36, 20, 38, 39, 40, 37, 41, 42, 210, 43, 44, 45, 217, 46, 47, 48, 49, 142, 50, 51, 52, 53, 55, 56, 58, 59, 23, 60, 62, 63, 64, 66, 67, 71, 68, 69, 73, 72, 207, 74, 75, 1, 76, 77, 78, 79, 61, 80, 82, 81, 170, 83, 84, 85, 117, 86, 87, 88, 89, 90, 91, 93, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 109, 110, 54, 111, 112, 115, 114, 116, 118, 119, 120, 121, 122, 124, 125, 123, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 139, 140, 141, 143, 146, 147, 145, 148, 149, 150, 151, 167, 153, 154, 155, 156, 57, 12, 201, 27, 157, 239, 158, 159, 160, 161, 162, 163, 166, 165, 236, 144, 138, 169, 168, 171, 172, 173, 174, 175, 176, 177, 178, 94, 221, 179, 180, 181, 182, 183, 184, 185, 186, 187, 7, 188, 189, 190, 191, 193, 194, 195, 196, 197, 198, 199, 200, 202, 241, 203, 205, 206, 248, 209, 208, 211, 245, 212, 213, 70, 214, 215, 216, 218, 220, 222, 223, 224, 225, 233, 226, 227, 228, 229, 230, 231, 232, 164, 65, 234, 92, 113, 108, 219, 235, 243, 35, 237, 238, 240, 244, 192, 246, 247, }; static unsigned const COUNTRY_SUBREGION_INDEX_COUNT = 248; static uint8_t COUNTRY_SUBREGION_INDEX [COUNTRY_SUBREGION_INDEX_COUNT] = { 0, 18, 25, 103, 105, 135, 155, 168, 210, 1, 60, 69, 73, 75, 92, 102, 107, 108, 113, 123, 129, 166, 213, 214, 234, 2, 5, 28, 55, 85, 86, 98, 110, 137, 148, 164, 178, 193, 197, 203, 209, 3, 65, 127, 150, 211, 226, 245, 4, 52, 78, 162, 176, 192, 223, 224, 230, 244, 6, 23, 29, 32, 35, 36, 37, 39, 42, 43, 49, 50, 51, 54, 61, 67, 68, 70, 71, 79, 80, 81, 84, 93, 94, 116, 125, 126, 132, 133, 136, 140, 141, 142, 151, 153, 160, 161, 181, 184, 186, 194, 196, 198, 199, 205, 206, 208, 219, 222, 231, 247, 248, 7, 9, 10, 12, 16, 19, 22, 26, 27, 30, 31, 41, 44, 48, 53, 56, 57, 62, 63, 64, 66, 72, 77, 88, 89, 91, 95, 96, 99, 111, 139, 143, 149, 159, 171, 173, 174, 179, 185, 187, 188, 189, 191, 201, 207, 212, 225, 229, 237, 240, 242, 243, 11, 15, 17, 58, 82, 106, 109, 114, 120, 124, 167, 170, 180, 195, 216, 227, 233, 246, 13, 46, 47, 97, 158, 163, 14, 21, 76, 83, 128, 130, 146, 156, 215, 20, 34, 59, 101, 145, 177, 182, 183, 202, 232, 24, 40, 87, 190, 235, 33, 38, 104, 122, 134, 152, 175, 200, 220, 221, 241, 45, 100, 112, 118, 119, 131, 147, 217, 74, 157, 172, 204, 239, 90, 117, 138, 144, 154, 165, 169, 236, 115, 121, 218, 228, 238, }; const country_t* country_from_countries(countries_t label) { return &COUNTRY_TABLE[label]; } countries_t country_countries(const country_t *s) { return (countries_t)(s-COUNTRY_TABLE); } subregion_iter_t region_subregions(const region_t* s) { long cons = s - REGION_TABLE; // bissect left uint8_t* lo = SUBREGION_REGION_INDEX; uint8_t* hi = SUBREGION_REGION_INDEX + SUBREGION_REGION_INDEX_COUNT; while( lo < hi ){ uint8_t* mid = lo + ( hi-lo)/2; if ( cons > SUBREGION_TABLE[*mid].region_ ) { lo = mid + 1; } else { hi = mid; } } uint8_t* begin = lo; // bissect-right hi = SUBREGION_REGION_INDEX + SUBREGION_REGION_INDEX_COUNT; while( lo < hi ){ uint8_t* mid = lo + ( hi-lo)/2; if( cons < SUBREGION_TABLE[*mid].region_ ) { hi = mid; } else { lo = mid + 1; } } subregion_iter_t res = { begin, lo }; return res; } const region_t* subregion_region(const subregion_t* s) { return ®ION_TABLE[s->region_];} country_iter_t subregion_countries(const subregion_t* s) { long cons = s - SUBREGION_TABLE + 1; // bissect left uint8_t* lo = COUNTRY_SUBREGION_INDEX; uint8_t* hi = COUNTRY_SUBREGION_INDEX + COUNTRY_SUBREGION_INDEX_COUNT; while( lo < hi ){ uint8_t* mid = lo + ( hi-lo)/2; if ( cons > COUNTRY_TABLE[*mid].subregion_ ) { lo = mid + 1; } else { hi = mid; } } uint8_t* begin = lo; // bissect-right hi = COUNTRY_SUBREGION_INDEX + COUNTRY_SUBREGION_INDEX_COUNT; while( lo < hi ){ uint8_t* mid = lo + ( hi-lo)/2; if( cons < COUNTRY_TABLE[*mid].subregion_ ) { hi = mid; } else { lo = mid + 1; } } country_iter_t res = { begin, lo }; return res; } country_iter_t country_alpha3_range( const char* start, const char* stop) { uint8_t* lo = COUNTRY_ALPHA3_INDEX; uint8_t* hi = COUNTRY_ALPHA3_INDEX + COUNTRY_ALPHA3_INDEX_COUNT; while( lo < hi ){ uint8_t* mid = lo + ( hi-lo)/2; if( strcmp(start,COUNTRY_TABLE[*mid].alpha3_ )>0 ){ lo = mid + 1; } else { hi = mid; } } uint8_t* begin = lo; hi = COUNTRY_ALPHA3_INDEX + COUNTRY_ALPHA3_INDEX_COUNT; while( lo < hi ){ uint8_t* mid = lo + ( hi-lo)/2; if( strcmp(stop,COUNTRY_TABLE[*mid].alpha3_ )<0 ){ hi = mid; } else { lo = mid + 1; } } country_iter_t res = { begin, lo }; return res; } country_iter_t country_code_range( uint16_t start, uint16_t stop) { uint8_t* lo = COUNTRY_CODE_INDEX; uint8_t* hi = COUNTRY_CODE_INDEX + COUNTRY_CODE_INDEX_COUNT; while( lo < hi ){ uint8_t* mid = lo + ( hi-lo)/2; if( start>COUNTRY_TABLE[*mid].code_ ){ lo = mid + 1; } else { hi = mid; } } uint8_t* begin = lo; hi = COUNTRY_CODE_INDEX + COUNTRY_CODE_INDEX_COUNT; while( lo < hi ){ uint8_t* mid = lo + ( hi-lo)/2; if( stopsubregion_) { *ptr = &SUBREGION_TABLE[s->subregion_-1]; return true; } return false; }