Removing throw specifiers from internal Printer hierarchy. (#1393)
[cvc5.git] / src / printer / printer.h
1 /********************* */
2 /*! \file printer.h
3 ** \verbatim
4 ** Top contributors (to current version):
5 ** Morgan Deters, Tim King, Paul Meng
6 ** This file is part of the CVC4 project.
7 ** Copyright (c) 2009-2017 by the authors listed in the file AUTHORS
8 ** in the top-level source directory) and their institutional affiliations.
9 ** All rights reserved. See the file COPYING in the top-level source
10 ** directory for licensing information.\endverbatim
11 **
12 ** \brief Base of the pretty-printer interface
13 **
14 ** Base of the pretty-printer interface.
15 **/
16
17 #include "cvc4_private.h"
18
19 #ifndef __CVC4__PRINTER__PRINTER_H
20 #define __CVC4__PRINTER__PRINTER_H
21
22 #include <map>
23 #include <string>
24
25 #include "expr/node.h"
26 #include "options/language.h"
27 #include "smt/command.h"
28 #include "smt/model.h"
29 #include "util/sexpr.h"
30
31 namespace CVC4 {
32
33 class Printer {
34 /** Printers for each OutputLanguage */
35 static Printer* d_printers[language::output::LANG_MAX];
36
37 /** Make a Printer for a given OutputLanguage */
38 static Printer* makePrinter(OutputLanguage lang);
39
40 // disallow copy, assignment
41 Printer(const Printer&) CVC4_UNDEFINED;
42 Printer& operator=(const Printer&) CVC4_UNDEFINED;
43
44 protected:
45 // derived classes can construct, but no one else.
46 Printer() {}
47 virtual ~Printer() {}
48
49 /** write model response to command */
50 virtual void toStream(std::ostream& out,
51 const Model& m,
52 const Command* c) const = 0;
53
54 /** write model response to command using another language printer */
55 void toStreamUsing(OutputLanguage lang,
56 std::ostream& out,
57 const Model& m,
58 const Command* c) const
59 {
60 getPrinter(lang)->toStream(out, m, c);
61 }
62
63 public:
64 /** Get the Printer for a given OutputLanguage */
65 static Printer* getPrinter(OutputLanguage lang);
66
67 /** Write a Node out to a stream with this Printer. */
68 virtual void toStream(std::ostream& out,
69 TNode n,
70 int toDepth,
71 bool types,
72 size_t dag) const = 0;
73
74 /** Write a Command out to a stream with this Printer. */
75 virtual void toStream(std::ostream& out,
76 const Command* c,
77 int toDepth,
78 bool types,
79 size_t dag) const = 0;
80
81 /** Write a CommandStatus out to a stream with this Printer. */
82 virtual void toStream(std::ostream& out, const CommandStatus* s) const = 0;
83
84 /** Write a Model out to a stream with this Printer. */
85 virtual void toStream(std::ostream& out, const Model& m) const;
86
87 /** Write an UnsatCore out to a stream with this Printer. */
88 virtual void toStream(std::ostream& out, const UnsatCore& core) const;
89
90 /**
91 * Write the term that sygus datatype term n
92 * encodes to a stream with this Printer.
93 * For example, consider the datatype term
94 * (C_plus (C_minus C_x C_0) C_y)
95 * where C_plus, C_minus, C_x, C_0, C_y are constructors
96 * whose sygus operators are PLUS, MINUS, x, 0, y.
97 * In this case, this method is equivalent to printing
98 * the integer term:
99 * (PLUS (MINUS x 0) y)
100 * This method may make calls to sygus printing callback
101 * methods stored in sygus datatype constructors.
102 */
103 virtual void toStreamSygus(std::ostream& out, TNode n) const;
104
105 };/* class Printer */
106
107 }/* CVC4 namespace */
108
109 #endif /* __CVC4__PRINTER__PRINTER_H */