C++ Throw函数代码示例

本文整理汇总了C++中Throw函数的典型用法代码示例。如果您正苦于以下问题:C++ Throw函数的具体用法?C++ Throw怎么用?C++ Throw使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


C++ Throw函数代码示例

在下文中一共展示了Throw函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: extract1BitsDestination

/*
*	Extract Destination to operand2
*	
*	Operation:
*		To Catch No Argument and Empty Argument Value,extract value
*
*	Data:
*		Make operand2 to default value 0x1;
*
*  Return:
*		operand2 value
*
*/
int extract1BitsDestination(String *arguments){
	ErrorCode error;
	int operand2;
	
	Try{
		operand2 = extractDestination(arguments);
	}Catch(error){
		if(error == ERR_NO_ARGUMENT){
				operand2 = 0x1;
		}else if(error != ERR_EMPTY_ARGUMENT){
			if(error == ERR_ILLEGAL_ARGUMENT){
					Throw(error);
			}
		}
	}
	
	return operand2;
}
开发者ID:jasonchuah93,项目名称:PIC18Simulator,代码行数:31,代码来源:Extract1BitsDestination.c

示例2: throwError

void throwError(ErrorCode errCode,char *msg , ...){
  ErrorObject *errorObj=malloc(sizeof(ErrorObject));

  char *msgBuffer;
  int strLength;

  va_list args;
  va_start(args,msg);
  strLength=vsnprintf(msgBuffer,0,msg,args);
  msgBuffer=malloc(strLength + 1);
  vsprintf(msgBuffer, msg, args);

  errorObj->errorMsg=msgBuffer;
  errorObj->errorCode=errCode;

  va_end(args);
  Throw(errorObj);
}
开发者ID:JangSing,项目名称:JSON_Parser,代码行数:18,代码来源:ErrorObject.c

示例3: tr

 void GetSubMatrix::Inject(const GeneralMatrix& gmx) {
	REPORT
	    Tracer tr("SubMatrix(inject)");
	SetUpLHS();
	if (row_number != gmx.Nrows() || col_number != gmx.Ncols())
	    Throw(IncompatibleDimensionsException());
	MatrixRow mrx((GeneralMatrix*)(&gmx), LoadOnEntry);
	MatrixRow mr(gm, LoadOnEntry+StoreOnExit+DirectPart, row_skip);
	// do need LoadOnEntry
	MatrixRowCol sub; int i = row_number;
	while (i--) {
	    mr.SubRowCol(sub, col_skip, col_number);    // put values in sub
	    sub.Inject(mrx); mr.Next(); mrx.Next();
	}
#ifdef TEMPS_DESTROYED_QUICKLY
	delete this;
#endif
    }
开发者ID:ndilday,项目名称:virtualu,代码行数:18,代码来源:Submat.cpp

示例4: suite

void UnitTests::runTest (UnitTest& test)
{
    try
    {
        ScopedPointer <UnitTest::Suite> suite (test.run (this).release ());

        m_results->cases += suite->cases.size ();
        m_results->tests += suite->tests;
        m_results->failures += suite->failures;

        m_results->suites.add (suite.release ());
    }
    catch (...)
    {
        // Should never get here.
        Throw (std::runtime_error ("unhandled exception during unit tests"));
    }
}
开发者ID:AUSTRALIANBITCOINS,项目名称:rippled,代码行数:18,代码来源:beast_UnitTest.cpp

示例5: setControl

