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

邓逍遥徐

邓逍遥徐

2016-02-19 21:06

岁数大了,QQ也不闪了,微信也不响了,电话也不来了,但是图老师依旧坚持为大家推荐最精彩的内容,下面为大家精心准备的VC中使用SCRIPT 正则写的LRC歌词分析类,希望大家看完后能赶快学习起来。

#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();
}

(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/bianchengyuyan/)

LRCOBJECT::LRCOBJECT(void)
{
}

LRCOBJECT::~LRCOBJECT(void)
{
    Release();
}
// //查找添加LRC标题

(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/bianchengyuyan/)

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;

            al= (pMatch-GetItem(0)).bstrVal;
        }
        //---------------------
        /*
        短整型(int)
        i = atoi(temp);
        长整型(long)
        l = atol(temp);
        浮点(double)
        d = atof(temp);
        */
        regExpPtr-PutPattern("[offset:(-?d+)]");
        matches = regExpPtr-Execute((const char * )Text); //用指针要出错
        if(matches-GetCount()0)
        {
            pMatch=((IMatch2Ptr)matches-GetItem(0))-GetSubMatches();//SubMatches;
            by= (pMatch-GetItem(0)).bstrVal;
            try
            {
                oTime=float(atof(by));
            }catch(...){};
        }
        //-----------------------------------------
        regExpPtr-PutPattern("[by:([^[]:]+)]");
        matches = regExpPtr-Execute((const char * )Text); //用指针要出错
        if(matches-GetCount()0)
        {
            pMatch=((IMatch2Ptr)matches-GetItem(0))-GetSubMatches();//SubMatches;
            by= (pMatch-GetItem(0)).bstrVal;
        }

        regExpPtr-PutPattern("[d+:[d.]+]");
        matches = regExpPtr-Execute((const char * )Text); //用指针要出错
        if(matches-GetCount()0)
        {
            isLrcFile=TRUE;
        }
        else
        {
            isLrcFile=FALSE;
        }
        pMatch=NULL;
        matches=NULL;
        regExpPtr=NULL;
        //"[d+:[d.]+]"

    }
    //catch(_com_error& e)
    //{
    /

展开更多 50%)
分享

猜你喜欢

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

编程语言 网络编程
VC中使用SCRIPT 正则写的LRC歌词分析类

VC#中使用XML之基于DOM的案例分析

编程语言 网络编程
VC#中使用XML之基于DOM的案例分析

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

在VBScript中使用类

Web开发
在VBScript中使用类

在ASP中使用类

ASP
在ASP中使用类

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

VC的CTreeCtrl类的递归使用

编程语言 网络编程
VC的CTreeCtrl类的递归使用

怎样在vc、delphi中使用mysql

编程语言 网络编程
怎样在vc、delphi中使用mysql

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

VC++ 水晶报表

VC++ 水晶报表

VC++ 替换 exe 可执行文件的图标

VC++ 替换 exe 可执行文件的图标
下拉加载更多内容 ↓