Cadabra
Computer algebra system for field theory problems
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
cadabra::DisplayTerminal Class Reference

Description

Class to display expressions to the terminal.

This is used in the PythonCdb bridge to provide 'str' type python printing for Ex objects. The cadabra2 command line application uses this class for all its output. This class does not necessarily produce output which is readable by sympy; for that, use the DisplaySympy class (as an example, partial derivatives will display using a LaTeX notation using the present class, but be printed as 'sympy.diff' by the DisplaySympy class).

#include <DisplayTerminal.hh>

Inheritance diagram for cadabra::DisplayTerminal:
cadabra::DisplayBase

Public Member Functions

 DisplayTerminal (const Kernel &, const Ex &, bool use_unicode=true)
 
- Public Member Functions inherited from cadabra::DisplayBase
 DisplayBase (const Kernel &, const Ex &)
 
void output (std::ostream &)
 
void output (std::ostream &, Ex::iterator)
 

Protected Member Functions

virtual void dispatch (std::ostream &, Ex::iterator) override
 
virtual bool needs_brackets (Ex::iterator it) override
 Determine if a node needs extra brackets around it. More...
 

Protected Attributes

bool use_unicode
 
- Protected Attributes inherited from cadabra::DisplayBase
const Extree
 
const Kernelkernel
 

Private Member Functions

void print_multiplier (std::ostream &, Ex::iterator, int mult=1)
 
void print_opening_bracket (std::ostream &, str_node::bracket_t, str_node::parent_rel_t)
 
void print_closing_bracket (std::ostream &, str_node::bracket_t, str_node::parent_rel_t)
 
void print_parent_rel (std::ostream &, str_node::parent_rel_t, bool first)
 
void print_children (std::ostream &, Ex::iterator, int skip=0)
 
void print_productlike (std::ostream &, Ex::iterator, const std::string &inbetween)
 Printing members for various standard constructions, e.g. More...
 
void print_sumlike (std::ostream &, Ex::iterator)
 
void print_fraclike (std::ostream &, Ex::iterator)
 
void print_commalike (std::ostream &, Ex::iterator)
 
void print_arrowlike (std::ostream &, Ex::iterator)
 
void print_dot (std::ostream &, Ex::iterator)
 
void print_powlike (std::ostream &, Ex::iterator)
 
void print_intlike (std::ostream &, Ex::iterator)
 
void print_conditional (std::ostream &, Ex::iterator)
 
void print_relation (std::ostream &, Ex::iterator)
 
void print_equalitylike (std::ostream &, Ex::iterator)
 
void print_commutator (std::ostream &str, Ex::iterator it, bool comm)
 
void print_components (std::ostream &, Ex::iterator)
 
void print_dots (std::ostream &, Ex::iterator)
 
void print_other (std::ostream &, Ex::iterator)
 
