dtg.sa
Generated by gen_html_sa_files from ICSI. Contact gomes@icsi.berkeley.edu for details
-------------------------> GNU Sather - sourcefile <-------------------------
-- Copyright (C) 2000 by K Hopper, University of Waikato, New Zealand --
-- This file is part of the GNU Sather library. It is free software; you may --
-- redistribute and/or modify it under the terms of the GNU Library General --
-- Public License (LGPL) as published by the Free Software Foundation; --
-- either version 2 of the license, 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 MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See Doc/LGPL for more details. --
-- The license text is also available from: Free Software Foundation, Inc., --
-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --
--------------> Please email comments to <bug-sather@gnu.org> <--------------
immutable class WEEKDAYS < $ENUMS{WEEKDAYS}
immutable class WEEKDAYS < $ENUMS{WEEKDAYS} is
-- This is an enumeration class which is provided for indicating which
-- day of the week some date may be.
-- Version 1.2 Oct 98. Copyright K Hopper, U of Waikato
-- Development History
-- -------------------
-- Date Who By Detail
-- ---- ------ ------
-- 3 Jun 96 kh Original from std Sather distrib.
-- 8 Apr 97 kh Modified for INT to CARD
-- 29 Oct 98 kh Added pre/post conditions
include EXACT_ENUM{WEEKDAYS} ;
private const val_count : CARD := 14 ;
private const Short_Offset : CARD := val_count / 2 ;
private const Max_Val : CARD := Short_Offset ;
-- The next routines provide the enumeration itself.
Sunday : SAME is return enum(1) end ;
Monday : SAME is return enum(2) end ;
Tuesday : SAME is return enum(3) end ;
Wednesday : SAME is return enum(4) end ;
Thursday : SAME is return enum(5) end ;
Friday : SAME is return enum(6) end ;
Saturday : SAME is return enum(7) end ;
next : SAME
pre ~is_nil
post result.previous = self
is
-- This routine returns the cyclic successor of self as a weekday.
if self = Saturday then
return Sunday
else
return create(self.card + offset)
end
end ;
previous : SAME
pre ~is_nil
post ((self = Sunday) -- this here to avoid circularity with above!
and (result = Saturday))
or (result = create(self.card - offset))
is
-- This routine returns the cyclic predecessor of self as a weekday.
if self = Sunday then
return Saturday
else
return create(self.card - offset)
end
end ;
short_str(
lib : LIBCHARS
) : STR
pre ~is_nil
and ~void(lib)
post ~void(result)
is
-- This routine returns the culture-dependent text name of the
-- enumeration for external representation, abbreviated to a
-- culture-dependent number of letters using the given encoding and
-- repertoire.
check_names(lib) ;
return Names[card + Short_Offset - offset].str
end ;
short_str : STR
pre ~is_nil
post ~void(result)
is
-- This routine returns the culture-dependent text name of the
-- enumeration for external representation, abbreviated to a
-- culture-dependent number of letters using the default encoding and
-- repertoire.
return short_str(LIBCHARS::default)
end ;
end ; -- WEEKDAYS
immutable class DAY_SET < $ENUM_SET{DAY_SET,WEEKDAYS}
immutable class DAY_SET < $ENUM_SET{DAY_SET,WEEKDAYS} is
-- This implementation provides operations on sets of days of the week.
-- All the usual set operations are available. This implementation
-- defines two constant sets.
-- Version 1.2 Mar 00. Copyright K Hopper, U of Waikato
-- Development History
-- -------------------
-- Date Who By Detail
-- ---- ------ ------
-- 3 Jun 96 kh Original from std Sather distrib.
-- 8 Apr 97 kh Modified for INT to CARD
-- 24 Mar 00 kh Renaming from BITSET to ENUM_SET.
include ENUM_SET{DAY_SET,WEEKDAYS} ;
const workdays : SAME := empty + WEEKDAYS::Monday + WEEKDAYS::Tuesday +
WEEKDAYS::Wednesday + WEEKDAYS::Thursday +
WEEKDAYS::Friday ;
const weekend : SAME := empty + WEEKDAYS::Sunday + WEEKDAYS::Saturday ;
end ; -- DAY_SET
immutable class MONTHS < $ENUMS{MONTHS}
immutable class MONTHS < $ENUMS{MONTHS} is
-- This is an enumeration class which is provided for indicating which
-- month of the year is in some date.
-- Version 1.2 Oct 98. Copyright K Hopper, U of Waikato
-- Development History
-- -------------------
-- Date Who By Detail
-- ---- ------ ------
-- 3 Jun 96 kh Original from std Sather distrib.
-- 8 Apr 97 kh Modified for INT to CARD
-- 29 Oct 98 kh Added pre/post conditions
include EXACT_ENUM{MONTHS} ;
private const val_count : CARD := 24 ;
private const Short_Offset : CARD := val_count / 2 ;
private const Max_Val : CARD := Short_Offset ;
-- The next routines provide the enumeration itself.
January : SAME is return enum(1) end ;
February : SAME is return enum(2) end ;
March : SAME is return enum(3) end ;
April : SAME is return enum(4) end ;
May : SAME is return enum(5) end ;
June : SAME is return enum(6) end ;
July : SAME is return enum(7) end ;
August : SAME is return enum(8) end ;
September : SAME is return enum(9) end ;
October : SAME is return enum(10) end ;
November : SAME is return enum(11) end ;
December : SAME is return enum(12) end ;
next : SAME
pre ~is_nil
post result.previous = self
is
-- This routine returns the cyclic successor of self as a month.
if self = December then
return January
else
return create(self.card + offset)
end
end ;
previous : MONTHS
pre ~is_nil
post ((self = January) -- this here to avoid circularity with above!
and (result = December))
or (result = create(self.card - offset))
is
-- The cyclic predecessor month is returned.
if self = January then
return December
else
return create(self.card - offset)
end
end ;
short_str(
lib : LIBCHARS
) : STR
pre ~is_nil
and ~void(lib)
post ~void(result)
is
-- This routine returns the culture-dependent text name of the
-- enumeration for external representation, abbreviated to a
-- culture-dependent number of letters using the given encoding and
-- repertoire.
check_names(lib) ;
return Names[card + Short_Offset - offset].str
end ;
short_str : STR
pre ~is_nil
post ~void(result)
is
-- This routine returns the culture-dependent text name of the
-- enumeration for external representation, abbreviated to a
-- culture-dependent number of letters using the default encoding and
-- repertoire.
return short_str(LIBCHARS::default)
end ;
end ; -- MONTHS
immutable class MONTH_SET < $ENUM_SET{MONTH_SET,MONTHS}
immutable class MONTH_SET < $ENUM_SET{MONTH_SET,MONTHS} is
-- This class provides for the manipulation of sets of months. All
-- the usual set operations are available. This implementation provides
-- a number of useful constant sets.
-- Version 1.2 Mar 00. Copyright K Hopper, U of Waikato
-- Development History
-- ------------------
-- Date Who By Detail
-- ---- ------ ------
-- 3 Jun 96 kh Original from std Sather distrib.
-- 8 Apr 97 kh Modified for INT to CARD
-- 24 Mar 00 kh Renaming from BIT_SET to ENUM_TEST
include ENUM_SET{MONTH_SET,MONTHS} ;
const thirty_days : SAME := empty + MONTHS::April + MONTHS::June +
MONTHS::September + MONTHS::November ;
const thirty_one_days : SAME := empty + MONTHS::January + MONTHS::March +
MONTHS::May + MONTHS::July + MONTHS::August +
MONTHS::October + MONTHS::December ;
const spring : SAME := empty + MONTHS::September + MONTHS::October +
MONTHS::November ;
const summer : SAME := empty + MONTHS::December + MONTHS::January +
MONTHS::February ;
const autumn : SAME := empty + MONTHS::March + MONTHS::April +
MONTHS::May ;
const winter : SAME := empty + MONTHS::May + MONTHS::June + MONTHS::July +
MONTHS::August ;
end ; -- MONTH_SET