当前位置: 首页>>代码示例>>C++>>正文


C++ SP_ASSERT函数代码示例

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


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

示例1: SP_ASSERT

void CKData::ChangeCurFormat( int format, DWORD dateAutoDRBegin, double dAutoDRLimit )
{
	SP_ASSERT( GetKType() != ktypeMonth && GetKType() != ktypeWeek );

	if( m_nCurFormat == format )
		return;

	switch( format )
	{
	case formatOriginal:
		LoadDataOriginal( );
		m_nCurFormat = format;
		break;
	case formatXDRup:
		StoreDataOriginal( );
		ConvertXDR( TRUE, dateAutoDRBegin, dAutoDRLimit );
		m_nCurFormat = format;
		break;
	case formatXDRdown:
		StoreDataOriginal( );
		ConvertXDR( FALSE, dateAutoDRBegin, dAutoDRLimit );
		m_nCurFormat = format;
		break;
	default:
		SP_ASSERT( FALSE );
	}
}
开发者ID:darwinbeing,项目名称:trade,代码行数:27,代码来源:KData.cpp

示例2: SP_ASSERT

void CReport::InsertAt(int nIndex, REPORT newElement, int nCount /*=1*/)
{
	SP_ASSERT(nIndex >= 0);    // will expand to meet need
	SP_ASSERT(nCount > 0);     // zero or negative size not allowed

	if (nIndex >= m_nSize)
	{
		// adding after the end of the array
		SetSize(nIndex + nCount);  // grow so nIndex is valid
	}
	else
	{
		// inserting in the middle of the array
		int nOldSize = m_nSize;
		SetSize(m_nSize + nCount);  // grow it to new size
		// shift old data up to fill gap
		memmove(&m_pData[nIndex+nCount], &m_pData[nIndex],
			(nOldSize-nIndex) * sizeof(REPORT));

		// re-init slots we copied from

		memset(&m_pData[nIndex], 0, nCount * sizeof(REPORT));

	}

	// insert new value in the gap
	SP_ASSERT(nIndex + nCount <= m_nSize);
	while (nCount--)
		m_pData[nIndex++] = newElement;
}
开发者ID:maerson,项目名称:mystkproj,代码行数:30,代码来源:Report.cpp

示例3: sptcl_raise_error

void sptcl_raise_error(char *mod, char *name, int arity)
{
  char *err_funct = "tcl_error";

  switch (local.err_type&0xff)
    {
    case SPTK_ERROR:
      SP_ASSERT(local.err_culprit == 0); /* xref CLEAR_ERROR() */
      err_funct = "tk_error";
    case SPTCL_ERROR:
      SP_ASSERT(local.err_culprit == 0); /* xref CLEAR_ERROR() */
      {
      SP_term_ref
	t1 = SP_new_term_ref(),
	t2 = SP_new_term_ref(),
	t3 = SP_new_term_ref();

      SP_put_string(t1, name);
      SP_put_integer(t2, arity);
      SP_cons_functor(t1, SP_atom_from_string("/"), 2, t1, t2);
      SP_put_list_codes(t2, t3, local.err_msg);
      SP_cons_functor(t1, SP_atom_from_string(err_funct), 2, t1, t2);
      SP_raise_exception(t1);
      break;
    }
    default:
      SP_save_and_raise_error(local.err_type, local.err_msg, local.err_culprit, mod, name, arity, local.err_argno);
    }
  CLEAR_ERROR(); /* paranoia */
}
开发者ID:stratosphr,项目名称:workflowverification,代码行数:30,代码来源:util.c

