]> www.ginac.de Git - ginac.git/blob - ginac/print.h
tinfo_key wasn't set correctly in certain constructors
[ginac.git] / ginac / print.h
1 /** @file print.h
2  *
3  *  Definition of helper classes for expression output. */
4
5 /*
6  *  GiNaC Copyright (C) 1999-2003 Johannes Gutenberg University Mainz, Germany
7  *
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2 of the License, or
11  *  (at your option) any later version.
12  *
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with this program; if not, write to the Free Software
20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22
23 #ifndef __GINAC_PRINT_H__
24 #define __GINAC_PRINT_H__
25
26 #include <iosfwd>
27 #include <string>
28
29 namespace GiNaC {
30
31
32 /*
33  *  The following classes remain publicly visible for compatibility
34  *  reasons only. New code should use the iostream manipulators defined
35  *  in operators.h instead.
36  */
37
38
39 /** Flags to control the behavior of a print_context. */
40 class print_options {
41 public:
42         enum {
43                 print_index_dimensions = 0x0001 ///< print the dimensions of indices
44         };
45 };
46
47
48 /** Context for default (ginsh-parsable) output. */
49 class print_context
50 {
51 public:
52         print_context();
53         print_context(std::ostream &, unsigned options = 0);
54         virtual ~print_context() {}
55         virtual print_context * duplicate() const {return new print_context(*this);}
56
57         std::ostream & s; /**< stream to output to */
58         unsigned options; /**< option flags */
59 };
60
61 /** Context for latex-parsable output. */
62 class print_latex : public print_context
63 {
64 public:
65         print_latex();
66         print_latex(std::ostream &, unsigned options = 0);
67         print_context * duplicate() const {return new print_latex(*this);}
68 };
69
70 /** Context for python pretty-print output. */
71 class print_python : public print_context
72 {
73 public:
74         print_python();
75         print_python(std::ostream &, unsigned options = 0);
76         print_context * duplicate() const {return new print_python(*this);}
77 };
78
79 /** Context for python-parsable output. */
80 class print_python_repr : public print_context
81 {
82 public:
83         print_python_repr();
84         print_python_repr(std::ostream &, unsigned options = 0);
85         print_context * duplicate() const {return new print_python_repr(*this);}
86 };
87
88 /** Context for tree-like output for debugging. */
89 class print_tree : public print_context
90 {
91 public:
92         print_tree(unsigned d = 4);
93         print_tree(std::ostream &, unsigned options = 0, unsigned d = 4);
94         print_context * duplicate() const {return new print_tree(*this);}
95
96         const unsigned delta_indent; /**< size of indentation step */
97 };
98
99 /** Base context for C source output. */
100 class print_csrc : public print_context
101 {
102 public:
103         print_csrc();
104         print_csrc(std::ostream &, unsigned options = 0);
105         print_context * duplicate() const {return new print_csrc(*this);}
106 };
107
108 /** Context for C source output using float precision. */
109 class print_csrc_float : public print_csrc
110 {
111 public:
112         print_csrc_float();
113         print_csrc_float(std::ostream &, unsigned options = 0);
114         print_context * duplicate() const {return new print_csrc_float(*this);}
115 };
116
117 /** Context for C source output using double precision. */
118 class print_csrc_double : public print_csrc
119 {
120 public:
121         print_csrc_double();
122         print_csrc_double(std::ostream &, unsigned options = 0);
123         print_context * duplicate() const {return new print_csrc_double(*this);}
124 };
125
126 /** Context for C source output using CLN numbers. */
127 class print_csrc_cl_N : public print_csrc
128 {
129 public:
130         print_csrc_cl_N();
131         print_csrc_cl_N(std::ostream &, unsigned options = 0);
132         print_context * duplicate() const {return new print_csrc_cl_N(*this);}
133 };
134
135 /** Check if obj is a T, including base classes. */
136 template <class T>
137 inline bool is_a(const print_context & obj)
138 { return dynamic_cast<const T *>(&obj)!=0; }
139
140 } // namespace GiNaC
141
142 #endif // ndef __GINAC_BASIC_H__