void FPUFlags::setCurrent (const FPUFlags& flags)
{
  unsigned int newControl = 0;
  unsigned int mask = 0;

  setControl (flags.getMaskNaNs(), newControl, mask,        _EM_INVALID);
  setControl (flags.getMaskDenormals(), newControl, mask,   _EM_DENORMAL);
  setControl (flags.getMaskZeroDivides(), newControl, mask, _EM_ZERODIVIDE);
  setControl (flags.getMaskOverflows(), newControl, mask,   _EM_OVERFLOW);
  setControl (flags.getMaskUnderflows(), newControl, mask,  _EM_UNDERFLOW);
//setControl (flags.getMaskInexacts(), newControl, mask,    _EM_INEXACT);
  setControl (flags.getFlushDenormals(), newControl, mask,  _DN_FLUSH);
  setControl (flags.getInfinitySigned(), newControl, mask,  _IC_AFFINE);

  if (flags.getRounding().is_set ())
  {
    Rounding rounding = flags.getRounding().value ();

    switch (rounding)
    {
    case roundChop: mask |= _MCW_RC; newControl |= _RC_CHOP; break;
    case roundUp:   mask |= _MCW_RC; newControl |= _RC_UP;   break;
    case roundDown: mask |= _MCW_RC; newControl |= _RC_DOWN; break;
    case roundNear: mask |= _MCW_RC; newControl |= _RC_NEAR; break;
    }
  }

  if (flags.getPrecision().is_set ())
  {
    switch (flags.getPrecision().value ())
    {
    case bits64: mask |= _MCW_PC; newControl |= _PC_64; break;
    case bits53: mask |= _MCW_PC; newControl |= _PC_53; break;
    case bits24: mask |= _MCW_PC; newControl |= _PC_24; break;
    }
  }

  unsigned int currentControl;

  errno_t result = _controlfp_s (&currentControl, newControl, mask);

  if (result != 0)
    Throw (std::runtime_error ("error in _controlfp_s"));
}
开发者ID:lucem,项目名称:VFLib,代码行数:44,代码来源:vf_win32_FPUFlags.cpp

示例6: client_negotiate

void client_negotiate( Transport *tpt )
{
  struct exception e;
  char header[ 8 ];
  int x = 1;

  // default client configuration
  tpt->loc_little = ( char )*( char * )&x;
  tpt->lnum_bytes = ( char )sizeof( lua_Number );
  tpt->loc_intnum = ( char )( ( ( lua_Number )0.5 ) == 0 );
  transport_write_uint8_t( tpt, RPC_CMD_CON );

  // write the protocol header 
  header[0] = 'L';
  header[1] = 'R';
  header[2] = 'P';
  header[3] = 'C';
  header[4] = RPC_PROTOCOL_VERSION;
  header[5] = tpt->loc_little;
  header[6] = tpt->lnum_bytes;
  header[7] = tpt->loc_intnum;
  //  printf("write version\n");
  transport_write_string( tpt, header, sizeof( header ) );
  transport_flush(tpt);
  //  printf("write version ok\n");
  
  // read server's response
  //  printf("read version\n");
  transport_read_string( tpt, header, sizeof( header ) );
  if( header[0] != 'L' ||
      header[1] != 'R' ||
      header[2] != 'P' ||
      header[3] != 'C' ||
      header[4] != RPC_PROTOCOL_VERSION )
  {
    e.errnum = ERR_HEADER;
    e.type = nonfatal;
    Throw( e );
  }
  // write configuration from response
  tpt->net_little = header[5];
  tpt->lnum_bytes = header[6];
  tpt->net_intnum = header[7];
}
开发者ID:lipp,项目名称:luarpc,代码行数:44,代码来源:luarpc_protocol.c

示例7: CCheck

String Environment::GetMachineVersion() {
#if UCFG_USE_POSIX
	utsname u;
	CCheck(::uname(&u));
	return u.machine;
#elif defined(WIN32)
	String s;	
	SYSTEM_INFO si;
	GetSystemInfo(&si);
	switch (si.wProcessorArchitecture) {
	case PROCESSOR_ARCHITECTURE_INTEL:
		switch (si.dwProcessorType)
		{
		case 586:
			switch (si.wProcessorRevision)
			{
			case 5895:
				s = "Core 2 Quad";
				break;
			default:
				s = "586";
			}
			break;
		default:
			s = "Intel";
		};
		break;
#if UCFG_WIN32_FULL
	case PROCESSOR_ARCHITECTURE_AMD64:
		s = "AMD64";
		break;
#endif
	case PROCESSOR_ARCHITECTURE_ARM:
		s = "ARM";
		break;
	default:
		s = "Unknown CPU";
		break;
	}
	return s;
#else
	Throw(E_NOTIMPL);
#endif
}
开发者ID:sirmax1,项目名称:coin,代码行数:44,代码来源:ext-fw.cpp