示例4: glCreateProgram

	GLuint Shader::Load(const String& vertSrc, const String& fragSrc)
	{
		const char* vertexSource = vertSrc.c_str();
		const char* fragmentSource = fragSrc.c_str();

		GLuint program = glCreateProgram();
		GLuint vertex = glCreateShader(GL_VERTEX_SHADER);
		GLuint fragment = glCreateShader(GL_FRAGMENT_SHADER);

		glShaderSource(vertex, 1, &vertexSource, NULL);
		glCompileShader(vertex);

		GLint result;
		glGetShaderiv(vertex, GL_COMPILE_STATUS, &result);
		if (result == GL_FALSE)
		{
			GLint length;
			glGetShaderiv(vertex, GL_INFO_LOG_LENGTH, &length);
			std::vector<char> error(length);
			glGetShaderInfoLog(vertex, length, &length, &error[0]);
			SP_ERROR("Failed to compile vertex shader!");
			SP_ERROR(&error[0]);
			SP_ASSERT(false, "Failed to compile vertex shader!");
			glDeleteShader(vertex);
			return 0;
		}

		glShaderSource(fragment, 1, &fragmentSource, NULL);
		glCompileShader(fragment);

		glGetShaderiv(fragment, GL_COMPILE_STATUS, &result);
		if (result == GL_FALSE)
		{
			GLint length;
			glGetShaderiv(fragment, GL_INFO_LOG_LENGTH, &length);
			std::vector<char> error(length);
			glGetShaderInfoLog(fragment, length, &length, &error[0]);
			SP_ERROR("Failed to compile fragment shader!");
			SP_ERROR(&error[0]);
			SP_ASSERT(false, "Failed to compile fragment shader!");
			glDeleteShader(fragment);
			return 0;
		}

		glAttachShader(program, vertex);
		glAttachShader(program, fragment);

		glLinkProgram(program);
		glValidateProgram(program);

		glDeleteShader(vertex);
		glDeleteShader(fragment);

		return program;
	}
开发者ID:Enigma0960,项目名称:Sparky,代码行数:55,代码来源:Shader.cpp

示例5: AfxGetMinMaxInfo2

// 技术指标有2个最终值
BOOL AfxGetMinMaxInfo2( int nStart, int nEnd, double *pdMin, double *pdMax, CTechnique * pTech )
{
	SP_ASSERT( pTech );
	if( nStart < 0 || nEnd < 0 || nStart > nEnd || !pTech )
		return FALSE;

	double	dMin = 0, dMax = 0;
	double	dValue1 = 0, dValue2 = 0;
	BOOL	bFirst	=	TRUE;
	for( int k=nStart; k<=nEnd; k++ )
	{
		if( pTech->Calculate( &dValue1, &dValue2, k, !bFirst ) )	// 技术指标有2个最终值
		{
			if( bFirst || dValue1 < dMin )	dMin	=	dValue1;
			if( bFirst || dValue1 > dMax )	dMax	=	dValue1;
			if( dValue2 < dMin )	dMin	=	dValue2;
			if( dValue2 > dMax )	dMax	=	dValue2;
			bFirst	=	FALSE;
		}
	}
	dMin	-=	fabs(dMin)*0.02;
	dMax	+=	fabs(dMax)*0.02;
	if( dMax - dMin < 0.03 )
		dMax	=	dMin + 0.05;
	if( pdMin )		*pdMin	=	dMin;
	if( pdMax )		*pdMax	=	dMax;
	
	return !bFirst;
}
开发者ID:ZhaoboMeng,项目名称:k-line-print,代码行数:30,代码来源:Technique.cpp

示例6: AfxGetTimeString

