Exemplo n.º 1
0
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 );
	}
}
Exemplo n.º 2
0
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;
}
Exemplo n.º 3
0
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 */
}
Exemplo n.º 4
0
	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;
	}
Exemplo n.º 5
0
void CReport::InsertAt(int nStartIndex, CReport* pNewArray)
{
	SP_ASSERT(pNewArray != NULL);
	SP_ASSERT(nStartIndex >= 0);

	if (pNewArray->GetSize() > 0)
	{
		InsertAt(nStartIndex, pNewArray->GetAt(0), pNewArray->GetSize());
		for (int i = 0; i < pNewArray->GetSize(); i++)
			SetAt(nStartIndex + i, pNewArray->GetAt(i));
	}
}
Exemplo n.º 6
0
void CReport::RemoveAt(int nIndex, int nCount /* = 1 */)
{
	SP_ASSERT(nIndex >= 0);
	SP_ASSERT(nCount >= 0);
	SP_ASSERT(nIndex + nCount <= m_nSize);

	// just remove a range
	int nMoveCount = m_nSize - (nIndex + nCount);

	if (nMoveCount)
		memcpy(&m_pData[nIndex], &m_pData[nIndex + nCount],
			nMoveCount * sizeof(REPORT));
	m_nSize -= nCount;
}
Exemplo n.º 7
0
// 技术指标有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;
}
Exemplo n.º 8
0
//////////////////////////////////////////////////////////////////////////////////
// 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;
}
Exemplo n.º 9
0
/*
  [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';
      }
    }
}
Exemplo n.º 10
0
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;
}
Exemplo n.º 11
0
	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 );
	}
Exemplo n.º 12
0
// 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;
}
Exemplo n.º 13
0
	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!");
		}
	}
Exemplo n.º 14
0
// 得到趋势信号
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;
}
Exemplo n.º 15
0
BOOL CKData::GetVolumeSum( double * pValue, DWORD dateCur, int nDays )
{
	SP_ASSERT( pValue && nDays > 0 );

	// Find date Current to calculate from
	int		nIndex	=	GetIndexByDate( dateCur );
	if( -1 == nIndex )
		return FALSE;

	// data not enough
	if( nDays > nIndex )
		return FALSE;

	// 检查是否是相邻成交日
	if( !IsAdjacentDays( nIndex, nDays ) )
		return FALSE;

	// begin calculate
	double	dAll	=	0;
	int		nCount	=	0;
	for( int i=nIndex; i>=0; i-- )
	{
		dAll	+=	ElementAt(i).m_fVolume;
		nCount	++;
		if( nCount >= nDays )
			break;
	}
	// data not enough
	if( nCount != nDays || nCount <= 0 )
		return FALSE;

	if( pValue )
		*pValue	=	dAll;
	return TRUE;
}
Exemplo n.º 16
0
BOOL CKData::IsAdjacentDays( int nIndex, int nDays )
{
	// check parameters
	SP_ASSERT( nIndex >= 0 && nIndex < GetSize() && nDays >= 1 );
	if( nIndex < 0 || nIndex >= GetSize() || nDays < 1 )
		return FALSE;

	// data not enougy
	if( nDays > nIndex )
		return FALSE;

	CSPTime	sptime1, sptime2;
	sptime1.FromStockTime( ElementAt(nIndex-nDays).m_date, CKData::IsDayOrMin(m_nKType) );
	sptime1.FromStockTime( ElementAt(nIndex).m_date, CKData::IsDayOrMin(m_nKType) );

	if( CKData::ktypeMonth == m_nKType )
	{
		if( sptime2 - sptime1 >= CSPTimeSpan(nDays+63,0,0,0) )
			return FALSE;
	}
	else if( CKData::ktypeWeek == m_nKType )
	{
		if( sptime2 - sptime1 >= CSPTimeSpan(nDays+15,0,0,0) )
			return FALSE;
	}
	else
	{
		if( sptime2 - sptime1 >= CSPTimeSpan(nDays+8,0,0,0) )
			return FALSE;
	}
	return TRUE;
}
Exemplo n.º 17
0
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;
}
Exemplo n.º 18
0
void	Object::operator delete( void *p, LPCSTR /* lpszFileName */,
								int	/* nLine */ )
{
	SP_ASSERT( SP_CheckMemory() );

	SP_FreeMemoryDebug(p, TRUE);
}
Exemplo n.º 19
0
//////////////////////////////////////////////////////////////////
// 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;
}
Exemplo n.º 20
0
// 给定买卖信号理由说明值,得到中文说明
CSPString	AfxGetIntensityCodeString( UINT nCode )
{
    switch( nCode )
    {
    case	ITSC_NOTHING:
        return	itsc_nothing;
    case	ITSC_DEVIATEONBOTTOM:
        return	itsc_deviateonbottom;
    case	ITSC_DEVIATEONTOP:
        return	itsc_deviateontop;
    case	ITSC_GOLDENFORK:
        return	itsc_goldenfork;
    case	ITSC_DEADFORK:
        return	itsc_deadfork;
    case	ITSC_LONG:
        return	itsc_long;
    case	ITSC_SHORT:
        return	itsc_short;
    case	ITSC_OVERBOUGHT:
        return	itsc_overbought;
    case	ITSC_OVERSOLD:
        return	itsc_oversold;
    case	ITSC_SUPPORT:
        return	itsc_support;
    case	ITSC_RESISTANCE:
        return	itsc_resistance;
    default:
        SP_ASSERT( FALSE );
    }
    return "";
}
Exemplo n.º 21
0
CKData	& CStock::GetKData( int ktype )
{
	switch( ktype )
	{
	case CKData::ktypeMonth:
		return GetKDataMonth();
	case CKData::ktypeWeek:
		return GetKDataWeek();
	case CKData::ktypeDay:
		return GetKDataDay();
	case CKData::ktypeMin60:
		return GetKDataMin60();
	case CKData::ktypeMin30:
		return GetKDataMin30();
	case CKData::ktypeMin15:
		return GetKDataMin15();
	case CKData::ktypeMin5:
		return GetKDataMin5();
	case CKData::ktypeMin1:
		return GetKDataMin1();
	default:
		SP_ASSERT( FALSE );
		return GetKDataDay();
	}
}
Exemplo n.º 22
0
static char const *trans_helper(int (*fun)(SP_term_ref, SP_stream *, struct event_stream_data *p), SP_term_ref t1, struct interp_data *interp_data)
{
  spio_t_error_code code = SPIO_E_ERROR;
  SP_stream *stream = NULL;
  struct event_stream_data *p = NULL;
  char const *buf;

  if (interp_data->stream_buf != NULL)
    {
      SP_free(interp_data->stream_buf);
      interp_data->stream_buf = NULL;
    }

  CHECK(init_tcl_stream(interp_data, FALSE, &stream, &p));
  SP_ASSERT(stream != NULL && p != NULL);
  p->presult = &interp_data->stream_buf;

  if (!(*fun)(t1, stream, p))
    {
      goto barf;
    }

  SP_ASSERT(interp_data->stream_buf == NULL);

  CHECK(SP_fclose(stream, 0));
  stream = NULL;
  SP_ASSERT(interp_data->stream_buf != NULL); /* set by user_close */

  buf = interp_data->stream_buf;

 cleanup:
  if (stream != NULL)
    {
      if (p != NULL)
        {
          p->presult = NULL;        /* dbg, not needed (but maybe if we cache stream) */
        }
      (void)SP_fclose(stream, SP_FCLOSE_OPTION_FORCE); /* this will change if we cache the stream */
    }

  return buf;

 barf:
  (void)code;
  buf = NULL;
  goto cleanup;
}
Exemplo n.º 23
0
int CKData::DayToMonth( CKData &kdday, CKData &kdmonth )
{
	// convert day k line to month k line
	SP_ASSERT( ktypeDay == kdday.GetKType() );
	SP_ASSERT( ktypeMonth == kdmonth.GetKType() );

	kdmonth.SetSize( 0, kdday.GetSize() / 20 + 5 );
	
	int nStart		=	kdday.GetSize() % 3;
	int	nCount		=	0;
	KDATA	dataDest;
	memset( &dataDest, 0, sizeof(dataDest) );
	int	nYearCur = 0, nMonthCur = 0 ;
	for( int pos=nStart; pos<kdday.GetSize(); pos++ )
	{
		KDATA & dataSrc = kdday.ElementAt( pos );

		CSPTime	tm;
		if( !tm.FromStockTimeDay(dataSrc.m_date) )
			continue;
		int nYear	=	tm.GetYear();
		int nMonth	=	tm.GetMonth();

		if( nYear != nYearCur || nMonth != nMonthCur )	// a new month
		{
			if( 0 != pos )
				kdmonth.Add( dataDest );				// add a month

			memcpy( &dataDest, &dataSrc, sizeof(dataDest) );	// begin a new month
			nYearCur	=	nYear;
			nMonthCur	=	nMonth;
		}
		else
		{
			dataDest.m_fAmount		+=	dataSrc.m_fAmount;
			if( dataDest.m_fHigh < dataSrc.m_fHigh )	dataDest.m_fHigh	=	dataSrc.m_fHigh;
			if( dataDest.m_fLow > dataSrc.m_fLow )		dataDest.m_fLow		=	dataSrc.m_fLow;
			dataDest.m_fVolume		+=	dataSrc.m_fVolume;
			dataDest.m_fClose		=	dataSrc.m_fClose;
		}

		if( pos == kdday.GetSize()-1 )	// the latest one
			kdmonth.Add( dataDest );
	}

	return kdmonth.GetSize();
}
Exemplo n.º 24
0
void CReport::SetAtGrow(int nIndex, REPORT newElement)
{
	SP_ASSERT(nIndex >= 0);

	if (nIndex >= m_nSize)
		SetSize(nIndex+1);
	m_pData[nIndex] = newElement;
}
Exemplo n.º 25
0
void COutline::SetAtGrow(int nIndex, OUTLINE newElement)
{
	SP_ASSERT(nIndex >= 0);

	if (nIndex >= m_nSize)
		SetSize(nIndex+1);
	m_pData[nIndex] = newElement;
}
Exemplo n.º 26
0
void CDRData::SetAtGrow(int nIndex, DRDATA newElement)
{
	SP_ASSERT(nIndex >= 0);

	if (nIndex >= m_nSize)
		SetSize(nIndex+1);
	m_pData[nIndex] = newElement;
}
Exemplo n.º 27
0
BOOL CStockContainer::GetNextStock( CStockInfo * pInfo )
{
	CSPMutex::Scoped	l(m_mutex);

	SP_ASSERT( pInfo );

	if( GetSize() == 0 )
		return FALSE;

	if( m_nCurrentStock < 0 || m_nCurrentStock >= GetSize() )
		m_nCurrentStock	=	-1;
	
	if( m_auidSort.GetSize() == GetSize() )
	{
		if( m_nCurrentStock == -1 )
			m_nCurrentStock	=	m_auidSort[0];
		else
		{
			int i;
			for(  i=0; i<m_auidSort.GetSize(); i++ )
			{
				if( m_nCurrentStock == (int)m_auidSort[i] )
					break;
			}
			i ++;
			if( i >= m_auidSort.GetSize() )
			{
				m_nCurrentStock	=	-1;
				return FALSE;
			}
			m_nCurrentStock	= m_auidSort[i];
		}
	}
	else
	{
		if( m_nCurrentStock < 0 )
			m_nCurrentStock	=	0;
		else
			m_nCurrentStock	++;
		if( m_nCurrentStock >= GetSize() )
		{
			m_nCurrentStock	=	-1;
			return FALSE;
		}
	}
	
	if( m_nCurrentStock >= 0 && m_nCurrentStock < GetSize() )
	{
		CStockInfo	& info	=	ElementAt(m_nCurrentStock);
		if( pInfo )
			* pInfo	=	info;
		return TRUE;
	}
	else
		m_nCurrentStock	=	-1;
		
	return FALSE;
}
Exemplo n.º 28
0
String ReadFile(const String& filepath)
{
    FILE* file = fopen(filepath.c_str(), "rb");
    if (file == nullptr)
        SP_ASSERT(file, "Could not open file '", filepath, "'!");

    fseek(file, 0, SEEK_END);
    int32 length = ftell(file);
    SP_ASSERT(length < 100 * 1024 * 1024);
    String result(length, 0);
    fseek(file, 0, SEEK_SET);
    fread(&result[0], 1, length, file);
    fclose(file);

    // Strip carriage returns
    result.erase(std::remove(result.begin(), result.end(), '\r'), result.end());
    return result;
}
Exemplo n.º 29
0
static spio_t_error_code SPCDECL legacy_user_write(void *user_data, void const *buf, size_t *pbuf_size, spio_t_bits write_options)
{
  spio_t_error_code code = SPIO_E_INTERNAL_ERROR;
  struct legacy_stream *legacy_handle;
  size_t i;
  spio_t_wchar c;
  size_t buf_item_count;
  (void)write_options;

  /* We ignore SPIO_DEVICE_WRITE_OPTION_NONBLOCKING */

  /* We assume SPIO_DEVICE_WRITE_OPTION_TEXT */
  SP_ASSERT(SPIO_MASK_IS_SET(write_options, SPIO_DEVICE_WRITE_OPTION_TEXT));

  legacy_handle = (struct legacy_stream*)user_data;
  SP_ASSERT(legacy_handle->sputc != NULL);

  /* Number of items in buf */
  buf_item_count = *pbuf_size / (sizeof c); /* round down */


  for (i = 0; i < buf_item_count; i++) {
    int tmp;
    char byte;
    memcpy(&c, ((char*)buf)+(i * sizeof c), sizeof c);
    byte = (char)(c & 0xFF);
    tmp = legacy_handle->sputc(byte, legacy_handle->handle);
    if (tmp == -1) {
      break;
    }
  }
  /* i is the first unwritten item index */

  *pbuf_size = (i * sizeof c);
  code = SPIO_S_NOERR;
  goto cleanup;
 cleanup:
  return code;
#if 0
 barf:
  goto cleanup;
#endif
}
Exemplo n.º 30
0
void*	Object::operator new( size_t nSize, LPCSTR lpszFileName, int nLine )
{
	SP_ASSERT( SP_CheckMemory() );
	void	*p	=	SP_AllocMemoryDebug( nSize, TRUE, lpszFileName, nLine );
	if( NULL == p )
	{
		SP_TRACE1("Object::new( size_t, LPCSTR, int ) allocate %d bytes fail.\n", nSize );
	}
	return	p;
}