示例8: sqlite3_step

bool statement_imp::fetch (Error& error)
{
  int result = sqlite3_step (m_stmt);

  if (result == SQLITE_ROW ||
      result == SQLITE_DONE)
  {
    if (m_bFirstTime)
    {
      m_last_insert_rowid = m_session.last_insert_rowid();
      m_bFirstTime = false;
    }

    if (result == SQLITE_ROW)
    {
      m_bGotData = true;
      m_session.set_got_data (m_bGotData);

      do_intos();
    }
    else
    {
      m_bGotData = false;
      m_session.set_got_data (m_bGotData);

      if (result == SQLITE_DONE)
      {
        m_bReady = false;
      }
    }
  }
  else if (result != SQLITE_OK)
  {
    m_bGotData = false;
    error = detail::sqliteError (__FILE__, __LINE__, result);
  }
  else
  {
    // should never get SQLITE_OK here
    Throw (Error().fail (__FILE__, __LINE__, Error::assertFailed));
  }

  return m_bGotData;
}
开发者ID:Izhaki,项目名称:LayerEffects,代码行数:44,代码来源:statement_imp.cpp

示例9: test_BasicThrowAndCatch_WithMiniSyntax

void test_BasicThrowAndCatch_WithMiniSyntax(void)
{
  CEXCEPTION_T e;

  //Mini Throw and Catch
  Try
    Throw(0xEF);
  Catch(e)
    TEST_ASSERT_EQUAL(0xEF, e);
  TEST_ASSERT_EQUAL(0xEF, e);
  
  //Mini Passthrough
  Try
    e = 0;
  Catch(e)
    TEST_FAIL_MESSAGE("I shouldn't be caught because there was no throw");

  TEST_ASSERT_EQUAL(0, e);
}
开发者ID:mikedlowis-archive,项目名称:bitbucket,代码行数:19,代码来源:TestException.c

示例10: FindAsset

void FFolderPackage::LoadAsset( FStringConst& Path )
{
	guard;

	//Get asset
	FAsset* Asset = FindAsset( Path );
	if(!Asset)
	{
		FString Err = FString( L"Asset '" ) + Path.Data + FString( L"' could not be read." );
		Throw( (wchar_t*)Err.Data, false );
	}

	Open( Path.Data );
	Asset->Ptr = (uint8*)GMemory->Malloc( Asset->Size );
	Read( Asset->Ptr, Asset->Size );
	Close();

	unguard;
}
开发者ID:Hyzoran,项目名称:Eoverse,代码行数:19,代码来源:Package.cpp

示例11: mcu_div

void mcu_div(uint8_t *reg)
{
  if( A == 0){
    C = 1;
    Throw(ERR_DIVIDER_IS_0);
  }
 
  uint16_t regXY      = getBigEndianWord(reg);
  uint16_t quotient   = regXY / A;
  uint8_t  remainder  = regXY % A;
  
  N = 0;
  Z = (quotient == 0 ? 1 : 0);
  H = 0;
  V = 0;
  
  A = remainder;
  setBigEndianWord(reg, quotient);
}
开发者ID:Raydivine,项目名称:STM8-Simulator,代码行数:19,代码来源:MCU_Operation.c

示例12: Rotate

void Rotate(RectMatrixCol& U, RectMatrixCol& V, Real tau, Real s)
{
   REPORT
   int n = U.n;
   if (n != V.n)
   {
      Tracer tr("newmatrm");
      Throw(InternalException("Dimensions differ in Rotate"));
   }
   Real* u = U.store; Real* v = V.store;
   int su = U.spacing; int sv = V.spacing;
   if (n) for(;;)
   {
      Real zu = *u; Real zv = *v;
      *u -= s * (zv + zu * tau); *v += s * (zu - zv * tau);
      if (!(--n)) break;
      u += su;  v += sv;
   }
}
开发者ID:vapd-radi,项目名称:rspf_v2.0,代码行数:19,代码来源:newmatrm.cpp

