comparison gcc/ada/libgnat/g-comlin.ads @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
comparison
equal deleted inserted replaced
111:04ced10e8804 131:84e7813d76e9
4 -- -- 4 -- --
5 -- G N A T . C O M M A N D _ L I N E -- 5 -- G N A T . C O M M A N D _ L I N E --
6 -- -- 6 -- --
7 -- S p e c -- 7 -- S p e c --
8 -- -- 8 -- --
9 -- Copyright (C) 1999-2017, AdaCore -- 9 -- Copyright (C) 1999-2018, AdaCore --
10 -- -- 10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under -- 11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- -- 12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- -- 13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- 14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
676 -- found on the command line. Output is always initialized to the empty 676 -- found on the command line. Output is always initialized to the empty
677 -- string if it does not have a value already (otherwise it is left as is 677 -- string if it does not have a value already (otherwise it is left as is
678 -- so that you can specify the default value directly in the declaration 678 -- so that you can specify the default value directly in the declaration
679 -- of the variable). The switch must accept an argument. 679 -- of the variable). The switch must accept an argument.
680 680
681 type Value_Callback is access procedure (Switch, Value : String);
682
683 procedure Define_Switch
684 (Config : in out Command_Line_Configuration;
685 Callback : not null Value_Callback;
686 Switch : String := "";
687 Long_Switch : String := "";
688 Help : String := "";
689 Section : String := "";
690 Argument : String := "ARG");
691 -- Call Callback for each instance of Switch. The callback is given the
692 -- actual switch and the corresponding value. The switch must accept
693 -- an argument.
694
681 procedure Set_Usage 695 procedure Set_Usage
682 (Config : in out Command_Line_Configuration; 696 (Config : in out Command_Line_Configuration;
683 Usage : String := "[switches] [arguments]"; 697 Usage : String := "[switches] [arguments]";
684 Help : String := ""; 698 Help : String := "";
685 Help_Msg : String := ""); 699 Help_Msg : String := "");
687 -- help text. These are both displayed by Display_Help. When a non-empty 701 -- help text. These are both displayed by Display_Help. When a non-empty
688 -- Help_Msg is given, it is used by Display_Help instead of the 702 -- Help_Msg is given, it is used by Display_Help instead of the
689 -- automatically generated list of supported switches. 703 -- automatically generated list of supported switches.
690 704
691 procedure Display_Help (Config : Command_Line_Configuration); 705 procedure Display_Help (Config : Command_Line_Configuration);
692 -- Display the help for the tool (ie its usage, and its supported switches) 706 -- Display the help for the tool (i.e. its usage, and its supported
707 -- switches).
693 708
694 function Get_Switches 709 function Get_Switches
695 (Config : Command_Line_Configuration; 710 (Config : Command_Line_Configuration;
696 Switch_Char : Character := '-'; 711 Switch_Char : Character := '-';
697 Section : String := "") return String; 712 Section : String := "") return String;
827 -- If the command line has sections (such as -bargs -cargs), then they 842 -- If the command line has sections (such as -bargs -cargs), then they
828 -- should be listed in the Sections parameter (as "-bargs -cargs"). 843 -- should be listed in the Sections parameter (as "-bargs -cargs").
829 -- 844 --
830 -- This function can be used to reset Cmd by passing an empty string 845 -- This function can be used to reset Cmd by passing an empty string
831 -- 846 --
832 -- If an invalid switch is found on the command line (ie wasn't defined in 847 -- If an invalid switch is found on the command line (i.e. wasn't defined
833 -- the configuration via Define_Switch), and the configuration wasn't set 848 -- in the configuration via Define_Switch), and the configuration wasn't
834 -- to accept all switches (by defining "*" as a valid switch), then an 849 -- set to accept all switches (by defining "*" as a valid switch), then an
835 -- exception Invalid_Switch is raised. The exception message indicates the 850 -- exception Invalid_Switch is raised. The exception message indicates the
836 -- invalid switch. 851 -- invalid switch.
837 852
838 procedure Add_Switch 853 procedure Add_Switch
839 (Cmd : in out Command_Line; 854 (Cmd : in out Command_Line;
880 -- 895 --
881 -- rather than the default 896 -- rather than the default
882 -- -from bar 897 -- -from bar
883 -- 898 --
884 -- Note however that Getopt doesn't know how to handle ":" as a separator. 899 -- Note however that Getopt doesn't know how to handle ":" as a separator.
885 -- So the recommendation is to declare the switch as "-from!" (ie no 900 -- So the recommendation is to declare the switch as "-from!" (i.e. no
886 -- space between the switch and its parameter). Then Getopt will return 901 -- space between the switch and its parameter). Then Getopt will return
887 -- ":bar" as the parameter, and you can trim the ":" in your application. 902 -- ":bar" as the parameter, and you can trim the ":" in your application.
888 -- 903 --
889 -- Invalid_Section is raised if Section was not defined in the 904 -- Invalid_Section is raised if Section was not defined in the
890 -- configuration of the command line. 905 -- configuration of the command line.
1109 Command_Line_Parser_Data'Access; 1124 Command_Line_Parser_Data'Access;
1110 1125
1111 type Switch_Type is (Switch_Untyped, 1126 type Switch_Type is (Switch_Untyped,
1112 Switch_Boolean, 1127 Switch_Boolean,
1113 Switch_Integer, 1128 Switch_Integer,
1114 Switch_String); 1129 Switch_String,
1130 Switch_Callback);
1115 1131
1116 type Switch_Definition (Typ : Switch_Type := Switch_Untyped) is record 1132 type Switch_Definition (Typ : Switch_Type := Switch_Untyped) is record
1117 Switch : GNAT.OS_Lib.String_Access; 1133 Switch : GNAT.OS_Lib.String_Access;
1118 Long_Switch : GNAT.OS_Lib.String_Access; 1134 Long_Switch : GNAT.OS_Lib.String_Access;
1119 Section : GNAT.OS_Lib.String_Access; 1135 Section : GNAT.OS_Lib.String_Access;
1133 Integer_Output : access Integer; 1149 Integer_Output : access Integer;
1134 Integer_Initial : Integer; 1150 Integer_Initial : Integer;
1135 Integer_Default : Integer; 1151 Integer_Default : Integer;
1136 when Switch_String => 1152 when Switch_String =>
1137 String_Output : access GNAT.Strings.String_Access; 1153 String_Output : access GNAT.Strings.String_Access;
1154 when Switch_Callback =>
1155 Callback : Value_Callback;
1138 end case; 1156 end case;
1139 end record; 1157 end record;
1140 type Switch_Definitions is array (Natural range <>) of Switch_Definition; 1158 type Switch_Definitions is array (Natural range <>) of Switch_Definition;
1141 type Switch_Definitions_List is access all Switch_Definitions; 1159 type Switch_Definitions_List is access all Switch_Definitions;
1142 -- [Switch] includes the leading '-' 1160 -- [Switch] includes the leading '-'