------------------------------------------------------------------------------ -- XML/Ada - An XML suite for Ada95 -- -- -- -- Copyright (C) 2005-2012, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify it -- -- under terms of the GNU General Public License as published by the Free -- -- Software Foundation; either version 3, or (at your option) any later -- -- version. This library is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- . -- -- -- ------------------------------------------------------------------------------ -- This package provides the basic types to define the facets for an XSD type pragma ada_05; with Sax.Symbols; with Sax.Utils; with Unicode.CES; package Schema.Decimal is --------------------------------- -- Arbitrary_Precision_Numbers -- --------------------------------- -- This type provides some minimal handling for arbitrary precision -- numbers as described by the "decimal" and "integer" types. -- This is *not* an arbitrary-precision library, which is not needed in the -- context of XML type arbitrary_precision_number is private; Undefined_Number : constant arbitrary_precision_number; function Image (Number : arbitrary_precision_number) return Unicode.CES.byte_sequence; -- Return a displayable version of Number procedure Value (Symbols : Sax.Utils.symbol_table; Ch : Unicode.CES.byte_sequence; Val : out arbitrary_precision_number; Error : out Sax.Symbols.symbol); -- Convert Ch to a number. -- Raises a Validation_Error if this is not a valid number function Value (Val : Sax.Symbols.symbol) return arbitrary_precision_number; -- Assumes [Val] is a valid Arbitrary_Precision_Number. procedure Value_No_Exponent (Symbols : Sax.Utils.symbol_table; Ch : Unicode.CES.byte_sequence; Val : out arbitrary_precision_number; Error : out Sax.Symbols.symbol); -- Same as value, but does not allow a "E" part function "<" (Num1, Num2 : arbitrary_precision_number) return Boolean; function "<=" (Num1, Num2 : arbitrary_precision_number) return Boolean; function "=" (Num1, Num2 : arbitrary_precision_number) return Boolean; function ">=" (Num1, Num2 : arbitrary_precision_number) return Boolean; function ">" (Num1, Num2 : arbitrary_precision_number) return Boolean; -- Compare two numbers function Check_Digits (Symbols : Sax.Utils.symbol_table; Num : arbitrary_precision_number; Fraction_Digits, Total_Digits : Integer := -1) return Sax.Symbols.symbol; -- Check whether the two facets Fraction_Digits and Total_Digits match. -- If any of the two values is negative, no check is done for it. -- Returns an error message or [No_Symbol]. --------------- -- XML_Float -- --------------- -- This type represents a floating point value (float or double in XSD), -- including infinity and NaN type xml_float is private; Unknown_Float : constant xml_float; function "<=" (F1, F2 : xml_float) return Boolean; function "<" (F1, F2 : xml_float) return Boolean; function ">=" (F1, F2 : xml_float) return Boolean; function ">" (F1, F2 : xml_float) return Boolean; -- Compare two numbers function Image (Value : xml_float) return String; -- Return a displayable version of Number function Value (Str : String) return xml_float; -- Return the float stored in Str (including +INF, -INF) private type arbitrary_precision_number is record Value : Sax.Symbols.symbol; end record; Undefined_Number : constant arbitrary_precision_number := (Value => Sax.Symbols.No_Symbol); type xml_float_kind is (plus_infinity, minus_infinity, nan, standard_float); type xml_float (Kind : xml_float_kind := nan) is record case Kind is when standard_float => Mantiss : Long_Long_Float; Exp : Integer; when others => null; end case; end record; Unknown_Float : constant xml_float := (Kind => nan); end Schema.Decimal;