charstr.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>  <--------------


partial class CHAR_STR < $TEXT, $ANCHORED_FMT

partial class CHAR_STR < $TEXT, $ANCHORED_FMT is -- This partial class provides string conversion and formatting services -- for the class CHAR. -- Version 1.1 Feb 99. Copyright K Hopper, U of Waikato -- Development History -- ------------------- -- Date Who By Detail -- ---- ------ ------ -- 22 Sep 98 kh Original from revised CHAR class -- 2 Feb 99 kh Now conforms to $FMT{$ANCHORED_DESCR} build( loc_cursor : STR_CURSOR ) : SAME pre ~void(loc_cursor) and (loc_cursor.remaining >= 1) post true is -- This routine takes the first character from the indicated string -- and returns it. return create(CHAR_CODE::create(loc_cursor.get_item, loc_cursor.buffer.index_lib)) end ; str( lib : LIBCHARS ) : STR pre ~void(lib) post ~void(result) is -- This routine returns the character string formed from self as -- the single character contained in the given encoding converted to the -- current default encoding -- which is, of course, of the same form. return STR::create(lib) + self.char end ; str : STR pre true post ~void(result) is -- This routine returns the character string formed from self as -- the single character contained -- which is, of course, of the same form. return STR::create(LIBCHARS::default) + self.char end ; fmt( format : ANCHORED_DESCR, lib : LIBCHARS ) : STR pre ~void(self) and (format.width > 0) and ~void(lib) and (format.filler.lib = lib) post ~void(result) is -- This routine returns self in accordance with the formatting -- instructions given in format. Note that the library of characters is -- not used. It is retained for commonality of syntax. res : STR := STR::create(lib) ; loc_filler : STR := STR::create(format.filler.card,lib) ; if format.leading > 1 then res := res + loc_filler.repeat(format.leading - 1) end ; return res + self.char + loc_filler.repeat(format.trailing) end ; fmt( format : ANCHORED_DESCR ) : STR pre ~void(self) and (format.width > 0) post ~void(result) is -- This routine returns self in accordance with the formatting -- instructions given in format. return fmt(format,LIBCHARS::default) end ; end ; -- CHAR_STR