| 1 | //
 | 
|---|
| 2 | // formio.h
 | 
|---|
| 3 | //
 | 
|---|
| 4 | // Copyright (C) 1996 Limit Point Systems, Inc.
 | 
|---|
| 5 | //
 | 
|---|
| 6 | // Author: Curtis Janssen <cljanss@limitpt.com>
 | 
|---|
| 7 | // Maintainer: LPS
 | 
|---|
| 8 | //
 | 
|---|
| 9 | // This file is part of the SC Toolkit.
 | 
|---|
| 10 | //
 | 
|---|
| 11 | // The SC Toolkit is free software; you can redistribute it and/or modify
 | 
|---|
| 12 | // it under the terms of the GNU Library General Public License as published by
 | 
|---|
| 13 | // the Free Software Foundation; either version 2, or (at your option)
 | 
|---|
| 14 | // any later version.
 | 
|---|
| 15 | //
 | 
|---|
| 16 | // The SC Toolkit is distributed in the hope that it will be useful,
 | 
|---|
| 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
|---|
| 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
|---|
| 19 | // GNU Library General Public License for more details.
 | 
|---|
| 20 | //
 | 
|---|
| 21 | // You should have received a copy of the GNU Library General Public License
 | 
|---|
| 22 | // along with the SC Toolkit; see the file COPYING.LIB.  If not, write to
 | 
|---|
| 23 | // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 | 
|---|
| 24 | //
 | 
|---|
| 25 | // The U.S. Government is granted a limited license as per AL 91-7.
 | 
|---|
| 26 | //
 | 
|---|
| 27 | 
 | 
|---|
| 28 | #ifndef _util_misc_formio_h
 | 
|---|
| 29 | #define _util_misc_formio_h
 | 
|---|
| 30 | 
 | 
|---|
| 31 | #include <iostream>
 | 
|---|
| 32 | #include <fstream>
 | 
|---|
| 33 | 
 | 
|---|
| 34 | namespace sc {
 | 
|---|
| 35 | 
 | 
|---|
| 36 | /** This utility class is used to print only on node 0 and to
 | 
|---|
| 37 |     provide attractive indentation of output. */
 | 
|---|
| 38 | class SCFormIO {
 | 
|---|
| 39 |   private:
 | 
|---|
| 40 |     static char *default_basename_;
 | 
|---|
| 41 |     static int  ready_;
 | 
|---|
| 42 |     static int  xalloc_inited_;
 | 
|---|
| 43 |     static long nindent_;
 | 
|---|
| 44 |     static long indent_size_;
 | 
|---|
| 45 |     static long skip_indent_;
 | 
|---|
| 46 |     static long verbose_;
 | 
|---|
| 47 |     static long initialized_;
 | 
|---|
| 48 |     static int node_to_print_;
 | 
|---|
| 49 |     static int debug_;
 | 
|---|
| 50 |     static int parallel_;
 | 
|---|
| 51 |     static int me_;
 | 
|---|
| 52 |     static void init();
 | 
|---|
| 53 |   public:
 | 
|---|
| 54 |     static std::ios& indent(std::ios&o);
 | 
|---|
| 55 |     static std::ios& decindent(std::ios&o);
 | 
|---|
| 56 |     static std::ios& incindent(std::ios&o);
 | 
|---|
| 57 |     static std::ios& skipnextindent(std::ios&o);
 | 
|---|
| 58 | 
 | 
|---|
| 59 |     static void setverbose(std::ios&o, long v);
 | 
|---|
| 60 |     static long getverbose(std::ios&o);
 | 
|---|
| 61 |     static void setindent(std::ios&o, long column);
 | 
|---|
| 62 |     static long getindent(std::ios&o);
 | 
|---|
| 63 |     static int  set_printnode(int);
 | 
|---|
| 64 |     static int  get_printnode() { return node_to_print_; }
 | 
|---|
| 65 |     static void set_debug(int);
 | 
|---|
| 66 |     static int  get_debug() { return debug_; }
 | 
|---|
| 67 |     static void init_mp(int me);
 | 
|---|
| 68 |     static int  get_node() { return me_; }
 | 
|---|
| 69 | 
 | 
|---|
| 70 |     static void set_default_basename(const char *);
 | 
|---|
| 71 |     static const char *default_basename();
 | 
|---|
| 72 |     static char *fileext_to_filename(const char *extension);
 | 
|---|
| 73 | 
 | 
|---|
| 74 |     static void init_ostream(std::ostream &);
 | 
|---|
| 75 | 
 | 
|---|
| 76 |     static std::ostream& license(std::ostream&);
 | 
|---|
| 77 |     static std::ostream& warranty(std::ostream&);
 | 
|---|
| 78 |     static std::ostream& copyright(std::ostream&);
 | 
|---|
| 79 | };
 | 
|---|
| 80 | 
 | 
|---|
| 81 | std::ios& indent(std::ios&);
 | 
|---|
| 82 | 
 | 
|---|
| 83 | std::ios& decindent(std::ios&);
 | 
|---|
| 84 | 
 | 
|---|
| 85 | std::ios& incindent(std::ios&);
 | 
|---|
| 86 | 
 | 
|---|
| 87 | std::ios& skipnextindent(std::ios&);
 | 
|---|
| 88 | 
 | 
|---|
| 89 | // ///////////////////////////////////////////////////////////////////////////
 | 
|---|
| 90 | 
 | 
|---|
| 91 | class scprintf;
 | 
|---|
| 92 | std::ostream& operator<<(std::ostream&, const scprintf&);
 | 
|---|
| 93 | 
 | 
|---|
| 94 | /** This class allows <tt>printf</tt> like output to put sent
 | 
|---|
| 95 |     to an <tt>ostream</tt>. */
 | 
|---|
| 96 | class scprintf {
 | 
|---|
| 97 |   private:
 | 
|---|
| 98 |     char str[1024];
 | 
|---|
| 99 | 
 | 
|---|
| 100 |   public:
 | 
|---|
| 101 |     scprintf(const char*,...);
 | 
|---|
| 102 |     friend std::ostream& sc::operator<<(std::ostream&, const scprintf&);
 | 
|---|
| 103 | };
 | 
|---|
| 104 | 
 | 
|---|
| 105 | }
 | 
|---|
| 106 | 
 | 
|---|
| 107 | #endif
 | 
|---|
| 108 | 
 | 
|---|
| 109 | // Local Variables:
 | 
|---|
| 110 | // mode: c++
 | 
|---|
| 111 | // c-file-style: "CLJ"
 | 
|---|
| 112 | // End:
 | 
|---|