]> www.ginac.de Git - ginac.git/blob - ginac/print.h
- added an optional algorithm-switch to lsolve().
[ginac.git] / ginac / print.h
1 /** @file print.h
2  *
3  *  Helper classes for expression output. */
4
5 /*
6  *  GiNaC Copyright (C) 1999-2001 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 <iostream>
27 #include <string>
28
29 namespace GiNaC {
30
31 /** Context for default (ginsh-parsable) output. */
32 class print_context
33 {
34 public:
35         print_context(std::ostream & os = std::cout) : s(os) {}
36         std::ostream & s; /**< stream to output to */
37
38         // dummy virtual function to make the class polymorphic
39         virtual void dummy(void) {}
40 };
41
42 /** Context for latex-parsable output. */
43 class print_latex : public print_context
44 {
45 public:
46         print_latex(std::ostream & os = std::cout)
47           : print_context(os) {}
48 };
49
50 /** Context for tree-like output for debugging. */
51 class print_tree : public print_context
52 {
53 public:
54         print_tree(std::ostream & os = std::cout, unsigned d = 4)
55           : print_context(os), delta_indent(d) {}
56         unsigned delta_indent; /**< size of indentation step */
57 };
58
59 /** Base context for C source output. */
60 class print_csrc : public print_context
61 {
62 public:
63         print_csrc(std::ostream & os = std::cout)
64           : print_context(os) {}
65 };
66
67 /** Context for C source output using float numbers. */
68 class print_csrc_float : public print_csrc
69 {
70 public:
71         print_csrc_float(std::ostream & os = std::cout)
72           : print_csrc(os) {}
73 };
74
75 /** Context for C source output using double numbers. */
76 class print_csrc_double : public print_csrc
77 {
78 public:
79         print_csrc_double(std::ostream & os = std::cout)
80           : print_csrc(os) {}
81 };
82
83 /** Context for C source output using CLN numbers. */
84 class print_csrc_cl_N : public print_csrc
85 {
86 public:
87         print_csrc_cl_N(std::ostream & os = std::cout)
88           : print_csrc(os) {}
89 };
90
91 /** Check if obj is a T, including base classes. */
92 template <class T>
93 inline bool is_a(const print_context & obj)
94 { return dynamic_cast<const T *>(&obj)!=0; }
95
96 } // namespace GiNaC
97
98 #endif // ndef __GINAC_BASIC_H__