openMSX
Classes | Public Member Functions | Friends | List of all members
openmsx::TclObject Class Reference

#include <TclObject.hh>

Classes

struct  MakeDictTag
 
struct  MakeListTag
 

Public Member Functions

 TclObject ()
 
 TclObject (Tcl_Obj *o)
 
template<typename T >
 TclObject (T t)
 
 TclObject (const TclObject &o)
 
 TclObject (TclObject &&o) noexcept
 
template<typename... Args>
 TclObject (MakeListTag, Args &&... args)
 
template<typename... Args>
 TclObject (MakeDictTag, Args &&... args)
 
 ~TclObject ()
 
TclObjectoperator= (const TclObject &other)
 
TclObjectoperator= (TclObject &other)
 
TclObjectoperator= (TclObject &&other) noexcept
 
template<typename T >
TclObjectoperator= (T &&t)
 
Tcl_Obj * getTclObject ()
 
Tcl_Obj * getTclObjectNonConst () const
 
template<typename T >
void addListElement (const T &t)
 
template<typename ITER >
void addListElements (ITER first, ITER last)
 
template<typename Range >
void addListElements (Range &&range)
 
template<typename... Args>
void addListElement (Args &&... args)
 
template<typename Key , typename Value >
void addDictKeyValue (const Key &key, const Value &value)
 
template<typename... Args>
void addDictKeyValues (Args &&... args)
 
zstring_view getString () const
 
int getInt (Interpreter &interp) const
 
bool getBoolean (Interpreter &interp) const
 
float getFloat (Interpreter &interp) const
 
double getDouble (Interpreter &interp) const
 
std::span< const uint8_t > getBinary () const
 
unsigned getListLength (Interpreter &interp) const
 
TclObject getListIndex (Interpreter &interp, unsigned index) const
 
TclObject getListIndexUnchecked (unsigned index) const
 
void removeListIndex (Interpreter &interp, unsigned index)
 
void setDictValue (Interpreter &interp, const TclObject &key, const TclObject &value)
 
TclObject getDictValue (Interpreter &interp, const TclObject &key) const
 
template<typename Key >
TclObject getDictValue (Interpreter &interp, const Key &key) const
 
std::optional< TclObjectgetOptionalDictValue (const TclObject &key) const
 
std::optional< int > getOptionalInt () const
 
std::optional< bool > getOptionalBool () const
 
std::optional< double > getOptionalDouble () const
 
std::optional< float > getOptionalFloat () const
 
unsigned size () const
 
bool empty () const
 
iterator begin () const
 
iterator end () const
 
bool evalBool (Interpreter &interp) const
 
TclObject eval (Interpreter &interp) const
 
TclObject executeCommand (Interpreter &interp, bool compile=false)
 Interpret this TclObject as a command and execute it.
 

Friends

bool operator== (const TclObject &x, const TclObject &y)
 
bool operator== (const TclObject &x, std::string_view y)
 

Detailed Description

Definition at line 26 of file TclObject.hh.

Constructor & Destructor Documentation

◆ TclObject() [1/7]

openmsx::TclObject::TclObject ( )
inline

◆ TclObject() [2/7]

openmsx::TclObject::TclObject ( Tcl_Obj *  o)
inlineexplicit

Definition at line 75 of file TclObject.hh.

◆ TclObject() [3/7]

template<typename T >
openmsx::TclObject::TclObject ( t)
inlineexplicit

Definition at line 76 of file TclObject.hh.

References t.

◆ TclObject() [4/7]

openmsx::TclObject::TclObject ( const TclObject o)
inline

Definition at line 77 of file TclObject.hh.

◆ TclObject() [5/7]

openmsx::TclObject::TclObject ( TclObject &&  o)
inlinenoexcept

Definition at line 78 of file TclObject.hh.

◆ TclObject() [6/7]

template<typename... Args>
openmsx::TclObject::TclObject ( MakeListTag  ,
Args &&...  args 
)
inline

Definition at line 82 of file TclObject.hh.

◆ TclObject() [7/7]

template<typename... Args>
openmsx::TclObject::TclObject ( MakeDictTag  ,
Args &&...  args 
)
inline

Definition at line 88 of file TclObject.hh.

References addDictKeyValues().

◆ ~TclObject()

openmsx::TclObject::~TclObject ( )
inline

Definition at line 93 of file TclObject.hh.

Member Function Documentation

◆ addDictKeyValue()

template<typename Key , typename Value >
void openmsx::TclObject::addDictKeyValue ( const Key &  key,
const Value &  value 
)
inline

◆ addDictKeyValues()

template<typename... Args>
void openmsx::TclObject::addDictKeyValues ( Args &&...  args)
inline

◆ addListElement() [1/2]

template<typename... Args>
void openmsx::TclObject::addListElement ( Args &&...  args)
inline

Definition at line 139 of file TclObject.hh.

◆ addListElement() [2/2]

template<typename T >
void openmsx::TclObject::addListElement ( const T &  t)
inline

◆ addListElements() [1/2]

template<typename ITER >
void openmsx::TclObject::addListElements ( ITER  first,
ITER  last 
)
inline

◆ addListElements() [2/2]

template<typename Range >
void openmsx::TclObject::addListElements ( Range &&  range)
inline

Definition at line 136 of file TclObject.hh.

References addListElements().

◆ begin()

iterator openmsx::TclObject::begin ( ) const
inline

Definition at line 179 of file TclObject.hh.

Referenced by TEST_CASE().

◆ empty()

bool openmsx::TclObject::empty ( ) const
inline

Definition at line 178 of file TclObject.hh.

References size().

Referenced by openmsx::ImGuiMedia::showMenu(), and TEST_CASE().

◆ end()

iterator openmsx::TclObject::end ( ) const
inline

Definition at line 180 of file TclObject.hh.

References size().

Referenced by TEST_CASE().

◆ eval()

TclObject openmsx::TclObject::eval ( Interpreter interp) const

Definition at line 239 of file TclObject.cc.

References TclObject().

◆ evalBool()

bool openmsx::TclObject::evalBool ( Interpreter interp) const

Definition at line 229 of file TclObject.cc.

◆ executeCommand()

TclObject openmsx::TclObject::executeCommand ( Interpreter interp,
bool  compile = false 
)

Interpret this TclObject as a command and execute it.

Parameters
interpThe Tcl interpreter
compileShould the command be compiled to bytecode? The bytecode is stored inside the TclObject can speed up future invocations of the same command. Only set this flag when the command will be executed more than once.

Definition at line 249 of file TclObject.cc.

References TclObject().

Referenced by openmsx::BreakPointBase::checkAndExecute(), openmsx::AfterCmd::execute(), openmsx::ImGuiManager::execute(), openmsx::ImGuiManager::executeDelayed(), openmsx::CassettePlayerCLI::parseFileType(), openmsx::LaserdiscPlayerCLI::parseFileType(), openmsx::ReplayCLI::parseFileType(), openmsx::SaveStateCLI::parseFileType(), openmsx::CDImageCLI::parseOption(), and TEST_CASE().

◆ getBinary()

std::span< const uint8_t > openmsx::TclObject::getBinary ( ) const

Definition at line 149 of file TclObject.cc.

Referenced by TEST_CASE().

◆ getBoolean()

bool openmsx::TclObject::getBoolean ( Interpreter interp) const

◆ getDictValue() [1/2]

template<typename Key >
TclObject openmsx::TclObject::getDictValue ( Interpreter interp,
const Key &  key 
) const
inline

Definition at line 166 of file TclObject.hh.

References getDictValue(), and TclObject().

◆ getDictValue() [2/2]

TclObject openmsx::TclObject::getDictValue ( Interpreter interp,
const TclObject key 
) const

Definition at line 210 of file TclObject.cc.

References TclObject().

Referenced by getDictValue(), TEST_CASE(), and TEST_CASE().

◆ getDouble()

double openmsx::TclObject::getDouble ( Interpreter interp) const

◆ getFloat()

float openmsx::TclObject::getFloat ( Interpreter interp) const

◆ getInt()

int openmsx::TclObject::getInt ( Interpreter interp) const

◆ getListIndex()

TclObject openmsx::TclObject::getListIndex ( Interpreter interp,
unsigned  index 
) const

◆ getListIndexUnchecked()

TclObject openmsx::TclObject::getListIndexUnchecked ( unsigned  index) const

Definition at line 183 of file TclObject.cc.

References TclObject().

Referenced by openmsx::ImGuiWatchExpr::loadLine().

◆ getListLength()

unsigned openmsx::TclObject::getListLength ( Interpreter interp) const

◆ getOptionalBool()

std::optional< bool > openmsx::TclObject::getOptionalBool ( ) const

Definition at line 99 of file TclObject.cc.

◆ getOptionalDictValue()

std::optional< TclObject > openmsx::TclObject::getOptionalDictValue ( const TclObject key) const

Definition at line 220 of file TclObject.cc.

References TclObject().

◆ getOptionalDouble()

std::optional< double > openmsx::TclObject::getOptionalDouble ( ) const

Definition at line 133 of file TclObject.cc.

Referenced by getOptionalFloat().

◆ getOptionalFloat()

std::optional< float > openmsx::TclObject::getOptionalFloat ( ) const

Definition at line 115 of file TclObject.cc.

References getOptionalDouble().

◆ getOptionalInt()

std::optional< int > openmsx::TclObject::getOptionalInt ( ) const

Definition at line 80 of file TclObject.cc.

◆ getString()

zstring_view openmsx::TclObject::getString ( ) const

◆ getTclObject()

Tcl_Obj * openmsx::TclObject::getTclObject ( )
inline

Definition at line 127 of file TclObject.hh.

◆ getTclObjectNonConst()

Tcl_Obj * openmsx::TclObject::getTclObjectNonConst ( ) const
inline

◆ operator=() [1/4]

TclObject & openmsx::TclObject::operator= ( const TclObject other)
inline

Definition at line 96 of file TclObject.hh.

◆ operator=() [2/4]

template<typename T >
TclObject & openmsx::TclObject::operator= ( T &&  t)
inline

Definition at line 115 of file TclObject.hh.

References t.

◆ operator=() [3/4]

TclObject & openmsx::TclObject::operator= ( TclObject &&  other)
inlinenoexcept

Definition at line 110 of file TclObject.hh.

◆ operator=() [4/4]

TclObject & openmsx::TclObject::operator= ( TclObject other)
inline

Definition at line 103 of file TclObject.hh.

◆ removeListIndex()

void openmsx::TclObject::removeListIndex ( Interpreter interp,
unsigned  index 
)

Definition at line 192 of file TclObject.cc.

◆ setDictValue()

void openmsx::TclObject::setDictValue ( Interpreter interp,
const TclObject key,
const TclObject value 
)

Definition at line 201 of file TclObject.cc.

◆ size()

unsigned openmsx::TclObject::size ( ) const
inline

Definition at line 177 of file TclObject.hh.

Referenced by empty(), end(), openmsx::ImGuiWatchExpr::loadLine(), and TEST_CASE().

Friends And Related Symbol Documentation

◆ operator== [1/2]

bool operator== ( const TclObject x,
const TclObject y 
)
friend

Definition at line 195 of file TclObject.hh.

◆ operator== [2/2]

bool operator== ( const TclObject x,
std::string_view  y 
)
friend

Definition at line 198 of file TclObject.hh.


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