Files
PolyORB/compilers/iac/utils.adb
Laurent Pautet a4391c528a Sources of Idl to Ada Compiler
[Imported from Perforce change 6618 at 2006-12-01 19:56:22]

Subversion-branch: /trunk/polyorb
Subversion-revision: 34572
2003-04-08 23:10:26 +00:00

83 lines
1.8 KiB
Ada

with Charset; use Charset;
with Namet; use Namet;
package body Utils is
Up_To_Low : constant := Character'Pos ('A') - Character'Pos ('a');
----------------
-- Capitalize --
----------------
procedure Capitalize (S : in out String) is
Up : Boolean := True;
begin
for I in S'Range loop
if Up then
Up := False;
if S (I) in 'a' .. 'z' then
S (I) := Character'Val (Character'Pos (S (I)) + Up_To_Low);
end if;
else
if S (I) in 'A' .. 'Z' then
S (I) := Character'Val (Character'Pos (S (I)) - Up_To_Low);
end if;
end if;
if S (I) = '_' then
Up := True;
end if;
end loop;
end Capitalize;
------------
-- Quoted --
------------
function Quoted (S : String; D : Character := '"') return String is -- "
begin
return (1 => D) & S & (1 => D);
end Quoted;
------------
-- Quoted --
------------
function Quoted (S : String; D : Character := '"') return Name_Id is -- "
begin
Set_Char_To_Name_Buffer (D);
Add_Str_To_Name_Buffer (S);
Add_Char_To_Name_Buffer (D);
return Name_Find;
end Quoted;
------------
-- Quoted --
------------
function Quoted (N : Name_Id; D : Character := '"') return String is -- "
begin
return Quoted (Get_Name_String (N), D);
end Quoted;
------------
-- Quoted --
------------
function Quoted (N : Name_Id; D : Character := '"') return Name_Id is -- "
begin
return Quoted (Get_Name_String (N), D);
end Quoted;
--------------
-- To_Lower --
--------------
function To_Lower (N : Name_Id) return Name_Id is
begin
Get_Name_String (N);
To_Lower (Name_Buffer (1 .. Name_Len));
return Name_Find;
end To_Lower;
end Utils;