本文整理汇总了C++中ToBool函数的典型用法代码示例。如果您正苦于以下问题:C++ ToBool函数的具体用法?C++ ToBool怎么用?C++ ToBool使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ToBool函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TYPESAFE_DOWNCAST
//
/// Called by EvHelp() to activate the help file with the help context ID.
//
void
THelpFileManager::ActivateHelp(TWindow* /*window*/, int helpFileContextId, uint helpCmd)
{
if (helpCmd == HELP_INDEX || helpCmd == HELP_CONTENTS)
helpCmd = HELP_FINDER;
TApplication* app = TYPESAFE_DOWNCAST(this, TApplication);
#if !defined(NO_HTMLHELP)
if(UseHTMLHelp){
if (app)
HelpState = ToBool(HtmlHelp(app->GetMainWindow(), GetHelpFile().c_str(),
helpCmd, helpFileContextId) != 0);
else
HelpState = ToBool(HtmlHelp(0, GetHelpFile().c_str(),
helpCmd, helpFileContextId) != 0);
}
else{
#endif
if (app)
HelpState = ToBool(app->GetMainWindow()->WinHelp(GetHelpFile().c_str(),
helpCmd, helpFileContextId));
else
HelpState = ToBool(::WinHelp(0, GetHelpFile().c_str(),
helpCmd, helpFileContextId));
#if !defined(NO_HTMLHELP)
}
#endif
}
示例2: LogWarning
void AnimationController::PlayAnimAutoStop(const String &name, const String &fadein, const String &exclusive)
{
if (!name.Length())
{
LogWarning("Empty animation name for PlayAnimAutoStop");
return;
}
float fadein_ = 0.0f;
if (fadein.Length())
fadein_ = ToFloat(fadein);
bool exclusive_ = false;
if (exclusive.Length())
exclusive_ = ToBool(exclusive);
bool success;
if (exclusive_)
success = EnableExclusiveAnimation(name, false, fadein_, false);
else
success = EnableAnimation(name, false, fadein_, false);
if (!success)
{
StringVector anims = AvailableAnimations();
void (*log)(const String &) = LogDebug; if (anims.Size() > 0) log = LogWarning;
log("Failed to play animation \"" + name + "\" on entity " + ParentEntity()->Name());
log("The entity has " + String(anims.Size()) + " animations available: " + Join(anims, ","));
// Enable autostop, and start always from the beginning
SetAnimationAutoStop(name, true);
SetAnimationTimePosition(name, 0.0f);
}
}
示例3: PRECONDITION
bool
TListViewCtrl::GetColumn(int index, LVCOLUMN* column)
{
PRECONDITION(column);
PRECONDITION(GetHandle());
return ToBool(SendMessage(LVM_GETCOLUMN, TParam1(index), TParam2(column)));
}
示例4: InitializeWindow
//--------------------------------------------------------------------------------
// @ InitializeWindow()
//--------------------------------------------------------------------------------
// Initialize WINDOW
//--------------------------------------------------------------------------------
static bool InitializeWindow()
{
//Fullscreen?
std::string str;
bool fullscreen = false;
if (global::SETTINGS->GetValue("fullscreen", str))
{
fullscreen = ToBool(str);
}
//Dimensions
uint32 h = 200, w = 200;
if (global::SETTINGS->GetValue("screen_height", str))
{
StringToNumber(h, str, std::dec);
}
if (global::SETTINGS->GetValue("screen_width", str))
{
StringToNumber(w, str, std::dec);
}
global::WINDOW = new WindowManager( w, h, fullscreen, "My Game");
//If everything initialized fine
return true;
} //End: InitializeWindow()
示例5: ToBool
void FFlagCVar::DoSet (UCVarValue value, ECVarType type)
{
bool newval = ToBool (value, type);
// Server cvars that get changed by this need to use a special message, because
// changes are not processed until the next net update. This is a problem with
// exec scripts because all flags will base their changes off of the value of
// the "master" cvar at the time the script was run, overriding any changes
// another flag might have made to the same cvar earlier in the script.
if ((ValueVar.GetFlags() & CVAR_SERVERINFO) && gamestate != GS_STARTUP && !demoplayback)
{
if (netgame && !players[consoleplayer].settings_controller)
{
Printf ("Only setting controllers can change %s\n", Name);
return;
}
D_SendServerFlagChange (&ValueVar, BitNum, newval);
}
else
{
int val = *ValueVar;
if (newval)
val |= BitVal;
else
val &= ~BitVal;
ValueVar = val;
}
}
示例6: ToBool
bool
TListViewCtrl::SortItemsEx(const TCompareFunc& comparator, LPARAM lParam)
{
TListCompareThunk ct;
ct.This = &comparator;
ct.ItemData = lParam;
return ToBool(SendMessage(LVM_SORTITEMSEX, TParam1(&ct), TParam2(OwlListViewCompare)));
}
示例7: TYPESAFE_DOWNCAST
//------------------------------------------------------------------------------
//
bool
TGadgetListBox::IsFlat()
{
TGadgetWindow* wnd = TYPESAFE_DOWNCAST(GetParentO(),TGadgetWindow);
if(wnd)
return ToBool(wnd->GetFlatStyle()&TGadgetWindow::FlatStandard);
return false;
}
示例8: Variant
Variant Material::ParseShaderParameterValue(const String& value)
{
String valueTrimmed = value.Trimmed();
if (valueTrimmed.Length() && IsAlpha(valueTrimmed[0]))
return Variant(ToBool(valueTrimmed));
else
return ToVectorVariant(valueTrimmed);
}
示例9: lua_getfield
BOOL CLuaBase::GetFieldToBool( int nStackPos, char* szName )
{
int bValue = 0;
lua_getfield( m_pLuaState, nStackPos, szName );
if( lua_isboolean( m_pLuaState, -1 ) )
bValue = ToBool( -1 );
Pop( 1 );
return (bValue == 0 ? FALSE : TRUE );
}
示例10: SetIndividualLambdas
void CSMMSeqPair::XMLParameters(TiXmlNode *node)
{
if(node->FirstChild("IndividualLambdas"))
SetIndividualLambdas(ToBool(node->FirstChild("IndividualLambdas")));
if(node->FirstChild("PairCoefCriteria"))
SetPairCoefCriteria(ToUInt(node->FirstChild("PairCoefCriteria")->FirstChild("MinCount")),ToDouble(node->FirstChild("PairCoefCriteria")->FirstChild("MaxDisagrement")));
if(node->FirstChild("SMMParameters"))
m_smm.XMLParameters(node->FirstChild("SMMParameters"));
}
示例11: lua_getglobal
BOOL CLuaBase::GetGlobalBool( char* szName )
{
BOOL bValue = FALSE;
lua_getglobal( m_pLuaState, szName );
if( lua_isboolean( m_pLuaState, -1 ) )
bValue = ToBool( -1 );
Pop( 1 );
return bValue;
}
示例12: switch
void* Service::ConvertToParameterPtr( int nTypeId,
const QString &sParamType,
void* pParam,
const QString &sValue )
{
// -=>NOTE: Only intrinsic or Qt type conversions should be here
// All others should be added to overridden implementation.
switch( nTypeId )
{
case QMetaType::Bool : *(( bool *)pParam) = ToBool( sValue ); break;
case QMetaType::Char : *(( char *)pParam) = ( sValue.length() > 0) ? sValue.at( 0 ).toAscii() : 0; break;
case QMetaType::UChar : *(( unsigned char *)pParam) = ( sValue.length() > 0) ? sValue.at( 0 ).toAscii() : 0; break;
case QMetaType::QChar : *(( QChar *)pParam) = ( sValue.length() > 0) ? sValue.at( 0 ) : 0; break;
case QMetaType::Short : *(( short *)pParam) = sValue.toShort (); break;
case QMetaType::UShort : *(( ushort *)pParam) = sValue.toUShort (); break;
case QMetaType::Int : *(( int *)pParam) = sValue.toInt (); break;
case QMetaType::UInt : *(( uint *)pParam) = sValue.toUInt (); break;
case QMetaType::Long : *(( long *)pParam) = sValue.toLong (); break;
case QMetaType::ULong : *(( ulong *)pParam) = sValue.toULong (); break;
case QMetaType::LongLong : *(( qlonglong *)pParam) = sValue.toLongLong (); break;
case QMetaType::ULongLong : *(( qulonglong *)pParam) = sValue.toULongLong (); break;
case QMetaType::Double : *(( double *)pParam) = sValue.toDouble (); break;
case QMetaType::Float : *(( float *)pParam) = sValue.toFloat (); break;
case QMetaType::QString : *(( QString *)pParam) = sValue; break;
case QMetaType::QByteArray : *(( QByteArray *)pParam) = sValue.toUtf8 (); break;
case QMetaType::QDateTime :
{
QDateTime dt = QDateTime::fromString( sValue, Qt::ISODate );
dt.setTimeSpec(Qt::UTC);
*(( QDateTime *)pParam) = dt.toLocalTime();
break;
}
case QMetaType::QTime : *(( QTime *)pParam) = QTime::fromString ( sValue, Qt::ISODate ); break;
case QMetaType::QDate : *(( QDate *)pParam) = QDate::fromString ( sValue, Qt::ISODate ); break;
}
return pParam;
}
示例13: PRECONDITION
//
/// Constructs a TCelArray from a bitmap by slicing the bitmap into a horizontal
/// array of cels of a specified size. If autoDelete is true, TCelArray can
/// automatically delete the bitmap. The ShouldDelete data member defaults to true,
/// ensuring that the handle will be deleted when the bitmap is destroyed. If
/// numRows is 0, the number of rows is calculated using the bitmap height and the
/// celSize y parameter.
//
TCelArray::TCelArray(TBitmap* bmp, int numCels, TSize celSize,
TPoint offset, int numRows, TAutoDelete autoDelete)
{
PRECONDITION(bmp);
NGrowBy = 1;
NCels = NCelsUsed = std::max(1, numCels);
NRows = std::max(1, numRows);
CSize = celSize.cx && celSize.cy ?
celSize :
TSize(bmp->Width() / NCels, bmp->Height() / NRows);
Offs = offset;
NCurRow = 0;
ShouldDelete = ToBool(autoDelete == AutoDelete);
Bitmap = bmp;
TRACEX(OwlGadget, OWL_CDLEVEL, "TCelArray constructed @" << (void*)this <<
" from slicing the bitmap @" << (void*)bmp);
}
示例14: ToBool
bool XMLElement::GetBool(const ea::string& name) const
{
return ToBool(GetAttribute(name));
}
示例15: test
void test()
{
// This function tests C++0x 5.16
// p1 (contextually convert to bool)
int i1 = ToBool() ? 0 : 1;
// p2 (one or both void, and throwing)
i1 ? throw 0 : throw 1;
i1 ? test() : throw 1;
i1 ? throw 0 : test();
i1 ? test() : test();
i1 = i1 ? throw 0 : 0;
i1 = i1 ? 0 : throw 0;
i1 ? 0 : test(); // expected-error {{right operand to ? is void, but left operand is of type 'int'}}
i1 ? test() : 0; // expected-error {{left operand to ? is void, but right operand is of type 'int'}}
(i1 ? throw 0 : i1) = 0; // expected-error {{expression is not assignable}}
(i1 ? i1 : throw 0) = 0; // expected-error {{expression is not assignable}}
// p3 (one or both class type, convert to each other)
// b1 (lvalues)
Base base;
Derived derived;
Convertible conv;
Base &bar1 = i1 ? base : derived;
Base &bar2 = i1 ? derived : base;
Base &bar3 = i1 ? base : conv;
Base &bar4 = i1 ? conv : base;
// these are ambiguous
BadBase bb;
BadDerived bd;
(void)(i1 ? bb : bd); // expected-error {{conditional expression is ambiguous; 'BadBase' can be converted to 'BadDerived' and vice versa}}
(void)(i1 ? bd : bb); // expected-error {{conditional expression is ambiguous}}
// curiously enough (and a defect?), these are not
// for rvalues, hierarchy takes precedence over other conversions
(void)(i1 ? BadBase() : BadDerived());
(void)(i1 ? BadDerived() : BadBase());
// b2.1 (hierarchy stuff)
extern const Base constret();
extern const Derived constder();
// should use const overload
A a1((i1 ? constret() : Base()).trick());
A a2((i1 ? Base() : constret()).trick());
A a3((i1 ? constret() : Derived()).trick());
A a4((i1 ? Derived() : constret()).trick());
// should use non-const overload
i1 = (i1 ? Base() : Base()).trick();
i1 = (i1 ? Base() : Base()).trick();
i1 = (i1 ? Base() : Derived()).trick();
i1 = (i1 ? Derived() : Base()).trick();
// should fail: const lost
(void)(i1 ? Base() : constder()); // expected-error {{incompatible operand types ('Base' and 'const Derived')}}
(void)(i1 ? constder() : Base()); // expected-error {{incompatible operand types ('const Derived' and 'Base')}}
Priv priv;
Fin fin;
(void)(i1 ? Base() : Priv()); // expected-error{{private base class}}
(void)(i1 ? Priv() : Base()); // expected-error{{private base class}}
(void)(i1 ? Base() : Fin()); // expected-error{{ambiguous conversion from derived class 'Fin' to base class 'Base':}}
(void)(i1 ? Fin() : Base()); // expected-error{{ambiguous conversion from derived class 'Fin' to base class 'Base':}}
(void)(i1 ? base : priv); // expected-error {{private base class}}
(void)(i1 ? priv : base); // expected-error {{private base class}}
(void)(i1 ? base : fin); // expected-error {{ambiguous conversion from derived class 'Fin' to base class 'Base':}}
(void)(i1 ? fin : base); // expected-error {{ambiguous conversion from derived class 'Fin' to base class 'Base':}}
// b2.2 (non-hierarchy)
i1 = i1 ? I() : i1;
i1 = i1 ? i1 : I();
I i2(i1 ? I() : J());
I i3(i1 ? J() : I());
// "the type [it] woud have if E2 were converted to an rvalue"
vfn pfn = i1 ? F() : test;
pfn = i1 ? test : F();
(void)(i1 ? A() : B()); // expected-error {{conversion from 'B' to 'A' is ambiguous}}
(void)(i1 ? B() : A()); // expected-error {{conversion from 'B' to 'A' is ambiguous}}
(void)(i1 ? 1 : Ambig()); // expected-error {{conversion from 'Ambig' to 'int' is ambiguous}}
(void)(i1 ? Ambig() : 1); // expected-error {{conversion from 'Ambig' to 'int' is ambiguous}}
// By the way, this isn't an lvalue:
&(i1 ? i1 : i2); // expected-error {{address expression must be an lvalue or a function designator}}
// p4 (lvalue, same type)
Fields flds;
int &ir1 = i1 ? flds.i1 : flds.i2;
(i1 ? flds.b1 : flds.i2) = 0;
(i1 ? flds.i1 : flds.b2) = 0;
(i1 ? flds.b1 : flds.b2) = 0;
// p5 (conversion to built-in types)
// GCC 4.3 fails these
double d1 = i1 ? I() : K();
pfn = i1 ? F() : G();
DFnPtr pfm;
pfm = i1 ? DFnPtr() : &Base::fn1;
pfm = i1 ? &Base::fn1 : DFnPtr();
// p6 (final conversions)
i1 = i1 ? i1 : ir1;
int *pi1 = i1 ? &i1 : 0;
pi1 = i1 ? 0 : &i1;
//.........这里部分代码省略.........