1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052
|
@comment{ $Source: e:\\cvsroot/ARM/Source/pre_strings.mss,v $ }
@comment{ $Revision: 1.82 $ $Date: 2015/04/03 04:12:43 $ $Author: randy $ }
@Part(predefstrings, Root="ada.mss")
@Comment{$Date: 2015/04/03 04:12:43 $}
@RMNewPageVer{Version=[3]}@Comment{For printed version of Ada 2012 RM}
@LabeledClause{String Handling}
@begin{Intro}
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00285-01]}
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
This @Chg{Version=[3],New=[subclause],Old=[clause]}
presents the specifications of the package Strings and
several child packages, which provide facilities for dealing with
string data. Fixed-length,
bounded-length, and unbounded-length strings are supported, for @Chg{Version=[2],New=[],Old=[both]}
String@Chg{Version=[2],New=[,],Old=[ and]} Wide_String@Chg{Version=[2],New=[,
and Wide_Wide_String],Old=[]}.
The string-handling subprograms include searches for pattern strings
and for characters in program-specified sets,
translation (via a character-to-character mapping), and transformation
(replacing, inserting, overwriting, and deleting of substrings).
@end{Intro}
@begin{Extend83}
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
@Defn{extensions to Ada 83}
This @Chg{Version=[3],New=[subclause],Old=[clause]}
is new to Ada 95.
@end{Extend83}
@begin{Diffword95}
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00285-01]}
@ChgAdded{Version=[2],Text=[Included Wide_Wide_String in this description;
the individual changes are documented as extensions as needed.]}
@end{Diffword95}
@LabeledSubClause{The Package Strings}
@begin{Intro}
The package Strings provides declarations
common to the string handling packages.
@end{Intro}
@begin{StaticSem}
@Leading@;The library package Strings has the following declaration:
@begin{example}
@ChildUnit{Parent=[Ada],Child=[Strings]}@key[package] Ada.Strings @key[is]
@key[pragma] Pure(Strings);
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00285-01]}
@AdaObjDefn{Space} : @key[constant] Character := ' ';
@AdaObjDefn{Wide_Space} : @key[constant] Wide_Character := ' ';@Chg{Version=[2],New=[
@AdaObjDefn{Wide_Wide_Space} : @key[constant] Wide_Wide_Character := ' ';],Old=[]}
@AdaExcDefn{Length_Error}, @AdaExcDefn{Pattern_Error}, @AdaExcDefn{Index_Error}, @AdaExcDefn{Translation_Error} : @key[exception];
@key[type] @AdaTypeDefn{Alignment} @key[is] (Left, Right, Center);
@key[type] @AdaTypeDefn{Truncation} @key[is] (Left, Right, Error);
@key[type] @AdaTypeDefn{Membership} @key[is] (Inside, Outside);
@key[type] @AdaTypeDefn{Direction} @key[is] (Forward, Backward);
@key[type] @AdaTypeDefn{Trim_End} @key[is] (Left, Right, Both);
@key[end] Ada.Strings;
@end{example}
@end{StaticSem}
@begin{Incompatible95}
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00285-01]}
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0005-1]}
@ChgAdded{Version=[2],Text=[@Defn{incompatibilities with Ada 95}
Constant Wide_Wide_Space is @Chg{Version=[3],New=[],Old=[newly ]}added
to Ada.Strings. If Ada.Strings is
referenced in a @nt{use_clause}, and an entity @i<E> with a
@nt{defining_identifier} of Wide_Wide_Space is defined in a package that is
also referenced in a @nt{use_clause}, the entity @i<E> may no longer be
use-visible, resulting in errors. This should be rare and is easily fixed if
it does occur.]}
@end{Incompatible95}
@RMNewPageVer{Version=[1]}@Comment{Insert page break so printed Ada 95 w/ Corr RM looks better.}
@LabeledSubClause{The Package Strings.Maps}
@begin{Intro}
The package Strings.Maps defines the types, operations, and other
entities needed for character sets and character-to-character mappings.
@end{Intro}
@begin{StaticSem}
@Leading@;The library package Strings.Maps has the following declaration:
@begin{example}
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00362-01]}
@ChildUnit{Parent=[Ada.Strings],Child=[Maps]}@key[package] Ada.Strings.Maps @key[is]
@key[pragma] @Chg{Version=[2],New=[Pure],Old=[Preelaborate]}(Maps);
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00161-01]}
--@Examcom{ Representation for a set of character values:}
@key[type] @AdaTypeDefn{Character_Set} @key[is] @key[private];@Chg{Version=[2],New=[
@key[pragma] Preelaborable_Initialization(Character_Set);],Old=[]}
@AdaObjDefn{Null_Set} : @key[constant] Character_Set;
@key[type] @AdaTypeDefn{Character_Range} @key[is]
@Key[record]
Low : Character;
High : Character;
@key[end] @key[record];
-- @Examcom[Represents Character range Low..High]
@key[type] @AdaTypeDefn{Character_Ranges} @key[is] @key[array] (Positive @key[range] <>) @key[of] Character_Range;
@key[function] @AdaSubDefn{To_Set} (Ranges : @key[in] Character_Ranges)@key[return] Character_Set;
@key[function] @AdaSubDefn{To_Set} (Span : @key[in] Character_Range)@key[return] Character_Set;
@key[function] @AdaSubDefn{To_Ranges} (Set : @key[in] Character_Set) @key[return] Character_Ranges;
@key[function] "=" (Left, Right : @key[in] Character_Set) @key[return] Boolean;
@key[function] "@key[not]" (Right : @key[in] Character_Set) @key[return] Character_Set;
@key[function] "@key[and]" (Left, Right : @key[in] Character_Set) @key[return] Character_Set;
@key[function] "@key[or]" (Left, Right : @key[in] Character_Set) @key[return] Character_Set;
@key[function] "@key[xor]" (Left, Right : @key[in] Character_Set) @key[return] Character_Set;
@key[function] "-" (Left, Right : @key[in] Character_Set) @key[return] Character_Set;
@key[function] @AdaSubDefn{Is_In} (Element : @key[in] Character;
Set : @key[in] Character_Set)
@key[return] Boolean;
@key[function] @AdaSubDefn{Is_Subset} (Elements : @key[in] Character_Set;
Set : @key[in] Character_Set)
@key[return] Boolean;
@key[function] "<=" (Left : @key[in] Character_Set;
Right : @key[in] Character_Set)
@key[return] Boolean @key[renames] Is_Subset;
--@Examcom{ Alternative representation for a set of character values:}
@key[subtype] @AdaSubtypeDefn{Name=[Character_Sequence],Of=[String]} @key[is] String;
@key[function] @AdaSubDefn{To_Set} (Sequence : @key[in] Character_Sequence)@key[return] Character_Set;
@key[function] @AdaSubDefn{To_Set} (Singleton : @key[in] Character) @key[return] Character_Set;
@key[function] @AdaSubDefn{To_Sequence} (Set : @key[in] Character_Set) @key[return] Character_Sequence;
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00161-01]}
--@Examcom{ Representation for a character to character mapping:}
@key[type] @AdaTypeDefn{Character_Mapping} @key[is] @key[private];@Chg{Version=[2],New=[
@key[pragma] Preelaborable_Initialization(Character_Mapping);],Old=[]}
@key[function] @AdaSubDefn{Value} (Map : @key[in] Character_Mapping;
Element : @key[in] Character)
@key[return] Character;
@AdaObjDefn{Identity} : @key[constant] Character_Mapping;
@key[function] @AdaSubDefn{To_Mapping} (From, To : @key[in] Character_Sequence)
@key[return] Character_Mapping;
@key[function] @AdaSubDefn{To_Domain} (Map : @key[in] Character_Mapping)
@key[return] Character_Sequence;
@key[function] @AdaSubDefn{To_Range} (Map : @key[in] Character_Mapping)
@key[return] Character_Sequence;
@key{type} @AdaTypeDefn{Character_Mapping_Function} @key{is}
@key{access} @key{function} (From : @key{in} Character) @key{return} Character;
@key[private]
... -- @Examcom{not specified by the language}
@key[end] Ada.Strings.Maps;
@end{example}
An object of type Character_Set represents a set of characters.
Null_Set represents the set containing no characters.
An object Obj of type Character_Range represents the set of characters
in the range Obj.Low .. Obj.High.
An object Obj of type Character_Ranges represents the
union of the sets corresponding to Obj(I) for I in Obj'Range.
@begin{DescribeCode}
@begin{Example}@Keepnext
@key[function] To_Set (Ranges : @key[in] Character_Ranges) @key[return] Character_Set;
@end{Example}
@Trailing@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
If Ranges'Length=0 then Null_Set is returned;
otherwise@Chg{Version=[3],New=[,],Old=[]}
the returned value represents the set corresponding to Ranges.
@begin{Example}@Keepnext
@key[function] To_Set (Span : @key[in] Character_Range) @key[return] Character_Set;
@end{Example}
The returned value represents the set containing each character in Span.
@begin{Example}@Keepnext
@key[function] To_Ranges (Set : @key[in] Character_Set) @key[return] Character_Ranges;
@end{Example}
@Trailing@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
If Set = Null_Set@Chg{Version=[3],New=[,],Old=[]}
then an empty Character_Ranges array is returned;
otherwise@Chg{Version=[3],New=[,],Old=[]} the shortest array of contiguous
ranges of Character values in Set, in increasing order of Low, is returned.
@begin{Example}@Keepnext
@key[function] "=" (Left, Right : @key[in] Character_Set) @key[return] Boolean;
@end{Example}
@Trailing@;The function "=" returns True if Left and Right represent identical sets,
and False otherwise.
@end{DescribeCode}
@Trailing@;Each of the logical operators "@key[not]", "@key[and]", "@key[or]",
and "@key[xor]" returns
a Character_Set value that represents the set obtained by applying
the corresponding operation to the set(s) represented by the parameter(s)
of the operator.
"@en"(Left, Right) is equivalent to "and"(Left, "not"(Right)).
@begin{reason}
The set minus operator is provided for efficiency.@end{reason}
@begin{DescribeCode}
@begin{Example}@Keepnext
@key[function] Is_In (Element : @key[in] Character;
Set : @key[in] Character_Set);
@key[return] Boolean;
@end{Example}
@Trailing@;Is_In returns True if Element is in Set, and False otherwise.
@begin{Example}@Keepnext
@key[function] Is_Subset (Elements : @key[in] Character_Set;
Set : @key[in] Character_Set)
@key[return] Boolean;
@end{Example}
@Trailing@;Is_Subset returns True if
Elements is a subset of Set, and False otherwise.
@begin{Example}@Keepnext
@key[subtype] Character_Sequence @key[is] String;
@end{Example}
@Trailing@;The Character_Sequence subtype is used to portray a set of character
values and also to identify the domain and range of a character
mapping.
@begin{reason}
Although a named subtype is redundant @em the predefined type String
could have been used for the parameter to To_Set and To_Mapping
below @em the use of a differently named subtype identifies the intended
purpose of the parameter.
@end{reason}
@begin{Example}@Keepnext
@key[function] To_Set (Sequence : @key[in] Character_Sequence) @key[return] Character_Set;@*
@key[function] To_Set (Singleton : @key[in] Character) @key[return] Character_Set;
@end{Example}
@Trailing@;Sequence portrays the set of character values that it explicitly
contains (ignoring duplicates).
Singleton portrays the set comprising a single Character.
Each of the To_Set functions
returns a Character_Set value that represents
the set portrayed by Sequence or Singleton.
@begin{Example}@Keepnext
@key[function] To_Sequence (Set : @key[in] Character_Set) @key[return] Character_Sequence;
@end{Example}
@Trailing@;The function To_Sequence returns a Character_Sequence value
containing each of the characters in the set represented by Set, in
ascending order with no duplicates.
@begin{Example}@Keepnext
@key[type] Character_Mapping @key[is] @key[private];
@end{Example}
@Trailing@;An object of type Character_Mapping represents a
Character-to-Character mapping.
@begin{Example}@Keepnext
@key[function] Value (Map : @key[in] Character_Mapping;
Element : @key[in] Character)
@key[return] Character;
@end{Example}
@Trailing@;The function Value returns the Character value to which Element maps
with respect to the mapping represented by Map.
@end{DescribeCode}
@Defn2{Term=[match], Sec=(a character to a pattern character)}
A character C @i{matches} a pattern character P
with respect to a given Character_Mapping value Map if
Value(Map, C) = P.
@Defn2{Term=[match], Sec=(a string to a pattern string)}
A string S @i{matches} a pattern string P with respect to a
given Character_Mapping if their lengths are the same
and if each character in S matches its corresponding character in
the pattern string P.
@begin{Discussion}
In an earlier version of the string handling packages,
the definition of matching was symmetrical, namely
C matches P if Value(Map,C) = Value(Map,P).
However, applying the mapping
to the pattern was confusing according to some reviewers.
Furthermore, if the symmetrical version is needed, it can
be achieved by applying the mapping to the pattern (via translation) prior to
passing it as a parameter.
@end{Discussion}
String handling subprograms that deal with character mappings have
parameters whose type is Character_Mapping.
@begin{DescribeCode}
@begin{Example}@Keepnext
Identity : @key[constant] Character_Mapping;
@end{Example}
@Trailing@;Identity maps each Character to itself.
@begin{Example}@Keepnext
@key[function] To_Mapping (From, To : @key[in] Character_Sequence)
@key[return] Character_Mapping;
@end{Example}
@Trailing@;To_Mapping produces a Character_Mapping such that
each element of From maps to the corresponding element of To,
and each other character maps to itself.
If From'Length /= To'Length, or
if some character is repeated in From, then Translation_Error
is propagated.
@begin{Example}@Keepnext
@key[function] To_Domain (Map : @key[in] Character_Mapping) @key[return] Character_Sequence;
@end{Example}
@Trailing@;To_Domain returns the shortest Character_Sequence value D such that
each character not in D maps to itself, and such that
the characters in D are in ascending order.
The lower bound of D is 1.
@begin{Example}@Keepnext
@key[function] To_Range (Map : @key[in] Character_Mapping) @key[return] Character_Sequence;
@end{Example}
@ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0048],ARef=[AI95-00151-01]}
@Trailing@;To_Range returns the Character_Sequence value R,
@Chg{New=[],Old=[with lower bound 1 and upper bound Map'Length,]}
such that if D = To_Domain(Map)@Chg{New=[, then R has the same bounds as D,
and],Old=[ then]} D(I) maps to R(I) for each I in D'Range.
@end{DescribeCode}
An object F of type Character_Mapping_Function maps a Character
value C to the Character value F.@key{all}(C), which is said to
@i{match} C with respect to mapping function F.
@Defn2[term=<match>,sec=<a character to a pattern character, with
respect to a character mapping function>]
@end{StaticSem}
@begin{Notes}
Character_Mapping and Character_Mapping_Function
are used both for character equivalence
mappings in the search subprograms (such as for case insensitivity) and
as transformational mappings in the Translate subprograms.
To_Domain(Identity) and To_Range(Identity) each returns the null string.
@begin{Reason}
Package Strings.Maps is not pure, since it declares an
access-to-subprogram type.
@end{Reason}
@end{Notes}
@begin{Examples}
To_Mapping("ABCD", "ZZAB") returns a Character_Mapping that maps 'A'
and 'B' to 'Z', 'C' to 'A', 'D' to 'B', and each other Character to
itself.
@end{Examples}
@begin{Extend95}
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00161-01]}
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
@b[Amendment Correction:] Added @nt{pragma} Preelaborable_Initialization to
types Character_Set and Character_Mapping, so that they can be used
to declare default-initialized objects in preelaborated units.]}
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00362-01]}
@ChgAdded{Version=[2],Text=[Strings.Maps is now Pure,
so it can be used in pure units.]}
@end{Extend95}
@begin{DiffWord95}
@ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0048],ARef=[AI95-00151-01]}
@ChgAdded{Version=[2],Text=[@b<Corrigendum:> Corrected the definition of
the range of the result of To_Range, since the Ada 95 definition makes no
sense.]}
@end{DiffWord95}
@LabeledSubClause{Fixed-Length String Handling}
@begin{Intro}
The language-defined package Strings.Fixed provides string-handling subprograms
for fixed-length strings;
that is, for values of type Standard.String.
Several of these subprograms are procedures that modify the contents of
a String that is passed as an @key[out] or an @key[in] @key[out] parameter;
each has additional
parameters to control the effect when the logical length of the result
differs from the parameter's length.
For each function that returns a String, the lower bound of the returned
value is 1.
@begin{Discussion}
@Chgref{Version=[2],Kind=[Revised],ARef=[AI95-00114-01]}
Most operations that @Chg{Version=[2],New=[yield],Old=[yields]} a String
are provided both as a
function and as a procedure. The functional form is possibly a more aesthetic
style but may introduce overhead due to extra copying or dynamic memory
usage in some implementations. Thus a procedural form, with an @key[in]
@key[out] parameter so that all copying is done `in place', is also
supplied.@end{discussion}
The basic model embodied in the package is that a fixed-length string
comprises significant characters and possibly padding
(with space characters)
on either or both
ends. When a shorter string is copied to a longer string, padding
is inserted, and when a longer string is copied to a shorter one,
padding is stripped. The Move procedure in Strings.Fixed, which takes a
String as an @key[out] parameter, allows the programmer to control these
effects. Similar control is provided by the string transformation
procedures.
@end{Intro}
@begin{StaticSem}
@Leading@keepnext
@Leading@;The library package Strings.Fixed has the following declaration:
@begin{example}
@key[with] Ada.Strings.Maps;
@ChildUnit{Parent=[Ada.Strings],Child=[Fixed]}@key[package] Ada.Strings.Fixed @key[is]
@key[pragma] Preelaborate(Fixed);
--@Examcom{ "Copy" procedure for strings of possibly different lengths}
@key[procedure] @AdaSubDefn{Move} (Source : @key[in] String;
Target : @key[out] String;
Drop : @key[in] Truncation := Error;
Justify : @key[in] Alignment := Left;
Pad : @key[in] Character := Space);
--@Examcom{ Search subprograms}
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]}
@ChgAdded{Version=[2],Text=[ @key[function] @AdaSubDefn{Index} (Source : @key[in] String;
Pattern : @key[in] String;
From : @key[in] Positive;
Going : @key[in] Direction := Forward;
Mapping : @key[in] Maps.Character_Mapping := Maps.Identity)
@key[return] Natural;]}
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]}
@ChgAdded{Version=[2],Text=[ @key[function] @AdaSubDefn{Index} (Source : @key[in] String;
Pattern : @key[in] String;
From : @key[in] Positive;
Going : @key[in] Direction := Forward;
Mapping : @key[in] Maps.Character_Mapping_Function)
@key[return] Natural;]}
@key[function] @AdaSubDefn{Index} (Source : @key[in] String;
Pattern : @key[in] String;
Going : @key[in] Direction := Forward;
Mapping : @key[in] Maps.Character_Mapping
:= Maps.Identity)
@key[return] Natural;
@key[function] @AdaSubDefn{Index} (Source : @key[in] String;
Pattern : @key[in] String;
Going : @key[in] Direction := Forward;
Mapping : @key[in] Maps.Character_Mapping_Function)
@key[return] Natural;
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]}
@ChgAdded{Version=[2],Text=[ @key[function] @AdaSubDefn{Index} (Source : @key[in] String;
Set : @key[in] Maps.Character_Set;
From : @key[in] Positive;
Test : @key[in] Membership := Inside;
Going : @key[in] Direction := Forward)
@key[return] Natural;]}
@key[function] @AdaSubDefn{Index} (Source : @key[in] String;
Set : @key[in] Maps.Character_Set;
Test : @key[in] Membership := Inside;
Going : @key[in] Direction := Forward)
@key[return] Natural;
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]}
@ChgAdded{Version=[2],Text=[ @key[function] @AdaSubDefn{Index_Non_Blank} (Source : @key[in] String;
From : @key[in] Positive;
Going : @key[in] Direction := Forward)
@key[return] Natural;]}
@key[function] @AdaSubDefn{Index_Non_Blank} (Source : @key[in] String;
Going : @key[in] Direction := Forward)
@key[return] Natural;
@key[function] @AdaSubDefn{Count} (Source : @key[in] String;
Pattern : @key[in] String;
Mapping : @key[in] Maps.Character_Mapping
:= Maps.Identity)
@key[return] Natural;
@key[function] @AdaSubDefn{Count} (Source : @key[in] String;
Pattern : @key[in] String;
Mapping : @key[in] Maps.Character_Mapping_Function)
@key[return] Natural;
@key[function] @AdaSubDefn{Count} (Source : @key[in] String;
Set : @key[in] Maps.Character_Set)
@key[return] Natural;
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0031-1]}
@ChgAdded{Version=[3],Text=[ @key[procedure] @AdaSubDefn{Find_Token} (Source : @key[in] String;
Set : @key[in] Maps.Character_Set;
From : @key[in] Positive;
Test : @key[in] Membership;
First : @key[out] Positive;
Last : @key[out] Natural);]}
@key[procedure] @AdaSubDefn{Find_Token} (Source : @key[in] String;
Set : @key[in] Maps.Character_Set;
Test : @key[in] Membership;
First : @key[out] Positive;
Last : @key[out] Natural);
@Keepnext@;--@Examcom{ String translation subprograms}
@key[function] @AdaSubDefn{Translate} (Source : @key[in] String;
Mapping : @key[in] Maps.Character_Mapping)
@key[return] String;
@key[procedure] @AdaSubDefn{Translate} (Source : @key[in] @key[out] String;
Mapping : @key[in] Maps.Character_Mapping);
@key[function] @AdaSubDefn{Translate} (Source : @key[in] String;
Mapping : @key[in] Maps.Character_Mapping_Function)
@key[return] String;
@key[procedure] @AdaSubDefn{Translate} (Source : @key[in] @key[out] String;
Mapping : @key[in] Maps.Character_Mapping_Function);
@Keepnext@;--@Examcom{ String transformation subprograms}
@key[function] @AdaSubDefn{Replace_Slice} (Source : @key[in] String;
Low : @key[in] Positive;
High : @key[in] Natural;
By : @key[in] String)
@key[return] String;
@key[procedure] @AdaSubDefn{Replace_Slice} (Source : @key[in] @key[out] String;
Low : @key[in] Positive;
High : @key[in] Natural;
By : @key[in] String;
Drop : @key[in] Truncation := Error;
Justify : @key[in] Alignment := Left;
Pad : @key[in] Character := Space);
@key[function] @AdaSubDefn{Insert} (Source : @key[in] String;
Before : @key[in] Positive;
New_Item : @key[in] String)
@key[return] String;
@key[procedure] @AdaSubDefn{Insert} (Source : @key[in] @key[out] String;
Before : @key[in] Positive;
New_Item : @key[in] String;
Drop : @key[in] Truncation := Error);
@key[function] @AdaSubDefn{Overwrite} (Source : @key[in] String;
Position : @key[in] Positive;
New_Item : @key[in] String)
@key[return] String;
@key[procedure] @AdaSubDefn{Overwrite} (Source : @key[in] @key[out] String;
Position : @key[in] Positive;
New_Item : @key[in] String;
Drop : @key[in] Truncation := Right);
@key[function] @AdaSubDefn{Delete} (Source : @key[in] String;
From : @key[in] Positive;
Through : @key[in] Natural)
@key[return] String;
@key[procedure] @AdaSubDefn{Delete} (Source : @key[in] @key[out] String;
From : @key[in] Positive;
Through : @key[in] Natural;
Justify : @key[in] Alignment := Left;
Pad : @key[in] Character := Space);
--@Examcom{String selector subprograms}
@key[function] @AdaSubDefn{Trim} (Source : @key[in] String;
Side : @key[in] Trim_End)
@key[return] String;
@key[procedure] @AdaSubDefn{Trim} (Source : @key[in] @key[out] String;
Side : @key[in] Trim_End;
Justify : @key[in] Alignment := Left;
Pad : @key[in] Character := Space);
@key[function] @AdaSubDefn{Trim} (Source : @key[in] String;
Left : @key[in] Maps.Character_Set;
Right : @key[in] Maps.Character_Set)
@key[return] String;
@key[procedure] @AdaSubDefn{Trim} (Source : @key[in] @key[out] String;
Left : @key[in] Maps.Character_Set;
Right : @key[in] Maps.Character_Set;
Justify : @key[in] Alignment := Strings.Left;
Pad : @key[in] Character := Space);
@key[function] @AdaSubDefn{Head} (Source : @key[in] String;
Count : @key[in] Natural;
Pad : @key[in] Character := Space)
@key[return] String;
@key[procedure] @AdaSubDefn{Head} (Source : @key[in] @key[out] String;
Count : @key[in] Natural;
Justify : @key[in] Alignment := Left;
Pad : @key[in] Character := Space);
@key[function] @AdaSubDefn{Tail} (Source : @key[in] String;
Count : @key[in] Natural;
Pad : @key[in] Character := Space)
@key[return] String;
@key[procedure] @AdaSubDefn{Tail} (Source : @key[in] @key[out] String;
Count : @key[in] Natural;
Justify : @key[in] Alignment := Left;
Pad : @key[in] Character := Space);
@keepnext@;--@Examcom{String constructor functions}
@key[function] "*" (Left : @key[in] Natural;
Right : @key[in] Character) @key[return] String;
@key[function] "*" (Left : @key[in] Natural;
Right : @key[in] String) @key[return] String;
@key[end] Ada.Strings.Fixed;
@end{example}
The effects of the above subprograms are as follows.
@begin{DescribeCode}
@begin{Example}@Keepnext
@key[procedure] Move (Source : @key[in] String;
Target : @key[out] String;
Drop : @key[in] Truncation := Error;
Justify : @key[in] Alignment := Left;
Pad : @key[in] Character := Space);
@end{Example}
@Leading@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
The Move procedure copies characters from Source to Target.
If Source has the same length as Target, then the effect is
to assign Source to Target.
If Source is shorter than Target@Chg{Version=[3],New=[,],Old=[]} then:
@begin{itemize}
If Justify=Left, then Source is copied into the first Source'Length
characters of Target.
If Justify=Right, then Source is copied into the last Source'Length
characters of Target.
If Justify=Center, then Source is copied into
the middle Source'Length characters of Target.
In this case, if the difference in length between
Target and Source is odd, then the extra Pad character
is on the right.
Pad is copied to each Target character not otherwise assigned.
@end{itemize}
If Source is longer than Target, then the effect is based on
Drop.
@begin{itemize}
If Drop=Left, then the rightmost Target'Length characters
of Source are copied into Target.
If Drop=Right, then the leftmost Target'Length characters
of Source are copied into Target.
@Leading@;If Drop=Error, then the effect depends on the value of the Justify
parameter and also on whether any characters in Source other than
Pad would fail to be copied:
@begin{inneritemize}
If Justify=Left, and if each of the rightmost Source'Length-Target'Length
characters in Source is Pad, then the leftmost Target'Length characters
of Source are copied to Target.
If Justify=Right, and if each of the leftmost Source'Length-Target'Length
characters in Source is Pad, then the rightmost Target'Length characters
of Source are copied to Target.
@Trailing@;Otherwise, Length_Error is propagated.
@end{inneritemize}
@end{itemize}
@begin{ramification}
The Move procedure will work even if Source and Target
overlap.@end{ramification}
@begin{reason}
The order of parameters (Source before Target)
corresponds to the order in COBOL's MOVE verb.@end{reason}
@begin{Example}
@ChgRef{Version=[2],Kind=[Added]}
@ChgAdded{Version=[2],Text=[@key[function] Index (Source : @key[in] String;
Pattern : @key[in] String;
From : @key[in] Positive;
Going : @key[in] Direction := Forward;
Mapping : @key[in] Maps.Character_Mapping := Maps.Identity)
@key[return] Natural;@*
@key[function] Index (Source : @key[in] String;
Pattern : @key[in] String;
From : @key[in] Positive;
Going : @key[in] Direction := Forward;
Mapping : @key[in] Maps.Character_Mapping_Function)
@key[return] Natural;]}
@end{Example}
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]}
@ChgRef{Version=[3],Kind=[RevisedAdded],ARef=[AI05-0056-1]}
@ChgAdded{Version=[2],Type=[Trailing],Text=[Each Index function searches, starting from From, for a slice of
Source, with length Pattern'Length, that matches Pattern with respect to
Mapping; the parameter Going indicates the direction of the lookup.
@Chg{Version=[3],New=[If Source is the null string, Index returns 0;
otherwise, if],Old=[If]}
From is not in Source'Range, then Index_Error is propagated. If Going =
Forward, then Index returns the smallest index I which is greater than or equal
to From such that the slice of Source starting at I matches Pattern. If Going =
Backward, then Index returns the largest index I such that the slice of Source
starting at I matches Pattern and has an upper bound less than or equal to
From. If there is no such slice, then 0 is returned. If Pattern is the null
string, then Pattern_Error is propagated.]}
@begin{Discussion}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[There is no default parameter for From; the
default value would need to depend on other parameters (the bounds of Source
and the direction Going). It is better to use overloaded functions rather
than a special value to represent the default.]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[There is no default value for the Mapping
parameter that is a Character_Mapping_Function; if there were, a call would
be ambiguous since there is also a default for the Mapping parameter that is
a Character_Mapping.]}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0056-1]}
@ChgAdded{Version=[3],Text=[The language does not define when the
Pattern_Error check is made. (That's because many common searching
implementations require a nonempty pattern) That means that the result for
a call like @f{Index ("", "")} could be 0 or could raise Pattern_Error.
Similarly, in the call @f{Index ("", "", From => 2)}, the language does not
define whether Pattern_Error or Index_Error is raised.]}
@end{Discussion}
@begin{Example}@Keepnext
@key[function] Index (Source : @key[in] String;
Pattern : @key[in] String;
Going : @key[in] Direction := Forward;
Mapping : @key[in] Maps.Character_Mapping
:= Maps.Identity)
@key[return] Natural;@*
@key[function] Index (Source : @key[in] String;
Pattern : @key[in] String;
Going : @key[in] Direction := Forward;
Mapping : @key[in] Maps.Character_Mapping_Function)
@key[return] Natural;
@end{Example}
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00301-01]}
@Comment{@ChgDeleted{Version=[2],Type=[Trailing],Text=[]}@Comment{Fake to hold conditional format.}Can't have both.}
@ChgAdded{Version=[2],Type=[Leading],Text=[]}@Comment{Fake to hold conditional format.}
@Chg{Version=[2],New=[If Going = Forward, returns],
Old=[Each Index function searches for a slice of Source, with length
Pattern'Length, that matches Pattern
with respect to Mapping;
the parameter Going indicates the direction of the lookup.
If Going = Forward, then Index
returns the smallest index I such that
the slice of Source starting at I matches Pattern.
If Going = Backward, then Index
returns the largest index I such that
the slice of Source starting at I matches Pattern.
If there is no such slice, then 0 is returned.
If Pattern is the null string then Pattern_Error is propagated.]}
@begin{Example}
@ChgRef{Version=[2],Kind=[Added]}
@ChgAdded{Version=[2],Text=[ Index (Source, Pattern, Source'First, Forward, Mapping);]}
@end{Example}
@ChgRef{Version=[2],Kind=[Added]}
@ChgRef{Version=[3],Kind=[RevisedAdded],ARef=[AI05-0264-1]}
@ChgAdded{Version=[2],Type=[Leading],Text=[otherwise@Chg{Version=[3],New=[,],Old=[]} returns]}
@begin{Example}
@ChgRef{Version=[2],Kind=[Added]}
@ChgAdded{Version=[2],Type=[Trailing],Text=[ Index (Source, Pattern, Source'Last, Backward, Mapping);]}
@end{Example}
@begin{discussion}
@ChgRef{Version=[2],Kind=[Deleted]}@ChgNote{Moved up}
@ChgAdded{Version=[2],Text=[There is no default value for the Mapping
parameter that is a Character_Mapping_Function; if there were, a call would
be ambiguous since there is also a default for the Mapping parameter that is
a Character_Mapping.]}
@end{discussion}
@begin{Example}
@ChgRef{Version=[2],Kind=[Added]}
@ChgAdded{Version=[2],Text=[@key[function] Index (Source : @key[in] String;
Set : @key[in] Maps.Character_Set;
From : @key[in] Positive;
Test : @key[in] Membership := Inside;
Going : @key[in] Direction := Forward)
@key[return] Natural;]}
@end{Example}
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]}
@ChgRef{Version=[3],Kind=[RevisedAdded],ARef=[AI05-0056-1]}
@ChgAdded{Version=[2],Type=[Trailing],Text=[Index searches for the first or
last occurrence of any of a set of characters (when Test=Inside), or any of the
complement of a set of characters (when Test=Outside).
@Chg{Version=[3],New=[If Source is the null string, Index returns 0;
otherwise, if],Old=[If]} From is not in
Source'Range, then Index_Error is propagated. Otherwise, it returns the
smallest index I >= From (if Going=Forward) or the largest index I <= From (if
Going=Backward) such that Source(I) satisfies the Test condition with respect
to Set; it returns 0 if there is no such Character in Source.]}
@begin{Example}@Keepnext
@key[function] Index (Source : @key[in] String;
Set : @key[in] Maps.Character_Set;
Test : @key[in] Membership := Inside;
Going : @key[in] Direction := Forward)
@key[return] Natural;
@end{Example}
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00301-01]}
@Comment{@ChgDeleted{Version=[2],Type=[Trailing],Text=[]}@Comment{Fake to hold conditional format.}Can't have both.}
@ChgAdded{Version=[2],Type=[Leading],Text=[]}@Comment{Fake to hold conditional format.}
@Chg{Version=[2],New=[If Going = Forward, returns],
Old=[Index searches for the first or last occurrence of any of a set of
characters (when Test=Inside),
or any of the complement of a set of characters (when Test=Outside).
It returns the smallest index I (if Going=Forward) or the largest index I
(if Going=Backward) such that
Source(I) satisfies the Test condition with respect to Set;
it returns 0 if there is no such Character in Source.]}
@begin{Example}
@ChgRef{Version=[2],Kind=[Added]}
@ChgAdded{Version=[2],Text=[ Index (Source, Set, Source'First, Test, Forward);]}
@end{Example}
@ChgRef{Version=[2],Kind=[Added]}
@ChgRef{Version=[3],Kind=[RevisedAdded],ARef=[AI05-0264-1]}
@ChgAdded{Version=[2],Type=[Leading],Text=[otherwise@Chg{Version=[3],New=[,],Old=[]} returns]}
@begin{Example}
@ChgRef{Version=[2],Kind=[Added]}
@ChgAdded{Version=[2],Type=[Trailing],Text=[ Index (Source, Set, Source'Last, Test, Backward);]}
@end{Example}
@begin{Example}
@ChgRef{Version=[2],Kind=[Added]}
@ChgAdded{Version=[2],Text=[@key[function] Index_Non_Blank (Source : @key[in] String;
From : @key[in] Positive;
Going : @key[in] Direction := Forward)
@key[return] Natural;]}
@end{Example}
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]}
@ChgAdded{Version=[2],Type=[Trailing],Text=[Returns Index (Source, Maps.To_Set(Space), From, Outside, Going);]}
@begin{Example}@Keepnext
@key[function] Index_Non_Blank (Source : @key[in] String;
Going : @key[in] Direction := Forward)
@key[return] Natural;
@end{Example}
@Trailing@;Returns Index(Source, Maps.To_Set(Space), Outside, Going)
@begin{Example}@Keepnext
@key[function] Count (Source : @key[in] String;
Pattern : @key[in] String;
Mapping : @key[in] Maps.Character_Mapping
:= Maps.Identity)
@key[return] Natural;@*
@key[function] Count (Source : @key[in] String;
Pattern : @key[in] String;
Mapping : @key[in] Maps.Character_Mapping_Function)
@key[return] Natural;
@end{Example}
@Trailing@;Returns the maximum number of nonoverlapping slices of Source that
match Pattern with respect to Mapping.
If Pattern is the null string then Pattern_Error is propagated.
@begin{reason}
We say `maximum number' because it is possible to slice a source
string in different ways yielding different numbers of matches. For
example if Source is "ABABABA" and Pattern is "ABA", then Count yields
2, although there is a partitioning of Source that yields just 1 match,
for the middle slice. Saying `maximum number' is equivalent to saying
that the pattern match starts either at the low index or the high index
position.
@end{reason}
@begin{Example}@Keepnext
@key[function] Count (Source : @key[in] String;
Set : @key[in] Maps.Character_Set)
@key[return] Natural;
@end{Example}
@Trailing@;Returns the number of occurrences in Source of characters that
are in Set.
@begin{Example}
@ChgRef{Version=[3],Kind=[Added]}
@ChgAdded{Version=[3],Text=[@key[procedure] Find_Token (Source : @key[in] String;
Set : @key[in] Maps.Character_Set;
From : @key[in] Positive;
Test : @key[in] Membership;
First : @key[out] Positive;
Last : @key[out] Natural);]}
@end{Example}
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0031-1]}
@ChgAdded{Version=[3],Type=[Trailing],Text=[If Source is not the null string and
From is not in Source'Range, then Index_Error is raised. Otherwise, First is set
to the index of the first character in Source(From .. Source'Last) that
satisfies the Test condition. Last is set to the largest index such that all
characters in Source(First .. Last) satisfy the Test condition. If no characters
in Source(From .. Source'Last) satisfy the Test condition, First is set to From,
and Last is set to 0.]}
@begin{Example}@Keepnext
@key[procedure] Find_Token (Source : @key[in] String;
Set : @key[in] Maps.Character_Set;
Test : @key[in] Membership;
First : @key[out] Positive;
Last : @key[out] Natural);
@end{Example}
@ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0049],ARef=[AI95-00128-01]}
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0031-1]}
@Trailing@;@Chg{Version=[3],New=[Equivalent to Find_Token (Source, Set,
Source'First, Test, First, Last).],Old=[Find_Token returns in
First and Last the indices of the beginning
and end of the first slice of Source all of whose elements
satisfy the Test condition, and such that the elements
(if any) immediately before and after the slice do not
satisfy the Test condition.
If no such slice exists, then the value returned for Last is zero, and
the value returned for First is Source'First@Chg{New=[; however, if
Source'First is not in Positive then Constraint_Error
@Defn2{Term=[Constraint_Error],Sec=(raised by failure of run-time check)}
is raised],Old=[]}.]}
@begin{Ramification}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0031-1]}
@ChgAdded{Version=[3],Text=[If Source'First is not in Positive, which can only
happen for an empty string, this will raise Constraint_Error.]}
@end{Ramification}
@begin{Example}@Keepnext
@key[function] Translate (Source : @key[in] String;
Mapping : @key[in] Maps.Character_Mapping)
@key[return] String;@*
@key[function] Translate (Source : @key[in] String;
Mapping : @key[in] Maps.Character_Mapping_Function)
@key[return] String;
@end{Example}
@Trailing@;Returns the string S whose length is Source'Length and such
that S(I) is the character to which Mapping maps the corresponding
element of Source, for I in 1..Source'Length.
@begin{Example}@Keepnext
@key[procedure] Translate (Source : @key[in] @key[out] String;
Mapping : @key[in] Maps.Character_Mapping);@*
@key[procedure] Translate (Source : @key[in] @key[out] String;
Mapping : @key[in] Maps.Character_Mapping_Function);
@end{Example}
@Trailing@;Equivalent to Source := Translate(Source, Mapping).
@begin{Example}@Keepnext
@key[function] Replace_Slice (Source : @key[in] String;
Low : @key[in] Positive;
High : @key[in] Natural;
By : @key[in] String)
@key[return] String;
@end{Example}
@ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0049],ARef=[AI95-00128-01]}
@Chg{New=[@Leading],Old=[@Trailing]}If Low > Source'Last+1, or
High < Source'First@en@;1, then Index_Error is propagated.
Otherwise@Chg{New=[:],Old=[, if High >= Low then the returned string
comprises Source(Source'First..Low@en@;1) & By & Source(High+1..Source'Last),
and if High < Low then the returned string is
Insert(Source, Before=>Low, New_Item=>By).]}
@begin{Itemize}
@ChgRef{Version=[1],Kind=[Added],Ref=[8652/0049],ARef=[AI95-00128-01]}
@ChgAdded{Version=[1],Text=[If High >= Low, then the returned string comprises
Source(Source'First..Low@en@;1) & By & Source(High+1..Source'Last), but with
lower bound 1.@Trailing]}
@ChgRef{Version=[1],Kind=[Added],Ref=[8652/0049],ARef=[AI95-00128-01]}
@ChgAdded{Version=[1],Text=[If High < Low, then the returned string is
Insert(Source, Before=>Low, New_Item=>By).]}
@end{Itemize}
@begin{Example}@Keepnext
@key[procedure] Replace_Slice (Source : @key[in] @key[out] String;
Low : @key[in] Positive;
High : @key[in] Natural;
By : @key[in] String;
Drop : @key[in] Truncation := Error;
Justify : @key[in] Alignment := Left;
Pad : @key[in] Character := Space);
@end{Example}
@Trailing@;Equivalent to Move(Replace_Slice(Source, Low, High,
By), Source, Drop, Justify, Pad).
@begin{Example}@Keepnext
@key[function] Insert (Source : @key[in] String;
Before : @key[in] Positive;
New_Item : @key[in] String)
@key[return] String;
@end{Example}
@Trailing@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
Propagates Index_Error if Before is not in Source'First .. Source'Last+1;
otherwise@Chg{Version=[3],New=[,],Old=[]}
returns Source(Source'First..Before@en@;1) & New_Item &
Source(Before..Source'Last), but with lower bound 1.
@begin{Example}@Keepnext
@key[procedure] Insert (Source : @key[in] @key[out] String;
Before : @key[in] Positive;
New_Item : @key[in] String;
Drop : @key[in] Truncation := Error);
@end{Example}
@Trailing@;Equivalent to Move(Insert(Source, Before, New_Item), Source, Drop).
@begin{Example}@Keepnext
@key[function] Overwrite (Source : @key[in] String;
Position : @key[in] Positive;
New_Item : @key[in] String)
@key[return] String;
@end{Example}
@Trailing@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
Propagates Index_Error if Position is not in Source'First .. Source'Last+1;
otherwise@Chg{Version=[3],New=[,],Old=[]}
returns the string obtained from Source by consecutively replacing
characters starting at Position with corresponding characters from
New_Item. If the end of Source is reached before the characters in
New_Item are exhausted, the remaining characters from New_Item are
appended to the string.
@begin{Example}@Keepnext
@key[procedure] Overwrite (Source : @key[in] @key[out] String;
Position : @key[in] Positive;
New_Item : @key[in] String;
Drop : @key[in] Truncation := Right);
@end{Example}
@Trailing@;Equivalent to Move(Overwrite(Source, Position,
New_Item), Source, Drop).
@begin{Example}@Keepnext
@key[function] Delete (Source : @key[in] String;
From : @key[in] Positive;
Through : @key[in] Natural)
@key[return] String;
@end{Example}
@ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0049],ARef=[AI95-00128-01]}
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
@Trailing@;If From <= Through, the returned string is Replace_Slice(Source, From,
Through, "")@Chg{Version=[3],New=[;],Old=[,]}
otherwise@Chg{Version=[3],New=[,],Old=[]} it is Source@Chg{New=[ with lower
bound 1],Old=[]}.
@begin{Example}@Keepnext
@key[procedure] Delete (Source : @key[in] @key[out] String;
From : @key[in] Positive;
Through : @key[in] Natural;
Justify : @key[in] Alignment := Left;
Pad : @key[in] Character := Space);
@end{Example}
@Trailing@;Equivalent to Move(Delete(Source, From, Through),
Source, Justify => Justify, Pad => Pad).
@begin{Example}@Keepnext
@key[function] Trim (Source : @key[in] String;
Side : @key[in] Trim_End)
@key[return] String;
@end{Example}
@Trailing@;Returns the string obtained by removing from Source all leading
Space characters (if Side = Left), all trailing Space characters
(if Side = Right), or all leading and trailing Space characters
(if Side = Both).
@begin{Example}@Keepnext
@key[procedure] Trim (Source : @key[in] @key[out] String;
Side : @key[in] Trim_End;
Justify : @key[in] Alignment := Left;
Pad : @key[in] Character := Space);
@end{Example}
@Trailing@;Equivalent to Move(Trim(Source, Side), Source, Justify=>Justify, Pad=>Pad).
@begin{Example}@Keepnext
@key[function] Trim (Source : @key[in] String;
Left : @key[in] Maps.Character_Set;
Right : @key[in] Maps.Character_Set)
@key[return] String;
@end{Example}
@Trailing@;Returns the string obtained by removing from Source all leading
characters in Left and all trailing characters in Right.
@begin{Example}@Keepnext
@key[procedure] Trim (Source : @key[in] @key[out] String;
Left : @key[in] Maps.Character_Set;
Right : @key[in] Maps.Character_Set;
Justify : @key[in] Alignment := Strings.Left;
Pad : @key[in] Character := Space);
@end{Example}
@Trailing@;Equivalent to Move(Trim(Source, Left, Right), Source,
Justify => Justify, Pad=>Pad).
@begin{Example}@Keepnext
@key[function] Head (Source : @key[in] String;
Count : @key[in] Natural;
Pad : @key[in] Character := Space)
@key[return] String;
@end{Example}
@Trailing@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
Returns a string of length Count. If Count <= Source'Length, the
string comprises the first Count characters of Source.
Otherwise@Chg{Version=[3],New=[,],Old=[]} its contents
are Source concatenated with Count@en@;Source'Length Pad characters.
@begin{Example}@Keepnext
@key[procedure] Head (Source : @key[in] @key[out] String;
Count : @key[in] Natural;
Justify : @key[in] Alignment := Left;
Pad : @key[in] Character := Space);
@end{Example}
@Trailing@;Equivalent to Move(Head(Source, Count, Pad), Source, Drop=>Error,
Justify=>Justify, Pad=>Pad).
@begin{Example}@Keepnext
@key[function] Tail (Source : @key[in] String;
Count : @key[in] Natural;
Pad : @key[in] Character := Space)
@key[return] String;
@end{Example}
@Trailing@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
Returns a string of length Count. If Count <= Source'Length, the
string comprises the last Count characters of Source.
Otherwise@Chg{Version=[3],New=[,],Old=[]} its contents
are Count-Source'Length Pad characters concatenated with Source.
@begin{Example}@Keepnext
@key[procedure] Tail (Source : @key[in] @key[out] String;
Count : @key[in] Natural;
Justify : @key[in] Alignment := Left;
Pad : @key[in] Character := Space);
@end{Example}
@Trailing@;Equivalent to Move(Tail(Source, Count, Pad), Source, Drop=>Error,
Justify=>Justify, Pad=>Pad).
@begin{Example}@Keepnext
@key[function] "*" (Left : @key[in] Natural;
Right : @key[in] Character) @key[return] String;@*
@key[function] "*" (Left : @key[in] Natural;
Right : @key[in] String) @key[return] String;
@end{Example}
@ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0049],ARef=[AI95-00128-01]}
These functions replicate a character or string a specified number
of times. The first function returns a string whose length is Left and each
of whose elements is Right. The second function returns a string whose
length is Left*Right'Length and whose value is the null
string if Left = 0 and @Chg{New=[otherwise ],Old=[]}is
(Left@en@;1)*Right & Right @Chg{New=[with lower bound 1],Old=[otherwise]}.
@end{DescribeCode}
@end{StaticSem}
@begin{Notes}
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
In the Index and Count functions taking Pattern and Mapping parameters,
the actual String parameter passed to Pattern should comprise characters
occurring as target characters of the mapping.
Otherwise@Chg{Version=[3],New=[,],Old=[]} the pattern will not match.
In the Insert subprograms, inserting at the end of a string is obtained
by passing Source'Last+1 as the Before parameter.
@Defn2{Term=[Constraint_Error],Sec=(raised by failure of run-time check)}
If a null Character_Mapping_Function is passed to any of the
string handling subprograms, Constraint_Error is propagated.
@end{Notes}
@begin{Incompatible95}
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00301-01]}
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0005-1]}
@ChgAdded{Version=[2],Text=[@Defn{incompatibilities with Ada 95}
Overloaded versions of Index and Index_Non_Blank are
@Chg{Version=[3],New=[],Old=[newly ]}added to
Strings.Fixed. If Strings.Fixed is referenced in a @nt{use_clause}, and an
entity @i<E> with a @nt{defining_identifier} of Index or Index_Non_Blank is
defined in a package that is also referenced in a @nt{use_clause}, the entity
@i<E> may no longer be use-visible, resulting in errors. This should be rare
and is easily fixed if it does occur.]}
@end{Incompatible95}
@begin{DiffWord95}
@ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0049],ARef=[AI95-00128-01]}
@ChgAdded{Version=[2],Text=[@b<Corrigendum:> Clarified that Find_Token
may raise Constraint_Error if Source'First is not in Positive (which is
only possible for a null string).]}
@ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0049],ARef=[AI95-00128-01]}
@ChgAdded{Version=[2],Text=[@b<Corrigendum:> Clarified that Replace_Slice,
Delete, and "*" always return a string with lower bound 1.]}
@end{DiffWord95}
@begin{Incompatible2005}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0031-1]}
@ChgAdded{Version=[3],Text=[@Defn{incompatibilities with Ada 2005}
An overloaded version of Find_Token is added to
Strings.Fixed. If Strings.Fixed is referenced in a @nt{use_clause}, and an
entity @i<E> with a @nt{defining_identifier} of Find_Token is
defined in a package that is also referenced in a @nt{use_clause}, the entity
@i<E> may no longer be use-visible, resulting in errors. This should be rare
and is easily fixed if it does occur.]}
@end{Incompatible2005}
@begin{DiffWord2005}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0056-1]}
@ChgAdded{Version=[3],Text=[@b<Correction:> Clarified that Index
never raises Index_Error if the source string is null.]}
@end{DiffWord2005}
@LabeledSubClause{Bounded-Length String Handling}
@begin{Intro}
The language-defined package Strings.Bounded provides a generic package
each of whose instances yields a private type Bounded_String and a
set of operations. An object of a particular Bounded_String type
represents a String whose low bound is 1 and whose length
can vary conceptually
between 0 and a maximum size established at the
generic instantiation.
The subprograms for fixed-length string handling
are either overloaded directly for Bounded_String, or are modified as
needed to reflect the variability in length. Additionally, since the
Bounded_String type is private, appropriate constructor and selector
operations are provided.
@begin{reason}
Strings.Bounded declares an inner generic package, versus itself
being directly a generic child of Strings, in order to retain
compatibility with a version of the string-handling packages that
is generic with respect to the character and string types.@end{reason}
@begin{reason}
The bound of a bounded-length string is specified as a parameter
to a generic, versus as the value for a discriminant, because of the
inappropriateness of assignment and equality of discriminated types for
the copying and comparison of bounded strings.@end{reason}
@end{Intro}
@begin{StaticSem}
@Leading@Keepnext@;The library package Strings.Bounded has the following declaration:
@begin{example}
@key[with] Ada.Strings.Maps;
@ChildUnit{Parent=[Ada.Strings],Child=[Bounded]}@key[package] Ada.Strings.Bounded @key[is]
@key[pragma] Preelaborate(Bounded);
@key[generic]
Max : Positive; --@Examcom{ Maximum length of a Bounded_String}
@key[package] @AdaPackDefn{Generic_Bounded_Length} @key[is]
@AdaObjDefn{Max_Length} : @key[constant] Positive := Max;
@key[type] @AdaTypeDefn{Bounded_String} @key[is] @key[private];
@AdaObjDefn{Null_Bounded_String} : @key[constant] Bounded_String;
@key[subtype] @AdaSubtypeDefn{Name=[Length_Range],Of=[Natural]} @key[is] Natural @key[range] 0 .. Max_Length;
@key[function] @AdaSubDefn{Length} (Source : @key[in] Bounded_String) @key[return] Length_Range;
--@Examcom{ Conversion, Concatenation, and Selection functions}
@key[function] @AdaSubDefn{To_Bounded_String} (Source : @key[in] String;
Drop : @key[in] Truncation := Error)
@key[return] Bounded_String;
@key[function] @AdaSubDefn{To_String} (Source : @key[in] Bounded_String) @key[return] String;
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]}
@ChgAdded{Version=[2],Text=[ @key[procedure] @AdaSubDefn{Set_Bounded_String}
(Target : @key[out] Bounded_String;
Source : @key[in] String;
Drop : @key[in] Truncation := Error);]}
@key[function] @AdaSubDefn{Append} (Left, Right : @key[in] Bounded_String;
Drop : @key[in] Truncation := Error)
@key[return] Bounded_String;
@key[function] @AdaSubDefn{Append} (Left : @key[in] Bounded_String;
Right : @key[in] String;
Drop : @key[in] Truncation := Error)
@key[return] Bounded_String;
@key[function] @AdaSubDefn{Append} (Left : @key[in] String;
Right : @key[in] Bounded_String;
Drop : @key[in] Truncation := Error)
@key[return] Bounded_String;
@key[function] @AdaSubDefn{Append} (Left : @key[in] Bounded_String;
Right : @key[in] Character;
Drop : @key[in] Truncation := Error)
@key[return] Bounded_String;
@key[function] @AdaSubDefn{Append} (Left : @key[in] Character;
Right : @key[in] Bounded_String;
Drop : @key[in] Truncation := Error)
@key[return] Bounded_String;
@key[procedure] @AdaSubDefn{Append} (Source : @key[in out] Bounded_String;
New_Item : @key[in] Bounded_String;
Drop : @key[in] Truncation := Error);
@key[procedure] @AdaSubDefn{Append} (Source : @key[in out] Bounded_String;
New_Item : @key[in] String;
Drop : @key[in] Truncation := Error);
@key[procedure] @AdaSubDefn{Append} (Source : @key[in out] Bounded_String;
New_Item : @key[in] Character;
Drop : @key[in] Truncation := Error);
@key[function] "&" (Left, Right : @key[in] Bounded_String)
@key[return] Bounded_String;
@key[function] "&" (Left : @key[in] Bounded_String; Right : @key[in] String)
@key[return] Bounded_String;
@key[function] "&" (Left : @key[in] String; Right : @key[in] Bounded_String)
@key[return] Bounded_String;
@key[function] "&" (Left : @key[in] Bounded_String; Right : @key[in] Character)
@key[return] Bounded_String;
@key[function] "&" (Left : @key[in] Character; Right : @key[in] Bounded_String)
@key[return] Bounded_String;
@key[function] @AdaSubDefn{Element} (Source : @key[in] Bounded_String;
Index : @key[in] Positive)
@key[return] Character;
@key[procedure] @AdaSubDefn{Replace_Element} (Source : @key[in] @key[out] Bounded_String;
Index : @key[in] Positive;
By : @key[in] Character);
@key[function] @AdaSubDefn{Slice} (Source : @key[in] Bounded_String;
Low : @key[in] Positive;
High : @key[in] Natural)
@key[return] String;
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]}
@ChgAdded{Version=[2],Text=[ @key[function] @AdaSubDefn{Bounded_Slice}
(Source : @key[in] Bounded_String;
Low : @key[in] Positive;
High : @key[in] Natural)
@key[return] Bounded_String;]}
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]}
@ChgAdded{Version=[2],Text=[ @key[procedure] @AdaSubDefn{Bounded_Slice}
(Source : @key[in] Bounded_String;
Target : @key[out] Bounded_String;
Low : @key[in] Positive;
High : @key[in] Natural);]}
@key[function] "=" (Left, Right : @key[in] Bounded_String) @key[return] Boolean;
@key[function] "=" (Left : @key[in] Bounded_String; Right : @key[in] String)
@key[return] Boolean;
@key[function] "=" (Left : @key[in] String; Right : @key[in] Bounded_String)
@key[return] Boolean;
@key[function] "<" (Left, Right : @key[in] Bounded_String) @key[return] Boolean;
@key[function] "<" (Left : @key[in] Bounded_String; Right : @key[in] String)
@key[return] Boolean;
@key[function] "<" (Left : @key[in] String; Right : @key[in] Bounded_String)
@key[return] Boolean;
@key[function] "<=" (Left, Right : @key[in] Bounded_String) @key[return] Boolean;
@key[function] "<=" (Left : @key[in] Bounded_String; Right : @key[in] String)
@key[return] Boolean;
@key[function] "<=" (Left : @key[in] String; Right : @key[in] Bounded_String)
@key[return] Boolean;
@key[function] ">" (Left, Right : @key[in] Bounded_String) @key[return] Boolean;
@key[function] ">" (Left : @key[in] Bounded_String; Right : @key[in] String)
@key[return] Boolean;
@key[function] ">" (Left : @key[in] String; Right : @key[in] Bounded_String)
@key[return] Boolean;
@key[function] ">=" (Left, Right : @key[in] Bounded_String) @key[return] Boolean;
@key[function] ">=" (Left : @key[in] Bounded_String; Right : @key[in] String)
@key[return] Boolean;
@key[function] ">=" (Left : @key[in] String; Right : @key[in] Bounded_String)
@key[return] Boolean;
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00301-01]}
--@Examcom{ Search @Chg{Version=[2],New=[subprograms],Old=[functions]}}
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]}
@ChgAdded{Version=[2],Text=[ @key[function] @AdaSubDefn{Index} (Source : @key[in] Bounded_String;
Pattern : @key[in] String;
From : @key[in] Positive;
Going : @key[in] Direction := Forward;
Mapping : @key[in] Maps.Character_Mapping := Maps.Identity)
@key[return] Natural;]}
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]}
@ChgAdded{Version=[2],Text=[ @key[function] @AdaSubDefn{Index} (Source : @key[in] Bounded_String;
Pattern : @key[in] String;
From : @key[in] Positive;
Going : @key[in] Direction := Forward;
Mapping : @key[in] Maps.Character_Mapping_Function)
@key[return] Natural;]}
@key[function] @AdaSubDefn{Index} (Source : @key[in] Bounded_String;
Pattern : @key[in] String;
Going : @key[in] Direction := Forward;
Mapping : @key[in] Maps.Character_Mapping
:= Maps.Identity)
@key[return] Natural;
@key[function] @AdaSubDefn{Index} (Source : @key[in] Bounded_String;
Pattern : @key[in] String;
Going : @key[in] Direction := Forward;
Mapping : @key[in] Maps.Character_Mapping_Function)
@key[return] Natural;
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]}
@ChgAdded{Version=[2],Text=[ @key[function] @AdaSubDefn{Index} (Source : @key[in] Bounded_String;
Set : @key[in] Maps.Character_Set;
From : @key[in] Positive;
Test : @key[in] Membership := Inside;
Going : @key[in] Direction := Forward)
@key[return] Natural;]}
@key[function] @AdaSubDefn{Index} (Source : @key[in] Bounded_String;
Set : @key[in] Maps.Character_Set;
Test : @key[in] Membership := Inside;
Going : @key[in] Direction := Forward)
@key[return] Natural;
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]}
@ChgAdded{Version=[2],Text=[ @key[function] @AdaSubDefn{Index_Non_Blank} (Source : @key[in] Bounded_String;
From : @key[in] Positive;
Going : @key[in] Direction := Forward)
@key[return] Natural;]}
@key[function] @AdaSubDefn{Index_Non_Blank} (Source : @key[in] Bounded_String;
Going : @key[in] Direction := Forward)
@key[return] Natural;
@key[function] @AdaSubDefn{Count} (Source : @key[in] Bounded_String;
Pattern : @key[in] String;
Mapping : @key[in] Maps.Character_Mapping
:= Maps.Identity)
@key[return] Natural;
@key[function] @AdaSubDefn{Count} (Source : @key[in] Bounded_String;
Pattern : @key[in] String;
Mapping : @key[in] Maps.Character_Mapping_Function)
@key[return] Natural;
@key[function] @AdaSubDefn{Count} (Source : @key[in] Bounded_String;
Set : @key[in] Maps.Character_Set)
@key[return] Natural;
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0031-1]}
@ChgAdded{Version=[3],Text=[ @key[procedure] @AdaSubDefn{Find_Token} (Source : @key[in] Bounded_String;
Set : @key[in] Maps.Character_Set;
From : @key[in] Positive;
Test : @key[in] Membership;
First : @key[out] Positive;
Last : @key[out] Natural);]}
@key[procedure] @AdaSubDefn{Find_Token} (Source : @key[in] Bounded_String;
Set : @key[in] Maps.Character_Set;
Test : @key[in] Membership;
First : @key[out] Positive;
Last : @key[out] Natural);
@Keepnext@; --@Examcom{ String translation subprograms}
@key[function] @AdaSubDefn{Translate} (Source : @key[in] Bounded_String;
Mapping : @key[in] Maps.Character_Mapping)
@key[return] Bounded_String;
@key[procedure] @AdaSubDefn{Translate} (Source : @key[in] @key[out] Bounded_String;
Mapping : @key[in] Maps.Character_Mapping);
@key[function] @AdaSubDefn{Translate} (Source : @key[in] Bounded_String;
Mapping : @key[in] Maps.Character_Mapping_Function)
@key[return] Bounded_String;
@key[procedure] @AdaSubDefn{Translate} (Source : @key[in] @key[out] Bounded_String;
Mapping : @key[in] Maps.Character_Mapping_Function);
@Keepnext@; --@Examcom{ String transformation subprograms}
@key[function] @AdaSubDefn{Replace_Slice} (Source : @key[in] Bounded_String;
Low : @key[in] Positive;
High : @key[in] Natural;
By : @key[in] String;
Drop : @key[in] Truncation := Error)
@key[return] Bounded_String;
@key[procedure] @AdaSubDefn{Replace_Slice} (Source : @key[in] @key[out] Bounded_String;
Low : @key[in] Positive;
High : @key[in] Natural;
By : @key[in] String;
Drop : @key[in] Truncation := Error);
@key[function] @AdaSubDefn{Insert} (Source : @key[in] Bounded_String;
Before : @key[in] Positive;
New_Item : @key[in] String;
Drop : @key[in] Truncation := Error)
@key[return] Bounded_String;
@key[procedure] @AdaSubDefn{Insert} (Source : @key[in] @key[out] Bounded_String;
Before : @key[in] Positive;
New_Item : @key[in] String;
Drop : @key[in] Truncation := Error);
@key[function] @AdaSubDefn{Overwrite} (Source : @key[in] Bounded_String;
Position : @key[in] Positive;
New_Item : @key[in] String;
Drop : @key[in] Truncation := Error)
@key[return] Bounded_String;
@key[procedure] @AdaSubDefn{Overwrite} (Source : @key[in] @key[out] Bounded_String;
Position : @key[in] Positive;
New_Item : @key[in] String;
Drop : @key[in] Truncation := Error);
@key[function] @AdaSubDefn{Delete} (Source : @key[in] Bounded_String;
From : @key[in] Positive;
Through : @key[in] Natural)
@key[return] Bounded_String;
@key[procedure] @AdaSubDefn{Delete} (Source : @key[in] @key[out] Bounded_String;
From : @key[in] Positive;
Through : @key[in] Natural);
--@Examcom{String selector subprograms}
@key[function] @AdaSubDefn{Trim} (Source : @key[in] Bounded_String;
Side : @key[in] Trim_End)
@key[return] Bounded_String;
@key[procedure] @AdaSubDefn{Trim} (Source : @key[in] @key[out] Bounded_String;
Side : @key[in] Trim_End);
@key[function] @AdaSubDefn{Trim} (Source : @key[in] Bounded_String;
Left : @key[in] Maps.Character_Set;
Right : @key[in] Maps.Character_Set)
@key[return] Bounded_String;
@key[procedure] @AdaSubDefn{Trim} (Source : @key[in] @key[out] Bounded_String;
Left : @key[in] Maps.Character_Set;
Right : @key[in] Maps.Character_Set);
@key[function] @AdaSubDefn{Head} (Source : @key[in] Bounded_String;
Count : @key[in] Natural;
Pad : @key[in] Character := Space;
Drop : @key[in] Truncation := Error)
@key[return] Bounded_String;
@key[procedure] @AdaSubDefn{Head} (Source : @key[in] @key[out] Bounded_String;
Count : @key[in] Natural;
Pad : @key[in] Character := Space;
Drop : @key[in] Truncation := Error);
@key[function] @AdaSubDefn{Tail} (Source : @key[in] Bounded_String;
Count : @key[in] Natural;
Pad : @key[in] Character := Space;
Drop : @key[in] Truncation := Error)
@key[return] Bounded_String;
@key[procedure] @AdaSubDefn{Tail} (Source : @key[in] @key[out] Bounded_String;
Count : @key[in] Natural;
Pad : @key[in] Character := Space;
Drop : @key[in] Truncation := Error);
--@Examcom{String constructor subprograms}
@key[function] "*" (Left : @key[in] Natural;
Right : @key[in] Character)
@key[return] Bounded_String;
@key[function] "*" (Left : @key[in] Natural;
Right : @key[in] String)
@key[return] Bounded_String;
@key[function] "*" (Left : @key[in] Natural;
Right : @key[in] Bounded_String)
@key[return] Bounded_String;
@key[function] @AdaSubDefn{Replicate} (Count : @key[in] Natural;
Item : @key[in] Character;
Drop : @key[in] Truncation := Error)
@key[return] Bounded_String;
@key[function] @AdaSubDefn{Replicate} (Count : @key[in] Natural;
Item : @key[in] String;
Drop : @key[in] Truncation := Error)
@key[return] Bounded_String;
@key[function] @AdaSubDefn{Replicate} (Count : @key[in] Natural;
Item : @key[in] Bounded_String;
Drop : @key[in] Truncation := Error)
@key[return] Bounded_String;
@key[private]
... -- @Examcom{not specified by the language}
@key[end] Generic_Bounded_Length;
@key[end] Ada.Strings.Bounded;
@end{example}
@begin{ImplNote}
@ChgRef{Version=[1],Kind=[Added],Ref=[8652/0097],ARef=[AI95-00115-01]}
@ChgRef{Version=[2],Kind=[DeletedAdded],ARef=[AI95-00344-01]}
@ChgDeleted{Version=[2],Text=[@Chg{Version=[1],New=[Bounded_String cannot be
implemented as a (directly) controlled type,
as Ada.Strings.Bounded.Generic_Bounded_Length can be instantiated at any
nesting depth. Bounded_String could have
a component of a controlled type, as long as that type is declared in some
other (nongeneric) package (including directly in Ada.Strings.Bounded).],Old=[]}]}
@ChgNote{AI-344 allows controlled types to be declared at
any nesting depth, so this note is obsolete.}
@end{ImplNote}
Null_Bounded_String represents the null string.
If an object of type Bounded_String is not otherwise initialized, it
will be initialized to the same value as Null_Bounded_String.
@begin{DescribeCode}
@begin{Example}@Keepnext
@key[function] Length (Source : @key[in] Bounded_String) @key[return] Length_Range;
@end{Example}
@Trailing@;The Length function returns the length of the string represented by
Source.
@begin{Example}@Keepnext
@key[function] To_Bounded_String (Source : @key[in] String;
Drop : @key[in] Truncation := Error)
@key[return] Bounded_String;
@end{Example}
@Leading@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
If Source'Length <= Max_Length@Chg{Version=[3],New=[,],Old=[]} then
this function
returns a Bounded_String that represents Source.
Otherwise@Chg{Version=[3],New=[,],Old=[]}
the effect depends on the value of Drop:
@begin{itemize}
If Drop=Left, then
the result is a Bounded_String that represents the string comprising
the rightmost Max_Length characters of Source.
If Drop=Right, then
the result is a Bounded_String that represents the string comprising
the leftmost Max_Length characters of Source.
@Trailing@;If Drop=Error, then Strings.Length_Error is propagated.
@end{itemize}
@begin{Example}@Keepnext
@key[function] To_String (Source : @key[in] Bounded_String) @key[return] String;
@end{Example}
@Trailing@;To_String returns the String value with lower bound 1 represented by
Source. If B is a Bounded_String, then B = To_Bounded_String(To_String(B)).
@begin{Example}
@ChgRef{Version=[2],Kind=[Added]}
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key[procedure] Set_Bounded_String
(Target : @key[out] Bounded_String;
Source : @key[in] String;
Drop : @key[in] Truncation := Error);]}
@end{Example}
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]}
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Target := To_Bounded_String (Source, Drop);]}
@end{DescribeCode}
Each of the Append functions returns a Bounded_String obtained by concatenating
the string or character given or represented by one of the parameters,
with the string or character given or represented by the other parameter,
and applying To_Bounded_String to the concatenation result string,
with Drop as provided to the Append function.
Each of the procedures Append(Source, New_Item, Drop) has the same
effect as the corresponding assignment Source :=
Append(Source, New_Item, Drop).
Each of the "&" functions has the same effect as the corresponding
Append function, with Error as the Drop parameter.
@begin{DescribeCode}
@begin{Example}@Keepnext
@key[function] Element (Source : @key[in] Bounded_String;
Index : @key[in] Positive)
@key[return] Character;
@end{Example}
@Trailing@;Returns the character at position Index in the string represented
by Source; propagates Index_Error if Index > Length(Source).
@begin{Example}@Keepnext
@key[procedure] Replace_Element (Source : @key[in] @key[out] Bounded_String;
Index : @key[in] Positive;
By : @key[in] Character);
@end{Example}
@Trailing@;Updates Source such that the character at position Index in the
string represented by Source is By;
propagates Index_Error if Index > Length(Source).
@begin{Example}@Keepnext
@key[function] Slice (Source : @key[in] Bounded_String;
Low : @key[in] Positive;
High : @key[in] Natural)
@key[return] String;
@end{Example}
@ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0049],ARef=[AI95-00128-01]}
@ChgRef{Version=[1],Kind=[Revised],ARef=[AI95-00238-01]}
@Trailing@;Returns the slice at positions Low through High in the string
represented by Source; propagates Index_Error if
Low > Length(Source)+1@Chg{New=[ or High > Length(Source)],Old=[]}.@Chg{Version=[2],
New=[ The bounds of the returned string are Low and High.],Old=[]}.
@begin{Example}
@ChgRef{Version=[2],Kind=[Added]}
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key[function] Bounded_Slice
(Source : @key[in] Bounded_String;
Low : @key[in] Positive;
High : @key[in] Natural)
@key[return] Bounded_String;]}
@end{Example}
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]}
@ChgAdded{Version=[2],Type=[Trailing],Text=[Returns the slice at positions Low
through High in the string represented by Source as a bounded string;
propagates Index_Error if Low > Length(Source)+1 or High > Length(Source).]}
@begin{Example}
@ChgRef{Version=[2],Kind=[Added]}
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key[procedure] Bounded_Slice
(Source : @key[in] Bounded_String;
Target : @key[out] Bounded_String;
Low : @key[in] Positive;
High : @key[in] Natural);]}
@end{Example}
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]}
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Target := Bounded_Slice (Source, Low, High);]}
@end{DescribeCode}
Each of the functions "=", "<", ">", "<=", and ">="
returns the same result as the corresponding String
operation applied to the String values given or represented by
the two parameters.
Each of the search subprograms (Index, Index_Non_Blank,
Count, Find_Token) has the
same effect as the corresponding subprogram in Strings.Fixed applied
to the string represented by the Bounded_String parameter.
Each of the Translate subprograms, when applied to a Bounded_String, has
an analogous effect to the corresponding subprogram in Strings.Fixed.
For the Translate function,
the translation is applied to the string represented by the Bounded_String
parameter, and the result is converted (via To_Bounded_String) to a
Bounded_String.
For the Translate procedure, the string represented by the Bounded_String
parameter after the translation is given by the Translate function for
fixed-length strings applied to the string represented by the
original value of the parameter.
@ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0049],ARef=[AI95-00128-01]}
Each of the transformation subprograms (Replace_Slice, Insert,
Overwrite, Delete), selector subprograms (Trim, Head, Tail),
and constructor functions ("*") has an effect based on its
corresponding subprogram in Strings.Fixed, and Replicate is based on
Fixed."*". @Chg{New=[In the case of a function],
Old=[For each of these subprograms]}, the corresponding
fixed-length string subprogram is applied to the string represented by
the Bounded_String parameter. To_Bounded_String is applied the result
string, with Drop (or Error in the case of Generic_Bounded_Length."*")
determining the effect when the string length exceeds Max_Length.
@Chg{New=[In the case of a procedure, the corresponding function in
Strings.@!Bounded.@!Generic_@!Bounded_@!Length is applied, with the result
assigned into the Source parameter.],Old=[]}
@begin{Ramification}
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00114-01]}
The "/=" operations between Bounded_String and String, and between String
and Bounded_String, are automatically defined based on the @Chg{Version=[2],
New=[corresponding],Old=[corrsponding]}
"=" operations.
@end{Ramification}
@end{StaticSem}
@begin{ImplAdvice}
Bounded string objects should not be implemented by implicit
pointers and dynamic allocation.
@ChgImplAdvice{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2],
Text=[Bounded string objects should not be implemented by implicit
pointers and dynamic allocation.]}]}
@begin{ImplNote}
@Leading@;The following is a possible implementation of the private part
of the package:
@begin{example}
@key[type] Bounded_String_Internals (Length : Length_Range := 0) @key[is]
@key[record]
Data : String(1..Length);
@key[end] @key[record];
@key[type] Bounded_String @key[is]
@key[record]
Data : Bounded_String_Internals; --@Examcom{ Unconstrained}
@key[end] @key[record];
Null_Bounded_String : @key[constant] Bounded_String :=
(Data => (Length => 0,
Data => (1..0 => ' ')));
@end{example}
@end{ImplNote}
@end{ImplAdvice}
@begin{Inconsistent95}
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00238-01]}
@ChgAdded{Version=[2],Text=[@Defn{inconsistencies with Ada 95}
@B[Amendment Correction:] The bounds of the string returned from
Slice are now defined. This is technically an inconsistency; if a program
depended on some other lower bound for the string returned from Slice,
it could fail when compiled with Ada 2005. Such code is not portable even
between Ada 95 implementations, so it should be very rare.]}
@end{Inconsistent95}
@begin{Incompatible95}
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00301-01]}
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0005-1]}
@ChgAdded{Version=[2],Text=[@Defn{incompatibilities with Ada 95}
Procedure Set_Bounded_String, two Bounded_Slice subprograms, and overloaded
versions of Index and Index_Non_Blank are
@Chg{Version=[3],New=[],Old=[newly ]}added to
Strings.Bounded.Generic_Bounded_Length. If an instance of Generic_Bounded_Length is
referenced in a @nt{use_clause}, and an entity @i<E> with the
@nt{defining_identifier} as a new entity in Generic_Bounded_Length is defined in a
package that is also referenced in a @nt{use_clause}, the entity @i<E> may no
longer be use-visible, resulting in errors. This should be rare and is easily
fixed if it does occur.]}
@end{Incompatible95}
@begin{DiffWord95}
@ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0049],ARef=[AI95-00128-01]}
@ChgAdded{Version=[2],Text=[@b<Corrigendum:> Corrected the conditions for
which Slice raises Index_Error.]}
@ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0049],ARef=[AI95-00128-01]}
@ChgAdded{Version=[2],Text=[@b<Corrigendum:> Clarified the meaning of
transformation, selector, and constructor subprograms by describing the
effects of procedures and functions separately.]}
@end{DiffWord95}
@begin{Incompatible2005}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0031-1]}
@ChgAdded{Version=[3],Text=[@Defn{incompatibilities with Ada 2005}
An overloaded version of Find_Token is added to
Strings.Bounded.Generic_Bounded_Length. If an instance of Generic_Bounded_Length is
referenced in a @nt{use_clause}, and an
entity @i<E> with a @nt{defining_identifier} of Find_Token is
defined in a package that is also referenced in a @nt{use_clause}, the entity
@i<E> may no longer be use-visible, resulting in errors. This should be rare
and is easily fixed if it does occur.]}
@end{Incompatible2005}
@LabeledSubClause{Unbounded-Length String Handling}
@begin{Intro}
The language-defined package Strings.Unbounded provides a
private type Unbounded_String and a
set of operations. An object of type Unbounded_String represents a String
whose low bound is 1 and whose length
can vary conceptually between 0 and Natural'Last.
The subprograms for fixed-length string handling
are either overloaded directly for Unbounded_String, or are modified as
needed to reflect the flexibility in length. Since the
Unbounded_String type is private, relevant constructor and selector
operations are provided.
@begin{reason}
The transformation operations for fixed- and bounded-length strings that
are not necessarily length preserving are supplied for Unbounded_String
as procedures as well as functions.
This allows an implementation to do an initial allocation for
an unbounded string and to avoid further allocations as long
as the length does not exceed the allocated length.
@end{reason}
@end{Intro}
@begin{StaticSem}
@Leading@;The library package Strings.Unbounded has the following declaration:
@begin{example}
@key[with] Ada.Strings.Maps;
@ChildUnit{Parent=[Ada.Strings],Child=[Unbounded]}@key[package] Ada.Strings.Unbounded @key[is]
@key[pragma] Preelaborate(Unbounded);
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00161-01]}
@key[type] @AdaTypeDefn{Unbounded_String} @key[is] @key[private];@Chg{Version=[2],New=[
@key[pragma] Preelaborable_Initialization(Unbounded_String);],Old=[]}
@AdaObjDefn{Null_Unbounded_String} : @key[constant] Unbounded_String;
@key[function] @AdaSubDefn{Length} (Source : @key[in] Unbounded_String) @key[return] Natural;
@key[type] @AdaTypeDefn{String_Access} @key[is] @key[access] @key[all] String;
@key[procedure] @AdaSubDefn{Free} (X : @key[in] @key[out] String_Access);
--@Examcom{ Conversion, Concatenation, and Selection functions}
@key[function] @AdaSubDefn{To_Unbounded_String} (Source : @key[in] String)
@key[return] Unbounded_String;
@key[function] @AdaSubDefn{To_Unbounded_String} (Length : @key[in] Natural)
@key[return] Unbounded_String;
@key[function] @AdaSubDefn{To_String} (Source : @key[in] Unbounded_String) @key[return] String;
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]}
@ChgAdded{Version=[2],Text=[ @key[procedure] @AdaSubDefn{Set_Unbounded_String}
(Target : @key[out] Unbounded_String;
Source : @key[in] String);]}
@key[procedure] @AdaSubDefn{Append} (Source : @key[in out] Unbounded_String;
New_Item : @key[in] Unbounded_String);
@key[procedure] @AdaSubDefn{Append} (Source : @key[in out] Unbounded_String;
New_Item : @key[in] String);
@key[procedure] @AdaSubDefn{Append} (Source : @key[in out] Unbounded_String;
New_Item : @key[in] Character);
@key[function] "&" (Left, Right : @key[in] Unbounded_String)
@key[return] Unbounded_String;
@key[function] "&" (Left : @key[in] Unbounded_String; Right : @key[in] String)
@key[return] Unbounded_String;
@key[function] "&" (Left : @key[in] String; Right : @key[in] Unbounded_String)
@key[return] Unbounded_String;
@key[function] "&" (Left : @key[in] Unbounded_String; Right : @key[in] Character)
@key[return] Unbounded_String;
@key[function] "&" (Left : @key[in] Character; Right : @key[in] Unbounded_String)
@key[return] Unbounded_String;
@key[function] @AdaSubDefn{Element} (Source : @key[in] Unbounded_String;
Index : @key[in] Positive)
@key[return] Character;
@key[procedure] @AdaSubDefn{Replace_Element} (Source : @key[in] @key[out] Unbounded_String;
Index : @key[in] Positive;
By : @key[in] Character);
@key[function] @AdaSubDefn{Slice} (Source : @key[in] Unbounded_String;
Low : @key[in] Positive;
High : @key[in] Natural)
@key[return] String;
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]}
@ChgAdded{Version=[2],Text=[ @key[function] @AdaSubDefn{Unbounded_Slice}
(Source : @key[in] Unbounded_String;
Low : @key[in] Positive;
High : @key[in] Natural)
@key[return] Unbounded_String;]}
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]}
@ChgAdded{Version=[2],Text=[ @key[procedure] @AdaSubDefn{Unbounded_Slice}
(Source : @key[in] Unbounded_String;
Target : @key[out] Unbounded_String;
Low : @key[in] Positive;
High : @key[in] Natural);]}
@key[function] "=" (Left, Right : @key[in] Unbounded_String) @key[return] Boolean;
@key[function] "=" (Left : @key[in] Unbounded_String; Right : @key[in] String)
@key[return] Boolean;
@key[function] "=" (Left : @key[in] String; Right : @key[in] Unbounded_String)
@key[return] Boolean;
@key[function] "<" (Left, Right : @key[in] Unbounded_String) @key[return] Boolean;
@key[function] "<" (Left : @key[in] Unbounded_String; Right : @key[in] String)
@key[return] Boolean;
@key[function] "<" (Left : @key[in] String; Right : @key[in] Unbounded_String)
@key[return] Boolean;
@key[function] "<=" (Left, Right : @key[in] Unbounded_String) @key[return] Boolean;
@key[function] "<=" (Left : @key[in] Unbounded_String; Right : @key[in] String)
@key[return] Boolean;
@key[function] "<=" (Left : @key[in] String; Right : @key[in] Unbounded_String)
@key[return] Boolean;
@key[function] ">" (Left, Right : @key[in] Unbounded_String) @key[return] Boolean;
@key[function] ">" (Left : @key[in] Unbounded_String; Right : @key[in] String)
@key[return] Boolean;
@key[function] ">" (Left : @key[in] String; Right : @key[in] Unbounded_String)
@key[return] Boolean;
@key[function] ">=" (Left, Right : @key[in] Unbounded_String) @key[return] Boolean;
@key[function] ">=" (Left : @key[in] Unbounded_String; Right : @key[in] String)
@key[return] Boolean;
@key[function] ">=" (Left : @key[in] String; Right : @key[in] Unbounded_String)
@key[return] Boolean;
--@Examcom{ Search subprograms}
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]}
@ChgAdded{Version=[2],Text=[ @key[function] @AdaSubDefn{Index} (Source : @key[in] Unbounded_String;
Pattern : @key[in] String;
From : @key[in] Positive;
Going : @key[in] Direction := Forward;
Mapping : @key[in] Maps.Character_Mapping := Maps.Identity)
@key[return] Natural;]}
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]}
@ChgAdded{Version=[2],Text=[ @key[function] @AdaSubDefn{Index} (Source : @key[in] Unbounded_String;
Pattern : @key[in] String;
From : @key[in] Positive;
Going : @key[in] Direction := Forward;
Mapping : @key[in] Maps.Character_Mapping_Function)
@key[return] Natural;]}
@key[function] @AdaSubDefn{Index} (Source : @key[in] Unbounded_String;
Pattern : @key[in] String;
Going : @key[in] Direction := Forward;
Mapping : @key[in] Maps.Character_Mapping
:= Maps.Identity)
@key[return] Natural;
@key[function] @AdaSubDefn{Index} (Source : @key[in] Unbounded_String;
Pattern : @key[in] String;
Going : @key[in] Direction := Forward;
Mapping : @key[in] Maps.Character_Mapping_Function)
@key[return] Natural;
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]}
@ChgAdded{Version=[2],Text=[ @key[function] @AdaSubDefn{Index} (Source : @key[in] Unbounded_String;
Set : @key[in] Maps.Character_Set;
From : @key[in] Positive;
Test : @key[in] Membership := Inside;
Going : @key[in] Direction := Forward)
@key[return] Natural;]}
@key[function] @AdaSubDefn{Index} (Source : @key[in] Unbounded_String;
Set : @key[in] Maps.Character_Set;
Test : @key[in] Membership := Inside;
Going : @key[in] Direction := Forward) @key[return] Natural;
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]}
@ChgAdded{Version=[2],Text=[ @key[function] @AdaSubDefn{Index_Non_Blank} (Source : @key[in] Unbounded_String;
From : @key[in] Positive;
Going : @key[in] Direction := Forward)
@key[return] Natural;]}
@key[function] @AdaSubDefn{Index_Non_Blank} (Source : @key[in] Unbounded_String;
Going : @key[in] Direction := Forward)
@key[return] Natural;
@key[function] @AdaSubDefn{Count} (Source : @key[in] Unbounded_String;
Pattern : @key[in] String;
Mapping : @key[in] Maps.Character_Mapping
:= Maps.Identity)
@key[return] Natural;
@key[function] @AdaSubDefn{Count} (Source : @key[in] Unbounded_String;
Pattern : @key[in] String;
Mapping : @key[in] Maps.Character_Mapping_Function)
@key[return] Natural;
@key[function] @AdaSubDefn{Count} (Source : @key[in] Unbounded_String;
Set : @key[in] Maps.Character_Set)
@key[return] Natural;
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0031-1]}
@ChgAdded{Version=[3],Text=[ @key[procedure] @AdaSubDefn{Find_Token} (Source : @key[in] Unbounded_String;
Set : @key[in] Maps.Character_Set;
From : @key[in] Positive;
Test : @key[in] Membership;
First : @key[out] Positive;
Last : @key[out] Natural);]}
@key[procedure] @AdaSubDefn{Find_Token} (Source : @key[in] Unbounded_String;
Set : @key[in] Maps.Character_Set;
Test : @key[in] Membership;
First : @key[out] Positive;
Last : @key[out] Natural);
@Keepnext@;--@Examcom{ String translation subprograms}
@key[function] @AdaSubDefn{Translate} (Source : @key[in] Unbounded_String;
Mapping : @key[in] Maps.Character_Mapping)
@key[return] Unbounded_String;
@key[procedure] @AdaSubDefn{Translate} (Source : @key[in] @key[out] Unbounded_String;
Mapping : @key[in] Maps.Character_Mapping);
@key[function] @AdaSubDefn{Translate} (Source : @key[in] Unbounded_String;
Mapping : @key[in] Maps.Character_Mapping_Function)
@key[return] Unbounded_String;
@key[procedure] @AdaSubDefn{Translate} (Source : @key[in] @key[out] Unbounded_String;
Mapping : @key[in] Maps.Character_Mapping_Function);
@Keepnext@;--@Examcom{ String transformation subprograms}
@key[function] @AdaSubDefn{Replace_Slice} (Source : @key[in] Unbounded_String;
Low : @key[in] Positive;
High : @key[in] Natural;
By : @key[in] String)
@key[return] Unbounded_String;
@key[procedure] @AdaSubDefn{Replace_Slice} (Source : @key[in] @key[out] Unbounded_String;
Low : @key[in] Positive;
High : @key[in] Natural;
By : @key[in] String);
@key[function] @AdaSubDefn{Insert} (Source : @key[in] Unbounded_String;
Before : @key[in] Positive;
New_Item : @key[in] String)
@key[return] Unbounded_String;
@key[procedure] @AdaSubDefn{Insert} (Source : @key[in] @key[out] Unbounded_String;
Before : @key[in] Positive;
New_Item : @key[in] String);
@key[function] @AdaSubDefn{Overwrite} (Source : @key[in] Unbounded_String;
Position : @key[in] Positive;
New_Item : @key[in] String)
@key[return] Unbounded_String;
@key[procedure] @AdaSubDefn{Overwrite} (Source : @key[in] @key[out] Unbounded_String;
Position : @key[in] Positive;
New_Item : @key[in] String);
@key[function] @AdaSubDefn{Delete} (Source : @key[in] Unbounded_String;
From : @key[in] Positive;
Through : @key[in] Natural)
@key[return] Unbounded_String;
@key[procedure] @AdaSubDefn{Delete} (Source : @key[in] @key[out] Unbounded_String;
From : @key[in] Positive;
Through : @key[in] Natural);
@key[function] @AdaSubDefn{Trim} (Source : @key[in] Unbounded_String;
Side : @key[in] Trim_End)
@key[return] Unbounded_String;
@key[procedure] @AdaSubDefn{Trim} (Source : @key[in] @key[out] Unbounded_String;
Side : @key[in] Trim_End);
@key[function] @AdaSubDefn{Trim} (Source : @key[in] Unbounded_String;
Left : @key[in] Maps.Character_Set;
Right : @key[in] Maps.Character_Set)
@key[return] Unbounded_String;
@key[procedure] @AdaSubDefn{Trim} (Source : @key[in] @key[out] Unbounded_String;
Left : @key[in] Maps.Character_Set;
Right : @key[in] Maps.Character_Set);
@key[function] @AdaSubDefn{Head} (Source : @key[in] Unbounded_String;
Count : @key[in] Natural;
Pad : @key[in] Character := Space)
@key[return] Unbounded_String;
@key[procedure] @AdaSubDefn{Head} (Source : @key[in] @key[out] Unbounded_String;
Count : @key[in] Natural;
Pad : @key[in] Character := Space);
@key[function] @AdaSubDefn{Tail} (Source : @key[in] Unbounded_String;
Count : @key[in] Natural;
Pad : @key[in] Character := Space)
@key[return] Unbounded_String;
@key[procedure] @AdaSubDefn{Tail} (Source : @key[in] @key[out] Unbounded_String;
Count : @key[in] Natural;
Pad : @key[in] Character := Space);
@key[function] "*" (Left : @key[in] Natural;
Right : @key[in] Character)
@key[return] Unbounded_String;
@key[function] "*" (Left : @key[in] Natural;
Right : @key[in] String)
@key[return] Unbounded_String;
@key[function] "*" (Left : @key[in] Natural;
Right : @key[in] Unbounded_String)
@key[return] Unbounded_String;
@key[private]
... -- @Examcom{not specified by the language}
@key[end] Ada.Strings.Unbounded;
@end{example}
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00360-01]}
@ChgAdded{Version=[2],Text=[The type Unbounded_String
needs finalization@PDefn2{Term=<needs finalization>,Sec=<language-defined type>}
(see @RefSecNum{Assignment and Finalization}).]}
Null_Unbounded_String represents the null String.
If an object of type Unbounded_String is not otherwise initialized, it
will be initialized to the same value as Null_Unbounded_String.
The function Length returns the length of the String represented by Source.
The type String_Access provides a (nonprivate) access type for explicit
processing of unbounded-length strings. The procedure Free performs
an unchecked deallocation of an object of type String_Access.
The function To_Unbounded_String(Source : in String)
returns an Unbounded_String that represents Source.
The function To_Unbounded_String(Length : in Natural)
returns an Unbounded_String that represents an uninitialized String
whose length is Length.
@Leading@;The function To_String returns the String with lower bound 1
represented by Source. To_String and To_Unbounded_String are related as follows:
@begin{itemize}
If S is a String, then To_String(To_Unbounded_String(S)) = S.
If U is an Unbounded_String, then To_Unbounded_String(To_String(U)) = U.
@end{itemize}
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]}
@ChgAdded{Version=[2],Text=[The procedure Set_Unbounded_String sets Target to an Unbounded_String that
represents Source.]}
For each of the Append procedures,
the resulting string represented by the Source parameter is given
by the concatenation of the original value of Source and the value
of New_Item.
Each of the "&" functions returns an Unbounded_String obtained by concatenating
the string or character given or represented by one of the parameters,
with the string or character given or represented by the other parameter,
and applying To_Unbounded_String to the concatenation result string.
The Element, Replace_Element, and Slice subprograms have the same effect
as the corresponding bounded-length string subprograms.
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]}
@ChgRef{Version=[3],Kind=[RevisedAdded],ARef=[AI05-0262-1]}
@ChgAdded{Version=[2],Text=[The function Unbounded_Slice returns the slice at
positions Low through High in the string represented by Source as an
Unbounded_String. The procedure Unbounded_Slice sets Target to the
Unbounded_String representing the slice at positions Low through High in the
string represented by Source. Both
@Chg{Version=[3],New=[subprograms],Old=[routines]} propagate Index_Error
if Low > Length(Source)+1 or High > Length(Source).]}
Each of the functions "=", "<", ">", "<=", and ">="
returns the same result as the corresponding String
operation applied to the String values given or represented by Left and Right.
Each of the search subprograms (Index, Index_Non_Blank, Count, Find_Token)
has the same effect as the corresponding subprogram in Strings.Fixed applied
to the string represented by the Unbounded_String parameter.
The Translate function has
an analogous effect to the corresponding subprogram in Strings.Fixed.
The translation is applied to the string represented by the Unbounded_String
parameter, and the result is converted (via To_Unbounded_String) to an
Unbounded_String.
Each of the transformation functions (Replace_Slice, Insert, Overwrite,
Delete), selector functions (Trim, Head, Tail), and constructor functions
("*") is likewise analogous to its corresponding
subprogram in Strings.Fixed. For each of the subprograms,
the corresponding fixed-length string subprogram is applied to the string
represented by the Unbounded_String parameter, and
To_Unbounded_String is applied the result string.
For each of the procedures Translate,
Replace_Slice, Insert, Overwrite, Delete,
Trim, Head, and Tail, the resulting string represented by the Source parameter
is given by the corresponding function for fixed-length strings applied to
the string represented by Source's original value.
@end{StaticSem}
@begin{ImplReq}
No storage associated
with an Unbounded_String object shall be
lost upon assignment or scope exit.
@begin{ImplNote}
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00301-01]}
A sample implementation of the private part of
the package and several of the subprograms appears in the @Chg{Version=[2],
New=[Ada 95 ],Old=[]}Rationale.
@end{ImplNote}
@end{ImplReq}
@begin{Incompatible95}
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00360-01]}
@ChgAdded{Version=[2],Text=[@Defn{incompatibilities with Ada 95}
@b[Amendment Correction:] Type Unbounded_String is defined to need
finalization. If the restriction No_Nested_Finalization (see
@RefSecNum{Tasking Restrictions}) applies to the partition, and
Unbounded_String does not have a controlled part, it will not be allowed in
local objects in Ada 2005 whereas it would be allowed in original Ada 95.
Such code is not portable, as most Ada compilers have a controlled part in
Unbounded_String, and thus would be illegal.]}
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00301-01]}
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0005-1]}
@ChgAdded{Version=[2],Text=[Procedure Set_Unbounded_String,
two Unbounded_Slice subprograms, and overloaded
versions of Index and Index_Non_Blank are
@Chg{Version=[3],New=[],Old=[newly ]}added to Strings.Unbounded.
If Strings.Unbounded is
referenced in a @nt{use_clause}, and an entity @i<E> with the same
@nt{defining_identifier} as a new entity in Strings.Unbounded is defined in a
package that is also referenced in a @nt{use_clause}, the entity @i<E> may no
longer be use-visible, resulting in errors. This should be rare and is easily
fixed if it does occur.]}
@end{Incompatible95}
@begin{Extend95}
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00161-01]}
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
@b[Amendment Correction:] Added a @nt{pragma} Preelaborable_Initialization to
type Unbounded_String, so that it can be used to declare default-initialized
objects in preelaborated units.]}
@end{Extend95}
@begin{Incompatible2005}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0031-1]}
@ChgAdded{Version=[3],Text=[@Defn{incompatibilities with Ada 2005}
An overloaded version of Find_Token is added to
Strings.Unbounded. If Strings.Unbounded is referenced in a @nt{use_clause},
and an entity @i<E> with a @nt{defining_identifier} of Find_Token is
defined in a package that is also referenced in a @nt{use_clause}, the entity
@i<E> may no longer be use-visible, resulting in errors. This should be rare
and is easily fixed if it does occur.]}
@end{Incompatible2005}
@LabeledSubClause{String-Handling Sets and Mappings}
@begin{Intro}
The language-defined package Strings.Maps.Constants declares
Character_Set
and Character_Mapping
constants corresponding to classification and conversion functions
in package Characters.Handling.
@begin{discussion}
The Constants package is a child of Strings.Maps since it needs
visibility of the private part of Strings.Maps in order to
initialize the constants
in a preelaborable way (i.e. via aggregates versus function calls).
@end{discussion}
@end{Intro}
@begin{StaticSem}
@Leading@;The library package Strings.Maps.Constants has the following declaration:
@begin{example}
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00362-01]}
@ChildUnit{Parent=[Ada.Strings.Maps],Child=[Constants]}@key[package] Ada.Strings.Maps.Constants @key[is]
@key[pragma] @Chg{Version=[2],New=[Pure],Old=[Preelaborate]}(Constants);
@AdaObjDefn{Control_Set} : @key[constant] Character_Set;
@AdaObjDefn{Graphic_Set} : @key[constant] Character_Set;
@AdaObjDefn{Letter_Set} : @key[constant] Character_Set;
@AdaObjDefn{Lower_Set} : @key[constant] Character_Set;
@AdaObjDefn{Upper_Set} : @key[constant] Character_Set;
@AdaObjDefn{Basic_Set} : @key[constant] Character_Set;
@AdaObjDefn{Decimal_Digit_Set} : @key[constant] Character_Set;
@AdaObjDefn{Hexadecimal_Digit_Set} : @key[constant] Character_Set;
@AdaObjDefn{Alphanumeric_Set} : @key[constant] Character_Set;
@AdaObjDefn{Special_Set} : @key[constant] Character_Set;
@AdaObjDefn{ISO_646_Set} : @key[constant] Character_Set;
@AdaObjDefn{Lower_Case_Map} : @key[constant] Character_Mapping;
--@Examcom{Maps to lower case for letters, else identity}
@AdaObjDefn{Upper_Case_Map} : @key[constant] Character_Mapping;
--@Examcom{Maps to upper case for letters, else identity}
@AdaObjDefn{Basic_Map} : @key[constant] Character_Mapping;
--@Examcom{Maps to basic letter for letters, else identity}
@key[private]
... -- @Examcom{not specified by the language}
@key[end] Ada.Strings.Maps.Constants;
@end{example}
Each of these constants represents a correspondingly named
set of characters or
character mapping in Characters.Handling
(see @refsecnum(The Package Characters.Handling)).
@end{StaticSem}
@begin{Notes}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0114-1]}
@ChgAdded{Version=[3],Text=[There are certain characters which are defined to be
lower case letters by ISO 10646 and are therefore allowed in identifiers, but
are not considered lower case letters by Ada.Strings.Maps.Constants.]}
@begin{Reason}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[This is to maintain runtime compatibility with the
Ada 95 definitions of these constants; existing correct programs could break if
the definitions were changed in a way the programs did not anticipate.]}
@end{Reason}
@end{Notes}
@begin{Extend95}
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00362-01]}
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
Strings.Maps.Constants is now Pure,
so it can be used in pure units.]}
@end{Extend95}
@begin{DiffWord2005}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0114-1]}
@ChgAdded{Version=[3],Text=[@b<Correction:> Added a note to clarify that
these constants don't have any relationship to the characters allowed in
identifiers.]}
@end{DiffWord2005}
@LabeledSubClause{Wide_String Handling}
@begin{Intro}
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00302-03]}
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0286-1]}
Facilities for handling strings of Wide_Character elements are
found in the packages Strings.@!Wide_Maps, Strings.@!Wide_Fixed,
Strings.@!Wide_@!Bounded, Strings.@!Wide_@!Unbounded,
and Strings.@!Wide_Maps.@!Wide_@!Constants@Chg{Version=[2],New=[, and in the
@Chg{Version=[3],New=[library ],Old=[]}functions Strings.@!Wide_Hash,
Strings.@!Wide_Fixed.@!Wide_Hash,
Strings.@!Wide_Bounded.@!Wide_Hash,@Chg{Version=[3],New=[],Old=[ and]}
Strings.@!Wide_Unbounded.@!Wide_Hash@Chg{Version=[3],New=[,
Strings.@!Wide_@!Hash_@!Case_@!Insensitive,
Strings.@!Wide_@!Fixed.Wide_@!Hash_@!Case_@!Insensitive,
Strings.@!Wide_@!Bounded.Wide_@!Hash_@!Case_@!Insensitive,
Strings.@!Wide_@!Unbounded.Wide_@!Hash_@!Case_@!Insensitive,
Strings.@!Wide_@!Equal_@!Case_@!Insensitive,
Strings.@!Wide_@!Fixed.Wide_@!Equal_@!Case_@!Insensitive,
Strings.@!Wide_@!Bounded.Wide_@!Equal_@!Case_@!Insensitive, and
Strings.@!Wide_@!Unbounded.Wide_@!Equal_@!Case_@!Insensitive],Old=[]}],Old=[]}.
They provide the same string-handling operations
as the corresponding packages@Chg{Version=[2],New=[ and functions],Old=[]}
for strings of Character elements.
@ChildUnit{Parent=[Ada.Strings],Child=[Wide_@!Fixed]}
@ChildUnit{Parent=[Ada.Strings],Child=[Wide_@!Bounded]}
@ChildUnit{Parent=[Ada.Strings],Child=[Wide_@!Unbounded]}
@ChildUnit{Parent=[Ada.Strings],Child=[Wide_@!Hash]}
@SubChildUnit{Parent=[Ada.Strings.Wide_@!Fixed],Child=[Wide_@!Hash]}
@SubChildUnit{Parent=[Ada.Strings.Wide_@!Bounded],Child=[Wide_@!Hash]}
@SubChildUnit{Parent=[Ada.Strings.Wide_@!Unbounded],Child=[Wide_@!Hash]}
@Chg{Version=[3],New=[@ChildUnit{Parent=[Ada.Strings],Child=[Wide_@!Equal_Case_Insensitive]}
@SubChildUnit{Parent=[Ada.Strings.Wide_@!Fixed],Child=[Wide_@!Equal_Case_Insensitive]}
@SubChildUnit{Parent=[Ada.Strings.Wide_@!Bounded],Child=[Wide_@!Equal_Case_Insensitive]}
@SubChildUnit{Parent=[Ada.Strings.Wide_@!Unbounded],Child=[Wide_@!Equal_Case_Insensitive]}
@ChildUnit{Parent=[Ada.Strings],Child=[Wide_@!Hash_Case_Insensitive]}
@SubChildUnit{Parent=[Ada.Strings.Wide_@!Fixed],Child=[Wide_@!Hash_Case_Insensitive]}
@SubChildUnit{Parent=[Ada.Strings.Wide_@!Bounded],Child=[Wide_@!Hash_Case_Insensitive]}
@SubChildUnit{Parent=[Ada.Strings.Wide_@!Unbounded],Child=[Wide_@!Hash_Case_Insensitive]}],Old=[]}
@ChildUnit{Parent=[Ada.Strings.Wide_@!Maps],Child=[Wide_@!Constants]}
@end{Intro}
@begin{StaticSem}
The package Strings.Wide_Maps has the following declaration.
@begin{example}
@ChildUnit{Parent=[Ada.Strings],Child=[Wide_@!Maps]}@key[package] Ada.Strings.Wide_Maps @key[is]
@key[pragma] Preelaborate(Wide_Maps);
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00161-01]}
--@Examcom{ Representation for a set of Wide_Character values:}
@key[type] @AdaTypeDefn{Wide_Character_Set} @key[is] @key[private];@Chg{Version=[2],New=[
@key[pragma] Preelaborable_Initialization(Wide_Character_Set);],Old=[]}
@AdaObjDefn{Null_Set} : @key[constant] Wide_Character_Set;
@key[type] @AdaTypeDefn{Wide_Character_Range} @key[is]
@key[record]
Low : Wide_Character;
High : Wide_Character;
@key[end] @key[record];
-- @Examcom{Represents Wide_Character range Low..High}
@key[type] @AdaTypeDefn{Wide_Character_Ranges} @key[is] @key[array] (Positive @key[range] <>)
@key[of] Wide_Character_Range;
@key[function] @AdaSubDefn{To_Set} (Ranges : @key[in] Wide_Character_Ranges)
@key[return] Wide_Character_Set;
@key[function] @AdaSubDefn{To_Set} (Span : @key[in] Wide_Character_Range)
@key[return] Wide_Character_Set;
@key[function] @AdaSubDefn{To_Ranges} (Set : @key[in] Wide_Character_Set)
@key[return] Wide_Character_Ranges;
@key[function] "=" (Left, Right : @key[in] Wide_Character_Set) @key[return] Boolean;
@key[function] "@key[not]" (Right : @key[in] Wide_Character_Set)
@key[return] Wide_Character_Set;
@key[function] "@key[and]" (Left, Right : @key[in] Wide_Character_Set)
@key[return] Wide_Character_Set;
@key[function] "@key[or]" (Left, Right : @key[in] Wide_Character_Set)
@key[return] Wide_Character_Set;
@key[function] "@key[xor]" (Left, Right : @key[in] Wide_Character_Set)
@key[return] Wide_Character_Set;
@key[function] "-" (Left, Right : @key[in] Wide_Character_Set)
@key[return] Wide_Character_Set;
@key[function] @AdaSubDefn{Is_In} (Element : @key[in] Wide_Character;
Set : @key[in] Wide_Character_Set)
@key[return] Boolean;
@key[function] @AdaSubDefn{Is_Subset} (Elements : @key[in] Wide_Character_Set;
Set : @key[in] Wide_Character_Set)
@key[return] Boolean;
@key[function] "<=" (Left : @key[in] Wide_Character_Set;
Right : @key[in] Wide_Character_Set)
@key[return] Boolean @key[renames] Is_Subset;
--@Examcom{ Alternative representation for a set of Wide_Character values:}
@key[subtype] @AdaSubtypeDefn{Name=[Wide_Character_Sequence],Of=[Wide_String]} @key[is] Wide_String;
@key[function] @AdaSubDefn{To_Set} (Sequence : @key[in] Wide_Character_Sequence)
@key[return] Wide_Character_Set;
@key[function] @AdaSubDefn{To_Set} (Singleton : @key[in] Wide_Character)
@key[return] Wide_Character_Set;
@key[function] @AdaSubDefn{To_Sequence} (Set : @key[in] Wide_Character_Set)
@key[return] Wide_Character_Sequence;
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00161-01]}
--@Examcom{ Representation for a Wide_Character to Wide_Character mapping:}
@key[type] @AdaTypeDefn{Wide_Character_Mapping} @key[is] @key[private];@Chg{Version=[2],New=[
@key[pragma] Preelaborable_Initialization(Wide_Character_Mapping);],Old=[]}
@key[function] @AdaSubDefn{Value} (Map : @key[in] Wide_Character_Mapping;
Element : @key[in] Wide_Character)
@key[return] Wide_Character;
@AdaObjDefn{Identity} : @key[constant] Wide_Character_Mapping;
@key[function] @AdaSubDefn{To_Mapping} (From, To : @key[in] Wide_Character_Sequence)
@key[return] Wide_Character_Mapping;
@key[function] @AdaSubDefn{To_Domain} (Map : @key[in] Wide_Character_Mapping)
@key[return] Wide_Character_Sequence;
@key[function] @AdaSubDefn{To_Range} (Map : @key[in] Wide_Character_Mapping)
@key[return] Wide_Character_Sequence;
@key{type} @AdaTypeDefn{Wide_Character_Mapping_Function} @key{is}
@key{access} @key{function} (From : @key{in} Wide_Character) @key{return} Wide_Character;
@key[private]
... -- @Examcom{not specified by the language}
@key[end] Ada.Strings.Wide_Maps;
@end{example}
The context clause for each of the packages Strings.Wide_Fixed,
Strings.Wide_Bounded, and Strings.Wide_Unbounded
identifies Strings.Wide_Maps instead of Strings.Maps.
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0223-1]}
@ChgAdded{Version=[3],Text=[Types Wide_Character_Set and Wide_Character_Mapping
need finalization.]}
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00302-03]}
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0286-1]}
@Leading@;For each of the packages Strings.Fixed, Strings.Bounded,
Strings.Unbounded, and Strings.Maps.Constants@Chg{Version=[2],New=[, and
for @Chg{Version=[3],New=[library ],Old=[]}functions
Strings.Hash, Strings.Fixed.Hash, Strings.Bounded.Hash,
@Chg{Version=[3],New=[],Old=[and ]}Strings.@!Unbounded.Hash,
@Chg{Version=[3],New=[Strings.@!Hash_@!Case_@!Insensitive,
Strings.@!Fixed.Hash_@!Case_@!Insensitive,
Strings.@!Bounded.Hash_@!Case_@!Insensitive,
Strings.@!Unbounded.Hash_@!Case_@!Insensitive,
Strings.@!Equal_@!Case_@!Insensitive,
Strings.@!Fixed.Equal_@!Case_@!Insensitive,
Strings.@!Bounded.Equal_@!Case_@!Insensitive, and
Strings.@!Unbounded.Equal_@!Case_@!Insensitive, ],Old=[]}],Old=[]}the
corresponding wide string
package @Chg{Version=[3],New=[or function ],Old=[]}has
the same contents except that
@begin{itemize}
Wide_Space replaces Space
Wide_Character replaces Character
Wide_String replaces String
Wide_Character_Set replaces Character_Set
Wide_Character_Mapping replaces Character_Mapping
Wide_Character_Mapping_Function replaces Character_Mapping_Function
Wide_Maps replaces Maps
Bounded_Wide_String replaces Bounded_String
Null_Bounded_Wide_String replaces Null_Bounded_String
To_Bounded_Wide_String replaces To_Bounded_String
To_Wide_String replaces To_String
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]}
@ChgAdded{Version=[2],Text=[Set_Bounded_Wide_String replaces Set_Bounded_String]}
Unbounded_Wide_String replaces Unbounded_String
Null_Unbounded_Wide_String replaces Null_Unbounded_String
Wide_String_Access replaces String_Access
To_Unbounded_Wide_String replaces To_Unbounded_String
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]}
@ChgAdded{Version=[2],Text=[Set_Unbounded_Wide_String replaces Set_Unbounded_String]}
@end{Itemize}
@Leading@keepnext@;The following additional declaration is present in
Strings.Wide_Maps.Wide_Constants:
@begin{example}
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00285-01],ARef=[AI95-00395-01]}
@AdaObjDefn{Character_Set} : @key[constant] Wide_Maps.Wide_Character_Set;
--@Examcom{Contains each Wide_Character value WC such that}@Chg{Version=[2],New=[
--],Old=[]}@Examcom{Characters.@Chg{Version=[2],New=[Conversions.],Old=[]}Is_Character(WC) is True}
@end{example}
@end{StaticSem}
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00395-01]}
@ChgAdded{Version=[2],Text=[Each Wide_Character_Set constant in the package
Strings.Wide_Maps.Wide_Constants contains no values outside the Character
portion of Wide_Character. Similarly, each Wide_Character_Mapping constant in
this package is the identity mapping when applied to any element outside the
Character portion of Wide_Character.]}
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00362-01]}
@ChgAdded{Version=[2],Text=[@nt{Pragma} Pure is replaced by
@nt{pragma} Preelaborate in Strings.Wide_Maps.Wide_Constants.]}
@begin{Notes}
@Defn2{Term=[Constraint_Error],Sec=(raised by failure of run-time check)}
If a null Wide_Character_Mapping_Function is passed to any of the
Wide_String handling subprograms, Constraint_Error is propagated.
@ChgRef{Version=[2],Kind=[DeletedNoDelMsg],ARef=[AI95-00395-01]}
@ChgDeleted{Version=[2],Text=[Each Wide_Character_Set constant in the package
Strings.Wide_Maps.Wide_Constants contains no values outside the Character
portion of Wide_Character. Similarly, each Wide_Character_Mapping
constant in this package is the identity mapping when applied to
any element outside the Character portion of Wide_Character.]}
@end{Notes}
@begin{Incompatible95}
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00301-01]}
@ChgAdded{Version=[2],Text=[@Defn{incompatibilities with Ada 95}
Various new operations are added to Strings.Wide_Fixed, Strings.Wide_Bounded,
and Strings.Wide_Unbounded. If one of these packages is referenced in a
@nt{use_clause}, and an entity @i<E> with the same @nt{defining_identifier}
as a new entity is defined in a package that is also referenced in a
@nt{use_clause}, the entity @i<E> may no longer be use-visible, resulting in
errors. This should be rare and is easily fixed if it does occur.]}
@end{Incompatible95}
@begin{Extend95}
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00161-01]}
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
@b[Amendment Correction:] Added @nt{pragma} Preelaborable_Initialization to
types Wide_Character_Set and Wide_Character_Mapping, so that they can be
used to declare default-initialized objects in preelaborated units.]}
@end{Extend95}
@begin{DiffWord95}
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00285-01]}
@ChgAdded{Version=[2],Text=[Corrected the description of Character_Set.]}
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
@ChgAdded{Version=[2],Text=[Added wide versions of Strings.Hash and
Strings.Unbounded.Hash.]}
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00362-01]}
@ChgAdded{Version=[2],Text=[Added wording so that
Strings.Wide_Maps.Wide_Constants does not change to Pure.]}
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00395-01]}
@ChgAdded{Version=[2],Text=[The second Note is now normative text, since
there is no way to derive it from the other rules. It's a little
weird given the use of Unicode character classifications in Ada 2005;
but changing it would be inconsistent with Ada 95 and a one-to-one
mapping isn't necessarily correct anyway.]}
@end{DiffWord95}
@begin{Extend2005}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0286-1]}
@ChgAdded{Version=[3],Text=[@Defn{extensions to Ada 2005}
The case insenstive library functions
(Strings.Wide_@!Equal_@!Case_@!Insensitive,
Strings.Wide_@!Fixed.Wide_@!Equal_@!Case_@!Insensitive,
Strings.Wide_@!Bounded.Wide_@!Equal_@!Case_@!Insensitive,
Strings.Wide_@!Unbounded.Wide_@!Equal_@!Case_@!Insensitive,
Strings.Wide_@!Hash_@!Case_@!Insensitive,
Strings.Wide_@!Fixed.Wide_@!Hash_@!Case_@!Insensitive,
Strings.Wide_@!Bounded.Wide_@!Hash_@!Case_@!Insensitive, and
Strings.Wide_@!Unbounded.Wide_@!Hash_@!Case_@!Insensitive)
are new.]}
@end{Extend2005}
@begin{DiffWord2005}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0223-1]}
@ChgAdded{Version=[3],Text=[@b<Correction>: Identified Wide_Character_Set
and Wide_Character_Mapping as needing finalization. It is likely that they
are implemented with a controlled type, so this change is unlikely to make
any difference in practice.]}
@end{DiffWord2005}
@LabeledAddedSubClause{Version=[2],Name=[Wide_Wide_String Handling]}
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00285-01],ARef=[AI95-00395-01]}
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0286-1]}
@ChgAdded{Version=[2],Text=[Facilities for handling strings of
Wide_Wide_Character elements are found in
the packages Strings.@!Wide_Wide_@!Maps, Strings.@!Wide_Wide_@!Fixed,
Strings.@!Wide_Wide_@!Bounded, Strings.@!Wide_Wide_@!Unbounded, and
Strings.@!Wide_Wide_@!Maps.@!Wide_Wide_@!Constants, and in the
@Chg{Version=[3],New=[library ],Old=[]}functions Strings.@!Wide_Wide_@!Hash,
Strings.@!Wide_Wide_@!Fixed.@!Wide_Wide_@!Hash,
Strings.@!Wide_Wide_@!Bounded.@!Wide_@!Wide_@!Hash,@Chg{Version=[3],New=[],Old=[ and]}
Strings.@!Wide_Wide_@!Unbounded.@!Wide_@!Wide_@!Hash@Chg{Version=[3],New=[,
Strings.@!Wide_Wide_@!Hash_@!Case_@!Insensitive,
Strings.@!Wide_Wide_@!Fixed.Wide_Wide_@!Hash_@!Case_@!Insensitive,
Strings.@!Wide_Wide_@!Bounded.Wide_Wide_@!Hash_@!Case_@!Insensitive,
Strings.@!Wide_Wide_@!Unbounded.Wide_Wide_@!Hash_@!Case_@!Insensitive,
Strings.@!Wide_Wide_@!Equal_@!Case_@!Insensitive,
Strings.@!Wide_Wide_@!Fixed.Wide_Wide_@!Equal_@!Case_@!Insensitive,
Strings.@!Wide_Wide_@!Bounded.Wide_Wide_@!Equal_@!Case_@!Insensitive, and
Strings.@!Wide_Wide_@!Unbounded.Wide_Wide_@!Equal_@!Case_@!Insensitive],Old=[]}.
They provide the same
string-handling operations as the corresponding packages and functions
for strings of Character elements.
@ChildUnit{Parent=[Ada.Strings],Child=[Wide_Wide_Fixed]}
@ChildUnit{Parent=[Ada.Strings],Child=[Wide_Wide_Bounded]}
@ChildUnit{Parent=[Ada.Strings],Child=[Wide_Wide_Unbounded]}
@ChildUnit{Parent=[Ada.Strings],Child=[Wide_Wide_@!Hash]}
@SubChildUnit{Parent=[Ada.Strings.Wide_Wide_@!Fixed],Child=[Wide_Wide_@!Hash]}
@SubChildUnit{Parent=[Ada.Strings.Wide_Wide_@!Bounded],Child=[Wide_Wide_@!Hash]}
@SubChildUnit{Parent=[Ada.Strings.Wide_Wide_@!Unbounded],Child=[Wide_Wide_@!Hash]}
@Chg{Version=[3],New=[@ChildUnit{Parent=[Ada.Strings],Child=[Wide_Wide_@!Equal_Case_Insensitive]}
@SubChildUnit{Parent=[Ada.Strings.Wide_Wide_@!Fixed],Child=[Wide_Wide_@!Equal_Case_Insensitive]}
@SubChildUnit{Parent=[Ada.Strings.Wide_Wide_@!Bounded],Child=[Wide_Wide_@!Equal_Case_Insensitive]}
@SubChildUnit{Parent=[Ada.Strings.Wide_Wide_@!Unbounded],Child=[Wide_Wide_@!Equal_Case_Insensitive]}
@ChildUnit{Parent=[Ada.Strings],Child=[Wide_Wide_@!Hash_Case_Insensitive]}
@SubChildUnit{Parent=[Ada.Strings.Wide_Wide_@!Fixed],Child=[Wide_Wide_@!Hash_Case_Insensitive]}
@SubChildUnit{Parent=[Ada.Strings.Wide_Wide_@!Bounded],Child=[Wide_Wide_@!Hash_Case_Insensitive]}
@SubChildUnit{Parent=[Ada.Strings.Wide_Wide_@!Unbounded],Child=[Wide_Wide_@!Hash_Case_Insensitive]}],Old=[]}
@ChildUnit{Parent=[Ada.Strings.Wide_Wide_@!Maps],Child=[Wide_Wide_@!Constants]}]}
@begin{StaticSem}
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00285-01]}
@ChgAdded{Version=[2],Type=[Leading],Text=[The library package Strings.Wide_Wide_Maps has the following declaration.]}
@begin{Example}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[@key<package> Ada.Strings.Wide_Wide_Maps @key<is>@ChildUnit{Parent=[Ada.Strings],Child=[Wide_Wide_Maps]}
@key<pragma> Preelaborate(Wide_Wide_Maps);]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[ -- @Examcom[Representation for a set of Wide_Wide_Character values:]
@key<type> @AdaTypeDefn{Wide_Wide_Character_Set} @key<is private>;
@key<pragma> Preelaborable_Initialization(Wide_Wide_Character_Set);]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[ @AdaObjDefn{Null_Set} : @key<constant> Wide_Wide_Character_Set;]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[ @key<type> @AdaTypeDefn{Wide_Wide_Character_Range} @key<is>
@key<record>
Low : Wide_Wide_Character;
High : Wide_Wide_Character;
@key<end record>;
-- @Examcom[Represents Wide_Wide_Character range Low..High]]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[ @key<type> @AdaTypeDefn{Wide_Wide_Character_Ranges} @key<is array> (Positive @key<range> <>)
@key<of> Wide_Wide_Character_Range;]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[ @key<function> @AdaSubDefn{To_Set} (Ranges : @key<in> Wide_Wide_Character_Ranges)
@key<return> Wide_Wide_Character_Set;]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[ @key<function> @AdaSubDefn{To_Set} (Span : @key<in> Wide_Wide_Character_Range)
@key<return> Wide_Wide_Character_Set;]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[ @key<function> @AdaSubDefn{To_Ranges} (Set : @key<in> Wide_Wide_Character_Set)
@key<return> Wide_Wide_Character_Ranges;]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[ @key<function> "=" (Left, Right : @key<in> Wide_Wide_Character_Set) @key<return> Boolean;]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[ @key<function> "@key<not>" (Right : @key<in> Wide_Wide_Character_Set)
@key<return> Wide_Wide_Character_Set;
@key<function> "@key<and>" (Left, Right : @key<in> Wide_Wide_Character_Set)
@key<return> Wide_Wide_Character_Set;
@key<function> "@key<or>" (Left, Right : @key<in> Wide_Wide_Character_Set)
@key<return> Wide_Wide_Character_Set;
@key<function> "@key<xor>" (Left, Right : @key<in> Wide_Wide_Character_Set)
@key<return> Wide_Wide_Character_Set;
@key<function> "-" (Left, Right : @key<in> Wide_Wide_Character_Set)
@key<return> Wide_Wide_Character_Set;]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[ @key<function> @AdaSubDefn{Is_In} (Element : @key<in> Wide_Wide_Character;
Set : @key<in> Wide_Wide_Character_Set)
@key<return> Boolean;]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[ @key<function> @AdaSubDefn{Is_Subset} (Elements : @key<in> Wide_Wide_Character_Set;
Set : @key<in> Wide_Wide_Character_Set)
@key<return> Boolean;]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[ @key<function> "<=" (Left : @key<in> Wide_Wide_Character_Set;
Right : @key<in> Wide_Wide_Character_Set)
@key<return> Boolean @key<renames> Is_Subset;]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[ -- @Examcom[Alternative representation for a set of Wide_Wide_Character values:]
@key<subtype> @AdaSubtypeDefn{Name=[Wide_Wide_Character_Sequence],Of=[Wide_Wide_String]} @key<is> Wide_Wide_String;]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[ @key<function> @AdaSubDefn{To_Set} (Sequence : @key<in> Wide_Wide_Character_Sequence)
@key<return> Wide_Wide_Character_Set;]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[ @key<function> @AdaSubDefn{To_Set} (Singleton : @key<in> Wide_Wide_Character)
@key<return> Wide_Wide_Character_Set;]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[ @key<function> @AdaSubDefn{To_Sequence} (Set : @key<in> Wide_Wide_Character_Set)
@key<return> Wide_Wide_Character_Sequence;]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[ -- @Examcom[Representation for a Wide_Wide_Character to Wide_Wide_Character]
-- @Examcom[mapping:]
@key<type> @AdaTypeDefn{Wide_Wide_Character_Mapping} @key<is private>;
@key<pragma> Preelaborable_Initialization(Wide_Wide_Character_Mapping);]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[ @key<function> @AdaSubDefn{Value} (Map : @key<in> Wide_Wide_Character_Mapping;
Element : @key<in> Wide_Wide_Character)
@key<return> Wide_Wide_Character;]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[ @AdaObjDefn{Identity} : @key<constant> Wide_Wide_Character_Mapping;]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[ @key<function> @AdaSubDefn{To_Mapping} (From, To : @key<in> Wide_Wide_Character_Sequence)
@key<return> Wide_Wide_Character_Mapping;]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[ @key<function> @AdaSubDefn{To_Domain} (Map : @key<in> Wide_Wide_Character_Mapping)
@key<return> Wide_Wide_Character_Sequence;]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[ @key<function> @AdaSubDefn{To_Range} (Map : @key<in> Wide_Wide_Character_Mapping)
@key<return> Wide_Wide_Character_Sequence;]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[ @key<type> @AdaTypeDefn{Wide_Wide_Character_Mapping_Function} @key<is>
@key<access function> (From : @key<in> Wide_Wide_Character)
@key<return> Wide_Wide_Character;]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[@key<private>
... -- @Examcom[not specified by the language]
@key<end> Ada.Strings.Wide_Wide_Maps;]}
@end{Example}
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00285-01]}
@ChgAdded{Version=[2],Text=[@ChildUnit{Parent=[Ada.Strings.Wide_@!Maps],Child=[Wide_@!Constants]}
The context clause for each of the packages Strings.Wide_Wide_Fixed,
Strings.Wide_Wide_Bounded, and Strings.Wide_Wide_Unbounded identifies
Strings.Wide_Wide_Maps instead of Strings.Maps.]}
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0223-1]}
@ChgAdded{Version=[3],Text=[Types Wide_Wide_Character_Set and
Wide_Wide_Character_Mapping need finalization.]}
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00285-01]}
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0286-1]}
@ChgAdded{Version=[2],Type=[Leading],Text=[For each of the packages
Strings.@!Fixed, Strings.@!Bounded, Strings.@!Unbounded, and Strings.@!Maps.Constants,
and for @Chg{Version=[3],New=[library ],Old=[]}functions
Strings.@!Hash, Strings.@!Fixed.Hash, Strings.@!Bounded.Hash,
@Chg{Version=[3],New=[],Old=[and ]}Strings.@!Unbounded.Hash,
@Chg{Version=[3],New=[Strings.@!Hash_@!Case_@!Insensitive,
Strings.@!Fixed.Hash_@!Case_@!Insensitive,
Strings.@!Bounded.Hash_@!Case_@!Insensitive,
Strings.@!Unbounded.Hash_@!Case_@!Insensitive,
Strings.@!Equal_@!Case_@!Insensitive,
Strings.@!Fixed.Equal_@!Case_@!Insensitive,
Strings.@!Bounded.Equal_@!Case_@!Insensitive, and
Strings.@!Unbounded.Equal_@!Case_@!Insensitive,
],Old=[]}the corresponding wide wide string package or function has the same
contents except that]}
@begin{Itemize}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[Wide_Wide_Space replaces Space]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[Wide_Wide_Character replaces Character]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[Wide_Wide_String replaces String]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[Wide_Wide_Character_Set replaces Character_Set]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[Wide_Wide_Character_Mapping replaces Character_Mapping]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[Wide_Wide_Character_Mapping_Function replaces Character_Mapping_Function]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[Wide_Wide_Maps replaces Maps]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[Bounded_Wide_Wide_String replaces Bounded_String]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[Null_Bounded_Wide_Wide_String replaces Null_Bounded_String]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[To_Bounded_Wide_Wide_String replaces To_Bounded_String]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[To_Wide_Wide_String replaces To_String]}
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00301-01]}
@ChgAdded{Version=[2],Text=[Set_Bounded_Wide_Wide_String replaces Set_Bounded_String]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[Unbounded_Wide_Wide_String replaces Unbounded_String]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[Null_Unbounded_Wide_Wide_String replaces Null_Unbounded_String]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[Wide_Wide_String_Access replaces String_Access]}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[To_Unbounded_Wide_Wide_String replaces To_Unbounded_String]}
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00301-01]}
@ChgAdded{Version=[2],Text=[Set_Unbounded_Wide_Wide_String replaces Set_Unbounded_String]}
@end{Itemize}
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00285-01],ARef=[AI95-00395-01]}
@ChgAdded{Version=[2],Type=[Leading],Keepnext=[T],Text=[The following
additional declarations are present in
Strings.Wide_Wide_Maps.Wide_Wide_Constants:]}
@begin{Example}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[@AdaObjDefn{Character_Set} : @key<constant> Wide_Wide_Maps.Wide_Wide_Character_Set;
-- @Examcom[Contains each Wide_Wide_Character value WWC such that]
-- @Examcom[Characters.Conversions.Is_Character(WWC) is True]
@AdaObjDefn{Wide_Character_Set} : @key<constant> Wide_Wide_Maps.Wide_Wide_Character_Set;
-- @Examcom[Contains each Wide_Wide_Character value WWC such that]
-- @Examcom[Characters.Conversions.Is_Wide_Character(WWC) is True]]}
@end{Example}
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00395-01]}
@ChgAdded{Version=[2],Text=[Each Wide_Wide_Character_Set constant in the package
Strings.@!Wide_Wide_@!Maps.@!Wide_Wide_@!Constants contains no values outside the Character
portion of Wide_Wide_@!Character. Similarly, each Wide_Wide_@!Character_@!Mapping constant in
this package is the identity mapping when applied to any element outside the
Character portion of Wide_Wide_Character.]}
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00395-01]}
@ChgAdded{Version=[2],Text=[@nt{Pragma} Pure is replaced by
@nt{pragma} Preelaborate in Strings.Wide_Wide_Maps.Wide_Wide_Constants.]}
@end{StaticSem}
@begin{Notes}
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00285-01]}
@ChgAdded{Version=[2],Text=[@Defn2{Term=[Constraint_Error],Sec=(raised by failure of run-time check)}
If a null Wide_Wide_Character_Mapping_Function is passed to any of the
Wide_Wide_String handling subprograms, Constraint_Error is propagated.]}
@end{Notes}
@begin{Extend95}
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00285-01],ARef=[AI95-00395-01]}
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
The double-wide string-handling packages (Strings.Wide_Wide_Maps,
Strings.Wide_Wide_Fixed, Strings.Wide_Wide_Bounded,
Strings.Wide_Wide_Unbounded, and Strings.Wide_Wide_Maps.Wide_Wide_Constants),
and functions Strings.Wide_Wide_Hash and
Strings.Wide_Wide_Unbounded.Wide_Wide_Hash are new.]}
@end{Extend95}
@begin{Extend2005}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0286-1]}
@ChgAdded{Version=[3],Text=[@Defn{extensions to Ada 2005}
The case insenstive library functions
(Strings.Wide_Wide_@!Equal_@!Case_@!Insensitive,
Strings.Wide_Wide_@!Fixed.Wide_Wide_@!Equal_@!Case_@!Insensitive,
Strings.Wide_Wide_@!Bounded.Wide_Wide_@!Equal_@!Case_@!Insensitive,
Strings.Wide_Wide_@!Unbounded.Wide_Wide_@!Equal_@!Case_@!Insensitive,
Strings.Wide_Wide_@!Hash_@!Case_@!Insensitive,
Strings.Wide_Wide_@!Fixed.Wide_Wide_@!Hash_@!Case_@!Insensitive,
Strings.Wide_Wide_@!Bounded.Wide_Wide_@!Hash_@!Case_@!Insensitive, and
Strings.Wide_Wide_@!Unbounded.Wide_Wide_@!Hash_@!Case_@!Insensitive)
are new.]}
@end{Extend2005}
@begin{DiffWord2005}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0223-1]}
@ChgAdded{Version=[3],Text=[@b<Correction>: Identified Wide_Wide_Character_Set
and Wide_Wide_Character_Mapping as needing finalization. It is likely that
they are implemented with a controlled type, so this change is unlikely to
make any difference in practice.]}
@end{DiffWord2005}
@LabeledAddedSubClause{Version=[2],Name=[String Hashing]}
@begin{StaticSem}
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
@ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The library
function Strings.Hash has the following declaration:]}
@begin{Example}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0298-1]}
@ChgAdded{Version=[2],Text=[@key<with> Ada.Containers;
@key<function> Ada.Strings.Hash (Key : String) @key<return> Containers.Hash_Type;@SubChildUnit{Parent=[Ada.Strings],Child=[Hash]}
@key<pragma> Pure(@Chg{Version=[3],New=[Ada.Strings.Hash],Old=[Hash]});]}
@end{Example}
@begin{DescribeCode}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Type=[Trailing],Text=[Returns an implementation-defined
value which is a function of the value of Key. If @i<A> and @i<B> are strings
such that @i<A> equals @i<B>, Hash(@i<A>) equals Hash(@i<B>).]}
@ChgImplDef{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
Text=[The values returned by Strings.Hash.]}]}
@end{DescribeCode}
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
@ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The library
function Strings.Fixed.Hash has the following declaration:]}
@begin{Example}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0298-1]}
@ChgAdded{Version=[2],Text=[@key<with> Ada.Containers, Ada.Strings.Hash;
@key<function> Ada.Strings.Fixed.Hash (Key : String) @key<return> Containers.Hash_Type
@key<renames> Ada.Strings.Hash;@Chg{Version=[3],New=[],Old=[
@key<pragma> Pure(Hash);]}]}
@end{Example}
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
@ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The generic library
function Strings.Bounded.Hash has the following declaration:]}
@begin{Example}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0298-1]}
@ChgAdded{Version=[2],Text=[@key<with> Ada.Containers;
@key<generic>@SubChildUnit{Parent=[Ada.Strings.Bounded],Child=[Hash]}
@key<with package> Bounded @key<is>
@key<new> Ada.Strings.Bounded.Generic_Bounded_Length (<>);
@key<function> Ada.Strings.Bounded.Hash (Key : Bounded.Bounded_String)
@key<return> Containers.Hash_Type;
@key<pragma> Preelaborate(@Chg{Version=[3],New=[Ada.Strings.Bounded.Hash],Old=[Hash]});]}
@end{Example}
@begin{DescribeCode}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0001-1]}
@ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[3],New=[Equivalent to],
Old=[Strings.Bounded.Hash is
equivalent to the function call]} Strings.Hash (Bounded.To_String (Key));]}
@end{DescribeCode}
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
@ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The library
function Strings.Unbounded.Hash has the following declaration:]}
@begin{Example}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0298-1]}
@ChgAdded{Version=[2],Text=[@key<with> Ada.Containers;
@key<function> Ada.Strings.Unbounded.Hash (Key : Unbounded_String)@SubChildUnit{Parent=[Ada.Strings.Unbounded],Child=[Hash]}
@key<return> Containers.Hash_Type;
@key<pragma> Preelaborate(@Chg{Version=[3],New=[Ada.Strings.Unbounded.Hash],Old=[Hash]});]}
@end{Example}
@begin{DescribeCode}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0001-1]}
@ChgAdded{Version=[2],Type=[Trailing],Text=[@Chg{Version=[3],New=[Equivalent to],
Old=[Strings.Unbounded.Hash is
equivalent to the function call]}
Strings.Hash (To_String (Key));]}
@end{DescribeCode}
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1],ARef=[AI05-0298-1]}
@ChgAdded{Version=[3],KeepNext=[T],Type=[Leading],Text=[The library function
Strings.Hash_Case_Insensitive has the following declaration:]}
@begin{Example}
@ChgRef{Version=[3],Kind=[Added]}
@ChgAdded{Version=[3],Text=[@key<with> Ada.Containers;
@key<function> Ada.Strings.Hash_Case_Insensitive (Key : String)@SubChildUnit{Parent=[Ada.Strings],Child=[Hash_Case_Insensitive]}
@key<return> Containers.Hash_Type;
@key<pragma> Pure(Ada.Strings.Hash_Case_Insensitive);]}
@end{Example}
@begin{DescribeCode}
@ChgRef{Version=[3],Kind=[Added]}
@ChgAdded{Version=[3],Type=[Trailing],Text=[Returns an implementation-defined
value which is a function of the value of Key, converted to lower case. If
A and B are strings such that Strings.Equal_Case_Insensitive (A, B) (see
@RefSecNum{String Comparison}) is
True, then Hash_Case_Insensitive(A) equals Hash_Case_Insensitive(B).]}
@end{DescribeCode}
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1],ARef=[AI05-0298-1]}
@ChgAdded{Version=[3],KeepNext=[T],Type=[Leading],Text=[The library function
Strings.Fixed.Hash_Case_Insensitive has the following declaration:]}
@begin{Example}
@ChgRef{Version=[3],Kind=[Added]}
@ChgAdded{Version=[3],Text=[@key<with> Ada.Containers, Ada.Strings.Hash_Case_Insensitive;
@key[function] Ada.Strings.Fixed.Hash_Case_Insensitive (Key : String)@SubChildUnit{Parent=[Ada.Strings.Fixed],Child=[Hash_Case_Insensitive]}
@key[return] Containers.Hash_Type @key[renames] Ada.Strings.Hash_Case_Insensitive;]}
@end{Example}
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1],ARef=[AI05-0298-1]}
@ChgAdded{Version=[3],KeepNext=[T],Type=[Leading],Text=[The generic library
function Strings.Bounded.Hash_Case_Insensitive has the following declaration:]}
@begin{Example}
@ChgRef{Version=[3],Kind=[Added]}
@ChgAdded{Version=[3],Text=[@key<with> Ada.Containers;
@key[generic]
@key[with package] Bounded @key[is]
@key[new] Ada.Strings.Bounded.Generic_Bounded_Length (<>);
@key[function] Ada.Strings.Bounded.Hash_Case_Insensitive@SubChildUnit{Parent=[Ada.Strings.Bounded],Child=[Hash_Case_Insensitive]}
(Key : Bounded.Bounded_String) @key[return] Containers.Hash_Type;
@key[pragma] Preelaborate(Ada.Strings.Bounded.Hash_Case_Insensitive);]}
@end{Example}
@begin{DescribeCode}
@ChgRef{Version=[3],Kind=[Added]}
@ChgAdded{Version=[3],Type=[Trailing],Text=[Equivalent to
Strings.Hash_Case_Insensitive (Bounded.To_String (Key));]}
@end{DescribeCode}
@ChgRef{Version=[3],Kind=[Added],ARef=[AI05-0001-1],ARef=[AI05-0298-1]}
@ChgAdded{Version=[3],KeepNext=[T],Type=[Leading],Text=[The library function
Strings.Unbounded.Hash_Case_Insensitive has the following declaration:]}
@begin{Example}
@ChgRef{Version=[3],Kind=[Added]}
@ChgAdded{Version=[3],Text=[@key<with> Ada.Containers;
@key[function] Ada.Strings.Unbounded.Hash_Case_Insensitive@SubChildUnit{Parent=[Ada.Strings.Unbounded],Child=[Hash_Case_Insensitive]}
(Key : Unbounded_String) @key[return] Containers.Hash_Type;
@key[pragma] Preelaborate(Ada.Strings.Unbounded.Hash_Case_Insensitive);]}
@end{Example}
@begin{DescribeCode}
@ChgRef{Version=[3],Kind=[Added]}
@ChgAdded{Version=[3],Type=[Trailing],Text=[Equivalent to
Strings.Hash_Case_Insensitive (To_String (Key));]}
@end{DescribeCode}
@end{StaticSem}
@begin{ImplAdvice}
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
@ChgAdded{Version=[2],Text=[The Hash functions should be good hash
functions, returning a wide spread of values for different string values. It
should be unlikely for similar strings to return the same value.]}
@ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
Text=[Strings.Hash should be good a hash
function, returning a wide spread of values for different string values,
and similar strings should rarely return the same value.]}]}
@begin{Ramification}
@ChgRef{Version=[2],Kind=[AddedNormal]}
@ChgAdded{Version=[2],Text=[The other functions are defined in terms of
Strings.Hash, so they don't need separate advice in the Annex.]}
@end{Ramification}
@end{ImplAdvice}
@begin{Extend95}
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]}
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
The Strings.Hash, Strings.Fixed.Hash, Strings.Bounded.Hash, and
Strings.Unbounded.Hash functions are new.]}
@end{Extend95}
@begin{Extend2005}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1]}
@ChgAdded{Version=[3],Text=[@Defn{extensions to Ada 2005}
The Strings.Hash_Case_Insensitive, Strings.Fixed.Hash_Case_Insensitive,
Strings.Bounded.Hash_Case_Insensitive, and
Strings.Unbounded.Hash_Case_Insensitive functions are new.]}
@end{Extend2005}
@LabeledAddedSubClause{Version=[3],Name=[String Comparison]}
@begin{StaticSem}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1],ARef=[AI05-0286-1],ARef=[AI05-0298-1]}
@ChgAdded{Version=[3],KeepNext=[T],Type=[Leading],Text=[The library function
Strings.Equal_Case_Insensitive has the following declaration:]}
@begin{Example}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[@key[function] Ada.Strings.Equal_Case_Insensitive (Left, Right : String)@SubChildUnit{Parent=[Ada.Strings],Child=[Equal_Case_Insensitive]}
@key[return] Boolean;
@key[pragma] Pure(Ada.Strings.Equal_Case_Insensitive);]}
@end{Example}
@begin{DescribeCode}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Type=[Trailing],Text=[Returns True if the strings consist
of the same sequence of characters after applying locale-independent simple case
folding, as defined by documents referenced in the note in Clause 1 of ISO/IEC
10646:2011. Otherwise, returns False. This function uses the same method as is
used to determine whether two identifiers are the same.]}
@begin{Discussion}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0286-1]}
@ChgAdded{Version=[3],Text=[For String, this is equivalent to converting to
lower case and comparing. Not so for other string types. For Wide_Strings and
Wide_Wide_Strings, note that this result is a more accurate comparison than
converting the strings to lower case and comparing the results; it is possible
that the lower case conversions are the same but this routine will report the
strings as different. Additionally, Unicode says that the result of this
function will never change for strings made up solely of defined code points;
there is no such guarantee for case conversion to lower case.]}
@end{Discussion}
@end{DescribeCode}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1],ARef=[AI05-0248-1],ARef=[AI05-0298-1]}
@ChgAdded{Version=[3],KeepNext=[T],Type=[Leading],Text=[The library function
Strings.Fixed.Equal_Case_Insensitive has the following declaration:]}
@begin{Example}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[@key[with] Ada.Strings.Equal_Case_Insensitive;
@key[function] Ada.Strings.Fixed.Equal_Case_Insensitive@SubChildUnit{Parent=[Ada.Strings.Fixed],Child=[Equal_Case_Insensitive]}
(Left, Right : String) @key[return] Boolean
@key[renames] Ada.Strings.Equal_Case_Insensitive;]}
@end{Example}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1],ARef=[AI05-0248-1],ARef=[AI05-0298-1]}
@ChgAdded{Version=[3],KeepNext=[T],Type=[Leading],Text=[The generic library
function Strings.Bounded.Equal_Case_Insensitive has the following declaration:]}
@begin{Example}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[@key[generic]
@key[with package] Bounded @key[is]
@key[new] Ada.Strings.Bounded.Generic_Bounded_Length (<>);
@key[function] Ada.Strings.Bounded.Equal_Case_Insensitive@SubChildUnit{Parent=[Ada.Strings.Bounded],Child=[Equal_Case_Insensitive]}
(Left, Right : Bounded.Bounded_String) @key[return] Boolean;
@key[pragma] Preelaborate(Ada.Strings.Bounded.Equal_Case_Insensitive);]}
@end{Example}
@begin{DescribeCode}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Type=[Trailing],Text=[Equivalent to
Strings.Equal_Case_Insensitive (Bounded.To_String (Left), Bounded.To_String (Right));]}
@end{DescribeCode}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1],ARef=[AI05-0248-1],ARef=[AI05-0298-1]}
@ChgAdded{Version=[3],KeepNext=[T],Type=[Leading],Text=[The library function
Strings.Unbounded.Equal_Case_Insensitive has the following declaration:]}
@begin{Example}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[@key[function] Ada.Strings.Unbounded.Equal_Case_Insensitive@SubChildUnit{Parent=[Ada.Strings.Unbounded],Child=[Equal_Case_Insensitive]}
(Left, Right : Unbounded_String) @key[return] Boolean;
@key[pragma] Preelaborate(Ada.Strings.Unbounded.Equal_Case_Insensitive);]}
@end{Example}
@begin{DescribeCode}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Type=[Trailing],Text=[Equivalent to
Strings.Equal_Case_Insensitive (To_String (Left), To_String (Right));]}
@end{DescribeCode}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1],ARef=[AI05-0298-1]}
@ChgAdded{Version=[3],KeepNext=[T],Type=[Leading],Text=[The library function
Strings.Less_Case_Insensitive has the following declaration:]}
@begin{Example}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[@key[function] Ada.Strings.Less_Case_Insensitive (Left, Right : String)@SubChildUnit{Parent=[Ada.Strings],Child=[Less_Case_Insensitive]}
@key[return] Boolean;
@key[pragma] Pure(Ada.Strings.Less_Case_Insensitive);]}
@end{Example}
@begin{DescribeCode}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Type=[Trailing],Text=[Performs a lexicographic comparison
of strings Left and Right, converted to lower case.]}
@end{DescribeCode}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1],ARef=[AI05-0248-1],ARef=[AI05-0298-1]}
@ChgAdded{Version=[3],KeepNext=[T],Type=[Leading],Text=[The library function
Strings.Fixed.Less_Case_Insensitive has the following declaration:]}
@begin{Example}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[@key[with] Ada.Strings.Less_Case_Insensitive;
@key[function] Ada.Strings.Fixed.Less_Case_Insensitive@SubChildUnit{Parent=[Ada.Strings.Fixed],Child=[Less_Case_Insensitive]}
(Left, Right : String) @key[return] Boolean
@key[renames] Ada.Strings.Less_Case_Insensitive;]}
@end{Example}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1],ARef=[AI05-0248-1],ARef=[AI05-0298-1]}
@ChgAdded{Version=[3],KeepNext=[T],Type=[Leading],Text=[The generic library
function Strings.Bounded.Less_Case_Insensitive has the following declaration:]}
@begin{Example}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[@key[generic]
@key[with package] Bounded @key[is]
@key[new] Ada.Strings.Bounded.Generic_Bounded_Length (<>);
@key[function] Ada.Strings.Bounded.Less_Case_Insensitive@SubChildUnit{Parent=[Ada.Strings.Bounded],Child=[Less_Case_Insensitive]}
(Left, Right : Bounded.Bounded_String) @key[return] Boolean;
@key[pragma] Preelaborate(Ada.Strings.Bounded.Less_Case_Insensitive);]}
@end{Example}
@begin{DescribeCode}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Type=[Trailing],Text=[Equivalent to
Strings.Less_Case_Insensitive (Bounded.To_String (Left), Bounded.To_String (Right));]}
@end{DescribeCode}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1],ARef=[AI05-0248-1],ARef=[AI05-0298-1]}
@ChgAdded{Version=[3],KeepNext=[T],Type=[Leading],Text=[The library function
Strings.Unbounded.Less_Case_Insensitive has the following declaration:]}
@begin{Example}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[@key[function] Ada.Strings.Unbounded.Less_Case_Insensitive@SubChildUnit{Parent=[Ada.Strings.Unbounded],Child=[Less_Case_Insensitive]}
(Left, Right : Unbounded_String) @key[return] Boolean;
@key[pragma] Preelaborate(Ada.Strings.Unbounded.Less_Case_Insensitive);]}
@end{Example}
@begin{DescribeCode}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Type=[Trailing],Text=[Equivalent to
Strings.Less_Case_Insensitive (To_String (Left), To_String (Right));]}
@end{DescribeCode}
@end{StaticSem}
@begin{Extend2005}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0001-1],ARef=[AI05-0286-1]}
@ChgAdded{Version=[3],Text=[@Defn{extensions to Ada 2005}
The Strings.Equal_Case_Insensitive, Strings.Fixed.Equal_Case_Insensitive,
Strings.Bounded.Equal_Case_Insensitive,
Strings.Unbounded.Equal_Case_Insensitive,
Strings.Less_Case_Insensitive, Strings.Fixed.Less_Case_Insensitive,
Strings.Bounded.Less_Case_Insensitive,
Strings.Unbounded.Less_Case_Insensitive functions are new.]}
@end{Extend2005}
@LabeledAddedSubClause{Version=[3],Name=[String Encoding]}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2]}
@ChgAdded{Version=[3],Text=[Facilities for encoding, decoding, and converting strings in various character
encoding schemes are provided by packages Strings.@!UTF_Encoding,
Strings.@!UTF_Encoding.@!Conversions, Strings.@!UTF_Encoding.@!Strings,
Strings.@!UTF_Encoding.@!Wide_Strings, and
Strings.@!UTF_Encoding.@!Wide_Wide_Strings.]}
@begin{StaticSem}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2]}
@ChgAdded{Version=[3],Type=[Leading],Text=[The encoding library packages have
the following declarations:]}
@begin{Example}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2]}
@ChgAdded{Version=[3],Text=[@ChildUnit{Parent=[Ada.Strings],Child=[UTF_Encoding]}@key[package] Ada.Strings.UTF_Encoding @key[is]
@key[pragma] Pure (UTF_Encoding);]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[ -- @Examcom[Declarations common to the string encoding packages]
@key[type] @AdaTypeDefn{Encoding_Scheme} @key[is] (UTF_8, UTF_16BE, UTF_16LE);]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[ @key[subtype] @AdaSubtypeDefn{Name=[UTF_String],Of=[String]} @key[is] String;]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[ @key[subtype] @AdaSubtypeDefn{Name=[UTF_8_String],Of=[String]} @key[is] String;]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[ @key[subtype] @AdaSubtypeDefn{Name=[UTF_16_Wide_String],Of=[Wide_String]} @key[is] Wide_String;]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[ @AdaExcDefn{Encoding_Error} : @key[exception];]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[ @AdaObjDefn{BOM_8} : @key[constant] UTF_8_String :=
Character'Val(16#EF#) &
Character'Val(16#BB#) &
Character'Val(16#BF#);]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[ @AdaObjDefn{BOM_16BE} : @key[constant] UTF_String :=
Character'Val(16#FE#) &
Character'Val(16#FF#);]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[ @AdaObjDefn{BOM_16LE} : @key[constant] UTF_String :=
Character'Val(16#FF#) &
Character'Val(16#FE#);]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[ @AdaObjDefn{BOM_16} : @key[constant] UTF_16_Wide_String :=
(1 => Wide_Character'Val(16#FEFF#));]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Encoding} (Item : UTF_String;
Default : Encoding_Scheme := UTF_8)
@key[return] Encoding_Scheme;]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[@key[end] Ada.Strings.UTF_Encoding;]}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2]}
@ChgAdded{Version=[3],Text=[@ChildUnit{Parent=[Ada.Strings.UTF_Encoding],Child=[Conversions]}@key[package] Ada.Strings.UTF_Encoding.Conversions @key[is]
@key[pragma] Pure (Conversions);]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[ -- @Examcom{Conversions between various encoding schemes}
@key[function] @AdaSubDefn{Convert} (Item : UTF_String;
Input_Scheme : Encoding_Scheme;
Output_Scheme : Encoding_Scheme;
Output_BOM : Boolean := False) @key[return] UTF_String;]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Convert} (Item : UTF_String;
Input_Scheme : Encoding_Scheme;
Output_BOM : Boolean := False)
@key[return] UTF_16_Wide_String;]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Convert} (Item : UTF_8_String;
Output_BOM : Boolean := False)
@key[return] UTF_16_Wide_String;]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Convert} (Item : UTF_16_Wide_String;
Output_Scheme : Encoding_Scheme;
Output_BOM : Boolean := False) @key[return] UTF_String;]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Convert} (Item : UTF_16_Wide_String;
Output_BOM : Boolean := False) @key[return] UTF_8_String;]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[@key[end] Ada.Strings.UTF_Encoding.Conversions;]}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2]}
@ChgAdded{Version=[3],Text=[@ChildUnit{Parent=[Ada.Strings.UTF_Encoding],Child=[Strings]}@key[package] Ada.Strings.UTF_Encoding.Strings @key[is]
@key[pragma] Pure (Strings);]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[ -- @Examcom{Encoding / decoding between String and various encoding schemes}
@key[function] @AdaSubDefn{Encode} (Item : String;
Output_Scheme : Encoding_Scheme;
Output_BOM : Boolean := False) @key[return] UTF_String;]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Encode} (Item : String;
Output_BOM : Boolean := False) @key[return] UTF_8_String;]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Encode} (Item : String;
Output_BOM : Boolean := False)
@key[return] UTF_16_Wide_String;]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Decode} (Item : UTF_String;
Input_Scheme : Encoding_Scheme) @key[return] String;]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Decode} (Item : UTF_8_String) @key[return] String;]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Decode} (Item : UTF_16_Wide_String) @key[return] String;]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[@key[end] Ada.Strings.UTF_Encoding.Strings;]}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2]}
@ChgAdded{Version=[3],Text=[@ChildUnit{Parent=[Ada.Strings.UTF_Encoding],Child=[Wide_Strings]}@key[package] Ada.Strings.UTF_Encoding.Wide_Strings @key[is]
@key[pragma] Pure (Wide_Strings);]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[ -- @Examcom{Encoding / decoding between Wide_String and various encoding schemes}
@key[function] @AdaSubDefn{Encode} (Item : Wide_String;
Output_Scheme : Encoding_Scheme;
Output_BOM : Boolean := False) @key[return] UTF_String;]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Encode} (Item : Wide_String;
Output_BOM : Boolean := False) @key[return] UTF_8_String;]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Encode} (Item : Wide_String;
Output_BOM : Boolean := False)
@key[return] UTF_16_Wide_String;]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Decode} (Item : UTF_String;
Input_Scheme : Encoding_Scheme) @key[return] Wide_String;]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Decode} (Item : UTF_8_String) @key[return] Wide_String;]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Decode} (Item : UTF_16_Wide_String) @key[return] Wide_String;]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[@key[end] Ada.Strings.UTF_Encoding.Wide_Strings;]}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2]}
@ChgAdded{Version=[3],Text=[@ChildUnit{Parent=[Ada.Strings.UTF_Encoding],Child=[Wide_Wide_Strings]}@key[package] Ada.Strings.UTF_Encoding.Wide_Wide_Strings @key[is]
@key[pragma] Pure (Wide_Wide_Strings);]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[ -- @Examcom{Encoding / decoding between Wide_Wide_String and various encoding schemes}
@key[function] @AdaSubDefn{Encode} (Item : Wide_Wide_String;
Output_Scheme : Encoding_Scheme;
Output_BOM : Boolean := False) @key[return] UTF_String;]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Encode} (Item : Wide_Wide_String;
Output_BOM : Boolean := False) @key[return] UTF_8_String;]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Encode} (Item : Wide_Wide_String;
Output_BOM : Boolean := False)
@key[return] UTF_16_Wide_String;]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Decode} (Item : UTF_String;
Input_Scheme : Encoding_Scheme) @key[return] Wide_Wide_String;]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Decode} (Item : UTF_8_String) @key[return] Wide_Wide_String;]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Decode} (Item : UTF_16_Wide_String) @key[return] Wide_Wide_String;]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[@key[end] Ada.Strings.UTF_Encoding.Wide_Wide_Strings;]}
@end{Example}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2],ARef=[AI05-0262-1]}
@ChgAdded{Version=[3],Text=[The type Encoding_Scheme defines encoding schemes.
UTF_8 corresponds to the UTF-8 encoding scheme defined by Annex D of ISO/IEC
10646. UTF_16BE corresponds to the UTF-16 encoding scheme defined by Annex C of
ISO/IEC 10646 in 8 bit, big-endian order; and UTF_16LE corresponds to the
UTF-16 encoding scheme in 8 bit, little-endian
order.@Defn{encoding scheme}@Defn{character encoding}@Defn{UTF-8}@Defn{UTF-16}]}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2]}
@ChgAdded{Version=[3],Text=[The subtype UTF_String is used to represent a String
of 8-bit values containing a sequence of values encoded in one of three ways
(UTF-8, UTF-16BE, or UTF-16LE). The subtype UTF_8_String is used to represent a
String of 8-bit values containing a sequence of values encoded in UTF-8. The
subtype UTF_16_Wide_String is used to represent a Wide_String of 16-bit values
containing a sequence of values encoded in UTF-16.]}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2],ARef=[AI05-0262-1]}
@ChgAdded{Version=[3],Text=[The BOM_8, BOM_16BE, BOM_16LE, and BOM_16 constants
correspond to values used at the start of a string to indicate the encoding.]}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0262-1],ARef=[AI05-0269-1]}
@ChgAdded{Version=[3],Text=[Each of the Encode functions takes a String,
Wide_String, or Wide_Wide_String Item parameter that is assumed to be an array
of unencoded characters. Each of the Convert functions takes a UTF_String,
UTF_8_String, or UTF_16_String Item parameter that is assumed to
contain characters whose position values correspond to a valid encoding sequence
according to the encoding scheme required by the function or specified by its
Input_Scheme parameter.]}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2],ARef=[AI05-0262-1],ARef=[AI05-0269-1]}
@ChgAdded{Version=[3],Text=[Each of the Convert and Encode functions returns
a UTF_String, UTF_8_String, or UTF_16_String value whose characters have position values
that correspond to the encoding of the Item parameter according to the
encoding scheme required by the function or specified by its Output_Scheme
parameter. For UTF_8, no overlong encoding is returned. A BOM is included
at the start of the returned string if the Output_BOM parameter is set to
True. The lower bound of the returned string is 1.]}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2],ARef=[AI05-0262-1]}
@ChgAdded{Version=[3],Text=[Each of the Decode functions takes a UTF_String,
UTF_8_String, or UTF_16_String Item parameter which is assumed to
contain characters whose position values correspond to a valid encoding sequence
according to the encoding scheme required by the function or specified by its
Input_Scheme parameter, and returns the corresponding String, Wide_String, or
Wide_Wide_String value. The lower bound of the returned string is 1.]}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2],ARef=[AI05-0262-1]}
@ChgAdded{Version=[3],Text=[For each of the Convert and Decode functions, an
initial BOM in the input that matches the expected encoding scheme is ignored,
and a different initial BOM causes Encoding_Error to be propagated.]}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2]}
@ChgAdded{Version=[3],Type=[Leading],Text=[The exception Encoding_Error is also propagated in the following
situations:]}
@begin{Itemize}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgRef{Version=[4],Kind=[Revised],ARef=[AI12-0088-1]}
@ChgAdded{Version=[3],Text=[By a @Chg{Version=[4],New=[Convert or
],Old=[]}Decode function when a UTF encoded
string contains an invalid encoding sequence.]}
@begin{Honest}
@ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI12-0088-1]}
@ChgAdded{Version=[4],Text=[An overlong encoding is not invalid for the
purposes of this check, and this does not depend on the character set
version in use. Some recent character set standards declare overlong
encodings to be invalid; it would be unnecessary and unfriendly to users
for Convert or Decode to raise an exception for an overlong encoding.]}
@end{Honest}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgRef{Version=[4],Kind=[Revised],ARef=[AI12-0088-1]}
@ChgAdded{Version=[3],Text=[By a @Chg{Version=[4],New=[Convert or
],Old=[]}Decode function when the expected encoding is
UTF-16BE or UTF-16LE and the input string has an odd length.]}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0262-1]}
@ChgAdded{Version=[3],Text=[By a Decode function yielding a String when
the decoding of a sequence results in a code point whose value exceeds
16#FF#.]}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Text=[By a Decode function yielding a Wide_String when
the decoding of a sequence results in a code point whose value exceeds
16#FFFF#.]}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0262-1]}
@ChgAdded{Version=[3],Text=[By an Encode function taking a Wide_String as
input when an invalid character appears in the input. In particular, the
characters whose position is in the range 16#D800# .. 16#DFFF# are invalid
because they conflict with UTF-16 surrogate encodings, and the characters
whose position is 16#FFFE# or 16#FFFF# are also invalid because they
conflict with BOM codes.]}
@end{Itemize}
@begin{DescribeCode}
@begin{Example}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2]}
@ChgAdded{Version=[3],Keepnext=[T],Text=[@key[function] Encoding (Item : UTF_String;
Default : Encoding_Scheme := UTF_8)
@key[return] Encoding_Scheme;]}
@end{Example}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2],ARef=[AI05-0269-1]}
@ChgAdded{Version=[3],Type=[Trailing],Text=[Inspects a UTF_String value to
determine whether it starts with a BOM for UTF-8, UTF-16BE, or UTF_16LE. If so,
returns the scheme corresponding to the BOM; otherwise, returns the value of
Default.]}
@begin{Example}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2]}
@ChgAdded{Version=[3],Keepnext=[T],Text=[@key[function] Convert (Item : UTF_String;
Input_Scheme : Encoding_Scheme;
Output_Scheme : Encoding_Scheme;
Output_BOM : Boolean := False) @key[return] UTF_String;]}
@end{Example}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Type=[Trailing],Text=[Returns the value of Item
(originally encoded in UTF-8, UTF-16LE, or UTF-16BE as specified by
Input_Scheme) encoded in one of these three schemes as
specified by Output_Scheme.]}
@begin{Example}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2]}
@ChgAdded{Version=[3],Keepnext=[T],Text=[@key[function] Convert (Item : UTF_String;
Input_Scheme : Encoding_Scheme;
Output_BOM : Boolean := False)
@key[return] UTF_16_Wide_String;]}
@end{Example}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Type=[Trailing],Text=[Returns the value of Item
(originally encoded in UTF-8, UTF-16LE, or UTF-16BE as specified by
Input_Scheme) encoded in UTF-16.]}
@begin{Example}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2]}
@ChgAdded{Version=[3],Keepnext=[T],Text=[@key[function] Convert (Item : UTF_8_String;
Output_BOM : Boolean := False)
@key[return] UTF_16_Wide_String;]}
@end{Example}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Type=[Trailing],Text=[Returns the value of Item
(originally encoded in UTF-8) encoded in UTF-16.]}
@begin{Example}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2]}
@ChgAdded{Version=[3],Keepnext=[T],Text=[@key[function] Convert (Item : UTF_16_Wide_String;
Output_Scheme : Encoding_Scheme;
Output_BOM : Boolean := False) @key[return] UTF_String;]}
@end{Example}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Type=[Trailing],Text=[Returns the value of Item
(originally encoded in UTF-16) encoded in UTF-8,
UTF-16LE, or UTF-16BE as specified by Output_Scheme.]}
@begin{Example}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2]}
@ChgAdded{Version=[3],Keepnext=[T],Text=[@key[function] Convert (Item : UTF_16_Wide_String;
Output_BOM : Boolean := False) @key[return] UTF_8_String;]}
@end{Example}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Type=[Trailing],Text=[Returns the value of Item
(originally encoded in UTF-16) encoded in UTF-8.]}
@begin{Example}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2]}
@ChgAdded{Version=[3],Keepnext=[T],Text=[@key[function] Encode (Item : String;
Output_Scheme : Encoding_Scheme;
Output_BOM : Boolean := False) @key[return] UTF_String;]}
@end{Example}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0262-1]}
@ChgAdded{Version=[3],Type=[Trailing],Text=[Returns the value of Item
encoded in UTF-8, UTF-16LE, or UTF-16BE as specified
by Output_Scheme.]}
@begin{Example}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2]}
@ChgAdded{Version=[3],Keepnext=[T],Text=[@key[function] Encode (Item : String;
Output_BOM : Boolean := False) @key[return] UTF_8_String;]}
@end{Example}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Type=[Trailing],Text=[Returns the value of Item
encoded in UTF-8.]}
@begin{Example}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2]}
@ChgAdded{Version=[3],Keepnext=[T],Text=[@key[function] Encode (Item : String;
Output_BOM : Boolean := False) @key[return] UTF_16_Wide_String;]}
@end{Example}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Type=[Trailing],Text=[Returns the value of Item
encoded in UTF_16.]}
@begin{Example}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2]}
@ChgAdded{Version=[3],Keepnext=[T],Text=[@key[function] Decode (Item : UTF_String;
Input_Scheme : Encoding_Scheme) @key[return] String;]}
@end{Example}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Type=[Trailing],Text=[Returns the result of decoding Item,
which is encoded in UTF-8, UTF-16LE, or UTF-16BE as specified by Input_Scheme.]}
@begin{Example}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2]}
@ChgAdded{Version=[3],Keepnext=[T],Text=[@key[function] Decode (Item : UTF_8_String) @key[return] String;]}
@end{Example}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Type=[Trailing],Text=[Returns the result of decoding Item,
which is encoded in UTF-8.]}
@begin{Example}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2]}
@ChgAdded{Version=[3],Keepnext=[T],Text=[@key[function] Decode (Item : UTF_16_Wide_String) @key[return] String;]}
@end{Example}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Type=[Trailing],Text=[Returns the result of decoding Item,
which is encoded in UTF-16.]}
@begin{Example}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2]}
@ChgAdded{Version=[3],Keepnext=[T],Text=[@key[function] Encode (Item : Wide_String;
Output_Scheme : Encoding_Scheme;
Output_BOM : Boolean := False) @key[return] UTF_String;]}
@end{Example}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0262-1]}
@ChgAdded{Version=[3],Type=[Trailing],Text=[Returns the value of Item
encoded in UTF-8, UTF-16LE, or UTF-16BE as specified
by Output_Scheme.]}
@begin{Example}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2]}
@ChgAdded{Version=[3],Keepnext=[T],Text=[@key[function] Encode (Item : Wide_String;
Output_BOM : Boolean := False) @key[return] UTF_8_String;]}
@end{Example}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Type=[Trailing],Text=[Returns the value of Item
encoded in UTF-8.]}
@begin{Example}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2]}
@ChgAdded{Version=[3],Keepnext=[T],Text=[@key[function] Encode (Item : Wide_String;
Output_BOM : Boolean := False) @key[return] UTF_16_Wide_String;]}
@end{Example}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Type=[Trailing],Text=[Returns the value of Item
encoded in UTF_16.]}
@begin{Example}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2]}
@ChgAdded{Version=[3],Keepnext=[T],Text=[@key[function] Decode (Item : UTF_String;
Input_Scheme : Encoding_Scheme) @key[return] Wide_String;]}
@end{Example}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Type=[Trailing],Text=[Returns the result of decoding Item,
which is encoded in UTF-8, UTF-16LE, or UTF-16BE as specified by Input_Scheme.]}
@begin{Example}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2]}
@ChgAdded{Version=[3],Keepnext=[T],Text=[@key[function] Decode (Item : UTF_8_String) @key[return] Wide_String;]}
@end{Example}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Type=[Trailing],Text=[Returns the result of decoding Item, which is encoded in UTF-8.]}
@begin{Example}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2]}
@ChgAdded{Version=[3],Keepnext=[T],Text=[@key[function] Decode (Item : UTF_16_Wide_String) @key[return] Wide_String;]}
@end{Example}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Type=[Trailing],Text=[Returns the result of decoding Item,
which is encoded in UTF-16.]}
@begin{Example}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2]}
@ChgAdded{Version=[3],Keepnext=[T],Text=[@key[function] Encode (Item : Wide_Wide_String;
Output_Scheme : Encoding_Scheme;
Output_BOM : Boolean := False) @key[return] UTF_String;]}
@end{Example}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0262-1]}
@ChgAdded{Version=[3],Type=[Trailing],Text=[Returns the value of Item
encoded in UTF-8, UTF-16LE, or UTF-16BE as specified by Output_Scheme.]}
@begin{Example}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2]}
@ChgAdded{Version=[3],Keepnext=[T],Text=[@key[function] Encode (Item : Wide_Wide_String;
Output_BOM : Boolean := False) @key[return] UTF_8_String;]}
@end{Example}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Type=[Trailing],Text=[Returns the value of Item
encoded in UTF-8.]}
@begin{Example}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2]}
@ChgAdded{Version=[3],Keepnext=[T],Text=[@key[function] Encode (Item : Wide_Wide_String;
Output_BOM : Boolean := False) @key[return] UTF_16_Wide_String;]}
@end{Example}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Type=[Trailing],Text=[Returns the value of Item
encoded in UTF_16.]}
@begin{Example}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2]}
@ChgAdded{Version=[3],Keepnext=[T],Text=[@key[function] Decode (Item : UTF_String;
Input_Scheme : Encoding_Scheme) @key[return] Wide_Wide_String;]}
@end{Example}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Type=[Trailing],Text=[Returns the result of decoding Item,
which is encoded in UTF-8, UTF-16LE, or UTF-16BE as specified by Input_Scheme.]}
@begin{Example}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2]}
@ChgAdded{Version=[3],Keepnext=[T],Text=[@key[function] Decode (Item : UTF_8_String) @key[return] Wide_Wide_String;]}
@end{Example}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Type=[Trailing],Text=[Returns the result of decoding Item,
which is encoded in UTF-8.]}
@begin{Example}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2]}
@ChgAdded{Version=[3],Keepnext=[T],Text=[@key[function] Decode (Item : UTF_16_Wide_String) @key[return] Wide_Wide_String;]}
@end{Example}
@ChgRef{Version=[3],Kind=[AddedNormal]}
@ChgAdded{Version=[3],Type=[Trailing],Text=[Returns the result of decoding Item,
which is encoded in UTF-16.]}
@end{DescribeCode}
@end{StaticSem}
@begin{ImplAdvice}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2]}
@ChgAdded{Version=[3],Text=[If an implementation supports other encoding
schemes, another similar child of Ada.Strings should be defined.]}
@ChgImplAdvice{Version=[3],Kind=[Added],Text=[@ChgAdded{Version=[3],
Text=[If an implementation supports other string encoding
schemes, a child of Ada.Strings similar to UTF_Encoding should be defined.]}]}
@end{ImplAdvice}
@begin{Notes}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2]}
@ChgAdded{Version=[3],Text=[A BOM (Byte-Order Mark, code position 16#FEFF#) can
be included in a file or other entity to indicate the encoding; it is skipped
when decoding. Typically, only the first line of a file or other entity contains
a BOM. When decoding, the Encoding function can be called on the first line to
determine the encoding; this encoding will then be used in subsequent calls to
Decode to convert all of the lines to an internal format.]}
@end{Notes}
@begin{Extend2005}
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0137-2]}
@ChgAdded{Version=[3],Text=[@Defn{extensions to Ada 2005}
The packages Strings.UTF_Encoding, Strings.UTF_Encoding.Conversions,
Strings.UTF_Encoding.Strings, Strings.UTF_Encoding.Wide_Strings,
and Strings.UTF_Encoding.Wide_Wide_Strings are new.]}
@end{Extend2005}
@begin{Diffword2012}
@ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI12-0088-1]}
@ChgAdded{Version=[4],Text=[@b<Corrigendum:> Fixed the omission that Convert
routines make the same checks on input as Decode routines.]}
@end{Diffword2012}
|