本文整理汇总了C++中QSObject::isString方法的典型用法代码示例。如果您正苦于以下问题:C++ QSObject::isString方法的具体用法?C++ QSObject::isString怎么用?C++ QSObject::isString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSObject
的用法示例。
在下文中一共展示了QSObject::isString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isEqual
QSEqualsResult QSStringClass::isEqual( const QSObject &a, const QSObject &b ) const
{
Q_ASSERT( a.isA( this ) );
if ( b.isString() )
return (QSEqualsResult) (a.sVal() == b.sVal() || (a.sVal().isEmpty() && b.sVal().isEmpty()));
else if ( b.isNumber() )
return ( QSEqualsResult ) ( a.sVal() == b.toString() );
else if ( !b.isPrimitive() )
return isEqual( a, b.toPrimitive() );
else
return EqualsUndefined;
}
示例2: isEqual
QSEqualsResult QSNumberClass::isEqual( const QSObject &a, const QSObject &b ) const
{
Q_ASSERT( a.isA( this ) );
if ( b.isNumber() ) {
double n1 = a.dVal();
double n2 = b.dVal();
if ( isNaN( n1 ) || isNaN( n2 ) )
return EqualsNotEqual;
else
return ( QSEqualsResult ) ( n1 == n2 );
// ### compare -0 agains +0
} else if ( b.isString() ) {
return ( QSEqualsResult ) ( a.dVal() == b.toNumber() );
} else if ( !b.isPrimitive() ) {
return isEqual( a, b.toPrimitive() );
} else {
return EqualsUndefined;
}
}
示例3: qsEval
// eval()
static QSObject qsEval( QSEnv *env )
{
QSObject x = env->arg( 0 );
if ( !x.isString() ) {
return x;
} else {
QSEngineImp *eimp = env->engine()->imp();
QString s = x.toString();
QSNode *progNode = 0;
{ // begin mutext locker
QMutexLocker locker(qsa_lexer_mutex());
QSLexer::lexer()->setCode( s,
#ifdef QSDEBUGGER
eimp->sourceId()
#else
0
#endif
);
int yp = qsyyparse();
progNode = QSProgramNode::last();
if ( yp || QSLexer::lexer()->lexerState() == QSLexer::Bad ) {
if (!progNode && progNode->deref())
delete progNode;
return env->throwError( SyntaxError );
}
} // end mutext locker
QSCheckData data( env );
QSObject scopeTop = env->currentScope();
postfixAdd( scopeTop.objectType(), &data );
QSEvalScopeClass *cl = new QSEvalScopeClass( env->objectClass() );
data.enterEval( cl );
progNode->check( &data );
if ( data.hasError() ) {
if (!progNode->deref())
delete progNode;
return env->throwError( EvalError,
data.errorMessages().first(),
data.errorLines().first() );
}
QSList empty;
env->pushScope( cl->construct( empty ) );
// ### delete tmp scope class
QSObject res = ((QSProgramNode*)progNode)->execute( env );
if (!progNode->deref())
delete progNode;
env->popScope();
if ( env->isReturnValueMode() )
return res;
else if ( env->isNormalMode() ) {
if ( res.isValid() )
return res;
else
return env->createUndefined();
} else
return res;
}
}