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


C++ COpcText::SetEofDelim方法代码示例

本文整理汇总了C++中COpcText::SetEofDelim方法的典型用法代码示例。如果您正苦于以下问题:C++ COpcText::SetEofDelim方法的具体用法?C++ COpcText::SetEofDelim怎么用?C++ COpcText::SetEofDelim使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在COpcText的用法示例。


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

示例1: cReader

// Read
template<> bool OpcXml::Read(const COpcString& cString, Decimal& cValue)
{
    bool bResult = true;

    TRY
    {
        COpcText cText;
        COpcTextReader cReader(cString);

        // parse whole integer portion.
        cText.SetType(COpcText::Delimited);
        cText.SetDelims(L".");
        cText.SetEofDelim();

        if (!cReader.GetNext(cText))
        {
            THROW_(bResult, false);
        }

        // convert to signed integer.
        Long nValue = 0;

        if (!ToSigned(cText, nValue, MAX_DECIMAL, MIN_DECIMAL))
        {
            THROW_(bResult, false);
        }

        cValue.int64 = nValue*10000;
        
        if (cText.GetDelimChar() == L'.')
        {
            // parse decimal portion.
            cText.SetType(COpcText::Delimited);
            cText.SetEofDelim();

            if (!cReader.GetNext(cText))
            {
                THROW_(bResult, false);
            }

            // convert to unsigned integer.
            ULong uValue = 0;

            if (!ToUnsigned(cText, uValue, MAX_DEC_FRACTION, 0, 10))
            {
                THROW_(bResult, false);
            }

            cValue.int64 += (Long)uValue;
        }
    }
    CATCH
    {
        cValue.int64 = 0;
    }

    return bResult;
}
开发者ID:AnBesp,项目名称:UA-.NET,代码行数:59,代码来源:OpcXmlType.cpp

示例2: ToDate

// ToDate
static bool ToDate(
    const COpcString& cString, 
    WORD&             wYear,
    WORD&             wMonth,
    WORD&             wDay
)
{
    bool bResult = true;

    TRY
    {
        COpcText cText;
        COpcTextReader cReader(cString);

        ULong uValue = 0;

        // parse year field.
        cText.SetType(COpcText::Delimited);
        cText.SetDelims(L"-");

        if (!cReader.GetNext(cText)) THROW_(bResult, false);
        if (!ToUnsigned(cText, uValue, MAX_YEAR, MIN_YEAR, 10)) THROW_(bResult, false);
        wYear = (WORD)uValue;

        // parse month field.
        cText.SetType(COpcText::Delimited);
        cText.SetDelims(L"-");

        if (!cReader.GetNext(cText)) THROW_(bResult, false);
        if (!ToUnsigned(cText, uValue, MAX_MONTH, MIN_MONTH, 10)) THROW_(bResult, false);
        wMonth = (WORD)uValue;

        // parse day field.
        cText.SetType(COpcText::Delimited);
        cText.SetEofDelim();

        if (!cReader.GetNext(cText)) THROW_(bResult, false);
        if (!ToUnsigned(cText, uValue, MAX_DAY, MIN_DAY, 10)) THROW_(bResult, false);
        wDay = (WORD)uValue;
    }
    CATCH
    {
        wYear  = 0;
        wMonth = 0;
        wDay   = 0;
    }

    return bResult;
}
开发者ID:AnBesp,项目名称:UA-.NET,代码行数:50,代码来源:OpcXmlType.cpp

示例3: ToOffset

// ToOffset
static bool ToOffset(
    const COpcString& cString, 
	bool              bNegative,
    SHORT&            sMinutes
)
{
    bool bResult = true;

    TRY
    {
        COpcText cText;
        COpcTextReader cReader(cString);

        ULong uValue = 0;

        // parse hour field.
        cText.SetType(COpcText::Delimited);
        cText.SetDelims(L":");

        if (!cReader.GetNext(cText)) THROW_(bResult, false);
        if (!ToUnsigned(cText, uValue, MAX_HOUR, MIN_HOUR, 10)) THROW_(bResult, false);
      
		sMinutes = (SHORT)uValue*60;

        // parse minute field.
        cText.SetType(COpcText::Delimited);
        cText.SetDelims(L".");
        cText.SetEofDelim();

        if (!cReader.GetNext(cText)) THROW_(bResult, false);
        if (!ToUnsigned(cText, uValue, MAX_MINUTE, MIN_MINUTE, 10)) THROW_(bResult, false);
        
		sMinutes += (SHORT)uValue;

		// add sign.
		if (bNegative)
		{
			sMinutes = -sMinutes;
		}
    }
    CATCH
    {
        sMinutes = 0;
    }

    return bResult;
}
开发者ID:AnBesp,项目名称:UA-.NET,代码行数:48,代码来源:OpcXmlType.cpp

示例4: ToTime

// ToTime
static bool ToTime(
    const COpcString& cString, 
    WORD&             wHour,
    WORD&             wMinute,
    WORD&             wSeconds,
    WORD&             wFraction
)
{
    bool bResult = true;

    TRY
    {
        COpcText cText;
        COpcTextReader cReader(cString);

        ULong uValue = 0;

        // parse hour field.
        cText.SetType(COpcText::Delimited);
        cText.SetDelims(L":");

        if (!cReader.GetNext(cText)) THROW_(bResult, false);
        if (!ToUnsigned(cText, uValue, MAX_HOUR, MIN_HOUR, 10)) THROW_(bResult, false);
        wHour = (WORD)uValue;

        // parse month field.
        cText.SetType(COpcText::Delimited);
        cText.SetDelims(L":");

        if (!cReader.GetNext(cText)) THROW_(bResult, false);
        if (!ToUnsigned(cText, uValue, MAX_MINUTE, MIN_MINUTE, 10)) THROW_(bResult, false);
        wMinute = (WORD)uValue;

        // parse seconds field.
        cText.SetType(COpcText::Delimited);
        cText.SetDelims(L".");
        cText.SetEofDelim();

        if (!cReader.GetNext(cText)) THROW_(bResult, false);
        if (!ToUnsigned(cText, uValue, MAX_SECOND, MIN_SECOND, 10)) THROW_(bResult, false);
        wSeconds = (WORD)uValue;

        // parse seconds fraction field.
        wFraction = 0;

        if (cText.GetDelimChar() == L'.')
        {
            cText.SetType(COpcText::Delimited);
            cText.SetEofDelim();

            if (!cReader.GetNext(cText)) THROW_(bResult, false);

            // preprocess text.
            COpcString cFraction = cText;

            // add trailing zeros.
            while (cFraction.GetLength() < 3) cFraction += _T("0");

            // truncate extra digits.
            if (cFraction.GetLength() > 3) cFraction = cFraction.SubStr(0,3);

            if (!ToUnsigned(cFraction, uValue, MAX_ULONG, 0, 10))
            {
                THROW_(bResult, false);
            }

            // result is in milliseconds.
            wFraction = (WORD)uValue;
        }
    }
    CATCH
    {
        wHour     = 0;
        wMinute   = 0;
        wSeconds  = 0;
        wFraction = 0;
    }

    return bResult;
}
开发者ID:AnBesp,项目名称:UA-.NET,代码行数:81,代码来源:OpcXmlType.cpp

示例5: ToUnsigned

// ToUnsigned
static bool ToUnsigned(
    const COpcString& cString, 
    ULong&            nValue,
    ULong             nMax, 
    ULong             nMin, 
    UINT              uBase
)
{ 
    bool bResult = true;

    TRY
    {
        COpcText cText;
        COpcTextReader cReader(cString);

        // extract non-whitespace.
        cText.SetType(COpcText::NonWhitespace);
        cText.SetEofDelim();

        if (!cReader.GetNext(cText))
        {
            THROW_(bResult, false);
        }

        COpcString cValue = cText;

        nValue = 0;

        for (UINT ii = 0; ii < cValue.GetLength(); ii++)
        {
            UINT uDigit = CharToValue(cValue[ii], uBase);

            // invalid digit found.
            if (uDigit == -1) 
            {
                bResult = false;
                break;
            }

            // detect overflow
            if (nValue > nMax/uBase) THROW_(bResult, false);

            // shift result up by base.
            nValue *= uBase;

            // detect overflow
            if (nValue > nMax - uDigit) THROW_(bResult, false);

            // add digit.
            nValue += uDigit;
        }

        // detect underflow
        if (nMin > nValue) THROW_(bResult, false);
    }
    CATCH
    {
        nValue = 0;
    }

    return bResult;
}
开发者ID:AnBesp,项目名称:UA-.NET,代码行数:63,代码来源:OpcXmlType.cpp


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