Make your own free website on Tripod.com

File : oci-thick-number_functions.adb


with System,OCI.Thread;
package body OCI.Thick.Number_Functions is

   -------------------
   -- To_Long_Float --
   -------------------

   function To_Long_Float (numb : OCINumber) return Long_Float is
     use type uword;
     Result : aliased Long_Float;
     rc : sword := OCINumberToReal(Thread.Error,
                numb,
                Result'Size/System.Storage_Unit,
                Result'Access); 
   begin
      Check_Error(rc);
      return Result;
   end To_Long_Float;

   ---------------
   -- To_Number --
   ---------------

   function To_Number (From : Long_Float) return OCINumber is
     use type uword;
     Numb : aliased Long_Float := From;
     Result : aliased OCINumber;
     rc : sword := OCINumberFromReal(Thread.Error,
                numb'Access,
                Numb'Size/System.Storage_Unit,
                Result'Access); 
   begin
      Check_Error(rc);
      return Result;
   end To_Number;

   function To_String(From : OCINumber; Format : String) return String
         is
      use type Ub4;   
      Buff : aliased Text := (0..63 => c.nul);
      Len : aliased Ub4 := Buff'Length;
      Rc : Sword := OCINumberToText (
         Err => Thread.Error,
         Date => From,
         Fmt => C.To_C(Format),
         Fmt_Length => Format'Length,
         Nls_Name => 0,
         Nls_Length => 0,
         Buf_Size => Len'access,
         Buf => CStr.To_Chars_Ptr(Buff'Unchecked_Access));
   begin
      Check_Error(Rc);
      return C.To_Ada(Buff(0..C.Size_T(Len-1)),False);
   end To_String;

end OCI.Thick.Number_Functions;