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


C++ Pattern::createMatcher方法代码示例

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


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

示例1: loadD3DAPICallsCSVFile

//
// Load the D3DAPICalls benchmark report:
//
// benchmarkable_call_number,frame_time_ms,time_difference,call_type,draw_call_number,calls_skipped,calls_executed,ps_text,vs_text,vdecl_text
//
bool loadD3DAPICallsCSVFile(const char *name, const char *fname, const std::vector<std::string> &keywordTable, bool bDiffGraph, bool bCollapse)
{
    char tmpstr[1024];
    int graphDiff = -1;

    std::ifstream fs(fname);
    if(!fs.is_open())
	{
		if(g_pLog) g_pLog->AddMessage("no>>Failure...");
        return false;
	}
    // for size of the file so we can display a progress bar
    fs.seekg( -1, std::ios_base::end );
    int bSize = (int)fs.tellg();
    fs.seekg( 0, std::ios_base::beg );
    g_pProgressBar->SetTitle("Loading D3DAPICalls benchmark data...");
	if(g_pLog) g_pLog->AddMessage("Loading D3DAPICalls benchmark data %s", fname);

    fs.getline(tmpstr, 1023); //Dummy line
    if(*tmpstr == '\0')
	{
		if(g_pLog) g_pLog->AddMessage("no>>Failure...");
        return false;
	}
    g_apiCall.clear();

    int disp = (int)g_pDisplays.size();
    IWindowFolding *pWFold;
    if(disp == 0)
    {
        TLDisplay *pDisp = new TLDisplay(g_hwnd);
        pDisp->name = "API Calls Benchmark";
        g_pDisplays.push_back(pDisp);
        //UI:
        pWFold = g_pwinHandler->CreateWindowFolding((LPCSTR)(1<<16), "API Calls Benchmark", g_pMainContainer);
    }
    else
    {
        pWFold = (IWindowFolding *)g_pwinHandler->Get((LPCSTR)(1<<16))->QueryInterface("IWindowFolding");
    }
    // LET's ASSUME that this is always done in display #0 :
    disp = 0;
    int graphTime = g_pDisplays[disp]->addGraph(name);

    //Create a second graph for time difference...
    if(bDiffGraph)
    {
        TLDisplay *pDisp = new TLDisplay(g_hwnd);
        pDisp->name = "API Calls time difference";
        g_pDisplays.push_back(pDisp);
        graphDiff = g_pDisplays[1]->addGraph(name);
    }
    //UI:
    g_pwinHandler->CreateCtrlCheck((LPCSTR)graphTime, name, pWFold)->SetChecked(true);

    //Examples:
    //-1,2.40242,2.40242,first_call_was_skipped,,1999,0
    //0,2.4076,0.005188,Clear,,1998,1
    //Examples2:
    //-1,2.10559,2.10559,first_call_was_skipped,,4147,0,,,
    //0,2.42992,0.32433,Clear,,4146,1,,,
    //2,2.66265,0.215147,Draw,0,4144,3,ps_ea97b1f6b1cbfb27_1,vs_text_1,vdecl_text_1

    //Fill in the graph
    Pattern::registerPattern("int", "\\s*([\\-0-9]*)\\s*");
    Pattern::registerPattern("float", "\\s*([\\-0-9\\.eE]*)\\s*");
    Pattern::registerPattern("text", "\\s*(\\w*)\\s*");
    Pattern *p = Pattern::compile("{int},{float},{float},(\\w+),?{int},?{int},?{int},?{text},?{text},?{text}");
    Matcher *m = p->createMatcher("");
	int benchmarkable_call_number_collapsed = 0;
    do {
        int benchmarkable_call_number;
        float frame_time_ms;
        float time_difference;
        std::string call_type;
        int draw_call_number;
        int calls_skipped;
        int calls_executed;
        std::string ps_text;
        std::string vs_text;
        std::string vdecl_text;
        std::string comment;

        fs.getline(tmpstr, 1023);
        if(fs.eof())
            break;
        m->setString(tmpstr);
        if(m->findFirstMatch())
        {
            benchmarkable_call_number = atoi(m->getGroup(1).c_str());
            frame_time_ms = (float)atof(m->getGroup(2).c_str());
            time_difference = (float)atof(m->getGroup(3).c_str());
            call_type = m->getGroup(4);
            draw_call_number = atoi(m->getGroup(5).c_str());
            calls_skipped = atoi(m->getGroup(6).c_str());
//.........这里部分代码省略.........
开发者ID:tlorach,项目名称:nvGraphy,代码行数:101,代码来源:File_D3DAPICallsBenchmark.cpp

示例2: loadOGLAPICallsCSVFile

//
// Load the API Calls benchmark report:
//
//
bool loadOGLAPICallsCSVFile(const char *name, const char *fname, const std::vector<std::string> &keywordTable, bool bDiffGraph, bool bCollapse)
{
	int graphSignal, graphRawSignal, firstGraphId, firstGraphRawId;
	int firstGraphIdOffset, firstGraphRawIdOffset;
    char tmpstr[1024];
	std::vector< std::string > itemNames;
	std::vector< bool > itemIsPercent;
    int graphDiff = -1;
	bool bHasSignals = true;
	bool bHasAnalysis = true;
	int numSignals = 0, startIdxSignals = 0;

    std::ifstream fs(fname);
    if(!fs.is_open())
	{
		if(g_pLog) g_pLog->AddMessage("no>>Failure...");
        return false;
	}
    // for size of the file so we can display a progress bar
    fs.seekg( -1, std::ios_base::end );
    int bSize = fs.tellg();
    fs.seekg( 0, std::ios_base::beg );
    g_pProgressBar->SetTitle("Loading API Calls benchmark data...");
	if(g_pLog) g_pLog->AddMessage("Loading API Calls benchmark data %s", fname);

    fs.getline(tmpstr, 1023); //title line
    if(*tmpstr == '\0')
	{
		if(g_pLog) g_pLog->AddMessage("no>>Failure...");
        return false;
	}
    g_apiCall.clear();
	// Let's parse the title line : some names will be needed for the unknown signals
	Pattern *patNames = Pattern::compile("([0-9/\\[\\]\\-\\(\\)\\%\\.=:\\|_\\w\\s]+)");
    Matcher *matchNames = patNames->createMatcher(tmpstr);
	int nNames = 0;
	if(matchNames->findFirstMatch())
	{
		do {
			std::string name = matchNames->getGroup(1);
			itemNames.push_back(name);
			itemIsPercent.push_back(strstr(name.c_str(), "%") ? true : false);
			if((int)itemNames.size() == NUM_BASE_VALUES+1)
				if(strcmp("GPU Bottleneck", itemNames[NUM_BASE_VALUES].c_str()))
					bHasAnalysis = false;
		} while(matchNames->findNextMatch());
	}
	if((int)itemNames.size() == NUM_BASE_VALUES)
	{
		bHasSignals = false;
		bHasAnalysis = false;
	}
	else if(bHasAnalysis && (int)itemNames.size() == (NUM_BASE_VALUES+NUM_EXP_EVENTS) )
		bHasSignals = false;
	else 
	{
		startIdxSignals = (bHasAnalysis ? NUM_BASE_VALUES+NUM_EXP_EVENTS : NUM_BASE_VALUES);
		numSignals = (int)itemNames.size() - startIdxSignals;
	}

    IWindowFolding *pWFold, *pWFoldElts, *pWFoldEltsTotal, *pWFoldSignals, *pWFoldRawSignals, *pWFoldSignals2, *pWFoldRawSignals2;
    // FOR NOW: LET's ASSUME that this is always done in display #0 :
    int disp = 0;
	int dispElts = disp + 1;
	int dispEltsTotal = disp + 2;
	int dispSignals = disp + 3;
	int dispRawSignals = disp + 4;
    if((int)g_pDisplays.size() == 0)
    {
        TLDisplay *pDisp = new TLDisplay(g_hwnd);
        pDisp->name = "OGL API Calls Benchmark";
        g_pDisplays.push_back(pDisp);
        TLDisplay *pDispElts = new TLDisplay(g_hwnd);
        pDispElts->name = "OGL Num Elts";
        g_pDisplays.push_back(pDispElts);
        TLDisplay *pDispEltsTotal = new TLDisplay(g_hwnd);
        pDispElts->name = "OGL Total Num Elts";
        g_pDisplays.push_back(pDispEltsTotal);
        TLDisplay *pDispSignals = new TLDisplay(g_hwnd);
        pDispSignals->name = "Instrumentation%";
        g_pDisplays.push_back(pDispSignals);
        TLDisplay *pDispRawSignals = new TLDisplay(g_hwnd);
        pDispSignals->name = "Instrumentation";
        g_pDisplays.push_back(pDispRawSignals);
        //UI:
        (pWFold			= g_pwinHandler->CreateWindowFolding((LPCSTR)(1<<8), "API Calls Benchmark", g_pMainContainer))->UnFold();
        (pWFoldElts		= g_pwinHandler->CreateWindowFolding((LPCSTR)(2<<8), "API Calls Elements", g_pMainContainer))->UnFold();
        (pWFoldEltsTotal= g_pwinHandler->CreateWindowFolding((LPCSTR)(3<<8), "API Calls Elements Total", g_pMainContainer))->UnFold();
        (pWFoldSignals	= g_pwinHandler->CreateWindowFolding((LPCSTR)(4<<8), "Signals", g_pMainContainer))->UnFold();
        (pWFoldRawSignals	= g_pwinHandler->CreateWindowFolding((LPCSTR)(5<<8), "RawSignals", g_pMainContainer))->UnFold();

		firstGraphIdOffset = 0;
		firstGraphRawIdOffset = 0;
    }
    else
    {
//.........这里部分代码省略.........
开发者ID:tlorach,项目名称:nvGraphy,代码行数:101,代码来源:File_OGLAPICallsBenchmark.cpp


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