本文整理汇总了C++中TVar类的典型用法代码示例。如果您正苦于以下问题:C++ TVar类的具体用法?C++ TVar怎么用?C++ TVar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TVar类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getWVar
bool VarUnit::shouldSave(QTreeWidgetItem* p)
{
TVar* var = getWVar(p);
if (var->getValueType() == 6 || var->isReference()) {
return false;
}
return true;
}
示例2: CompAB
bool CompAB(const TVar& a, const TVar& b, TVarFuncCmp fcmp)
{
bool r = true;
__int64 bi;
double bd;
switch (a.vType)
{
case vtUnknown:
case vtInteger:
switch (b.vType)
{
case vtUnknown:
case vtInteger: r = fcmp(vtInteger,&a.inum,&b.inum); break;
case vtDouble: r = fcmp(vtDouble,&a.inum,&b.dnum); break;
case vtString:
{
switch (checkTypeString(b.asString()))
{
case tsStr: r = fcmp(vtString,a.asString().data(),b.str.data()); break;
case tsInt: bi=b.asInteger(); r = fcmp(vtInteger,&a.inum,&bi); break;
case tsFloat: bd=b.asDouble(); r = fcmp(vtDouble,&a.inum,&bd); break;
}
break;
}
}
break;
case vtDouble:
switch (b.vType)
{
case vtUnknown:
case vtInteger: r = fcmp(vtInteger,&a.dnum,&b.inum); break;
case vtDouble: r = fcmp(vtDouble,&a.dnum,&b.dnum); break;
case vtString:
{
switch (checkTypeString(b.str))
{
case tsStr: r = fcmp(vtString,a.asString().data(),b.str.data()); break;
case tsInt:
case tsFloat: bd=b.asDouble(); r = fcmp(vtDouble,&a.inum,&bd); break;
}
break;
}
}
break;
case vtString:
{
r = fcmp(vtString,a.asString().data(),b.asString().data());
break;
}
}
return r;
};
示例3: shortVarName
QStringList VarUnit::shortVarName(TVar * var){
QStringList names;
if (!var || var->getName() == "_G"){
names << "";
return names;
}
names << var->getName();
TVar * p = var->getParent();
while (p && p->getName() != "_G"){
names.insert(0, p->getName());
p = p->getParent();
}
return names;
}
示例4: varName
QStringList VarUnit::varName(TVar * var){
QStringList names;
names << "_G";
if (var == base || ! var ){
return names;
}
names << var->getName();
TVar * p = var->getParent();
while (p && p != base){
names.insert(1, p->getName());
if (p == base)
break;
p = p->getParent();
}
return names;
}
示例5: it
void VarUnit::buildVarTree(QTreeWidgetItem* p, TVar* var, bool showHidden)
{
QList<QTreeWidgetItem*> cList;
QListIterator<TVar*> it(var->getChildren(true));
while (it.hasNext()) {
TVar* child = it.next();
if (showHidden || !isHidden(child)) {
QStringList s1;
s1 << child->getName();
auto pItem = new QTreeWidgetItem(s1);
pItem->setText(0, child->getName());
pItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDropEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsTristate | Qt::ItemIsUserCheckable);
pItem->setToolTip(0, "Checked variables will be saved and loaded with your profile.");
pItem->setCheckState(0, Qt::Unchecked);
if (isSaved(child)) {
pItem->setCheckState(0, Qt::Checked);
}
if (!shouldSave(child)) { // 6 is lua_tfunction, parent must be saveable as well if not global
pItem->setFlags(pItem->flags() & ~(Qt::ItemIsDropEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsUserCheckable));
pItem->setForeground(0, QBrush(QColor("grey")));
pItem->setToolTip(0, "");
}
pItem->setData(0, Qt::UserRole, child->getValueType());
QIcon icon;
switch (child->getValueType()) {
case 5:
icon.addPixmap(QPixmap(QStringLiteral(":/icons/table.png")), QIcon::Normal, QIcon::Off);
break;
case 6:
icon.addPixmap(QPixmap(QStringLiteral(":/icons/function.png")), QIcon::Normal, QIcon::Off);
break;
default:
icon.addPixmap(QPixmap(QStringLiteral(":/icons/variable.png")), QIcon::Normal, QIcon::Off);
break;
}
pItem->setIcon(0, icon);
wVars.insert(pItem, child);
cList.append(pItem);
if (child->getValueType() == 5) {
buildVarTree((QTreeWidgetItem*)pItem, child, showHidden);
}
}
}
p->addChildren(cList);
}
示例6: if
TVar operator%(const TVar& a, const TVar& b)
{
TVar r;
switch (a.vType)
{
case vtUnknown:
case vtInteger:
{
switch (b.vType)
{
case vtUnknown:
case vtInteger: r = b.inum ? (a.inum % b.inum) : 0; break;
case vtDouble: r = fabs(b.dnum) > DBL_EPSILON? fmod((double)a.inum, b.dnum) : 0.0; break;
case vtString:
{
switch (checkTypeString(b.str))
{
case tsStr: r = a; break;
case tsInt:
{
__int64 bi=b.i();
r = bi ? a.inum % bi : 0; break;
}
case tsFloat:
{
double bd=b.d();
r = fabs(bd) > DBL_EPSILON? fmod((double)a.inum, bd) : 0.0; break;
}
}
break;
}
}
break;
}
case vtDouble:
{
switch (b.vType)
{
case vtUnknown:
case vtInteger: r = b.inum ? fmod(a.dnum,(double)b.inum) : 0.0; break;
case vtDouble: r = fabs(b.dnum) > DBL_EPSILON? fmod(a.dnum,b.dnum) : 0.0; break;
case vtString:
{
switch (checkTypeString(b.str))
{
case tsStr: r = a; break;
case tsInt:
case tsFloat:
{
double bd=b.d();
r = fabs(bd) > DBL_EPSILON? fmod(a.dnum, bd) : 0.0; break;
}
}
break;
}
}
break;
}
case vtString:
{
TypeString tsA=checkTypeString(a.str),tsB;
if (b.vType == vtInteger || b.vType == vtUnknown)
tsB=tsInt;
else if (b.vType == vtDouble)
tsB=tsFloat;
else
tsA=tsB=tsStr;
if ((tsA == tsStr && tsB == tsStr) || (tsA != tsStr && tsB == tsStr) || (tsA == tsStr && tsB != tsStr))
r = a;
else if (tsA == tsInt && tsB == tsInt)
{
__int64 bi=b.i();
r = bi ? (a.i() % bi) : 0;
}
else
{
double bd=b.d();
r = fabs(bd) > DBL_EPSILON? fmod(a.d() , bd) : 0.0;
}
break;
}
}
return r;
};
示例7: CompAB
int TVar::CompAB(const TVar& a, const TVar& b, TVarFuncCmp fcmp)
{
int r = 1;
__int64 bi;
double bd;
switch (a.vType)
{
case vtUnknown:
case vtInteger:
switch (b.vType)
{
case vtUnknown:
case vtInteger: r = fcmp(vtInteger,&a.inum,&b.inum); break;
case vtDouble: r = fcmp(vtDouble,&a.inum,&b.dnum); break;
case vtString:
{
switch (checkTypeString(b.s()))
{
case tsStr: r = fcmp(vtString,a.s(),b.str); break;
case tsInt: bi=b.i(); r = fcmp(vtInteger,&a.inum,&bi); break;
case tsFloat: bd=b.d(); r = fcmp(vtDouble,&a.inum,&bd); break;
}
break;
}
}
break;
case vtDouble:
switch (b.vType)
{
case vtUnknown:
case vtInteger: r = fcmp(vtInteger,&a.dnum,&b.inum); break;
case vtDouble: r = fcmp(vtDouble,&a.dnum,&b.dnum); break;
case vtString:
{
switch (checkTypeString(b.str))
{
case tsStr: r = fcmp(vtString,a.s(),b.str); break;
case tsInt:
case tsFloat: bd=b.d(); r = fcmp(vtDouble,&a.inum,&bd); break;
}
break;
}
}
break;
case vtString:
{
#if defined(TVAR_USE_STRMUN)
__int64 bi;
double bd;
TypeString tsA=checkTypeString(a.str), tsB;
if (b.vType == vtInteger || b.vType == vtUnknown)
tsB=tsInt;
else if (b.vType == vtDouble)
tsB=tsFloat;
else
tsB=checkTypeString(b.str);
if ((tsA == tsStr && tsB == tsStr) || (tsA != tsStr && tsB == tsStr) || (tsA == tsStr && tsB != tsStr))
r = fcmp(vtString,a.s(),b.s());
else if (tsA == tsInt && tsB == tsInt)
{
ai=a.i();
bi=b.i();
r = fcmp(vtInteger,&ai,&bi);
}
else
{
ad=a.d();
bd=b.d();
r = fcmp(vtDouble,&ad,&bd);
}
#else
r = fcmp(vtString,a.s(),b.s());
#endif
break;
}
}
return r;
};
示例8: writeStartElement
//.........这里部分代码省略.........
writeTextElement( "mWhite2", pT->mWhite_2.name() );
writeTextElement( "mLightWhite2", pT->mLightWhite_2.name() );
writeTextElement( "mSpellDic", pT->mSpellDic );
writeTextElement( "mLineSize", QString::number(pT->mLineSize) );
writeTextElement( "mRoomSize", QString::number(pT->mRoomSize) );
writeEndElement(); // end Host tag
writeEndElement(); // end HostPackage tag
writeStartElement( "TriggerPackage" );
bool ret = true;
typedef list<TTrigger *>::const_iterator ItTriggerUnit;
for( ItTriggerUnit it1 = pT->mTriggerUnit.mTriggerRootNodeList.begin(); it1 != pT->mTriggerUnit.mTriggerRootNodeList.end(); it1++)
{
TTrigger * pChildTrigger = *it1;
if( ! pChildTrigger || pChildTrigger->mModuleMember) continue;
if( ! pChildTrigger->isTempTrigger())
{
ret = writeTrigger( pChildTrigger );
}
}
writeEndElement(); //end trigger package tag
writeStartElement("TimerPackage");
typedef list<TTimer *>::const_iterator ItTimerUnit;
for( ItTimerUnit it2 = pT->mTimerUnit.mTimerRootNodeList.begin(); it2 != pT->mTimerUnit.mTimerRootNodeList.end(); it2++)
{
TTimer * pChildTimer = *it2;
if (pChildTimer->mModuleMember) continue;
if( ! pChildTimer->isTempTimer())
{
ret = writeTimer( pChildTimer );
}
}
writeEndElement();
writeStartElement("AliasPackage");
typedef list<TAlias *>::const_iterator ItAliasUnit;
for( ItAliasUnit it3 = pT->mAliasUnit.mAliasRootNodeList.begin(); it3 != pT->mAliasUnit.mAliasRootNodeList.end(); it3++)
{
TAlias * pChildAlias = *it3;
if (pChildAlias->mModuleMember) continue;
if( ! pChildAlias->isTempAlias())
{
ret = writeAlias( pChildAlias );
}
}
writeEndElement();
writeStartElement("ActionPackage");
typedef list<TAction *>::const_iterator ItActionUnit;
for( ItActionUnit it4 = pT->mActionUnit.mActionRootNodeList.begin(); it4 != pT->mActionUnit.mActionRootNodeList.end(); it4++)
{
TAction * pChildAction = *it4;
if (pChildAction->mModuleMember) continue;
ret = writeAction( pChildAction );
}
writeEndElement();
writeStartElement("ScriptPackage");
typedef list<TScript *>::const_iterator ItScriptUnit;
for( ItScriptUnit it5 = pT->mScriptUnit.mScriptRootNodeList.begin(); it5 != pT->mScriptUnit.mScriptRootNodeList.end(); it5++)
{
TScript * pChildScript = *it5;
if (pChildScript->mModuleMember) continue;
ret = writeScript( pChildScript );
}
writeEndElement();
writeStartElement("KeyPackage");
typedef list<TKey *>::const_iterator ItKeyUnit;
for( ItKeyUnit it6 = pT->mKeyUnit.mKeyRootNodeList.begin(); it6 != pT->mKeyUnit.mKeyRootNodeList.end(); it6++)
{
TKey * pChildKey = *it6;
if (pChildKey->mModuleMember) continue;
ret = writeKey( pChildKey );
}
writeEndElement();
writeStartElement("VariablePackage");
LuaInterface * lI = pT->getLuaInterface();
VarUnit * vu = lI->getVarUnit();
//do hidden variables first
writeStartElement("HiddenVariables");
QSetIterator<QString> it8( vu->hiddenByUser );
while( it8.hasNext() )
{
writeTextElement( "name", it8.next() );
}
writeEndElement();
TVar * base = vu->getBase();
QListIterator<TVar *> it7( base->getChildren() );
while( it7.hasNext() )
{
TVar * var = it7.next();
writeVariable( var, lI, vu );
}
writeEndElement();
return ret;
}
示例9: writeStartElement
//.........这里部分代码省略.........
for (auto it = pHost->mTimerUnit.mTimerRootNodeList.begin(); isOk && it != pHost->mTimerUnit.mTimerRootNodeList.end(); ++it) {
if (!(*it) || (*it)->mModuleMember) {
continue;
}
if (!(*it)->isTempTimer()) {
if (!writeTimer(*it)) {
isOk = false;
}
}
}
writeEndElement(); // </TimerPackage>
}
if (isOk) {
writeStartElement("AliasPackage");
for (auto it = pHost->mAliasUnit.mAliasRootNodeList.begin(); isOk && it != pHost->mAliasUnit.mAliasRootNodeList.end(); ++it) {
if (!(*it) || (*it)->mModuleMember) {
continue;
}
if (!(*it)->isTempAlias()) {
if (!writeAlias(*it)) {
isOk = false;
}
}
}
writeEndElement(); // </AliasPackage>
}
if (isOk) {
writeStartElement("ActionPackage");
for (auto it = pHost->mActionUnit.mActionRootNodeList.begin(); isOk && it != pHost->mActionUnit.mActionRootNodeList.end(); ++it) {
if (!(*it) || (*it)->mModuleMember) {
continue;
}
if (!writeAction(*it)) {
isOk = false;
}
}
writeEndElement(); // </ActionPackage>
}
if (isOk) {
writeStartElement("ScriptPackage");
for (auto it = pHost->mScriptUnit.mScriptRootNodeList.begin(); isOk && it != pHost->mScriptUnit.mScriptRootNodeList.end(); ++it) {
if (!(*it) || (*it)->mModuleMember) {
continue;
}
if (!writeScript(*it)) {
isOk = false;
}
}
writeEndElement(); // </ScriptPackage>
}
if (isOk) {
writeStartElement("KeyPackage");
for (auto it = pHost->mKeyUnit.mKeyRootNodeList.begin(); isOk && it != pHost->mKeyUnit.mKeyRootNodeList.end(); ++it) {
if (!(*it) || (*it)->mModuleMember) {
continue;
}
if (!writeKey(*it)) {
isOk = false;
}
}
writeEndElement(); // </KeyPackage>
}
if (isOk) {
writeStartElement("VariablePackage");
LuaInterface* lI = pHost->getLuaInterface();
VarUnit* vu = lI->getVarUnit();
//do hidden variables first
{ // Blocked so that indentation reflects that of the XML file
writeStartElement("HiddenVariables");
QSetIterator<QString> itHiddenVariableName(vu->hiddenByUser);
while (itHiddenVariableName.hasNext()) {
writeTextElement("name", itHiddenVariableName.next());
}
writeEndElement(); // </HiddenVariables>
}
TVar* base = vu->getBase();
if (!base) {
lI->getVars(false);
base = vu->getBase();
}
if (base) {
QListIterator<TVar*> itVariable(base->getChildren(false));
while (isOk && itVariable.hasNext()) {
if (!writeVariable(itVariable.next(), lI, vu)) {
isOk = false;
}
}
}
writeEndElement(); // </VariablePackage>
}
return (isOk && (!hasError()));
}
示例10: prim
static void prim()
{
switch (currTok)
{
case tEnd:
break;
case tFunc:
calcFunc();
getToken();
break;
case tVar:
put(MCODE_OP_PUSHVAR);
putstr(nameString);
getToken();
break;
case tConst:
put(MCODE_OP_PUSHCONST);
putstr(nameString);
getToken();
break;
case tInt:
put(MCODE_OP_PUSHINT);
put64(currVar.i());
getToken();
break;
case tFloat:
put(MCODE_OP_PUSHFLOAT);
putDouble(currVar.d());
getToken();
break;
case tFARVar:
put(FARVar); // nFARVar получаем в getToken()
getToken();
break;
case tStr:
put(MCODE_OP_PUSHSTR);
putstr(currVar.s());
getToken();
break;
case tMinus:
getToken();
prim();
put(MCODE_OP_NEGATE);
break;
case tBitNot:
getToken();
prim();
put(MCODE_OP_BITNOT);
break;
case tNot:
getToken();
prim();
put(MCODE_OP_NOT);
break;
case tLp:
getToken();
expr();
if (currTok != tRp)
keyMacroParseError(err_Expected_Token, L")");
getToken();
break;
case tRp: //???
break;
default:
keyMacroParseError(err_Expr_Expected);
break;
}
}
示例11: getToken
static TToken getToken()
{
oSrcString = sSrcString;
int ch = getNextChar();
bool verbStr=false;
switch (ch)
{
case EOFCH:
case 0: currTok = tEnd; break;
case L',': currTok = tComma; break;
case L'+': currTok = tPlus; break;
case L'-': currTok = tMinus; break;
case L'*': currTok = tMul; break;
case L'/': currTok = tDiv; break;
case L'(': currTok = tLp; break;
case L')': currTok = tRp; break;
case L'^':
if ((ch = getChar()) == L'^')
currTok = tBoolXor;
else
{
putBack(ch);
currTok = tBitXor;
}
break;
case L'~':
if ((ch = getChar()) != L' ')
{
putBack(ch);
currTok = tBitNot;
break;
}
putBack(ch); //????
currTok = tEnd;
break;
case L'|':
if ((ch = getChar()) == L'|')
currTok = tBoolOr;
else
{
putBack(ch);
currTok = tBitOr;
}
break;
case L'&':
if ((ch = getChar()) == L'&')
currTok = tBoolAnd;
else
{
putBack(ch);
currTok = tBitAnd;
}
break;
case L'=':
if ((ch = getChar()) == L'=')
currTok = tEq;
else
{
putBack(ch);
currTok = tLet;
}
break;
case L'>':
switch ((ch = getChar()))
{
case L'=': currTok = tGe; break;
case L'>': currTok = tBitShr; break;
default:
putBack(ch);
currTok = tGt;
break;
}
break;
case L'<':
switch (ch = getChar())
{
case L'=': currTok = tLe; break;
case L'<': currTok = tBitShl; break;
default:
putBack(ch);
currTok = tLt;
break;
}
break;
case L'!':
//.........这里部分代码省略.........