bool handle_unprintable_wildcards (std::ostream &, Ex::iterator it) const
 Handle unprintable constructions like \pow{#}, which need to print verbatim. More...
 
bool children_have_brackets (Ex::iterator ch) const
 

Private Attributes

int bracket_level =0
 
std::map< std::string, std::string > symmap
 

Constructor & Destructor Documentation

◆ DisplayTerminal()

DisplayTerminal::DisplayTerminal ( const Kernel k,
const Ex e,
bool  use_unicode = true 
)

Member Function Documentation

◆ children_have_brackets()

bool DisplayTerminal::children_have_brackets ( Ex::iterator  ch) const
private

◆ dispatch()

void DisplayTerminal::dispatch ( std::ostream &  str,
Ex::iterator  it 
)
overrideprotectedvirtual

Implements cadabra::DisplayBase.

◆ handle_unprintable_wildcards()

bool DisplayTerminal::handle_unprintable_wildcards ( std::ostream &  str,
Ex::iterator  it 
) const
private

Handle unprintable constructions like \pow{#}, which need to print verbatim.

Pass it the top-level iterator, will return true if printing has been taken care of.

◆ needs_brackets()

bool DisplayTerminal::needs_brackets ( Ex::iterator  it)
overrideprotectedvirtual

Determine if a node needs extra brackets around it.

Uses context from the parent node if necessary. Has to be implemented in a derived class, because the answer depends on the printing method (e.g. (a+b)/c needs brackets when printed like this, but does not need brackets when printed as \frac{a+b}{c}).

Implements cadabra::DisplayBase.

◆ print_arrowlike()

void DisplayTerminal::print_arrowlike ( std::ostream &  str,
Ex::iterator  it 
)
private

◆ print_children()

void DisplayTerminal::print_children ( std::ostream &  str,
Ex::iterator  it,
int  skip = 0 
)
private

◆ print_closing_bracket()

void DisplayTerminal::print_closing_bracket ( std::ostream &  str,
str_node::bracket_t  br,
str_node::parent_rel_t  pr 
)
private

◆ print_commalike()

void DisplayTerminal::print_commalike ( std::ostream &  str,
Ex::iterator  it 
)
private

◆ print_commutator()

void DisplayTerminal::print_commutator ( std::ostream &  str,
Ex::iterator  it,
bool  comm 
)
private

◆ print_components()

void DisplayTerminal::print_components ( std::ostream &  str,
Ex::iterator  it 
)
private

◆ print_conditional()

void DisplayTerminal::print_conditional ( std::ostream &  str,
Ex::iterator  it 
)
private

◆ print_dot()

void DisplayTerminal::print_dot ( std::ostream &  str,
Ex::iterator  it 
)
private

◆ print_dots()

void DisplayTerminal::print_dots ( std::ostream &  str,
Ex::iterator   
)
private

◆ print_equalitylike()

void DisplayTerminal::print_equalitylike ( std::ostream &  str,
Ex::iterator  it 
)
private

◆ print_fraclike()

void DisplayTerminal::print_fraclike ( std::ostream &  str,
Ex::iterator  it 
)
private

◆ print_intlike()

void DisplayTerminal::print_intlike ( std::ostream &  str,
Ex::iterator  it 
)
private

◆ print_multiplier()

void DisplayTerminal::print_multiplier ( std::ostream &  str,
Ex::iterator  it,
int  mult = 1 
)
private

◆ print_opening_bracket()

void DisplayTerminal::print_opening_bracket ( std::ostream &  str,
str_node::bracket_t  br,
str_node::parent_rel_t  pr 
)
private

◆ print_other()

void DisplayTerminal::print_other ( std::ostream &  str,
Ex::iterator  it 
)
private

◆ print_parent_rel()

void DisplayTerminal::print_parent_rel ( std::ostream &  str,
str_node::parent_rel_t  pr,
bool  first 
)
private

◆ print_powlike()

void DisplayTerminal::print_powlike ( std::ostream &  str,
Ex::iterator  it 
)
private

◆ print_productlike()

void DisplayTerminal::print_productlike ( std::ostream &  str,
Ex::iterator  it,
const std::string &  inbetween 
)
private

Printing members for various standard constructions, e.g.

print as a list, or as a decorated symbol with super/subscripts etc. The names reflect the structure of the output, not necessarily the meaning or name of the object that is being printed.

◆ print_relation()

void DisplayTerminal::print_relation ( std::ostream &  str,
Ex::iterator  it 
)
private

◆ print_sumlike()

void DisplayTerminal::print_sumlike ( std::ostream &  str,
Ex::iterator  it 
)
private

Member Data Documentation

◆ bracket_level

int cadabra::DisplayTerminal::bracket_level =0
private

◆ symmap

std::map<std::string, std::string> cadabra::DisplayTerminal::symmap
private

◆ use_unicode

bool cadabra::DisplayTerminal::use_unicode
protected

The documentation for this class was generated from the following files: