本文整理汇总了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());
}