//////////////////////////////////////////////////////////////////////////////////
// usful functions
CSPString AfxGetTimeString( time_t time, LPCTSTR lpszTimeFmt, BOOL bAddWeekDay )
{
	SP_ASSERT( lpszTimeFmt );
	if( !lpszTimeFmt || strlen(lpszTimeFmt) == 0 )
		return "";

	CSPTime	sptime(time);
	CSPString strTime = sptime.Format( lpszTimeFmt );

	if( bAddWeekDay )
	{
		int	nDayOfWeek	=	sptime.GetDayOfWeek();
		switch( nDayOfWeek )
		{
		case 1:	strTime	+=	sz_sunday;		break;
		case 2:	strTime	+=	sz_monday;		break;
		case 3:	strTime	+=	sz_tuesday;		break;
		case 4:	strTime	+=	sz_wednesday;	break;
		case 5:	strTime	+=	sz_thursday;	break;
		case 6:	strTime	+=	sz_friday;		break;
		case 7:	strTime	+=	sz_saturday;	break;
		default:;
		}
	}
	return strTime;
}
开发者ID:darwinbeing,项目名称:trade,代码行数:28,代码来源:AfxCore.cpp

示例7: save_error_message

/*
  [PM] 4.3 Copy message to local.err_msg[], with UTF8-aware truncation if necessary.
*/
static void save_error_message(char const *msg_UTF8)
{
  size_t const size = sizeof local.err_msg;
  size_t const len = strlen(msg_UTF8);
        
  if (len < size)
    {
      memcpy(local.err_msg, msg_UTF8, len +1); /* +1 for NUL */
    }
  else
    {
      memcpy(local.err_msg, msg_UTF8, size);

      /* [PM] 4.0 find a UTF-8 boundary at which to NUL-terminate */
      {
        size_t i;

        /* could use BACK_WIDE_CHAR */
        SP_ASSERT(size > 0);
        for (i = size-1; i > 0; i--)
          {
            unsigned char byte = local.err_msg[i];
            if ( (byte & 0x80) == 0) break; /* start of one-byte (7-bit) sequence */
            if ( (byte & (0x80 | 0x40)) == (0x80 | 0x40) ) break; /* start of multi-byte sequence */
          }
        local.err_msg[i] = '\0';
      }
    }
}
开发者ID:stratosphr,项目名称:workflowverification,代码行数:32,代码来源:util.c

示例8: strlen

SP_stream *get_tcl_stream(struct interp_data *interp_data, char *goal_utf8)
{
  spio_t_error_code code = SPIO_E_ERROR;
  SP_stream *stream = NULL;
  struct event_stream_data *p = NULL;
  size_t const goal_len = strlen(goal_utf8);
  char const * const pad = " . "; /* Adds extra dot so never miss it */
  size_t const pad_len = strlen(pad);
  size_t const length = goal_len + pad_len;

  CHECK(init_tcl_stream(interp_data, TRUE, &stream, &p));
  SP_ASSERT(stream != NULL && p != NULL);

  ENSURE_SPACE(length +1);      /* +1 for NUL */
  p->length = length;

  memcpy(p->buffer, goal_utf8, goal_len);
  memcpy(p->buffer+goal_len, pad, pad_len);
  p->buffer[length] = '\0';     /* debug, not needed */

  return stream;

 barf:
  if (stream != NULL) (void)SP_fclose(stream, SP_FCLOSE_OPTION_FORCE);
  return NULL;
}
开发者ID:stratosphr,项目名称:workflowverification,代码行数:26,代码来源:util.c

示例9: SP_Trace

	void _cdecl	SP_Trace(LPCSTR pszFormat, ...)
	{
		int nBuf;
	#ifndef _WINDLL
		char szBuffer[512];
	#else
		static char szBuffer[512];
	#endif
		char* pszLocalFormat;

	#ifdef _NEARDATA
		char szFormat[128];
		ASSERT(lstrlen(pszFormat) < 128);
		lstrcpy(szFormat, pszFormat);
		pszLocalFormat = szFormat;
	#else
		pszLocalFormat = (LPSTR)pszFormat;
	#endif

		va_list args;
		va_start(args, pszFormat);

		nBuf = vsprintf(szBuffer, pszLocalFormat, args);
		SP_ASSERT(nBuf < sizeof(szBuffer));
		SP_OutputDebugString( szBuffer );
	}
开发者ID:darwinbeing,项目名称:trade,代码行数:26,代码来源:SpDebug.cpp

