From: "Schroeer, Joachim Dr." <Joachim.Schroeer@vs.dasa.de>
To: "'comp.lang.ada@ada.eu.org'" <comp.lang.ada@ada.eu.org>
Cc: "'christoph.grein@eurocopter.de'" <christoph.grein@eurocopter.de>
Subject: Re: Gnat 3.13p: Command_Name RM A.15
Date: Thu, 18 Jan 2001 13:10:26 +0100
Date: 2001-01-18T13:10:26+01:00 [thread overview]
Message-ID: <mailman.979819871.21605.comp.lang.ada@ada.eu.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 1743 bytes --]
Hallo Herr Grein,
ich habe auch ein kleines Paket, das ich innerhalb eines
größeren Ada95 Projekts unter WinNT/98 zum Scannen der
command-line benutzt habe. Es wurde bisher mit ObjectAda
und GNAT eingesetzt und sollte auch auf anderen Plattformen
laufen. Die function command_name dürfte Ihnen weiterhelfen.
Wenn Sie auch das Paket Portable.Standard haben wollen,
das im Body benutzt wird, melden Sie sich bitte.
P.S. Eurocopter gehört doch zur EADS. Warum finde ich Ihren
Namen dann nicht in unserer internen Mailing-Liste, wo doch
die Kollegen von Daimler-Chrysler noch und die von der Casa
schon zu sehen sind?
Beste Grüße
J. Schröer
Dr.-Ing. Joachim Schröer
EADS Germany GmbH
Defense Electronics
Dept.: VEE22
Wörthstraße 85
D-89070 ULM
Telefon: +49 731 392 5993
Christoph Grein <christoph.grein@eurocopter.de> schrieb in im Newsbeitrag:
<mailman.979801451.11095.comp.lang.ada@ada.eu.org>...
> Thanks to all for their responses.
>
> Randy Brukardt gave me a nice solution (it may not be applicable for all
cases,
> but for me, it worked).
>
> The original question was:
>
> How do I get the full name of Ada.Command_Line.Command_Name? The result of
> Command_Name is implementation dependent.
>
> Open the file with the name given by Command_Name, call the Name function
which
> by A8.2(22) must return the full name, then close the file again:
>
> Open (File, in_file, Ada.Command_Line.Command_Name);
> Full_Name := Name (File); -- this is the idea only (careful, string
sizes)
> Close (File);
>
> OK, A8.2(22) actually says "should", but Randy confirmed that the ACATS
test for
> the full name, so you can rely on this.
>
> Christoph Grein
>
>
[-- Attachment #2: utilities-command_line.adb --]
[-- Type: application/octet-stream, Size: 3647 bytes --]
-- -*- Mode: Ada -*-
-- Filename : utilities-command_line.ads
-- Description : Simplifies access on the command_line parameters
-- via key strings (options).
-- Author : J. Schroeer
-- Created On : 18. Feb. 1998
-- Last Modified By:
-- Last Modified On:
-- Update Count : 1
-- Status :
with Ada.Command_Line;
with Ada.Strings.Fixed;
with Ada.Strings.Unbounded;
with Portable.Operating_System;
package body Utilities.Command_Line is
Dir_Sep : constant String := Portable.Operating_System.Directory_Separator & "";
----------------------------------------------------------------------------
function Argument(Key : in String) return String is
begin
for I in 1 .. Ada.Command_Line.Argument_Count - 1 loop
if Key = Ada.Command_Line.Argument(I) then
return Ada.Command_Line.Argument(I + 1);
end if;
end loop;
return "";
end Argument;
----------------------------------------------------------------------------
function Argument(Key : in String;
Default : in String) return String is
Arg : constant String := Argument(Key);
begin
if Arg /= "" then
return Arg;
else
return Default;
end if;
end Argument;
----------------------------------------------------------------------------
function Argument(Key : in String;
Default : in Float'Base) return Float'Base is
Arg : constant String := Argument(Key);
begin
if Arg /= "" then
return Float'Value(Arg);
else
return Default;
end if;
end Argument;
----------------------------------------------------------------------------
function Argument(Key : in String;
Default : in Integer) return Integer is
Arg : constant String := Argument(Key);
begin
if Arg /= "" then
return Integer'Value(Arg);
else
return Default;
end if;
end Argument;
----------------------------------------------------------------------------
function Has_Argument(Key : in String) return Boolean is
begin
for I in 1 .. Ada.Command_Line.Argument_Count loop
if Key = Ada.Command_Line.Argument(I) then
return True;
end if;
end loop;
return False;
end Has_Argument;
----------------------------------------------------------------------------
function Command_Name(Full_Path : in Boolean := True) return String is
Name : constant String := Ada.Command_Line.Command_Name;
begin
if Full_Path then
return Name;
else
return Name(Ada.Strings.Fixed.Index(Source => Name,
Pattern => Dir_Sep,
Going => Ada.Strings.Backward)
+ 1 .. Name'Last);
end if;
end Command_Name;
----------------------------------------------------------------------------
function Total_Command_Line(Full_Path : in Boolean := True) return String is
Cl : Ada.Strings.Unbounded.Unbounded_String :=
Ada.Strings.Unbounded.Null_Unbounded_String;
use type Ada.Strings.Unbounded.Unbounded_String;
begin
for I in 1 .. Ada.Command_Line.Argument_Count loop
Cl := Cl & " " & Ada.Command_Line.Argument(I);
end loop;
return Command_Name(Full_Path) & Ada.Strings.Unbounded.To_String(Cl);
end Total_Command_Line;
----------------------------------------------------------------------------
end Utilities.Command_Line;
[-- Attachment #3: utilities-command_line.ads --]
[-- Type: application/octet-stream, Size: 1948 bytes --]
-- -*- Mode: Ada -*-
-- Filename : utilities-command_line.ads
-- Description : Simplifies access on the command_line parameters
-- via key strings (options).
-- Author : J. Schroeer
-- Created On : 18. Feb. 1998
-- Last Modified By:
-- Last Modified On:
-- Update Count : 1
-- Status :
package Utilities.Command_Line is
-- All functions herein are case-sensitive for "key".
function Argument(Key : in String) return String;
-- Returns the argument on the command-line preceded by key if key is found,
-- the empty string "" otherwise.
--
-- Example: If the main is called like
--
-- main -file filename -number 10
--
-- then argument("-file") = "filename", argument(key => "-number") = "10",
-- argument("-FILE") = "".
function Argument(Key : in String;
Default : in String) return String;
function Argument(Key : in String;
Default : in Float'Base) return Float'Base;
function Argument(Key : in String;
Default : in Integer) return Integer;
-- If has_argument(key) then return the string / float'value / integer'value
-- of the corresponding argument.
-- If not has_argument(key) then return the default.
function Has_Argument(Key : in String) return Boolean;
-- Returns true if key is an argument an the command_line, false otherwise.
function Command_Name(Full_Path : in Boolean := True) return String;
-- Returns ada.command_line.command_name if full_path.
-- Returns ada.command_line.command_name without path when not full_path.
-- ada.command_line.command_name is the full name of the Main-unit.
function Total_Command_Line(Full_Path : in Boolean := True) return String;
-- Returns the total command_line including command_name and all arguments
-- separated by blanks.
end Utilities.Command_Line;
[-- Attachment #4: utilities.ads --]
[-- Type: application/octet-stream, Size: 362 bytes --]
-- -*- Mode: Ada -*-
-- Filename : utilities.ads
-- Description : Parent package for Utilities
-- Author : J. Schroeer
-- Created On : Wed Mar 26 17:25:34 1997
-- Last Modified By:
-- Last Modified On: Wed Jul 2 13:41:50 1997
-- Update Count : 2
-- Status :
package Utilities is
end Utilities;
next reply other threads:[~2001-01-18 12:10 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-01-18 12:10 Schroeer, Joachim Dr. [this message]
2001-01-18 12:19 ` Gnat 3.13p: Command_Name RM A.15 Lutz Donnerhacke
-- strict thread matches above, loose matches on Subject: below --
2001-01-19 7:26 Christoph Grein
2001-01-18 6:59 Christoph Grein
2001-01-18 12:38 ` Larry Kilgallen
2001-01-18 14:32 ` Marin David Condic
2001-01-18 14:54 ` Ted Dennison
2001-01-18 15:12 ` Robert Dewar
2001-01-16 6:12 Christoph Grein
2001-01-16 14:22 ` Marin David Condic
2001-01-16 18:14 ` Jean-Pierre Rosen
2001-01-17 13:15 ` Marin David Condic
2001-01-17 19:12 ` Jean-Pierre Rosen
2001-01-18 3:28 ` Robert Dewar
2001-01-18 13:23 ` Marin David Condic
2001-01-18 15:15 ` Robert Dewar
2001-01-18 17:37 ` Jean-Pierre Rosen
2001-01-19 20:31 ` Florian Weimer
2001-01-18 3:25 ` Robert Dewar
2001-01-18 14:06 ` Marin David Condic
2001-01-17 19:17 ` Stephen Leake
2001-01-18 3:31 ` Robert Dewar
2001-01-18 14:13 ` Marin David Condic
2001-01-18 15:16 ` Robert Dewar
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox