#include <YStatement.h>
Public Member Functions | |
YSSwitch (YCodePtr condition) | |
YSSwitch (bytecodeistream &str) | |
~YSSwitch () | |
virtual ykind | kind () const |
string | name () const |
string | toString () const |
std::ostream & | toStream (std::ostream &str) const |
std::ostream & | toXml (std::ostream &str, int indent) const |
YCPValue | evaluate (bool cse=false) |
constTypePtr | type () const |
constTypePtr | conditionType () const |
bool | setCase (YCPValue value) |
bool | setDefaultCase () |
void | setBlock (YBlockPtr block) |
Private Member Functions | |
REP_BODY (YSSwitch) | |
Private Attributes | |
YCodePtr | m_condition |
YBlockPtr | m_block |
int | m_defaultcase |
map< YCPValue, int, ycp_less > | m_cases |
switch
YSSwitch::YSSwitch | ( | YCodePtr | condition | ) |
Switch
YSSwitch::YSSwitch | ( | bytecodeistream & | str | ) |
References YCPElement::isNull(), m_block, m_cases, m_condition, m_defaultcase, Bytecode::readCode(), Bytecode::readInt32(), and Bytecode::readValue().
YSSwitch::~YSSwitch | ( | ) |
constTypePtr YSSwitch::conditionType | ( | ) | const [inline] |
References m_condition.
YCPValue YSSwitch::evaluate | ( | bool | cse = false |
) | [virtual] |
Execute YCP code to get the resulting YCPValue. Every inherited class of YCode should reimplement this method.
cse | should the evaluation be done for parse time evaluation (i.e. constant subexpression elimination) |
Reimplemented from YStatement.
References YCPElement::isNull(), m_block, m_cases, m_condition, m_defaultcase, y2debug, and ycperror.
virtual ykind YSSwitch::kind | ( | ) | const [inline, virtual] |
Kind of this YCode. This method must be reimplemented in the inherited classes.
Implements YCode.
References YCode::ysSwitch.
string YSSwitch::name | ( | ) | const |
YSSwitch::REP_BODY | ( | YSSwitch | ) | [private] |
void YSSwitch::setBlock | ( | YBlockPtr | block | ) |
References m_block.
bool YSSwitch::setDefaultCase | ( | ) |
References m_block, and m_defaultcase.
std::ostream & YSSwitch::toStream | ( | std::ostream & | str | ) | const [virtual] |
Write YCP code to a byte stream (bytecode implementation). Every class inheriting from YCode must reimplement this method.
str | byte stream to store into |
Reimplemented from YStatement.
References m_block, m_cases, m_condition, m_defaultcase, Bytecode::writeInt32(), and Bytecode::writeValue().
string YSSwitch::toString | ( | void | ) | const [virtual] |
Return ASCII represtation of this YCP code.
Reimplemented from YStatement.
References m_block, m_cases, m_condition, and m_defaultcase.
std::ostream & YSSwitch::toXml | ( | std::ostream & | str, | |
int | indent | |||
) | const [virtual] |
Write YCP code as XML representation. Every class inheriting from YCode must reimplement this method.
str | string stream to store into | |
indend | indentation level for pretty print |
Reimplemented from YStatement.
References m_block, m_cases, m_condition, m_defaultcase, and Xmlcode::spaces().
constTypePtr YSSwitch::type | ( | ) | const [inline, virtual] |
Return type of this YCP code (interesting mostly for function calls).
Reimplemented from YStatement.
References Type::Void.
YBlockPtr YSSwitch::m_block [private] |
Referenced by evaluate(), setBlock(), setCase(), setDefaultCase(), toStream(), toString(), toXml(), and YSSwitch().
map<YCPValue, int, ycp_less> YSSwitch::m_cases [private] |
Referenced by evaluate(), setCase(), toStream(), toString(), toXml(), and YSSwitch().
YCodePtr YSSwitch::m_condition [private] |
Referenced by conditionType(), evaluate(), toStream(), toString(), toXml(), and YSSwitch().
int YSSwitch::m_defaultcase [private] |
Referenced by evaluate(), setDefaultCase(), toStream(), toString(), toXml(), and YSSwitch().