本文整理匯總了C++中Except函數的典型用法代碼示例。如果您正苦於以下問題:C++ Except函數的具體用法?C++ Except怎麽用?C++ Except使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Except函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: Except
int
P4ClientApi::FormatSpec( const char * type, int table )
{
if ( !specMgr.HaveSpecDef( type ) )
{
StrBuf m;
m = "No spec definition for ";
m.Append( type );
m.Append( " objects." );
return Except( "P4#format_spec", m.Text() );
}
// Got a specdef so now we can attempt to convert.
StrBuf buf;
Error e;
specMgr.SpecToString( type, table, buf, &e );
if( !e.Test() ) {
lua_pushstring( L, buf.Text() );
return 1;
}
StrBuf m;
m = "Error converting hash to a string.";
if( e.Test() ) e.Fmt( m, EF_PLAIN );
return Except( "P4#format_spec", m.Text() );
}
示例2: fprintf
int P4ClientAPI::SetCharset( const char *c )
{
if( P4LUADEBUG_COMMANDS )
fprintf( stderr, "[P4] Setting charset: %s\n", c );
CharSetApi::CharSet cs = CharSetApi::NOCONV;
if ( strlen(c) > 0 ) {
cs = CharSetApi::Lookup( c );
if( cs < 0 )
{
if( exceptionLevel )
{
StrBuf m;
m = "Unknown or unsupported charset: ";
m.Append( c );
return Except( "P4.charset", m.Text() );
}
return 0;
}
}
if( CharSetApi::Granularity( cs ) != 1 ) {
return Except( "P4.charset", "P4Lua does not support a wide charset!");
}
client.SetCharset(c);
client.SetTrans( cs, cs, cs, cs );
return 1;
}
示例3: Except
//--------------------------------------------------------------------------------------------------------------
//創建二維紋理
Texture* D3D9TextureManager::CreateTexture( UINT nWidth, UINT nHeight, PixelFormat ePixelFormat,
TextureUsage Type, int nNumLevels )
{
//如果為壓縮紋理格式
if( ePixelFormat & PF_COMPRESS_MASK )
{
//檢測指定紋理壓縮格式是否可用
if( !CheckCompressFormat( ePixelFormat ) )
Except( Exception::ERR_INTERNAL_ERROR, "硬件不支持指定的紋理壓縮格式,無法創建紋理。" );
if( !IsPow2( nWidth ) || !IsPow2( nHeight ) )
Except( Exception::ERR_INTERNAL_ERROR, "無法創建非 2 次冪尺寸的壓縮紋理。" );
}
//獲取最佳的紋理尺寸
UINT texWidth = 0;
UINT texHeight = 0;
GetBestSize( nWidth, nHeight, texWidth, texHeight );
nNumLevels = (UINT)( ( nNumLevels == -1 ) ? mDefTexLevels : nNumLevels );
Texture* pTex = new D3D9Texture( texWidth, texHeight, ePixelFormat, nNumLevels, Type );
*mTextureList.Push() = pTex;
++mNumTextures;
return pTex;
}
示例4: Except
//--------------------------------------------------------------------------------------------------------------
TextSurface::TextSurface( ZOrderType eZType, OverlaySurface* pZRefOverlay, FontFace* pFont, LPCWSTR szText,
int nX, int nY, int nLineWidth, int nMaxChars, DWORD dwColor, TextureFilterType eFilterType )
:OverlaySurface ( eZType, pZRefOverlay, eFilterType )
,mpFont (pFont)
, mpText (NULL)
, mNumChars (0)
, mX (nX)
, mY (nY)
, mLineWidth (nLineWidth)
, mTextColor (dwColor)
{
if( nX + mpFont->mnMaxWidth > nLineWidth )
Except( Exception::ERR_INVALIDPARAMS, "指定平麵文字行寬度過小。" );
//計算字符串長度
int nNumChars = 0;
wchar_t* pChar = (wchar_t*)szText;
while( *pChar != 0 )
{
++pChar;
++nNumChars;
}
//如果未指定最大字符數量則使用當前字符串字符數量
if( nMaxChars == 0 )
mMaxChars = nNumChars;
else if( nMaxChars < nNumChars )
Except( Exception::ERR_INVALIDPARAMS, "指定的最大字符數量小於當前文字字符數量。" );
else
mMaxChars = nMaxChars;
mNumChars = nNumChars;
//分配內存
size_t nStrLen = sizeof(wchar_t) * ( mMaxChars + 1 );
size_t nDrawLen = sizeof(FontFace::GlyphDraw) * mMaxChars;
BYTE* pMem = (BYTE*)malloc( nStrLen + nDrawLen + sizeof(OverlayVertex)*6*mMaxChars );
//複製字符串
mpText = (wchar_t*)pMem;
memcpy( mpText, szText, sizeof(wchar_t) * ( mNumChars + 1 ) );
//分配字形數據緩存
mpGlyphDraw = (FontFace::GlyphDraw*)( pMem + nStrLen );
memset( mpGlyphDraw, 0, nDrawLen );
//分配頂點數據緩存
mpVertexData = (OverlayVertex*)( pMem + nStrLen + nDrawLen );
mpVertexPtr = mpVertexData;
mNumVertex = 0;
//更新文字數據
_UpdateText();
}
示例5: throw
float CNProbeSet::getIntensityContrast(double dK)
{
if ((m_fAMedianIntensity + m_fBMedianIntensity) == 0) {
throw(Except("Zero median intensities found. CEL file may be corrupted."));
}
float fContrast = (float)(sinh(dK * (m_fAMedianIntensity - m_fBMedianIntensity) / (m_fAMedianIntensity + m_fBMedianIntensity)) / sinh(dK));
if (fabs(fContrast) > 1) {
throw(Except("Can't have abs(contrast) > 1."));
}
return fContrast;
}
示例6: Except
//--------------------------------------------------------------------------------------------------------------
//創建紋理狀態
TextureState* Material::CreateTextureState( UINT nStage )
{
if( mppTextureState[nStage] != NULL )
Except( Exception::ERR_INVALIDPARAMS, "指定的紋理狀態已經存在,無法重複創建。" );
if( nStage >= RenderSystem::mpSingleton->mMaxTextureNum )
Except( Exception::ERR_INTERNAL_ERROR, "無法超過支持的紋理狀態最大限,創建紋理狀態失敗。" );
mppTextureState[nStage] = new TextureState;
return mppTextureState[nStage];
}
示例7: _SyncOperation
//--------------------------------------------------------------------------------------------------------------
//讀取文件數據
void BaseFile::Read( void* pBuf, DWORD dwLen )
{
//如果最後進行的緩存操作不是讀取操作
if( mLastBuffedOp != BOT_Read )
_SyncOperation();
BYTE* pDstBuf = (BYTE*)pBuf;
while( dwLen != 0 )
{
//如果緩存中已存在數據
if( mdwCachedLen != 0 )
{
//讀取緩存中的剩餘數據
DWORD dwCopyLen = ( dwLen < mdwCachedLen ) ? dwLen : mdwCachedLen;
memcpy( pBuf, mpCachePtr, dwCopyLen );
mdwCachedLen -= dwCopyLen;
mpCachePtr += dwCopyLen;
dwLen -= dwCopyLen;
pDstBuf += dwCopyLen;
}
//如果緩存中已不存在數據且讀取長度大於等於緩存長度
else if( dwLen >= mCacheLen )
{
//直接從文件中讀取數據
if( dwLen != _InternalRead( pDstBuf, dwLen ) )
Except( Exception::ERR_CANNOT_READ_FILE, STR_ERR_READ_LEN );
break;
}
//如果緩存中已不存在數據且讀取長度小於緩存長度
else
{
//從文件中讀取數據填充緩存
DWORD dwReadLen = _InternalRead( mpCache, mCacheLen );
if( dwReadLen < dwLen )
Except( Exception::ERR_CANNOT_READ_FILE, STR_ERR_READ_LEN );
//從緩存中讀取指定長度的數據
memcpy( pDstBuf, mpCache, dwLen );
mpCachePtr = mpCache + dwLen;
mdwCachedLen = dwReadLen - dwLen;
break;
}
}
//記錄最後的緩存操作類型
mLastBuffedOp = BOT_Read;
mPosition += dwLen;
}
示例8: runImp
/**
* @brief Run the copy number ratio engine. The copy number ratio engine will inturn call the copy number engine.
* @param CopyNumberOptions* - The options to run with.
* @return int - 0 if successful else 1
*/
void CNReferenceEngine::runImp()
{
try
{
m_data.setEngine(m_pEngine);
uint64_t memAvail = ::getDouble(m_pEngine->getOpt("free-mem-at-start"));
if (memAvail >= (2000 * MEGABYTE))
{
m_pEngine->setOpt("mem-usage", "2000");
}
else
{
int iMemUsage = (memAvail / MEGABYTE);
m_pEngine->setOpt("mem-usage", ::getInt(iMemUsage));
}
m_data.loadAnnotation(true);
m_iProbeSetCount = m_data.getProbeSets()->getCount();
m_iExperimentCount = m_data.loadExperiments(m_pEngine->getOpt("expr-summary-file"));
if (m_iExperimentCount == 0) {throw(Except("No experiments to process."));}
if (m_iProbeSetCount == 0) {throw(Except("No probesets to process."));}
if (!determineMemoryUsage()) {return;}
if (!processData()) {return;}
m_pEngine->setOpt("sample-count", ::getInt(m_iExperimentCount));
if (!m_data.writeModelFile(m_pEngine->getOpt("reference-file"))) {return;}
if (m_pEngine->isOptDefined("wave-correction-reference-method"))
{
if ((m_pEngine->getOpt("wave-correction-reference-method") != "none") && (m_pEngine->getOpt("wave-correction-reference-method") != ""))
{
CNAnalysisMethodFactory amFactory;
CNAnalysisMethod* am = NULL;
am = amFactory.CNAnalysisMethodForString(m_pEngine->getOpt("wave-correction-reference-method"));
am->setEngine(m_pEngine);
am->run();
delete am;
}
}
if ((m_pEngine->isOptDefined("temp-reference-file")) && (m_pEngine->getOpt("temp-reference-file") != ""))
{
Fs::rm(m_pEngine->getOpt("temp-reference-file"));
}
clear();
}
catch(...) {m_data.clear(); throw;}
}
示例9: Except
int P4ClientAPI::Except( const char *func, Error *e )
{
StrBuf m;
e->Fmt( &m );
return Except( func, m.Text() );
}
示例10: ResetFlags
int P4ClientAPI::ConnectOrReconnect()
{
if( IsTrackMode() )
client.SetProtocol( "track", "" );
Error e;
ResetFlags();
client.Init( &e );
if ( e.Test() && exceptionLevel ) {
return Except( "P4:connect()", &e );
}
if ( e.Test() )
return 0;
// If an iterator is defined, reset the break functionality
// for the KeepAlive function
if( ui.GetHandler() != LUA_NOREF )
{
client.SetBreak( &ui );
}
SetConnected();
lua_pushboolean( L, true );
return 1;
}
示例11: switch
//--------------------------------------------------------------------------------------------------------------
//建立新二叉樹分割麵
void BSPGenerator::_BuildNewPlane3( WORD pVerIndex[4], int nNumVer, BSPPlaneList* pNewPlane3List )
{
//根據頂點數量判斷建立的三角麵數量
switch (nNumVer)
{
case 3:
{
*pNewPlane3List->Push() = mpPlane3Buf + mNumFace;
mpPlane3Buf[ mNumFace++ ].SetFromPoints( mpVertexBuf, pVerIndex[0], pVerIndex[1], pVerIndex[2] );
break;
}
case 4:
{
*pNewPlane3List->Push() = mpPlane3Buf + mNumFace;
mpPlane3Buf[ mNumFace++ ].SetFromPoints( mpVertexBuf, pVerIndex[0], pVerIndex[1], pVerIndex[2] );
*pNewPlane3List->Push() = mpPlane3Buf + mNumFace;
mpPlane3Buf[ mNumFace++ ].SetFromPoints( mpVertexBuf, pVerIndex[0], pVerIndex[2], pVerIndex[3] );
break;
}
default:
Except( Exception::ERR_INTERNAL_ERROR, "三角形分割後生成的新頂點數量錯誤。" );
}
}
示例12: determineMemoryUsage
/**
* Guesstimate the maximum number of probe sets we can load for all experiments.
* Guesstimate the maximum number of experiments we can load for all probe sets.
* @return bool - true if successful
*/
bool CNReferenceEngine::determineMemoryUsage()
{
int iMemUsage = m_pEngine->getOptInt("mem-usage");
int iMBUsedForProbeSetList = (int)((77 * m_iProbeSetCount) / 1000000.0);
int iMBUsedForExperimentList = (int)((58 * m_iExperimentCount) / 1000000.0);
m_iProbeSetsToProcess = (int)((((iMemUsage - iMBUsedForProbeSetList - iMBUsedForExperimentList) * 1000000.0) / 9.0) / m_iExperimentCount);
if (m_iProbeSetsToProcess <= 0) {throw(Except("Not enough memory to run application. ProbeSetsToProcess = " + ::getInt(m_iProbeSetsToProcess)));}
if (m_iProbeSetsToProcess > m_iProbeSetCount) {m_iProbeSetsToProcess = m_iProbeSetCount;}
m_iExperimentsToProcess = (int)((((iMemUsage - iMBUsedForProbeSetList - iMBUsedForExperimentList) * 1000000.0) / 9.0) / m_iProbeSetCount);
if (m_iExperimentsToProcess <= 0) {throw(Except("Not enough memory to run application. ExperimentsToProcess = " + ::getInt(m_iExperimentsToProcess)));}
if (m_iExperimentsToProcess > m_iExperimentCount) {m_iExperimentsToProcess = m_iExperimentCount;}
return true;
}
示例13: Except
//-----------------------------------------------------------------------
SubEntity* Entity::getSubEntity(unsigned int index) {
if (index >= mSubEntityList.size())
Except(Exception::ERR_INVALIDPARAMS,
"Index out of bounds.",
"Entity::getSubEntity");
return mSubEntityList[index];
}
示例14: dbms
Dbms* dbms()
{
if (isclient())
{
if (! tls().thedbms)
{
if (Fibers::inMain())
tls().thedbms = dbms_remote(server_ip);
else
{
try
{
tls().thedbms = dbms_remote_async(server_ip);
}
catch (const Except& e)
{
throw Except(e,
"thread failed to connect to db server: " + e.gcstr());
}
tls().thedbms->auth(Fibers::main_dbms()->token());
}
}
return tls().thedbms;
}
else
{
static Dbms* local = dbms_local();
return local;
}
}
示例15: GetCheckVal
// Will do is IsTypeOf T before getting and throw if types dont match
T GetCheckVal() const
{
if(IsTypeOf<T>())
return GetVal();
else
throw Except(String("GetCheckVal expected ")+typeid(T).name());
}