本文整理汇总了C++中MHUnion类的典型用法代码示例。如果您正苦于以下问题:C++ MHUnion类的具体用法?C++ MHUnion怎么用?C++ MHUnion使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MHUnion类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetBool
// Return a bool value. May throw an exception if it isn't the correct type.
static bool GetBool(MHParameter *parm, MHEngine *engine)
{
MHUnion un;
un.GetValueFrom(*parm, engine);
un.CheckType(MHUnion::U_Bool);
return un.m_fBoolVal;
}
示例2: GetString
// Extract a string value.
static void GetString(MHParameter *parm, MHOctetString &str, MHEngine *engine)
{
MHUnion un;
un.GetValueFrom(*parm, engine);
un.CheckType(MHUnion::U_String);
str.Copy(un.m_StrVal);
}
示例3: _snprintf
// Return the value, looking up any indirect ref.
void MHGenericOctetString::GetValue(MHOctetString &str, MHEngine *engine) const
{
if (m_fIsDirect) str.Copy(m_Direct);
else {
MHUnion result;
MHRoot *pBase = engine->FindObject(m_Indirect);
pBase->GetVariableValue(result, engine);
// From my reading of the MHEG documents implicit conversion is only
// performed when assigning variables. Nevertheless the Channel 4
// Teletext assumes that implicit conversion takes place here as well.
if (result.m_Type == MHUnion::U_Int) {
// Implicit conversion of int to string.
char buff[30]; // 30 chars is more than enough.
#ifdef WIN32
_snprintf(buff, sizeof(buff), "%0d", result.m_nIntVal);
#else
snprintf(buff, sizeof(buff), "%0d", result.m_nIntVal);
#endif
str.Copy(buff);
}
else {
result.CheckType(MHUnion::U_String);
str.Copy(result.m_StrVal);
}
}
}
示例4: GetInt
// Return an integer value. May throw an exception if it isn't the correct type.
static int GetInt(MHParameter *parm, MHEngine *engine)
{
MHUnion un;
un.GetValueFrom(*parm, engine);
un.CheckType(MHUnion::U_Int);
return un.m_nIntVal;
}
示例5: GetValue
// Return the value, looking up any indirect ref.
int MHGenericInteger::GetValue(MHEngine *engine) const
{
if (m_fIsDirect) return m_nDirect;
else {
MHUnion result;
MHRoot *pBase = engine->FindObject(m_Indirect);
pBase->GetVariableValue(result, engine);
// From my reading of the MHEG documents implicit conversion is only
// performed when assigning variables. Nevertheless the Channel 4
// Teletext assumes that implicit conversion takes place here as well.
if (result.m_Type == MHUnion::U_String) {
// Implicit conversion of string to integer.
int v = 0;
int p = 0;
bool fNegative = false;
if (result.m_StrVal.Size() > 0 && result.m_StrVal.GetAt(0) == '-') { p++; fNegative = true; }
for ( ; p < result.m_StrVal.Size(); p++) {
unsigned char ch = result.m_StrVal.GetAt(p);
if (ch < '0' || ch > '9') break;
v = v * 10 + ch - '0';
}
if (fNegative) return -v; else return v;
}
else {
result.CheckType(MHUnion::U_Int);
return result.m_nIntVal;
}
}
}
示例6: Perform
void MHSetVariable::Perform(MHEngine *engine)
{
MHObjectRef target;
m_Target.GetValue(target, engine); // Get the target
MHUnion newValue;
newValue.GetValueFrom(m_NewValue, engine); // Get the actual value to set.
engine->FindObject(target)->SetVariableValue(newValue); // Set the value.
}
示例7: Perform
void MHSendEvent::Perform(MHEngine *engine)
{
// The target is always the current scene so we ignore it here.
MHObjectRef target, source;
m_Target.GetValue(target, engine); // TODO: Check this is the scene?
m_EventSource.GetValue(source, engine);
// Generate the event.
if (m_EventData.m_Type == MHParameter::P_Null)
engine->EventTriggered(engine->FindObject(source), m_EventType);
else {
MHUnion data;
data.GetValueFrom(m_EventData, engine);
engine->EventTriggered(engine->FindObject(source), m_EventType, data);
}
}
示例8: TestVariable
// Implement the TestVariable action. Triggers a TestEvent event on the result.
void MHOctetStrVar::TestVariable(int nOp, const MHUnion &parm, MHEngine *engine)
{
parm.CheckType(MHUnion::U_String);
int nRes = m_Value.Compare(parm.m_StrVal);
bool fRes = false;
switch (nOp)
{
case TC_Equal:
fRes = nRes == 0;
break;
case TC_NotEqual:
fRes = nRes != 0;
break;
/* case TC_Less: fRes = nRes < 0; break;
case TC_LessOrEqual: fRes = nRes <= 0; break;
case TC_Greater: fRes = nRes > 0; break;
case TC_GreaterOrEqual: fRes = nRes >= 0; break;*/
default:
MHERROR("Invalid comparison for string"); // Shouldn't ever happen
}
MHOctetString sample1(m_Value, 0, 10);
MHOctetString sample2(parm.m_StrVal, 0, 10);
MHLOG(MHLogDetail, QString("Comparison %1 %2 and %3 => %4").arg(TestToText(nOp))
.arg(sample1.Printable()).arg(sample2.Printable()).arg(fRes ? "true" : "false"));
engine->EventTriggered(this, EventTestEvent, fRes);
}
示例9: GetValue
// Return the value, looking up any indirect ref.
void MHGenericObjectRef::GetValue(MHObjectRef &ref, MHEngine *engine) const
{
if (m_fIsDirect)
{
ref.Copy(m_ObjRef);
}
else
{
// LVR - Hmm I don't think this is right. Should be: ref.Copy(m_Indirect);
// But it's used in several places so workaround in Stream::MHActionGenericObjectRefFix
MHUnion result;
MHRoot *pBase = engine->FindObject(m_Indirect);
pBase->GetVariableValue(result, engine);
result.CheckType(MHUnion::U_ObjRef);
ref.Copy(result.m_ObjRefVal);
}
}
示例10: TestVariable
// Implement the TestVariable action. Triggers a TestEvent event on the result.
void MHContentRefVar::TestVariable(int nOp, const MHUnion &parm, MHEngine *engine)
{
parm.CheckType(MHUnion::U_ContentRef);
bool fRes = false;
switch (nOp) {
case TC_Equal: fRes = m_Value.Equal(parm.m_ContentRefVal, engine); break;
case TC_NotEqual: fRes = !m_Value.Equal(parm.m_ContentRefVal, engine); break;
default: MHERROR("Invalid comparison for content ref");
}
engine->EventTriggered(this, EventTestEvent, fRes);
}
示例11: snprintf
// Implement the SetVariable action.
void MHOctetStrVar::SetVariableValue(const MHUnion &value)
{
if (value.m_Type == MHUnion::U_Int) {
// Implicit conversion of int to string.
char buff[30]; // 30 chars is more than enough.
snprintf(buff, sizeof(buff), "%0d", value.m_nIntVal);
m_Value.Copy(buff);
}
else {
value.CheckType(MHUnion::U_String);
m_Value.Copy(value.m_StrVal);
}
// Debug
MHOctetString sample(m_Value, 0, 10);
MHLOG(MHLogDetail, QString("Update %1 := %2").arg(m_ObjectReference.Printable())
.arg(sample.Printable()));
}
示例12: SetVariableValue
// Implement the SetVariable action. Also used as part of Add, Subtract etc
void MHIntegerVar::SetVariableValue(const MHUnion &value)
{
if (value.m_Type == MHUnion::U_String)
{
// Implicit conversion of string to integer.
int v = 0;
int p = 0;
bool fNegative = false;
if (value.m_StrVal.Size() > 0 && value.m_StrVal.GetAt(0) == '-')
{
p++;
fNegative = true;
}
for (; p < value.m_StrVal.Size(); p++)
{
unsigned char ch = value.m_StrVal.GetAt(p);
if (ch < '0' || ch > '9')
{
break;
}
v = v * 10 + ch - '0';
}
if (fNegative)
{
m_nValue = -v;
}
else
{
m_nValue = v;
}
}
else
{
value.CheckType(MHUnion::U_Int);
m_nValue = value.m_nIntVal;
}
MHLOG(MHLogDetail, QString("Update %1 := %2").arg(m_ObjectReference.Printable()).arg(m_nValue));
}
示例13: Preparation
//.........这里部分代码省略.........
int netId, origNetId, transportId, serviceId;
// Look the information up in the database.
bool res = engine->GetContext()->GetServiceInfo(channelId, netId, origNetId,
transportId, serviceId);
if (res)
{
engine->FindObject(*(args.GetAt(1)->GetReference()))->SetVariableValue(netId);
engine->FindObject(*(args.GetAt(2)->GetReference()))->SetVariableValue(origNetId);
engine->FindObject(*(args.GetAt(3)->GetReference()))->SetVariableValue(transportId);
engine->FindObject(*(args.GetAt(4)->GetReference()))->SetVariableValue(serviceId);
}
SetSuccessFlag(success, res, engine);
}
else
{
SetSuccessFlag(success, false, engine);
}
}
else if (m_Name.Equal("GBI")) // GetBootInfo
{
// Gets the NB_info field.
MHERROR("GetBootInfo ResidentProgram is not implemented");
}
else if (m_Name.Equal("CCR")) // CheckContentRef
{
// Sees if an item with a particular content reference is available
// in the carousel. This looks like it should block until the file
// is available. The profile recommends that this should be forked
// rather than called.
if (args.Size() == 3)
{
MHUnion un;
un.GetValueFrom(*(args.GetAt(0)), engine);
un.CheckType(MHUnion::U_ContentRef);
MHContentRef fileName;
fileName.Copy(un.m_ContentRefVal);
QString csPath = engine->GetPathName(fileName.m_ContentRef);
bool result = false;
QByteArray text;
// Try to load the object.
if (! csPath.isEmpty())
{
result = engine->GetContext()->GetCarouselData(csPath, text);
}
// Set the result variable.
MHParameter *pResFlag = args.GetAt(1);
engine->FindObject(*(pResFlag->GetReference()))->SetVariableValue(result);
MHParameter *pResCR = args.GetAt(2);
// Copy the file name to the resulting content ref.
engine->FindObject(*(pResCR->GetReference()))->SetVariableValue(fileName);
SetSuccessFlag(success, true, engine);
}
else
{
SetSuccessFlag(success, false, engine);
}
}
else if (m_Name.Equal("CGR")) // CheckGroupIDRef
{
// Sees if an application or scene with a particular group id
// is available in the carousel.
MHERROR("CheckGroupIDRef ResidentProgram is not implemented");