示例13: circularBufferAdd

/*
 * circularBufferAdd
 *
 * Input
 *		cb			is a pointer to CircularBuffer
 *		value2Add	value to be added to the Circular Buffer
 *
 * Function
 *		to add value to Circular Buffer and set the cb->head to be
 *		the last added value and cb->tail to be the first added value
 *		and raise an exception if Circular Buffer is full
 */
void circularBufferAdd(CircularBuffer *cb, int value2Add)
{
	if(cb->length == cb->size)
		Throw(ERR_BUFFER_IS_FULL);
	
	
	*cb->buffer = value2Add;
	
	if(cb->size == 0)
		*cb->tail = value2Add;
	
	if((cb->length - 1) != cb->size)
		cb->head++;
	else
		*cb->head = value2Add;

	cb->buffer++;
	cb->size++;
}
开发者ID:JacksonTeh,项目名称:CircularBuffer,代码行数:31,代码来源:CircularBuffer.c

示例14: tr

void GetSubMatrix::operator<<(const Real* r)
{
   REPORT
   Tracer tr("SubMatrix(<<Real*)");
   SetUpLHS();
   if (row_skip+row_number > gm->Nrows() || col_skip+col_number > gm->Ncols())
      Throw(SubMatrixDimensionException());
   MatrixRow mr(gm, LoadOnEntry+StoreOnExit+DirectPart, row_skip);
                                  // do need LoadOnEntry
   MatrixRowCol sub; int i = row_number;
   while (i--)
   {
      mr.SubRowCol(sub, col_skip, col_number);   // put values in sub
      sub.Copy(r); mr.Next();
   }
#ifdef TEMPS_DESTROYED_QUICKLY
   delete this;
#endif
}
开发者ID:151706061,项目名称:sofa,代码行数:19,代码来源:submat.cpp

示例15: updateQRZ

void updateQRZ(UpperTriangularMatrix& X, UpperTriangularMatrix& U)
{
   REPORT
   Tracer et("updateQRZ(3)");
   int s = X.Ncols();
   if (s != U.Ncols())
      Throw(ProgramException("Incompatible dimensions",X,U));
   if (s == 0) return; 
   Real* xi0 = X.data(); Real* u = U.data();
   for (int i=1; i<=s; ++i)
   {
		  Real r = *u; Real sum = 0.0;
			{
         Real* xi=xi0; int k=i; int l=s;
			   while(k--) { sum += square(*xi); xi+= --l;}
			}
      sum = sqrt(sum + square(r));
      if (sum == 0.0) { REPORT X.column(i) = 0.0; *u = 0.0; }
      else
      {
         Real frs = fabs(r) + sum;
         Real a0 = sqrt(frs / sum); Real alpha = a0 / frs;
         if (r <= 0) { REPORT *u = sum; alpha = -alpha; }
         else { REPORT *u = -sum; }
         {
            Real* xj0=xi0; int k=i; int l=s;
            while(k--) { *xj0 *= alpha; --l; xj0 += l;}
         }
         Real* xj0=xi0; Real* uj=u;
         for (int j=i+1; j<=s; ++j)
         {
            Real sum = 0.0; ++xj0; ++uj;
            Real* xi=xi0; Real* xj=xj0; int k=i; int l=s; 
            while(k--) { sum += *xi * *xj; --l; xi += l; xj += l; }
            sum += a0 * *uj;
            xi=xi0; xj=xj0; k=i; l=s;
            while(k--) { *xj -= sum * *xi; --l; xi += l; xj += l; }
            *uj -= sum * a0;
         }
      }
			++xi0; u += s-i+1;
   }
}
开发者ID:BloodyPudding,项目名称:Sign_Language_Recognition,代码行数:43,代码来源:hholder.cpp

本文标签属性:

示例:示例的拼音

代码:代码是什么

Throw:throwing

上一篇:Java AbsoluteLayout类代码示例
下一篇:Java TourGuide类代码示例

为您推荐