Index

Package: Values

Description

package Values is
Copyright (c) 2012 Kevin Wellwood All rights reserved. This source code is distributed under the Modified BSD License. For terms and conditions, see license.txt.

Classes

Value (abstract)

type Value is abstract new Object with private;

Ancestors:

Immediate Children:

Values.Val_Bool
Values.Val_Int
Values.Val_String

Primitive operations:

Construct
Object_Input
Object_Read (overriding Objects.Object_Read)
Object_Write (overriding Objects.Object_Write)
Objects.Adjust (Inherited)
Objects.Construct (Inherited)
Objects.Delete (Inherited)
Objects.To_String (Inherited)
A Value represents a generic value of type boolean, integer or string. The value can be converted to other types in certain cases. Values can also be copied and written to a stream.

Types

Data_Type

type Data_Type is (V_NULL, V_BOOLEAN, V_NUMERIC, V_STRING);
Defines the base data types supported by Values.

A_Value

type A_Value is access all Value'Class;

Constants & Global variables

VALUE_NOT_FOUND

VALUE_NOT_FOUND,
    INVALID_CONVERSION : exception;

INVALID_CONVERSION

INVALID_CONVERSION : exception;

Subprograms & Entries

Create_Value

function Create_Value
( val: Boolean ) return A_Value;
Creates a new boolean Value.

Create_Value

function Create_Value
( val: Integer ) return A_Value;
Creates a new integer Value.

Create_Value

function Create_Value
( val: String ) return A_Value;
Creates a new string Value.

As_Boolean

function As_Boolean
( this: access Value ) return Boolean;
Returns the Value as a boolean. Raises INVALID_CONVERSION if the value can't be converted to a boolean.

As_Integer

function As_Integer
( this: access Value ) return Integer;
Returns the Value as a boolean. Raises INVALID_CONVERSION if the value can't be converted to an integer.

As_String

function As_String
( this: access Value ) return String;
Returns the Value as a boolean. Raises INVALID_CONVERSION if the value can't be converted to a string.

Get_Type

function Get_Type
( this: access Value'Class ) return Data_Type;
Returns the base data type the Value contains. A null Value reference will return V_NULL.

Object_Input (abstract)

function Object_Input
( stream: access Root_Stream_Type'Class ) return Value is abstract;

Compare (abstract)

function Compare
( this: access Value;
that: A_Value ) return Integer is abstract;
Compares 'this' to 'that'. Returns 0 for equal, < 0 if 'this' is less than 'that', and > 0 if 'this' is greater than 'that'. If 'that' is a different data type then the result is undefined because they are not equal and not comparable.

Copy

function Copy
( src: A_Value ) return A_Value;
Returns a copy of 'src'.

Delete

procedure Delete
( this: in out A_Value );
Deletes the Value.

Img

function Img
( this: A_Value ) return String;
Returns the same as To_String but allows for a null pointer.