TABLE OF CONTENTS


Cashe/Currency_Handling [ Packages ]

[ Top ] [ Cashe ] [ Packages ]

DESCRIPTION

    This package provides methods of defining custom currency and storing
    currencies.

SOURCE

package Cashe.Currency_Handling is

Currency_Handling/Currency_Handling.Currency_Type [ Types ]

[ Top ] [ Currency_Handling ] [ Types ]

DESCRIPTION

    For Currency_Data variant record.

SOURCE

   type Currency_Type is (Type_Custom_Currency, Type_ISO_Currency);

SEE ALSO

    Currency_Handling/Currency_Handling.Currency_Data

Currency_Handling/Currency_Handling.Custom_Currency [ Classes ]

[ Top ] [ Currency_Handling ] [ Classes ]

DESCRIPTION

    Allows for defining and storing a custom currency.  Member functions
    can be used to retrieve information such as its code, minor units,
    and symbols.  Can be initialized with the Create function.

SOURCE

   type Custom_Currency is tagged private;

USAGE

   --    with Cashe.Currency_Handling; use Cashe.Currency_Handling;
   --    King : Custom_Currency := Create (Code => "KNG",
   --                                      Minor_Unit => 2,
   --                                      Name => "King Currency",
   --                                      Symbol => "K");

METHODS

  * Currency_Handling.Custom_Currency/Set_Code
  * Currency_Handling.Custom_Currency/Set_Name
  * Currency_Handling.Custom_Currency/Set_Symbol
  * Currency_Handling.Custom_Currency/Set_Unit
  * Currency_Handling.Custom_Currency/Code
  * Currency_Handling.Custom_Currency/Name
  * Currency_Handling.Custom_Currency/Symbol
  * Currency_Handling.Custom_Currency/Unit

Currency_Handling.Custom_Currency/Code [ Methods ]

[ Top ] [ Currency_Handling.Custom_Currency ] [ Methods ]

SOURCE

   function  Code   (This : Custom_Currency) return Wide_Wide_String;

EXAMPLE

   --    Ada.Text_Wide_Wide_IO.Put_Line (My_Currency.Code);

FUNCTION

    Retrieves the code of the custom currency.

RETURN VALUE

    Wide_Wide_String - Code belonging to currency.

Currency_Handling.Custom_Currency/Name [ Methods ]

[ Top ] [ Currency_Handling.Custom_Currency ] [ Methods ]

SOURCE

   function  Name   (This : Custom_Currency) return Wide_Wide_String;

EXAMPLE

   --    Ada.Text_Wide_Wide_IO.Put_Line (My_Currency.Name);

FUNCTION

    Retrieves the name of the custom currency.

RETURN VALUE

    Wide_Wide_String - name belonging to currency.

Currency_Handling.Custom_Currency/Set_Code [ Methods ]

[ Top ] [ Currency_Handling.Custom_Currency ] [ Methods ]

SOURCE

   procedure Set_Code
      (This : in out Custom_Currency;
       --  The custom currency
       Item : Wide_Wide_String
       --  New code for the custom currency
      );

PARAMETERS

    Item - New code for the custom currency as wide_wide_string

EXAMPLE

   --    with Cashe.Currency_Handling; use Cashe.Currency_Handling;
   --    declare
   --       My_Cur : Custom_Currency;
   --    begin
   --       My_Cur.Set_Code ("CUR");
   --    end;

FUNCTION

    [Re]define the code associated with the currency.

Currency_Handling.Custom_Currency/Set_Name [ Methods ]

[ Top ] [ Currency_Handling.Custom_Currency ] [ Methods ]

SOURCE

   procedure Set_Name
      (This : in out Custom_Currency;
       --   The custom currency.
       Item : Wide_Wide_String
       --  New name
      );

PARAMETERS

    Item - New name as wide_wide_string

EXAMPLE

   --    with Cashe.Currency_Handling; use Cashe.Currency_Handling;
   --    declare
   --       My_Cur : Custom_Currency;
   --    begin
   --       My_Cur.Set_Name ("Custom Currency");
   --    end;

FUNCTION

    [Re]define the name of the custom currency.

Currency_Handling.Custom_Currency/Set_Symbol [ Methods ]

[ Top ] [ Currency_Handling.Custom_Currency ] [ Methods ]

SOURCE

   procedure Set_Symbol
      (This : in out Custom_Currency;
       --   The custom currency.
       Item : Wide_Wide_String
       --  New symbol
      );

PARAMETERS

    Item - New symbol as wide_wide_string

