Cadabra
Computer algebra system for field theory problems
DisplayTerminal.hh
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "Props.hh"
5 #include "Storage.hh"
6 #include "DisplayBase.hh"
7 #include <ostream>
8 #include <map>
9 #include <string>
10 
11 typedef uint32_t kunichar;
12 
13 namespace cadabra {
14 
25 
26  class DisplayTerminal : public DisplayBase {
27  public:
28  DisplayTerminal(const Kernel&, const Ex&, bool use_unicode = true);
29 
30  protected:
32 
33  virtual void dispatch(std::ostream&, Ex::iterator) override;
34  virtual bool needs_brackets(Ex::iterator it) override;
35 
36  private:
37  void print_multiplier(std::ostream&, Ex::iterator, int mult=1);
40  void print_parent_rel(std::ostream&, str_node::parent_rel_t, bool first);
41  void print_children(std::ostream&, Ex::iterator, int skip=0);
42 
44 
50 
51  void print_productlike(std::ostream&, Ex::iterator, const std::string& inbetween);
52  void print_sumlike(std::ostream&, Ex::iterator);
53  void print_fraclike(std::ostream&, Ex::iterator);
54  void print_commalike(std::ostream&, Ex::iterator);
55  void print_arrowlike(std::ostream&, Ex::iterator);
56  void print_dot(std::ostream&, Ex::iterator);
57  void print_powlike(std::ostream&, Ex::iterator);
58  void print_intlike(std::ostream&, Ex::iterator);
59  void print_conditional(std::ostream&, Ex::iterator);
60  void print_relation(std::ostream&, Ex::iterator);
61  void print_equalitylike(std::ostream&, Ex::iterator);
62  void print_commutator(std::ostream& str, Ex::iterator it, bool comm);
63  void print_components(std::ostream&, Ex::iterator);
64  void print_dots(std::ostream&, Ex::iterator);
65  void print_other(std::ostream&, Ex::iterator);
66 
70  bool handle_unprintable_wildcards(std::ostream&, Ex::iterator it) const;
71 
72  bool children_have_brackets(Ex::iterator ch) const;
73 
74  std::map<std::string, std::string> symmap;
75  };
76 
77  const char *unichar(kunichar c);
78 
79  }
uint32_t kunichar
Definition: DisplayMMA.hh:9
uint32_t kunichar
Definition: DisplayTerminal.hh:11
Base class for all display classes.
Definition: DisplayBase.hh:19
Class to display expressions to the terminal.
Definition: DisplayTerminal.hh:26
void print_parent_rel(std::ostream &, str_node::parent_rel_t, bool first)
Definition: DisplayTerminal.cc:266
void print_relation(std::ostream &, Ex::iterator)
Definition: DisplayTerminal.cc:491
void print_dots(std::ostream &, Ex::iterator)
Definition: DisplayTerminal.cc:594
void print_components(std::ostream &, Ex::iterator)
Definition: DisplayTerminal.cc:546
void print_fraclike(std::ostream &, Ex::iterator)
Definition: DisplayTerminal.cc:369
void print_equalitylike(std::ostream &, Ex::iterator)
Definition: DisplayTerminal.cc:519
virtual bool needs_brackets(Ex::iterator it) override
Determine if a node needs extra brackets around it.
Definition: DisplayTerminal.cc:28
virtual void dispatch(std::ostream &, Ex::iterator) override
Definition: DisplayTerminal.cc:290
void print_commutator(std::ostream &str, Ex::iterator it, bool comm)
Definition: DisplayTerminal.cc:530
bool children_have_brackets(Ex::iterator ch) const
Definition: DisplayTerminal.cc:585
DisplayTerminal(const Kernel &, const Ex &, bool use_unicode=true)
Definition: DisplayTerminal.cc:9
void print_commalike(std::ostream &, Ex::iterator)
Definition: DisplayTerminal.cc:329
void print_productlike(std::ostream &, Ex::iterator, const std::string &inbetween)
Printing members for various standard constructions, e.g.
Definition: DisplayTerminal.cc:397
void print_intlike(std::ostream &, Ex::iterator)
Definition: DisplayTerminal.cc:501
void print_sumlike(std::ostream &, Ex::iterator)
Definition: DisplayTerminal.cc:440
bool handle_unprintable_wildcards(std::ostream &, Ex::iterator it) const
Handle unprintable constructions like \pow{#}, which need to print verbatim.
Definition: DisplayTerminal.cc:315
void print_opening_bracket(std::ostream &, str_node::bracket_t, str_node::parent_rel_t)
Definition: DisplayTerminal.cc:216
std::map< std::string, std::string > symmap
Definition: DisplayTerminal.hh:74
int bracket_level
Definition: DisplayTerminal.hh:43
void print_dot(std::ostream &, Ex::iterator)
Definition: DisplayTerminal.cc:357
bool use_unicode
Definition: DisplayTerminal.hh:31
void print_closing_bracket(std::ostream &, str_node::bracket_t, str_node::parent_rel_t)
Definition: DisplayTerminal.cc:241
void print_conditional(std::ostream &, Ex::iterator)
Definition: DisplayTerminal.cc:482
void print_children(std::ostream &, Ex::iterator, int skip=0)
Definition: DisplayTerminal.cc:94
void print_powlike(std::ostream &, Ex::iterator)
Definition: DisplayTerminal.cc:461
void print_multiplier(std::ostream &, Ex::iterator, int mult=1)
Definition: DisplayTerminal.cc:155
void print_arrowlike(std::ostream &, Ex::iterator)
Definition: DisplayTerminal.cc:345
void print_other(std::ostream &, Ex::iterator)
Definition: DisplayTerminal.cc:599
Basic storage class for symbolic mathemematical expressions.
Definition: Storage.hh:142
Definition: Kernel.hh:15
bracket_t
Definition: Storage.hh:58
parent_rel_t
Child nodes are related to their parent node by a so-called parent relation, which can be one of thes...
Definition: Storage.hh:62
Functions to handle the exchange properties of two or more symbols in a product.
Definition: Adjform.cc:83
const char * unichar(kunichar c)