Cadabra
Computer algebra system for field theory problems
Loading...
Searching...
No Matches
cadabra::DisplayBase Class Referenceabstract

Description

Base class for all display classes.

A key difficulty with printing is to figure out when to print additional brackets for objects which would otherwise not render correctly. For example, a sum inside a product need brackets, but it does not need brackets when it is given as an argument to a function, because then the brackets are already there from the function call.

#include <DisplayBase.hh>

Inheritance diagram for cadabra::DisplayBase:
cadabra::DisplayMMA cadabra::DisplaySympy cadabra::DisplayTeX cadabra::DisplayTerminal sympy::SympyBridge

Public Member Functions

 DisplayBase (const Kernel &, const Ex &)
void output (std::ostream &)
void output (std::ostream &, Ex::iterator)
virtual void dispatch (std::ostream &, Ex::iterator)=0

Protected Member Functions

virtual bool needs_brackets (Ex::iterator it)=0
 Determine if a node needs extra brackets around it.

Protected Attributes

const Extree
const Kernelkernel

Constructor & Destructor Documentation

◆ DisplayBase()

DisplayBase::DisplayBase ( const Kernel & k,
const Ex & e )

Member Function Documentation

◆ dispatch()

virtual void cadabra::DisplayBase::dispatch ( std::ostream & ,
Ex::iterator  )
pure virtual

◆ needs_brackets()

virtual bool cadabra::DisplayBase::needs_brackets ( Ex::iterator it)
protectedpure virtual

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}).

Implemented in cadabra::DisplayMMA, cadabra::DisplaySympy, cadabra::DisplayTerminal, and cadabra::DisplayTeX.

◆ output() [1/2]

void DisplayBase::output ( std::ostream & str)

◆ output() [2/2]

void DisplayBase::output ( std::ostream & str,
Ex::iterator it )

Member Data Documentation

◆ kernel

const Kernel& cadabra::DisplayBase::kernel
protected

◆ tree

const Ex& cadabra::DisplayBase::tree
protected

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