龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 软件开发 > VC开发 >

VC中使用SCRIPT 正则写的LRC歌词分析类(4)

时间:2009-12-30 15:42来源:未知 作者:admin 点击:
分享到:
} IRegExpSubPtr=NULL; matches=NULL; matches2=NULL; regExpPtr=NULL; } catch(...){}; //--------------------- //CoUninitialize(); return m_reText; } void LRCOBJECT::AddToList(const char * text) { //lrcBo

        }
        IRegExpSubPtr=NULL;
        matches=NULL;
        matches2=NULL;
        regExpPtr=NULL;
    }
    catch(...){};
    //---------------------
    //CoUninitialize();
    return m_reText;
}

void LRCOBJECT::AddToList(const char * text)
{
    //lrcBoxclassList
    Release();
    CString m_Text,m_strtmp;
    lrcBox* pLrcBox;
    float m_t,m_t2;
    //CoInitialize(NULL);
    CString debg,ttt;
    try
    {
        IRegExpPtr regExpPtr(__uuidof(RegExp));
        regExpPtr->PutGlobal(VARIANT_TRUE);
        regExpPtr->PutPattern("[([^:]+):([^]]+)](.*)[ ]");
        IMatchCollectionPtr matches = regExpPtr->Execute(text);
        int m_count=matches->GetCount();
        ISubMatchesPtr pSubMatch;
        if(m_count>0)
        {
            for(int i=0;i<m_count;i++)
            {
                pSubMatch=((IMatch2Ptr)matches->GetItem(i))->GetSubMatches();//SubMatches;
                m_Text= (pSubMatch->GetItem(2)).bstrVal;

                //::MessageBox(::GetTopWindow(::GetDesktopWindow()),m_Text, "URL CLIENT", MB_OK);
                m_t=float(atof((CString)(pSubMatch->GetItem(0)).bstrVal));
                m_t2=float(atof((CString)(pSubMatch->GetItem(1)).bstrVal));


                m_t=m_t*60 + m_t2;
                pLrcBox=new lrcBox(m_t,m_Text);
                //Length++;
                lrcBoxclassList.AddTail(pLrcBox);
            }
        }
        pSubMatch=NULL;
        matches=NULL;
        regExpPtr=NULL;

    }
    catch(...)
    {
        Release();
    }
    //-----------------------------

    //-----------------------------
    //CoUninitialize();
    PaiXu();
}

精彩图集

赞助商链接