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


class FBINSTR < $FSTRING{OCTET}, $IS_EQ, $STR

class FBINSTR < $FSTRING{OCTET}, $IS_EQ, $STR is -- This class provides a fast mutable version of an octet string. The -- buffers provide for efficient construction of binary strings by repeated -- concatenation using amortized doubling. -- Version 1.0 Jan 97. Copyright K Hopper, U of Waikato -- Development History -- ------------------- -- Date Who By Detail -- ---- ------ ------ -- 1 Dec 96 kh Original built round CHAR -- 3 Jan 97 kh Changed to OCTET from CHAR -- 10 Jan 97 kh Used FSTRING include. include FSTRING{OCTET,BINSTR} ; include FSTRING_INCL{OCTET} loc -> loc, index_of ->, oct_acopy -> oct_acopy ; private const Min_Size : CARD := 16 ; -- 128 bits! build( cursor : BIN_CURSOR ) : SAME pre ~void(cursor) post true is -- This routine creates a new object using underlying FLIST features. me : SAME := new(cursor.remaining) ; me.acopy(cursor.get_remainder) ; me.loc := me.size ; return me end ; create : SAME pre true post ~void(result) and (result.asize = Min_Size) is -- This creation routine returns a new buffer of an initial nominal size -- of MIN_SIZE. return new(Min_Size) end ; create( sz : CARD ) : SAME pre true post ~void(result) and (result.asize = sz) is -- This creation routine returns a new buffer of the given size. return new(sz) end ; create( bstr : BINSTR ) : SAME pre true post (void(bstr) and (result.asize = 0)) or ((result.size = bstr.size) and (result.loc = bstr.size)) is -- This routine creates a new object using underlying FLIST features. me : SAME := new(bstr.size) ; me.acopy(bstr) ; me.loc := bstr.size ; return me end ; nil : SAME is -- This routine returns a new nil (empty but not void) string. return create end ; binstr : BINSTR pre ~void(self) post (self.size = result.size) is -- This routine returns a binary string copy of self return BINSTR::create(self.array) end ; text_str( lib : LIBCHARS ) : STR pre ~void(lib) and (size > 0) post (result.size = (3 * size - 1)) is -- This routine returns an implementation-dependent default textual -- representation of the contents of self. This implementation provides a -- sequence of hexadecimal octet representations. res : STR := STR::create ; loop res := res + lib.Space.str.separate!(elt!.hex_str(lib)) end ; return res end ; text_str : STR pre size > 0 post result.size = (3 * size - 1) is -- This routine returns an implementation-dependent default textual -- representation of self. return str(LIBCHARS::default) end ; str( lib : LIBCHARS ) : STR pre ~void(self) and ~void(lib) and (asize % lib.my_size = 0) post (result.size * lib.my_size = loc) is -- This routine is a synonym for the following routine to conform -- to the signature of $STR. return binstr.str(lib) end ; str : STR pre ~void(self) post (result.size * LIBCHARS::default.my_size = loc) is -- This routine returns the binary string as though it were text in the -- current repertoire and encoding (which need not be known here!)! return binstr.str(LIBCHARS::default) end ; end ; -- FBINSTR