本文整理汇总了C++中idStr::Empty方法的典型用法代码示例。如果您正苦于以下问题:C++ idStr::Empty方法的具体用法?C++ idStr::Empty怎么用?C++ idStr::Empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类idStr
的用法示例。
在下文中一共展示了idStr::Empty方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LocalizedKeyName
/*
========================
idKeyInput::LocalizedKeyName
========================
*/
const char* idKeyInput::LocalizedKeyName( keyNum_t keynum )
{
// RB
#if defined(_WIN32)
// DG TODO: move this into a win32 Sys_GetKeyName()
if( keynum < K_JOY1 )
{
// On the PC, we want to turn the scan code in to a key label that matches the currently selected keyboard layout
unsigned char keystate[256] = { 0 };
WCHAR temp[5];
int scancode = ( int )keynum;
int vkey = MapVirtualKey( keynum, MAPVK_VSC_TO_VK_EX );
int result = -1;
while( result < 0 )
{
result = ToUnicode( vkey, scancode, keystate, temp, sizeof( temp ) / sizeof( temp[0] ), 0 );
}
if( result > 0 && temp[0] > ' ' && iswprint( temp[0] ) )
{
static idStr bindStr;
bindStr.Empty();
bindStr.AppendUTF8Char( temp[0] );
return bindStr;
}
}
#else // DG: for !Windows I introduced Sys_GetKeyName() to get key label for current keyboard layout
const char* ret = nullptr;
if( keynum < K_JOY1 ) // only for keyboard keys, not joystick or mouse
{
ret = Sys_GetKeyName( keynum );
}
if( ret != NULL )
{
return ret;
}
#endif
// check for a key string
for( keyname_t* kn = keynames; kn->name; kn++ )
{
if( keynum == kn->keynum )
{
return idLocalization::GetString( kn->strId );
}
}
return "????";
// RB/DG end
}
示例2: ReadString
/*
================
idRestoreGame::ReadString
================
*/
void idRestoreGame::ReadString( idStr& string )
{
string.Empty();
int offset = -1;
ReadInt( offset );
if( offset < 0 )
{
return;
}
stringFile->Seek( offset, FS_SEEK_SET );
stringFile->ReadString( string );
return;
}
示例3: ExtractFileExtension
/*
====================
idStr::ExtractFileExtension
====================
*/
void idStr::ExtractFileExtension( idStr &dest ) const {
int pos;
//
// back up until a . or the start
//
pos = Length() - 1;
while( ( pos > 0 ) && ( ( *this )[ pos - 1 ] != '.' ) ) {
pos--;
}
if ( !pos ) {
// no extension
dest.Empty();
} else {
Right( Length() - pos, dest );
}
}
示例4: StripMediaName
/*
=============
idStr::StripMediaName
makes the string lower case, replaces backslashes with forward slashes, and removes extension
=============
*/
void idStr::StripMediaName( const char *name, idStr &mediaName ) {
char c;
mediaName.Empty();
for ( c = *name; c; c = *(++name) ) {
// truncate at an extension
if ( c == '.' ) {
break;
}
// convert backslashes to forward slashes
if ( c == '\\' ) {
mediaName.Append( '/' );
} else {
mediaName.Append( idStr::ToLower( c ) );
}
}
}
示例5: LocalizedKeyName
/*
========================
idKeyInput::LocalizedKeyName
========================
*/
const char* idKeyInput::LocalizedKeyName( keyNum_t keynum )
{
// RB: FIXME
#if defined(_WIN32)
if( keynum < K_JOY1 )
{
// On the PC, we want to turn the scan code in to a key label that matches the currently selected keyboard layout
unsigned char keystate[256] = { 0 };
WCHAR temp[5];
int scancode = ( int )keynum;
int vkey = MapVirtualKey( keynum, MAPVK_VSC_TO_VK_EX );
int result = -1;
while( result < 0 )
{
result = ToUnicode( vkey, scancode, keystate, temp, sizeof( temp ) / sizeof( temp[0] ), 0 );
}
if( result > 0 && temp[0] > ' ' && iswprint( temp[0] ) )
{
static idStr bindStr;
bindStr.Empty();
bindStr.AppendUTF8Char( temp[0] );
return bindStr;
}
}
// check for a key string
for( keyname_t* kn = keynames; kn->name; kn++ )
{
if( keynum == kn->keynum )
{
return idLocalization::GetString( kn->strId );
}
}
return "????";
#else
return KeyNumToString( keynum );
#endif
// RB end
}
示例6: GetRegisterValue
/*
================
idInterpreter::GetRegisterValue
Returns a string representation of the value of the register. This is
used primarily for the debugger and debugging
//FIXME: This is pretty much wrong. won't access data in most situations.
================
*/
bool idInterpreter::GetRegisterValue( const char *name, idStr &out, int scopeDepth ) {
varEval_t reg;
idVarDef *d;
char funcObject[ 1024 ];
char *funcName;
const idVarDef *scope;
const idTypeDef *field;
const idScriptObject *obj;
const function_t *func;
out.Empty();
if ( scopeDepth == -1 ) {
scopeDepth = callStackDepth;
}
if ( scopeDepth == callStackDepth ) {
func = currentFunction;
} else {
func = callStack[ scopeDepth ].f;
}
if ( !func ) {
return false;
}
idStr::Copynz( funcObject, func->Name(), sizeof( funcObject ) );
funcName = strstr( funcObject, "::" );
if ( funcName ) {
*funcName = '\0';
scope = gameLocal.program.GetDef( NULL, funcObject, &def_namespace );
funcName += 2;
} else {
funcName = funcObject;
scope = &def_namespace;
}
// Get the function from the object
d = gameLocal.program.GetDef( NULL, funcName, scope );
if ( !d ) {
return false;
}
// Get the variable itself and check various namespaces
d = gameLocal.program.GetDef( NULL, name, d );
if ( !d ) {
if ( scope == &def_namespace ) {
return false;
}
d = gameLocal.program.GetDef( NULL, name, scope );
if ( !d ) {
d = gameLocal.program.GetDef( NULL, name, &def_namespace );
if ( !d ) {
return false;
}
}
}
reg = GetVariable( d );
switch( d->Type() ) {
case ev_float:
if ( reg.floatPtr ) {
out = va("%g", *reg.floatPtr );
} else {
out = "0";
}
return true;
break;
case ev_vector:
if ( reg.vectorPtr ) {
out = va( "%g,%g,%g", reg.vectorPtr->x, reg.vectorPtr->y, reg.vectorPtr->z );
} else {
out = "0,0,0";
}
return true;
break;
case ev_boolean:
if ( reg.intPtr ) {
out = va( "%d", *reg.intPtr );
} else {
out = "0";
}
return true;
break;
case ev_field:
if ( scope == &def_namespace ) {
// should never happen, but handle it safely anyway
//.........这里部分代码省略.........