示例10: UpdateStockContainerByREPORT

// update CStockContainer by Report data
BOOL UpdateStockContainerByREPORT( CStockContainer &container, REPORT * pReport, BOOL bAddIfNotExist, REPORT * pReportLast )
{
	SP_ASSERT( pReport );
	if( NULL == pReport )
		return FALSE;

	REPORT	reportLast;
	memset( &reportLast, 0, sizeof(reportLast) );

	int	id = 0;
	if( container.GetStockInfo( pReport->m_szCode, NULL, &id ) )
	{
		container.Lock();

		CStockInfo	& info	=	container.ElementAt(id);
		reportLast	=	info.m_reportLatest;
		UpdateStockInfoByREPORT( info, pReport );

		container.UnLock();
	}
	else if( bAddIfNotExist && strlen(pReport->m_szCode)>0 )
	{
		CStockInfo	info;
		info.SetStockCode( pReport->m_dwMarket, pReport->m_szCode );
		if( UpdateStockInfoByREPORT( info, pReport ) )
		{
			container.Add( info );
		}
	}

	if( pReportLast )
		memcpy( pReportLast, &reportLast, sizeof(reportLast) );

	return TRUE;
}
开发者ID:amikey,项目名称:tradingstrategyking,代码行数:36,代码来源:Packets.cpp

示例11: switch

	void Shader::ResolveAndSetUniform(ShaderUniformDeclaration* uniform, byte* data, int offset)
	{
		switch (uniform->GetType())
		{
			case ShaderUniformDeclaration::Type::FLOAT32:
				SetUniform1f(uniform->GetLocation(), *(float*)&data[offset]);
				break;
			case ShaderUniformDeclaration::Type::SAMPLER2D:
			case ShaderUniformDeclaration::Type::INT32:
				SetUniform1i(uniform->GetLocation(), *(int*)&data[offset]);
				break;
			case ShaderUniformDeclaration::Type::VEC2:
				SetUniform2f(uniform->GetLocation(), *(maths::vec2*)&data[offset]);
				break;
			case ShaderUniformDeclaration::Type::VEC3:
				SetUniform3f(uniform->GetLocation(), *(maths::vec3*)&data[offset]);
				break;
			case ShaderUniformDeclaration::Type::VEC4:
				SetUniform4f(uniform->GetLocation(), *(maths::vec4*)&data[offset]);
				break;
			case ShaderUniformDeclaration::Type::MAT3:
				// TODO: SetUniformMat3(uniform->GetLocation(), *(maths::mat3*)&data[offset]);
				break;
			case ShaderUniformDeclaration::Type::MAT4:
				SetUniformMat4(uniform->GetLocation(), *(maths::mat4*)&data[offset]);
				break;
			default:
				SP_ASSERT(false, "Unknown type!");
		}
	}
开发者ID:Enigma0960,项目名称:Sparky,代码行数:30,代码来源:Shader.cpp

示例12: SP_ASSERT

// 得到趋势信号
int CTechnique::GetTrendIntensity(int nIndex, double * pdValue1, double * pdValue2,
							  UINT itsLong, UINT itsShort, UINT *pnCode )
{
	if( pnCode )	*pnCode	=	ITSC_NOTHING;

	SP_ASSERT( NULL != pdValue1 && NULL != pdValue2 );
	if( NULL == pdValue1 || NULL == pdValue2 )
		return FALSE;
	if( m_nLength <= 0 || m_nIndexStart < 0
		|| nIndex < m_nIndexStart || nIndex-m_nIndexStart>=m_nLength
		|| nIndex-m_nIndexStart < 1 )
		return FALSE;

	int	k	=	nIndex-m_nIndexStart;
	if( pdValue1[k] >= pdValue1[k-1] && pdValue2[k] >= pdValue2[k-1]
		&& pdValue1[k] > pdValue2[k] && (pdValue1[k]-pdValue2[k])>=(pdValue1[k-1]-pdValue2[k-1]) )
	{
		if( pnCode )	*pnCode	=	ITSC_LONG;
		return itsLong;
	}
	if( pdValue1[k] <= pdValue1[k-1] && pdValue2[k] <= pdValue2[k-1]
		&& pdValue1[k] < pdValue2[k] && (pdValue1[k]-pdValue2[k])<=(pdValue1[k-1]-pdValue2[k-1]) )
	{
		if( pnCode )	*pnCode	=	ITSC_SHORT;
		return itsShort;
	}
	return ITS_NOTHING;
}
开发者ID:ZhaoboMeng,项目名称:k-line-print,代码行数:29,代码来源:Technique.cpp

