Beispiel #1
0
CTypeUnitDouble::CTypeUnitDouble( const CStringEx _sxll, const CStringEx _sxhl, const CStringEx _sxdv, const CStringEx _sxf ) : CTypeUnit( _sxll, _sxhl, _sxdv, _sxf )
{
	dlowlimit = atof( sxlowlimit.c_str() ); 
	dhighlimit = atof( sxhighlimit.c_str() ); 
	ddefaultvalue = atof( sxdefaultvalue.c_str() ); 
	if( sxformula.empty() )
		sxformula.format( "double(%s,%s)", FormatDouble( dlowlimit ).c_str(), FormatDouble( dhighlimit ).c_str() );
}
Beispiel #2
0
PRINTSIZECHECKRESULT CPrintSize::CheckDouble(UINT id, double &value, double min, double max, SHORT precision)
{
	PRINTSIZECHECKRESULT Result;
	
	Result = PRINT_SIZE_CHECK_UNCHANGED;

	TRY
	{
		if (m_last_active_item_changed)
		{	
			/* get the current value */
	
			CDataExchange cDX(this, TRUE);
			DDX_Text(&cDX, id, value);
		
			/* if the user entered something, reformat the number for specified precision */

			CString s;
			cDX.m_bSaveAndValidate = FALSE;
			FormatDouble(value, precision, s);
			DDX_Text(&cDX, id, s);
			Result = PRINT_SIZE_CHECK_CHANGED;
		
			/* validate value */

			if ((value < min) || (value > max))
			{
				CString csMin;
				CString csMax;
				FormatDouble(min, precision, csMin);
				FormatDouble(max, precision, csMax);
			
				char szMessage[256];
				wsprintf(
					szMessage,
					// JRO "Please enter a value between %s and %s.",
               GET_PMWAPP()->GetResourceStringPointer (IDS_ENTER_VAL_S),
					(const char far *)csMin,
					(const char far *)csMax);
				m_ignore_change_focus = TRUE;
				AfxMessageBox(szMessage);
				m_ignore_change_focus = FALSE;
				Result = PRINT_SIZE_CHECK_ERROR;
			}
		}
	}
	CATCH_ALL(e)
	{
		Result = PRINT_SIZE_CHECK_ERROR;
	}
	END_CATCH_ALL

	return Result;
}
Beispiel #3
0
/*									
CStringEx CTypeUnitDouble::CalculateResult( const CStringEx _sxbasevalue, const CStringEx _sxvalue ) const	
{
	nlassert( !_sxbasevalue.empty() );
	if( _sxvalue.empty() )
		return( _sxbasevalue );
	return( Format( _sxvalue ) );
}
*/
CStringEx CTypeUnitDouble::CalculateResult( const CStringEx _sxbasevalue, const CStringEx _sxvalue ) const	
{
	nlassert( !_sxbasevalue.empty() );
	if( _sxvalue.empty() )
		return( _sxbasevalue );

	std::vector< std::pair< CStringEx, CStringEx > > modificationValues;
	CStringEx value( _sxvalue );
	value.purge();
	while( value[0] == '<' )
	{
		std::string::size_type pos = value.find( '>' );
		if( pos == std::string::npos )
			break;
		CStringEx sxoperateur = value.get_mid( 1, 1 );
		CStringEx sxoperande = value.get_mid( 2, (int)pos-2);
		value.right( (int)(value.size()-pos-1) );
		modificationValues.push_back( std::make_pair( sxoperateur, sxoperande ) );
	}
	if( modificationValues.size() )
	{
		double dr = atof( _sxbasevalue.c_str() );
		for( std::vector< std::pair< CStringEx, CStringEx > >::iterator it = modificationValues.begin(); it != modificationValues.end(); ++it )
		{
			double dvalue = atof( it->second.c_str() );
			if( it->first == "+" )
				dr += dvalue;
			else if( it->first == "*" )
					dr *= dvalue;
				else if( it->first == "-" )
						dr -= dvalue;
					else if( it->first == "/" )
							dr /= dvalue;   
						else if( it->first == "^" )
								dr = pow( dr, dvalue );   
		}
		if( dr < dlowlimit )
			dr = dlowlimit;
		if( dr > dhighlimit )
			dr = dhighlimit;
		return( FormatDouble( dr ) );
	}
	else
	{
		double dvalue = atof( _sxvalue.c_str() );
		if( dvalue < dlowlimit )
			dvalue = dlowlimit;
		if( dvalue > dhighlimit )
			dvalue = dhighlimit;
		return( FormatDouble( dvalue ) );
	}

	return( Format( _sxvalue ) );
}
Beispiel #4
0
CString FormatLongLongHuman(ULONGLONG n)
{
    // Returns formatted number like "12,4 GB".
    ASSERT(n >= 0);
    const int base = 1024;
    const int half = base / 2;

    CString s;

    double B = (int)(n % base);
    n/= base;

    double KB = (int)(n % base);
    n/= base;

    double MB = (int)(n % base);
    n/= base;

    double GB = (int)(n % base);
    n/= base;

    double TB = (int)(n);

    if(TB != 0 || GB == base - 1 && MB >= half)
    {
        s.Format(_T("%s %s"), FormatDouble(TB + GB/base), GetSpec_TB());
    }
    else if(GB != 0 || MB == base - 1 && KB >= half)
    {
        s.Format(_T("%s %s"), FormatDouble(GB + MB/base), GetSpec_GB());
    }
    else if(MB != 0 || KB == base - 1 && B >= half)
    {
        s.Format(_T("%s %s"), FormatDouble(MB + KB/base), GetSpec_MB());
    }
    else if(KB != 0)
    {
        s.Format(_T("%s %s"), FormatDouble(KB + B/base), GetSpec_KB());
    }
    else if(B != 0)
    {
        s.Format(_T("%d %s"), (int)B, GetSpec_Bytes());
    }
    else
    {
        s = _T("0");
    }

    return s;
}
Beispiel #5
0
void CPrintSize::DoDataExchange(CDataExchange* pDX)
{
	/*
	// Only used for shoving the initial data values into the
	// dialog. Input values are recorded as the fields are
	// validated when the user moves from field to field.
	*/

	if (!pDX->m_bSaveAndValidate)
	{
		CString csScale;
		CString csInchesTall;
		CString csInchesWide;
		
		TRY
		{
			CPmwDialog::DoDataExchange(pDX);
		
			limit_control(IDC_SHEETS_TALL, PRINT_SIZE_SHEETS_LIMIT);
			limit_control(IDC_SHEETS_WIDE, PRINT_SIZE_SHEETS_LIMIT);
			limit_control(IDC_INCHES_TALL, PRINT_SIZE_INCHES_LIMIT);
			limit_control(IDC_INCHES_WIDE, PRINT_SIZE_INCHES_LIMIT);
			limit_control(IDC_PRINT_SCALE, PRINT_SIZE_PERCENT_LIMIT);

			FormatDouble(m_scale, PRINT_SIZE_PERCENT_PRECISION, csScale);
			FormatDouble(m_inches_tall, PRINT_SIZE_INCHES_PRECISION, csInchesTall);
			FormatDouble(m_inches_wide, PRINT_SIZE_INCHES_PRECISION, csInchesWide);

			//{{AFX_DATA_MAP(CPrintSize)
			DDX_Control(pDX, IDC_SIZE_PREVIEW, m_preview);
			DDX_Text(pDX, IDC_SHEETS_TALL, m_sheets_tall);
			DDX_Text(pDX, IDC_SHEETS_WIDE, m_sheets_wide);
			DDX_Text(pDX, IDC_PRINT_SCALE, csScale);
			DDX_Text(pDX, IDC_INCHES_TALL, csInchesTall);
			DDX_Text(pDX, IDC_INCHES_WIDE, csInchesWide);
			//}}AFX_DATA_MAP
		}
		CATCH (CException, e)
		{
			csScale.Empty();
			csInchesTall.Empty();
			csInchesWide.Empty();
			THROW_LAST();
		}
Beispiel #6
0
void CMyEdit::SetValue(double fValue, int nUnits)
{
	m_fValue = static_cast<int>(fValue * 100.0 + 0.5) / 100.0;
	m_nUnits = nUnits;
	if (m_nUnits < CAppSettings::Centimeters || m_nUnits > CAppSettings::Inches)
		m_nUnits = theApp.GetAppSettings()->nUnits;

	CString strUnits;
	AfxExtractSubString(strUnits, LoadString(IDS_UNITS_SHORT), nUnits, ',');
	SetWindowText(FormatString(_T("%s %s"), FormatDouble(m_fValue), strUnits));
}
Beispiel #7
0
VOID CPrintSize::update_all_but(UINT this_id)
{
	CString s;
	
	TRY
	{
		CDataExchange cDX(this, FALSE);
	
		if (this_id != IDC_SHEETS_TALL)
		{
			DDX_Text(&cDX, IDC_SHEETS_TALL, m_sheets_tall);
		}
		if (this_id != IDC_SHEETS_WIDE)
		{
			DDX_Text(&cDX, IDC_SHEETS_WIDE, m_sheets_wide);
		}
		if (this_id != IDC_PRINT_SCALE)
		{
			FormatDouble(m_scale, PRINT_SIZE_PERCENT_PRECISION, s);
			DDX_Text(&cDX, IDC_PRINT_SCALE, s);
		}
		if (this_id != IDC_INCHES_TALL)
		{
			FormatDouble(m_inches_tall, PRINT_SIZE_INCHES_PRECISION, s);
			DDX_Text(&cDX, IDC_INCHES_TALL, s);
		}
		if (this_id != IDC_INCHES_WIDE)
		{
			FormatDouble(m_inches_wide, PRINT_SIZE_INCHES_PRECISION, s);
			DDX_Text(&cDX, IDC_INCHES_WIDE, s);
		}
	
		m_preview.Invalidate(FALSE);
	}
	CATCH (CException, e)
	{
		s.Empty();
		THROW_LAST();
	}
Beispiel #8
0
static Bool
check_float_format_test(double number)
{
    char string[21];
    char expected[21];

    /* we currently always print float as .2f */
    sprintf(expected, "%.2f", number);

    FormatDouble(number, string);
    if(strncmp(string, expected, 21) != 0) {
        fprintf(stderr, "Failed to convert %f to string (%s vs %s)\n",
                number, expected, string);
        return FALSE;
    }

    return TRUE;
}
Beispiel #9
0
/*
CStringEx CTypeUnitDouble::Format( const CStringEx _sxvalue ) const
{
	if( _sxvalue.empty() )
		return( sxdefaultvalue );

	double dvalue = atof( _sxvalue.c_str() );
	if( dvalue < dlowlimit )
		dvalue = dlowlimit;
	if( dvalue > dhighlimit )
		dvalue = dhighlimit;
	return( FormatDouble( dvalue ) );
}
*/
CStringEx CTypeUnitDouble::Format( const CStringEx _sxvalue ) const
{
	if( _sxvalue.empty() )
		return( sxdefaultvalue );

	std::vector< std::pair< CStringEx, CStringEx > > modificationValues;
	CStringEx value( _sxvalue );
	value.purge();
	while( value[0] == '<' )
	{
		std::string::size_type pos = value.find( '>' );
		if( pos == std::string::npos )
			break;
		CStringEx sxoperateur = value.get_mid( 1, 1 );
		CStringEx sxoperande = value.get_mid( 2, (int)pos-2);
		value.right( (int)(value.size()-pos-1) );
		modificationValues.push_back( std::make_pair( sxoperateur, sxoperande ) );
	}
	if( modificationValues.size() )
	{
		CStringEx sxr;
		for( std::vector< std::pair< CStringEx, CStringEx > >::iterator it = modificationValues.begin(); it != modificationValues.end(); ++it )
		{
			sxr += CStringEx( "<" );
			sxr += it->first;
			sxr += it->second;
			sxr += CStringEx( ">" );
		}
		return( sxr );
	}
	else
	{
		double dvalue = atof( _sxvalue.c_str() );
		if( dvalue < dlowlimit )
			dvalue = dlowlimit;
		if( dvalue > dhighlimit )
			dvalue = dhighlimit;
		return( FormatDouble( dvalue ) );
	}
}
CString CDriveItem::GetText(int subitem) const
{
	CString s;

	switch (subitem)
	{
	case COL_NAME:
		s= m_name;
		break;

	case COL_TOTAL:
		if (m_success)
			s= FormatBytes((LONGLONG)m_totalBytes);
		break;

	case COL_FREE:
		if (m_success)
			s= FormatBytes((LONGLONG)m_freeBytes);
		break;

	case COL_GRAPH:
		if (m_querying)
			s.LoadString(IDS_QUERYING);
		else if (!m_success)
			s.LoadString(IDS_NOTACCESSIBLE);
		break;

	case COL_PERCENTUSED:
		if (m_success)
			s= FormatDouble(m_used * 100) + _T("%");
		break;

	default:
		ASSERT(0);
	}
	
	return s;
}
Beispiel #11
0
double LinearInterpolation(double x, Point_<double> p1, Point_<double> p2, bool yx) {
	double y, k;

	if(!yx) {
		k = ((p2.y - p1.y) / (p2.x - p1.x));
		if(k >= 0) y = x - (p1.x * k) + p1.y;
		else y = (p1.x * k) - x + p1.y;
	}
	else {
		k = ((p2.y - p1.y) / (p2.x - p1.x));
		if(k < 0) y = p2.x - ((p2.x - x) * k);
		else y = p1.x + ((x - p1.y) / k); // 20.07.2005  provato - OK
	}
#ifdef _WITH_DEBUG
RLOG("\nLinearInterpolation()");
RLOG("k: " + FormatDouble(k));
RLOG("x: " + FormatDouble(x));
RLOG("p1: " + FormatDouble(p1.x) + "," + FormatDouble(p1.y));
RLOG("p2: " + FormatDouble(p2.x) + "," + FormatDouble(p2.y));
RLOG("y: " + FormatDouble(y));
#endif
	return y;
}
Beispiel #12
0
CString CExtensionListControl::CListItem::GetBytesPercent() const
{
    CString s;
    s.Format(_T("%s%%"), FormatDouble(GetBytesFraction() * 100));
    return s;
}
std::string PDFTools::FormatFloat(float value)
{
  return FormatDouble((double)value);
}
Beispiel #14
0
	virtual String Save() const {
		return FormatDouble(~editor, 10);
	}
Beispiel #15
0
CString CItem::GetText(int subitem) const
{
	CString s;
	switch (subitem)
	{
	case COL_NAME:
		s = m_name;
		break;

	case COL_SUBTREEPERCENTAGE:
		if (IsDone())
		{
			ASSERT(m_readJobs == 0);
			//s = "ok";
		}
		else
		{
			if (m_readJobs == 1)
				s.LoadString(IDS_ONEREADJOB);
			else
				s.FormatMessage(IDS_sREADJOBS, FormatCount(m_readJobs));
		}
		break;

	case COL_PERCENTAGE:
		if (GetOptions()->IsShowTimeSpent() && MustShowReadJobs() || IsRootItem())
		{
			s.Format(_T("[%s s]"), FormatMilliseconds(GetTicksWorked()));
		}
		else
		{
			s.Format(_T("%s%%"), FormatDouble(GetFraction() * 100));
		}
		break;

	case COL_SUBTREETOTAL:
		s = FormatBytes(GetSize());
		break;

	case COL_ITEMS:
		if (GetType() != IT_FILE && GetType() != IT_FREESPACE && GetType() != IT_UNKNOWN)
			s = FormatCount(GetItemsCount());
		break;

	case COL_FILES:
		if (GetType() != IT_FILE && GetType() != IT_FREESPACE && GetType() != IT_UNKNOWN)
			s = FormatCount(GetFilesCount());
		break;

	case COL_SUBDIRS:
		if (GetType() != IT_FILE && GetType() != IT_FREESPACE && GetType() != IT_UNKNOWN)
			s = FormatCount(GetSubdirsCount());
		break;

	case COL_LASTCHANGE:
		if (GetType() != IT_FREESPACE && GetType() != IT_UNKNOWN)
		{
			s = FormatFileTime(m_lastChange);
		}
		break;

	case COL_ATTRIBUTES:
		if (GetType() != IT_FREESPACE && GetType() != IT_UNKNOWN && GetType() != IT_MYCOMPUTER && GetType() != IT_FILESFOLDER)
		{
			s = FormatAttributes(GetAttributes());
		}
		break;

	default:
		ASSERT(0);
		break;
	}
	return s;
}
Beispiel #16
0
String PieDraw::GetPercent(double a, double total) {
	double p = a*100/total;
	return FormatDouble(p, 1) + '%';
}
Beispiel #17
0
    StringExt *StringExt::AppendFormatV(char *sFormat, va_list sArgList)
    {
        StringExtFormatArg uArg;
        int nIndex, nWidth, nPrecision;
        bool bReverseAlign, bZeroFill;
        StringExtFormatType eFormatType;
        char sBuffer[65];
        int nLen;
        char *pCur, *pTemp, *sTemp;

        int nArgsLen = 0;
        int nArgsSize = 8;
        StringExtFormatArg *arrArgs = (StringExtFormatArg *)MemUtilsMallocArray( nArgsSize, sizeof(StringExtFormatArg));

        pCur = sFormat;
        while ( *pCur )
        {
            if ( *pCur == '{' )
            {
                ++pCur;
                if ( *pCur == '{' )
                {
                    ++pCur;
                    Append('{');
                }
                else
                {
                    // Разбираем форматированную строку
                    if ( !(*pCur >= '0' && *pCur <= '9') )
                        break;
                    nIndex = *pCur - '0';
                    for (++pCur; *pCur >= '0' && *pCur <= '9'; ++pCur )
                        nIndex = 10 * nIndex + (*pCur - '0');

                    if ( *pCur != ':' )
                        break;
                    ++pCur;
                    if ( *pCur == '-' )
                    {
                        bReverseAlign = true;
                        ++pCur;
                    }
                    else
                        bReverseAlign = false;
                    nWidth = 0;
                    bZeroFill = *pCur == '0';
                    for (; *pCur >= '0' && *pCur <= '9'; ++pCur )
                        nWidth = 10 * nWidth + (*pCur - '0');
                    if ( *pCur == '.' )
                    {
                        ++pCur;
                        nPrecision = 0;
                        for (; *pCur >= '0' && *pCur <= '9'; ++pCur )
                        {
                            nPrecision = 10 * nPrecision + (*pCur - '0');
                        }
                    }
                    else
                    {
                        nPrecision = 0;
                    }
                    for ( eFormatType = (StringExtFormatType)0;
                        c_arrsFormatStrings[ eFormatType ];
                    eFormatType = (StringExtFormatType)( eFormatType + 1 ) )
                    {
                        if (!strncmp( pCur, c_arrsFormatStrings[ eFormatType ], strlen(c_arrsFormatStrings[ eFormatType ])))
                        {
                            break;
                        }
                    }
                    if ( !c_arrsFormatStrings[ eFormatType ] )
                    {
                        break;
                    }
                    pCur += strlen( c_arrsFormatStrings[ eFormatType ] );
                    if (*pCur != '}')
                    {
                        break;
                    }
                    ++pCur;
                    // fetch the argument
                    if ( nIndex > nArgsLen )
                    {
                        break;
                    }
                    if ( nIndex == nArgsLen )
                    {
                        if ( nArgsLen == nArgsSize )
                        {
                            nArgsSize *= 2;
                            arrArgs = (StringExtFormatArg *)MemUtilsReallocArray( arrArgs, nArgsSize, sizeof(StringExtFormatArg));
                        }
                        switch ( eFormatType )
                        {
                        case fmtIntDecimal:
                        case fmtIntHex:
                        case fmtIntOctal:
                        case fmtIntBinary:
                        case fmtSpace:
                            arrArgs[nArgsLen].iValue = va_arg( sArgList, int );
                            break;
                        case fmtUIntDecimal:
                        case fmtUIntHex:
                        case fmtUIntOctal:
                        case fmtUIntBinary:
                            arrArgs[nArgsLen].uiValue = va_arg( sArgList, unsigned int );
                            break;
                        case fmtLongDecimal:
                        case fmtLongHex:
                        case fmtLongOctal:
                        case fmtLongBinary:
                            arrArgs[nArgsLen].lValue = va_arg( sArgList, long );
                            break;
                        case fmtULongDecimal:
                        case fmtULongHex:
                        case fmtULongOctal:
                        case fmtULongBinary:
                            arrArgs[nArgsLen].ulValue = va_arg( sArgList, unsigned long );
                            break;
                        case fmtDouble:
                        case fmtDoubleTrim:
                            arrArgs[nArgsLen].fValue = va_arg( sArgList, double );
                            break;
                        case fmtChar:
                            arrArgs[nArgsLen].cValue = (char)va_arg( sArgList, int );
                            break;
                        case fmtString:
                            arrArgs[nArgsLen].sValue = va_arg( sArgList, char * );
                            break;
                        case fmtStringExt:
                            arrArgs[nArgsLen].seValue = va_arg(sArgList, StringExt *);
                            break;
                        }
                        ++nArgsLen;
                    }

                    uArg = arrArgs[ nIndex ];
                    switch ( eFormatType )
                    {
                    case fmtIntDecimal:
                        FormatInt( uArg.iValue, sBuffer, sizeof(sBuffer), bZeroFill, nWidth, 10, &sTemp, &nLen );
                        break;
                    case fmtIntHex:
                        FormatInt( uArg.iValue, sBuffer, sizeof(sBuffer), bZeroFill, nWidth, 16, &sTemp, &nLen );
                        break;
                    case fmtIntOctal:
                        FormatInt( uArg.iValue, sBuffer, sizeof(sBuffer), bZeroFill, nWidth, 8, &sTemp, &nLen );
                        break;
                    case fmtIntBinary:
                        FormatInt( uArg.iValue, sBuffer, sizeof(sBuffer), bZeroFill, nWidth, 2, &sTemp, &nLen );
                        break;
                    case fmtUIntDecimal:
                        FormatUInt( uArg.uiValue, sBuffer, sizeof(sBuffer), bZeroFill, nWidth, 10, &sTemp, &nLen );
                        break;
                    case fmtUIntHex:
                        FormatUInt( uArg.uiValue, sBuffer, sizeof(sBuffer), bZeroFill, nWidth, 16, &sTemp, &nLen );
                        break;
                    case fmtUIntOctal:
                        FormatUInt( uArg.uiValue, sBuffer, sizeof(sBuffer), bZeroFill, nWidth, 8, &sTemp, &nLen );
                        break;
                    case fmtUIntBinary:
                        FormatUInt( uArg.uiValue, sBuffer, sizeof(sBuffer), bZeroFill, nWidth, 2, &sTemp, &nLen );
                        break;
                    case fmtLongDecimal:
                        FormatInt( uArg.lValue, sBuffer, sizeof(sBuffer), bZeroFill, nWidth, 10, &sTemp, &nLen );
                        break;
                    case fmtLongHex:
                        FormatInt( uArg.lValue, sBuffer, sizeof(sBuffer), bZeroFill, nWidth, 16, &sTemp, &nLen );
                        break;
                    case fmtLongOctal:
                        FormatInt( uArg.lValue, sBuffer, sizeof(sBuffer), bZeroFill, nWidth, 8, &sTemp, &nLen );
                        break;
                    case fmtLongBinary:
                        FormatInt( uArg.lValue, sBuffer, sizeof(sBuffer), bZeroFill, nWidth, 2, &sTemp, &nLen );
                        break;
                    case fmtULongDecimal:
                        FormatUInt( uArg.ulValue, sBuffer, sizeof(sBuffer), bZeroFill, nWidth, 10, &sTemp, &nLen );
                        break;
                    case fmtULongHex:
                        FormatUInt( uArg.ulValue, sBuffer, sizeof(sBuffer), bZeroFill, nWidth, 16, &sTemp, &nLen );
                        break;
                    case fmtULongOctal:
                        FormatUInt( uArg.ulValue, sBuffer, sizeof(sBuffer), bZeroFill, nWidth, 8, &sTemp, &nLen );
                        break;
                    case fmtULongBinary:
                        FormatUInt( uArg.ulValue, sBuffer, sizeof(sBuffer), bZeroFill, nWidth, 2, &sTemp, &nLen );
                        break;
                    case fmtDouble:
                        FormatDouble( uArg.fValue, sBuffer, sizeof(sBuffer), nPrecision, false, &sTemp, &nLen );
                        break;
                    case fmtDoubleTrim:
                        FormatDouble( uArg.fValue, sBuffer, sizeof(sBuffer), nPrecision, true, &sTemp, &nLen );
                        break;
                    case fmtChar:
                        sBuffer[0] = uArg.cValue;
                        sTemp = sBuffer;
                        nLen = 1;
                        bReverseAlign = !bReverseAlign;
                        break;
                    case fmtString:
                        sTemp = uArg.sValue;
                        nLen = strlen( sTemp );
                        bReverseAlign = !bReverseAlign;
                        break;
                    case fmtStringExt:
                        sTemp = uArg.seValue->GetBuffer();
                        nLen = uArg.seValue->GetLength();
                        bReverseAlign = !bReverseAlign;
                        break;
                    case fmtSpace:
                        sTemp = sBuffer;
                        nLen = 0;
                        nWidth = uArg.iValue;
                        break;
                    }
                    // Добавляем аргумент в нужном формате, с нужным прилеганием
                    if ( !bReverseAlign && nLen < nWidth )
                    {
                        for (int nCounter = nLen; nCounter < nWidth; ++nCounter )
                            Append(' ');
                    }
                    Append( sTemp, nLen);
                    if ( bReverseAlign && nLen < nWidth )
                    {
                        for (int nCounter = nLen; nCounter < nWidth; ++nCounter )
                            Append(' ');
                    }
                }
            }
            else if ( *pCur == '}' )
Beispiel #18
0
static int UppValueSimplify(VarItem &varItem, int step)
{
	enum { SMALL = 0, MEDIUM = 31 }; // SMALL has to be 0 because of GetSpecial and because is it ending zero
	enum { KIND = 14, SLEN = 15, LLEN = 2, SPECIAL = 13 };
	enum { STRING = 0, REF = 255, VOIDV = 3 };

	// get the embedded 'data' string 'chr' member
	// it contains info about value type
	union
	{
		char chr[16];
		char  *ptr;
		dword *wptr;
		qword *qptr;
		word   v[8];
		dword  w[4];
		qword  q[2];
		
		int iData;
		int64 i64Data;
		double dData;
		bool bData;
		struct
		{
			byte   day;
			byte   month;
			int16  year;
			byte   hour;
			byte   minute;
			byte   second;
		};
	} u;
	
	// see Upp::String code for how it works....
	MIValue val = varItem.EvaluateExpression("(" + varItem.evaluableExpression + ").data.chr");
	if(!val.IsString())
		return 0;
	String chrs = val.ToString();
	memcpy(u.chr, ~chrs, 16);

	// get value type, among the fixed ones
	// we could try later to decode registered types....
	dword type;
	bool isSpecial = !u.v[7] && u.v[6];
	if(!isSpecial)
		type = STRING_V;
	else
	{
		byte st = u.chr[SPECIAL];
		if(st == REF)
		{
			// ptr()->GetType()
			// by now, just mark as ref...
			type = REF;
		}
		else if(st == VOIDV)
			type = VOID_V;
		else
			type = st;
	}
	
	// by now, treat all types beyond VALUEMAP_V as unknown
	if(type > VALUEMAP_V)
		type = UNKNOWN_V;
	
	// now, based on type, we can decode it
	varItem.kind = VarItem::SIMPLE;
	switch(type)
	{
		case VOID_V:
		{
			varItem.value = "<VOID>";
			return 0;
		}
			
		case INT_V:
		{
			varItem.value = FormatInt(u.iData);
			return 0;
		}
			
		case DOUBLE_V:
		{
			varItem.value = FormatDouble(u.dData);
			return 0;
		}
			
		case STRING_V:
		{
			// we simply replace the VarItem with the string
			VarItem vItem(&varItem.Debugger(), "(" + varItem.evaluableExpression + ").data");
			vItem.evaluableExpression = varItem.evaluableExpression;
			vItem.shortExpression = varItem.shortExpression;
			varItem = vItem;
			return 0;
		}
			
		case DATE_V:
		{
			varItem.value = Format("Upp::Date = %02d/%02d/%04d", u.day, u.month, u.year);
			return 0;
		}
			
		case TIME_V:
		{
			varItem.value = Format("Upp::Time = %02d/%02d/%04d - %02d:%02d:%02d", u.day, u.month, u.year, u.hour, u.minute, u.second);
			return 0;
		}
			break;
			
		case ERROR_V:
		{
			varItem.value = "<ERROR_V>";
			return 0;
		}
			
		case VALUE_V:
		{
			varItem.value = "<VALUE_V>";
			return 0;
		}
			
		case WSTRING_V:
		{
			varItem.value = "<WSTRING_V>";
			return 0;
		}
			
		case VALUEARRAY_V:
		{
			varItem.value = "<VALUEARRAY_V>";
			return 0;
		}
			
		case INT64_V:
		{
			varItem.value = FormatInt64(u.i64Data);
			return 0;
		}
			
		case BOOL_V:
		{
			varItem.value = (u.bData ? "TRUE" : "FALSE");
			return 0;
		}
			
		case VALUEMAP_V:
		{
			varItem.value = "<VALUEMAP_V>";
			return 0;
		}
			
		case UNKNOWN_V:
		default:
		{
			varItem.value = "<UNKNOWN_V>";
			return 0;
		}
	}

}