EXAMPLE

   --    with Cashe.Currency_Handling; use Cashe.Currency_Handling;
   --    declare
   --       My_Cur : Custom_Currency;
   --    begin
   --       My_Cur.Set_Symbol ("$");
   --    end;

FUNCTION

    [Re]define the symbol of the custom currency.

Currency_Handling.Custom_Currency/Set_Unit [ Methods ]

[ Top ] [ Currency_Handling.Custom_Currency ] [ Methods ]

SOURCE

   procedure Set_Unit
      (This : in out Custom_Currency;
       --  The custom currency.
       Item : Natural
       --  New minor
      );

PARAMETERS

    Item - New symbol unit as Natural

EXAMPLE

   --    with Cashe.Currency_Handling; use Cashe.Currency_Handling;
   --    declare
   --       My_Cur : Custom_Currency;
   --    begin
   --       My_Cur.Set_Unit (2);
   --    end;

FUNCTION

    [Re]define the minor unit of the custom currency.

Currency_Handling.Custom_Currency/Symbol [ Methods ]

[ Top ] [ Currency_Handling.Custom_Currency ] [ Methods ]

SOURCE

   function  Symbol (This : Custom_Currency) return Wide_Wide_String;

EXAMPLE

   --    Ada.Text_Wide_Wide_IO.Put_Line (My_Currency.Symbol);

FUNCTION

    Retrieves the symbol of the custom currency.

RETURN VALUE

    Wide_Wide_String - symbol belonging to currency.

Currency_Handling.Custom_Currency/Unit [ Methods ]

[ Top ] [ Currency_Handling.Custom_Currency ] [ Methods ]

SOURCE

   function  Unit   (This : Custom_Currency) return Natural;

EXAMPLE

   --    My_Unit : Natural := My_Currency.Unit;

FUNCTION

    Retrieves the code of the custom currency.

RETURN VALUE

    Natural - Minor Unit belonging to currency.

Currency_Handling/Currency_Handling.Currency_Data [ Records ]

[ Top ] [ Currency_Handling ] [ Records ]

DESCRIPTION

     A "holder" for both custom or non-custom currency, if needed.
     Which kind of currency can be verified by accessing the object's
     "Which_Currency_Data" later on.

SOURCE

   type Currency_Data
      (Which_Currency_Type : Currency_Type := Type_ISO_Currency)
   is record
      case Which_Currency_Type is
         when Type_Custom_Currency =>
            --  The custom currency that will be stored in money/exchange.
            Custom_Code : Custom_Currency;
         when Type_ISO_Currency =>
            --  The ISO currency that will be stored in the money/exchange.
            ISO_Code : ISO.Currencies.Currency;
      end case;
   end record;

PARAMETERS

    Which_Currency_Type: Which kind of currency?

EXAMPLE

   --    declare
   --       My_Holder : Currency_Data :=
   --          (Which_Currency_Type => Type_ISO_Currency,
   --           ISO_Code            => ISO.Currencies.From_Code ("USD"));
   --    begin
   --       case My_Holder.Which_Currency_Type is
   --          when Type_Custom_Currency =>
   --             Put_Line ("Currency is " & My_Holder.Custom_Code.Name);
   --          when Type_ISO_Currency =>
   --             Put_Line ("Currency is " & My_Holder.ISO_Code.Name);
   --             Put_Line ("And Numeric is " & My_Holder.ISO_Code.Numeric);
   --       end case;
   --    end;

SEE ALSO

    Currency_Handling/Currency_Handling.Currency_Type

Currency_Handling/Currency_Handling.Create [ Subprograms ]

[ Top ] [ Currency_Handling ] [ Subprograms ]

SOURCE

   function Create
      (Code        : Wide_Wide_String;
       --  Currency's code
       Minor_Unit  : Natural := 0;
       --  Currency's minor unit. Optional.
       Name        : Wide_Wide_String := "";
       --  Currency's name. Optional.
       Symbol      : Wide_Wide_String := ""
       --  Currency's symbol. Optional.
      )
   return Custom_Currency with pre => Minor_Unit <= Max_Precision;

PARAMETERS

    Code - A code as a string, such as "EUR" or "USD".
    Minor_Unit - Currency's minor unit. Optional.
    Name - Currency's name. Optional.
    Symbol - Currency's symbol. Optional.

EXAMPLE

   --    King : Custom_Currency := Create (Code => "KNG",
   --                                      Minor_Unit => 2,
   --                                      Name => "King Currency",
   --                                      Symbol => "K");

FUNCTION

    Create a custom currency according to parameters. Minor unit may not
    be greater than maximum precision supported by library.

RETURN VALUE

    Currency_Handling/Currency_Handling.Custom_Currency