本文整理汇总了C++中MHUnion::CheckType方法的典型用法代码示例。如果您正苦于以下问题:C++ MHUnion::CheckType方法的具体用法?C++ MHUnion::CheckType怎么用?C++ MHUnion::CheckType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MHUnion
的用法示例。
在下文中一共展示了MHUnion::CheckType方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例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: 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;
}
示例4: GetValue
// 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);
}
}
}
示例5: 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;
}
示例6: 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);
}
示例7: Perform
void MHAppend::Perform(MHEngine *engine)
{
MHUnion targetVal;
// Find the target and get its current value. The target can be an indirect reference.
MHObjectRef parm;
m_Target.GetValue(parm, engine);
MHRoot *pTarget = engine->FindObject(parm);
pTarget->GetVariableValue(targetVal, engine);
targetVal.CheckType(MHUnion::U_String);
// Get the string to append.
MHOctetString toAppend;
m_Operand.GetValue(toAppend, engine);
targetVal.m_StrVal.Append(toAppend); // Add it on the end
pTarget->SetVariableValue(targetVal); // Set the target to the result.
}
示例8: 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);
}
}
示例9: SetVariableValue
// 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()));
}
示例10: 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));
}
示例11: CallProgram
//.........这里部分代码省略.........
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");
}
else if (m_Name.Equal("VTG")) // VideoToGraphics