⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rpfilobj.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 5 页
字号:
                    ulEffectMax += pEffect->GetDuration();                }                if (ulEffectMax > ulMax)                {                    ulMax = ulEffectMax;                }            }        }        // Assign the duration        m_ulDuration = ulMax;        // Check for errors        if (m_ulDuration == 0)        {            rulErrorID = IDS_ERR_PIX_NODURNOEFFECT;            rErrText   = "";            return FALSE;        }    }    // Compute the first and last use flags    retVal = InitImageUseFlags();    if (retVal != HXR_OK)    {        rulErrorID = IDS_ERR_PIX_INVALIDEFFECTS;        rErrText   = "";        return FALSE;    }    // Now we do logical checking of parameters. We should check for:    //    // 1. Effect target handles which don't reference any image tag    // 2. Effects with the same start time    return TRUE;}BOOL CIMFFileObject::GetAttributeSubstring(GString &rStr, const char *pszAttr, GString &rSubstr){    // Find attribute name in string    LONG32 lPos = rStr.find(pszAttr);    if (lPos < 0)    {        return FALSE;    }    // Go to next non-whitespace character after attribute name    lPos = rStr.find_first_not_of(m_pszWhitespace, lPos + strlen(pszAttr));    if (lPos < 0)    {        return FALSE;    }    if (rStr[lPos] != '=')    {        return FALSE;    }    // Go to beginning of whatever is after the "=" and following whitespace    lPos = rStr.find_first_not_of(m_pszWhitespace, lPos + 1);    if (lPos < 0)    {        return FALSE;    }    // If a quoted string, use string inside quotes    if (rStr[lPos] == '"')    {        // Find matching quote        LONG32 lNewPos = rStr.find('"', lPos + 1);        if (lNewPos < 0)        {            return FALSE;        }        if (lPos + 1 > lNewPos - 1)        {            rSubstr = "";            return TRUE;        }        // Build & return substring        rSubstr = rStr.substr(lPos + 1, lNewPos - 1);        return TRUE;    }    else    {        // Look for whitespace after the value string        LONG32 lNewPos = rStr.find_first_of(m_pszWhitespace, lPos);        if (lNewPos < 0)        {            // Look for tag end            lNewPos = rStr.find(m_pszTagEnd, lPos);            if (lNewPos < 0)            {                lNewPos = rStr.length();            }        }                // Build & return substring        rSubstr = rStr.substr(lPos, lNewPos - 1);        return TRUE;    }}BOOL CIMFFileObject::SetAttributeValue(GString &rStr, const char *pszAttr, GString &rStrTarget){    return GetAttributeSubstring(rStr, pszAttr, rStrTarget);}BOOL CIMFFileObject::SetAttributeValue(GString &rStr, const char *pszAttr, INT32 &rlTarget){    GString rStrTarget;    if (GetAttributeSubstring(rStr, pszAttr, rStrTarget))    {        rlTarget = atol(rStrTarget.c_str());        return TRUE;    }    return FALSE;}BOOL CIMFFileObject::SetAttributeValue(GString &rStr, const char *pszAttr, ULONG32 &rulTarget){    GString rStrTarget;    if (GetAttributeSubstring(rStr, pszAttr, rStrTarget))    {        rulTarget = strtoul(rStrTarget.c_str(), NULL, 10);        return TRUE;    }    return FALSE;}BOOL CIMFFileObject::SetAttributeValueBOOL(GString &rStr, const char *pszAttr, BOOL &rbTarget){    GString rStrTarget;    if (GetAttributeSubstring(rStr, pszAttr, rStrTarget))    {        if (rStrTarget == "true")        {            rbTarget = TRUE;            return TRUE;        }        if (rStrTarget == "false")        {            rbTarget = FALSE;            return TRUE;        }    }    return FALSE;}HX_RESULT CIMFFileObject::SetAttributeTimeValue(GString &rStr, const char *pszAttribute, ULONG32 ulFormat, ULONG32 &rulTimeTarget){    GString cTimeStr;    BOOL    bRet = GetAttributeSubstring(rStr, pszAttribute, cTimeStr);    if (bRet == FALSE)    {        return HXR_PROP_NOT_FOUND;    }    if (ulFormat == kTimeFormatMilliseconds)    {        // The attribute is present and the head says we're using        // the milliseconds time format        rulTimeTarget = strtoul(cTimeStr.c_str(), NULL, 10);    }    else    {        // The attribute is present and the head says we're using        // the dd:hh:mm:ss:xyz time format        // HACK to workaround length bug in GString        char *pszStr = (char *) cTimeStr.c_str();        bRet         = ConvertTimeStringToULONG32(pszStr, strlen(pszStr), rulTimeTarget);        if (bRet == FALSE)        {            // This indicates there was a formatting error in the time value            rulTimeTarget = 0;            return HXR_FAILED;        }    }    return HXR_OK;}#define MIN_TIMEBUFFERLENGTH            1  //Min time-format string is "s" (0-9 secs)#define NUM_DECIMAL_DIGITS_OF_SECONDS   3BOOL CIMFFileObject::ConvertTimeStringToULONG32(char *pTimeBuf, ULONG32 timeBufLen, ULONG32 &timeValInMillisec){    char   *pTimeBuffer            = pTimeBuf;    ULONG32 timeBufferLen          = timeBufLen;    char    savedEndChar           = '\0';   //for restoring '\"' char at end, if found.    LONG32  bufIndx                = 0L;    BOOL    bDotEncounteredAlready = FALSE;    LONG32  indexOfDot             = -1;    BOOL    endCharWasChanged      = FALSE;    ULONG32 days_;    ULONG32 hours_;    ULONG32 minutes_;    ULONG32 seconds_;    ULONG32 milliseconds_;    // Initialize    days_ = hours_ = minutes_ = seconds_ = milliseconds_ = 0L;    timeValInMillisec=0;    // Check for input error    if(!pTimeBuffer  ||  timeBufLen < MIN_TIMEBUFFERLENGTH)    {        return FALSE;    }    savedEndChar = pTimeBuffer[timeBufferLen-1];    //Get rid of start & terminating quotation mark, if they exist:    if(pTimeBuffer[0] == '\"')    {        pTimeBuffer++;        timeBufferLen--;        //Added this check to kill bug if (pTimeBuffer==")        // and got shortened to an empty string:        if(!timeBufferLen)        {            return FALSE;        }    }    if(pTimeBuffer[timeBufferLen - 1] == '\"')    {        pTimeBuffer[timeBufferLen - 1] = '\0'; //get rid of end '\"'.        timeBufferLen--;        endCharWasChanged = TRUE;    }        // Work from right to left, searching first for milliseconds and then for    // seconds (or seconds only if no '.' found):    BOOL bColonWasFound = FALSE;    for(bufIndx=timeBufferLen-1; 0L<=bufIndx; bufIndx--)    {        char ch = toupper(pTimeBuffer[bufIndx]);        if('0' > ch  ||  '9' < ch)        {            if(' '==ch  ||  '\t'==ch  ||  '\n'==ch  ||  '\r'==ch)            {                //Added everything up to "break;" to                // handle (valid) strings with leading space(s) like " 39":                //previous found was seconds_, so translate into ULONG:                seconds_ = atol(&pTimeBuffer[bufIndx+1L]);                timeValInMillisec += seconds_*1000; //converts seconds to ms.                break; //we're done; we found seconds only.            }            else if('.' == ch)            {                if(bDotEncounteredAlready)                {                    //Make sure pTimeBuffer is in original state:                    if(endCharWasChanged)                    {                        timeBufferLen++;                        pTimeBuffer[timeBufferLen-1] = savedEndChar;                    }                    if(indexOfDot >= 0)                    {                        pTimeBuffer[indexOfDot] = '.';                    }                    //this second '.' is unexpected, so return with                    //  timeValInMillisec set to whatever was read so far:                    return FALSE;                }                bDotEncounteredAlready = TRUE;                indexOfDot = bufIndx;                pTimeBuffer[bufIndx] = '\0'; //end the buffr at the '.' .                //previously-read #'s are milliseconds, so count them:                //added "-1" to fix bug if buf ends with ".":                if(1L > timeBufferLen-bufIndx - 1)                {                    milliseconds_ = 0L;                }                else                {                    //Now, make sure that more than three digits (base 10)                    //  are not present, e.g., reduce "46371" to "463" since                    //  we only allow millisecond precision (3 digits past                    //  the decimal point:                    char    chTmp = '\0';                    ULONG32 ulNumDecimalDigitsFound = timeBufferLen-1 - bufIndx;                    if(NUM_DECIMAL_DIGITS_OF_SECONDS < ulNumDecimalDigitsFound)                    {                        chTmp                                                = pTimeBuffer[bufIndx + 1L];                        pTimeBuffer[bufIndx+NUM_DECIMAL_DIGITS_OF_SECONDS+1] = '\0';                    }                    milliseconds_ = atol(&pTimeBuffer[bufIndx+1L]);                    //Added this to fix "y.x" being converted                    // to y00x instead of yx00 milliseconds:                    if(ulNumDecimalDigitsFound < NUM_DECIMAL_DIGITS_OF_SECONDS)                    {                        for(ULONG32 ulDiff= NUM_DECIMAL_DIGITS_OF_SECONDS - ulNumDecimalDigitsFound; ulDiff > 0; ulDiff--)                        {                            milliseconds_ *= 10;                        }                    }                    if(NUM_DECIMAL_DIGITS_OF_SECONDS < ulNumDecimalDigitsFound)                    {                        //restore the changed char in the pTimeBuffer:                        pTimeBuffer[bufIndx+ NUM_DECIMAL_DIGITS_OF_SECONDS + 1] = chTmp;                    }                }                        timeValInMillisec = milliseconds_;            }            else if(':' == ch)            {                bColonWasFound = TRUE;                //previous found was seconds_, so translate into ULONG:                seconds_           = atol(&pTimeBuffer[bufIndx + 1L]);                timeValInMillisec += seconds_ * 1000; //converts seconds to ms.                break; //done with "seconds_[.milliseconds_]" part.            }            else  //unexpected char found, so quit parsing:            {                //Make sure pTimeBuffer is in original state:                if(endCharWasChanged)                {                    timeBufferLen++;                    pTimeBuffer[timeBufferLen - 1] = savedEndChar;                }                if(indexOfDot >= 0)                {                    pTimeBuffer[indexOfDot] = '.';                }                //this char is unexpected, so return FALSE with                //  timeValInMillisec set to whatever was read so far:                return FALSE;            }        }        else if(0L == bufIndx) //we're done with the buffer:        {            //previous found was seconds_, so translate into ULONG:            seconds_           = atol(pTimeBuffer);            timeValInMillisec += seconds_*1000; //converts seconds to ms.            break; //done with "seconds_[.milliseconds_]" part.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -