home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / shareware / dev / ppcsmalleiffel / lib_se / echo.e < prev    next >
Encoding:
Text File  |  1998-01-16  |  3.8 KB  |  169 lines

  1. --          This file is part of SmallEiffel The GNU Eiffel Compiler.
  2. --          Copyright (C) 1994-98 LORIA - UHP - CRIN - INRIA - FRANCE
  3. --            Dominique COLNET and Suzanne COLLIN - colnet@loria.fr 
  4. --                       http://www.loria.fr/SmallEiffel
  5. -- SmallEiffel is  free  software;  you can  redistribute it and/or modify it 
  6. -- under the terms of the GNU General Public License as published by the Free
  7. -- Software  Foundation;  either  version  2, or (at your option)  any  later 
  8. -- version. SmallEiffel is distributed in the hope that it will be useful,but
  9. -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  10. -- or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU General Public License 
  11. -- for  more  details.  You  should  have  received a copy of the GNU General 
  12. -- Public  License  along  with  SmallEiffel;  see the file COPYING.  If not,
  13. -- write to the  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  14. -- Boston, MA 02111-1307, USA.
  15. --
  16. class ECHO
  17.    -- **** CHATTER ?????? *****
  18.    -- 
  19.    -- Unique Global Object in charge of ECHOing some information
  20.    -- messages during compilation for example.
  21.    -- This object is used to implement the flag "-verbose".
  22.    -- 
  23.    --
  24.  
  25. inherit GLOBALS;
  26.  
  27. creation make
  28.  
  29. feature
  30.    
  31.    verbose: BOOLEAN;
  32.      -- Is `echo' verbose (default is false).
  33.  
  34. feature
  35.    
  36.    make is do end;
  37.  
  38.    set_verbose is
  39.       do
  40.      verbose := true;
  41.       end;
  42.  
  43. feature  -- To echo some additional information (echo is only done
  44.      -- when `verbose' is true).
  45.  
  46.    put_string(msg: STRING) is
  47.       do
  48.      if verbose then
  49.         std_output.put_string(msg);
  50.         std_output.flush;
  51.      end;
  52.       end;
  53.  
  54.    put_character(c: CHARACTER) is
  55.       do
  56.      if verbose then
  57.         std_output.put_character(c);
  58.         std_output.flush;
  59.      end;
  60.       end;
  61.  
  62.    put_new_line is
  63.       do
  64.      if verbose then
  65.         std_output.put_new_line;
  66.      end;
  67.       end;
  68.  
  69.    put_integer(i: INTEGER) is
  70.       do
  71.      if verbose then
  72.         std_output.put_integer(i);
  73.         std_output.flush;
  74.      end;
  75.       end;
  76.  
  77.    put_double_format(d: DOUBLE; f: INTEGER) is
  78.       do
  79.      if verbose then
  80.         std_output.put_double_format(d,f);
  81.         std_output.flush;
  82.      end;
  83.       end;
  84.  
  85.    file_removing(path: STRING) is
  86.          -- If `path' is an existing file, echo a message on `std_output'
  87.          -- while removing the file.
  88.          -- Otherwise, do nothing.
  89.       require
  90.          path /= Void
  91.       do
  92.      if file_exists(path) then
  93.         put_string("Removing %"");
  94.         put_string(path);
  95.         put_string("%"%N");
  96.         remove_file(path);
  97.      end;
  98.       ensure
  99.          not file_exists(path)
  100.       end;
  101.  
  102.    sfr_connect(sfr: STD_FILE_READ; path: STRING) is
  103.       require
  104.      not sfr.is_connected;
  105.      path /= Void
  106.       do
  107.      put_string("Try to read file %"");
  108.      put_string(path);
  109.      put_string("%".%N");
  110.      sfr.connect_to(path);
  111.       end;
  112.  
  113.    call_system(cmd: STRING) is 
  114.       require
  115.      cmd.count > 0
  116.       do
  117.      put_string("System call %"");
  118.      put_string(cmd);
  119.          put_string(fz_18);
  120.      system(cmd);
  121.       end;
  122.  
  123.    print_count(msg: STRING; count: INTEGER) is
  124.       require
  125.      count >= 0;
  126.       do
  127.      if verbose then
  128.         if count > 0 then
  129.            put_string("Total ");
  130.            put_string(msg);
  131.            if count > 1 then
  132.           put_character('s');
  133.            end;
  134.            put_string(": ");
  135.            put_integer(count);
  136.            put_string(fz_b6);
  137.         else
  138.            put_string("No ");
  139.            put_string(msg);
  140.            put_string(fz_b6);
  141.         end;
  142.      end;
  143.       end;
  144.  
  145. feature  -- To echo some warning or some problem (echo is done whathever 
  146.      -- the value of `verbose').
  147.  
  148.    w_put_string(msg: STRING) is
  149.       do
  150.      std_error.put_string(msg);
  151.      std_error.flush;
  152.       end;
  153.  
  154.    w_put_character(c: CHARACTER) is
  155.       do
  156.      std_error.put_character(c);
  157.      std_error.flush;
  158.       end;
  159.      
  160.    w_put_integer(i: INTEGER) is
  161.       do
  162.      std_error.put_integer(i);
  163.      std_error.flush;
  164.       end;
  165.  
  166. end -- ECHO
  167.  
  168.  
  169.