#include "StdAfx.h"
#include ".lrcobject.h"
#include <comdef.h>
LRCOBJECT::LRCOBJECT(const char * text)
: ar(_T(""))
, by(_T(""))
, al(_T(""))
, ti(_T(""))
, oTime(0)
, isLrcFile(FALSE)
{
Text=text;
steLrcTi();
}
LRCOBJECT::LRCOBJECT(void)
{
}
LRCOBJECT::~LRCOBJECT(void)
{
Release();
}
// //查找添加LRC標題
void LRCOBJECT::steLrcTi(void)
{
CoInitialize(NULL);
try{
IRegExpPtr regExpPtr(__uuidof(RegExp));
regExpPtr->PutGlobal(VARIANT_TRUE);
regExpPtr->PutPattern("[ti:([^[]:]+)]");
IMatchCollectionPtr matches = regExpPtr->Execute((const char * )Text); //Execute方法接受的是_bstr_t類型,因此要進行(const char * )轉換
ISubMatchesPtr pMatch;
if(matches->GetCount() >0 )
{
//IMatch2Ptr類型才有GetSubMatches()方法,因此,要進行顯式的類型轉換
pMatch=((IMatch2Ptr)matches->GetItem(0))->GetSubMatches();//SubMatches;
//pMatch->GetItem(0)返回是_variant_t類型,_variant_t類型的屬性bstrVal是BSTR類型
ti= (pMatch->GetItem(0)).bstrVal;
}
//--------------------------------------------------
regExpPtr->PutPattern("[ar:([^[]:]+)]");
matches = regExpPtr->Execute((const char * )Text);
if(matches->GetCount()>0)
{
pMatch=((IMatch2Ptr)matches->GetItem(0))->GetSubMatches();//SubMatches;
ar= (pMatch->GetItem(0)).bstrVal;
}
//-----------------------------------------
regExpPtr->PutPattern("[al:([^[]:]+)]");
matches = regExpPtr->Execute((const char * )Text); //用指針要出錯
if(matches->GetCount()>0)
{
pMatch=((IMatch2Ptr)matches->GetItem(0))->GetSubMatches();//SubMatches;