示例13: legacy_flush_output

static spio_t_error_code SPCDECL legacy_flush_output(void *user_data, spio_t_bits flush_options)
{
  spio_t_error_code code = SPIO_E_INTERNAL_ERROR;
  struct legacy_stream *legacy_handle;
  (void)flush_options;

  /* We do not support SPIO_DEVICE_FLUSH_OPTION_NONBLOCKING */
  if (SPIO_MASK_IS_SET(flush_options, SPIO_DEVICE_FLUSH_OPTION_NONBLOCKING)) {
    code = SPIO_E_NOT_SUPPORTED;
    goto barf;
  }

  legacy_handle = (struct legacy_stream*)user_data;
  SP_ASSERT(legacy_handle->sflush != NULL);
  if (legacy_handle->sflush(legacy_handle->handle) == -1) {
    /* FIXME: Proper error handling */
    code = SPIO_E_END_OF_FILE;
    goto barf;
  }

  code = SPIO_S_NOERR;
 cleanup:
  return code;
 barf:
  goto cleanup;
}
开发者ID:stratosphr,项目名称:workflowverification,代码行数:26,代码来源:tkterm.c

示例14: delete

void	Object::operator delete( void *p, LPCSTR /* lpszFileName */,
								int	/* nLine */ )
{
	SP_ASSERT( SP_CheckMemory() );

	SP_FreeMemoryDebug(p, TRUE);
}
开发者ID:darwinbeing,项目名称:trade,代码行数:7,代码来源:SpObject.cpp

示例15: AfxGetMinMaxInfo

//////////////////////////////////////////////////////////////////
// GetMinMaxInfo
// 一些反复使用的代码,用函数代替,得到技术指标在指定范围内的最大最小值
// 技术指标有不同日期作为参数
BOOL AfxGetMinMaxInfo( int nStart, int nEnd, double *pdMin, double *pdMax, CTechnique * pTech, CSPDWordArray & adwDays )
{
	SP_ASSERT( pTech );
	if( nStart < 0 || nEnd < 0 || nStart > nEnd || !pTech )
		return FALSE;

	double	dMin = 0, dMax = 0;
	double	dValue = 0;
	BOOL	bFirst	=	TRUE;
	for( int i=0; i<adwDays.GetSize(); i++ )
	{
		for( int k=nStart; k<=nEnd; k++ )
		{
			if( pTech->Calculate( &dValue, k, adwDays[i], !bFirst ) )
			{
				if( bFirst || dValue < dMin )	dMin	=	dValue;
				if( bFirst || dValue > dMax )	dMax	=	dValue;
				bFirst	=	FALSE;
			}
		}
	}
	dMin	-=	fabs(dMin - dMax)*0.2;
	dMax	+=	fabs(dMax - dMin)*0.2;
	if( dMax - dMin < 0.03 )
		dMax	=	dMin + 0.05;
	if( pdMin )		*pdMin	=	dMin;
	if( pdMax )		*pdMax	=	dMax;
	
	return !bFirst;
}
开发者ID:ZhaoboMeng,项目名称:k-line-print,代码行数:34,代码来源:Technique.cpp


注:本文中的SP_ASSERT函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。