本文整理汇总了C++中ds::String::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ String::empty方法的具体用法?C++ String::empty怎么用?C++ String::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ds::String
的用法示例。
在下文中一共展示了String::empty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool ds::StringTable::Open( const ds::String& Filename, ds::String& Language )
{
BoostXmlTree Tree;
try
{
boost::property_tree::read_xml( Filename, Tree );
}
catch( const std::exception& e )
{
dsPushError( "%s", e.what( ) );
return false;
}
Tree = Tree.get_child( "translate" );
if( Language.empty( ) )
Language = Tree.get< ds::String >( "<xmlattr>.default", "eng" );
for( auto It = Tree.begin( ); It != Tree.end( ); It++ )
if( It->first == "lang" && It->second.get< ds::String >( "<xmlattr>.id" ) == Language )
for( auto Line = It->second.begin( ); Line != It->second.end( ); Line++ )
if( Line->first == "string" )
{
ds::String Text = ds::String( Line->second.data( ).begin( ), Line->second.data( ).end( ) );
for ( unsigned i = 0; i < Text.size( ); i++ )
{
if( ( int)Text[ i ] == 92 )
Text[ i ] = '\n';
}
Set( Line->second.get< ds::String >( "<xmlattr>.id", ""), Text );
}
return true;
}
示例2: VideoMode
bool ds::Render::Create( HWND Handle, const ds::String& BasicEffect )
{
g_SwapChain.OutputWindow = Handle;
RECT Rect;
GetClientRect( Handle, &Rect );
g_SwapChain.BufferDesc.Width = ( unsigned ) Rect.right - ( unsigned ) Rect.left;
g_SwapChain.BufferDesc.Height = ( unsigned ) Rect.bottom - ( unsigned ) Rect.top;
for( unsigned i = 0; i < 2; i++ )
{
if( SUCCEEDED( D3D10CreateDeviceAndSwapChain(
nullptr,
( D3D10_DRIVER_TYPE )i,
nullptr,
0,
D3D10_SDK_VERSION,
&g_SwapChain,
&Swap,
&Device
) ) )
{
if( ( D3D10_DRIVER_TYPE )i == D3D10_DRIVER_TYPE_REFERENCE )
dsPushMessage( ErrRenderCreateDevice );
break;
}
}
if( !Device )
{
dsPushErrorStatic( ErrRenderCreateDevice );
return false;
}
IDXGIOutput* l_Info;
unsigned l_ModesCount = 0;
Swap->GetContainingOutput( &l_Info );
l_Info->GetDisplayModeList( g_SwapChain.BufferDesc.Format,
0, &l_ModesCount, nullptr );
DXGI_MODE_DESC* l_Modes = new DXGI_MODE_DESC[l_ModesCount];
l_Info->GetDisplayModeList( g_SwapChain.BufferDesc.Format,
0, &l_ModesCount, l_Modes );
for( unsigned i = 0; i < l_ModesCount; i++ )
VideoModes.push_back( VideoMode( ds::Size( l_Modes[i].Width, l_Modes[i].Height ), l_Modes[i].RefreshRate.Numerator / l_Modes[i].RefreshRate.Denominator ) );
delete[] l_Modes;
l_Info->Release( );
ID3D10Texture2D* l_BackBuffer = nullptr;
if( FAILED( Swap->GetBuffer( 0, __uuidof( ID3D10Texture2D ), ( LPVOID* )&l_BackBuffer ) ) )
return false;
if( FAILED( Device->CreateRenderTargetView( l_BackBuffer, nullptr, &RenderTargetView ) ) )
return false;
l_BackBuffer->Release( );
CreateDepthBuffer( ds::Size(
g_SwapChain.BufferDesc.Width,
g_SwapChain.BufferDesc.Height
) );
Device->OMSetRenderTargets( 1, &RenderTargetView, DepthBufferEnable ? DepthStencilView : nullptr );
Device->RSSetViewports( 1, &g_ViewPort );
SetRenderRect( v4<unsigned>( 0, 0,
g_SwapChain.BufferDesc.Width,
g_SwapChain.BufferDesc.Height ) );
if( !BasicEffect.empty( ) )
Effect = new ds::BasicEffect( BasicEffect, "Render" );
else
Effect = nullptr;
SetRenderMode( 1 );
SetView( v2<unsigned>(
g_SwapChain.BufferDesc.Width, g_SwapChain.BufferDesc.Height ),
v2<unsigned>( g_ViewPort.TopLeftX, g_ViewPort.TopLeftY ),
g_ViewPort.MinDepth, g_ViewPort.MaxDepth );
ds::Clock::Reset( );
return true;
}