Cadabra
Computer algebra system for field theory problems
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
Shell Class Reference

#include <cadabra2-cli.hh>

Public Types

enum  Flags : unsigned int {
  Flags::None = 0x00, Flags::NoBanner = 0x01, Flags::IgnoreSemicolons = 0x02, Flags::NoColour = 0x04,
  Flags::NoReadline = 0x08
}
 

Public Member Functions

 Shell (Flags flags)
 
 ~Shell ()
 
void restart ()
 
void interact ()
 
void interact_file (const std::string &filename, bool preprocess=true)
 
bool execute_file (const std::string &filename, bool preprocess=true)
 
bool execute (const std::string &code, const std::string &filename="<stdin>")
 
PyObject * evaluate (const std::string &code, const std::string &filename="<stdin>")
 
std::string evaluate_to_string (const std::string &code, const std::string &err_val="<error>")
 
void write (const std::string &text, const char *end="\n", const char *stream="stdout", bool flush=false)
 
void write (PyObject *obj, const char *end="\n", const char *stream="stdout", bool flush=false)
 

Private Member Functions

void set_histfile ()
 
std::string to_string (PyObject *obj)
 
std::string sanitize (std::string s)
 
bool process_ps1 (const std::string &line)
 
bool process_ps2 (const std::string &line)
 
void set_completion_callback (const char *buffer, std::vector< std::string > &completions)
 
std::string get_ps1 ()
 
std::string get_ps2 ()
 
bool is_syntax_error ()
 
bool is_eof_error ()
 
void handle_error ()
 
void clear_error ()
 

Private Attributes

std::string histfile
 
PyObject * globals
 
PyObject * sys
 
std::string collect
 
const char * colour_error
 
const char * colour_warning
 
const char * colour_info
 
const char * colour_success
 
const char * colour_reset
 
Flags flags
 

Member Enumeration Documentation

◆ Flags

enum Shell::Flags : unsigned int
strong
Enumerator
None 
NoBanner 
IgnoreSemicolons 
NoColour 
NoReadline 

Constructor & Destructor Documentation

◆ Shell()

Shell::Shell ( Flags  flags)

◆ ~Shell()

Shell::~Shell ( )

Member Function Documentation

◆ clear_error()

void Shell::clear_error ( )
private

◆ evaluate()

PyObject * Shell::evaluate ( const std::string &  code,
const std::string &  filename = "<stdin>" 
)

◆ evaluate_to_string()

std::string Shell::evaluate_to_string ( const std::string &  code,
const std::string &  err_val = "<error>" 
)

◆ execute()

bool Shell::execute ( const std::string &  code,
const std::string &  filename = "<stdin>" 
)

◆ execute_file()

bool Shell::execute_file ( const std::string &  filename,
bool  preprocess = true 
)

◆ get_ps1()

std::string Shell::get_ps1 ( )
private

◆ get_ps2()

std::string Shell::get_ps2 ( )
private

◆ handle_error()

void Shell::handle_error ( )
private

◆ interact()

void Shell::interact ( )

◆ interact_file()

void Shell::interact_file ( const std::string &  filename,
bool  preprocess = true 
)

◆ is_eof_error()

bool Shell::is_eof_error ( )
private

◆ is_syntax_error()

bool Shell::is_syntax_error ( )
private

◆ process_ps1()

bool Shell::process_ps1 ( const std::string &  line)
private

◆ process_ps2()

bool Shell::process_ps2 ( const std::string &  line)
private

◆ restart()

void Shell::restart ( )

◆ sanitize()

std::string Shell::sanitize ( std::string  s)
private

◆ set_completion_callback()

void Shell::set_completion_callback ( const char *  buffer,
std::vector< std::string > &  completions 
)
private

◆ set_histfile()

void Shell::set_histfile ( )
private

◆ to_string()

std::string Shell::to_string ( PyObject *  obj)
private

◆ write() [1/2]

void Shell::write ( const std::string &  text,
const char *  end = "\n",
const char *  stream = "stdout",
bool  flush = false 
)

◆ write() [2/2]

void Shell::write ( PyObject *  obj,
const char *  end = "\n",
const char *  stream = "stdout",
bool  flush = false 
)

Member Data Documentation

◆ collect

std::string Shell::collect
private

◆ colour_error

const char* Shell::colour_error
private

◆ colour_info

const char* Shell::colour_info
private

◆ colour_reset

const char* Shell::colour_reset
private

◆ colour_success

const char* Shell::colour_success
private

◆ colour_warning

const char* Shell::colour_warning
private

◆ flags

Flags Shell::flags
private

◆ globals

PyObject* Shell::globals
private

◆ histfile

std::string Shell::histfile
private

◆ sys

PyObject* Shell::sys
private

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