chxavparseiterator.h

来自「著名的 helix realplayer 基于手机 symbian 系统的 播放」· C头文件 代码 · 共 85 行

H
85
字号
/*============================================================================*
 *
 * (c) 1995-2002 RealNetworks, Inc. Patents pending. All rights reserved.
 *
 *============================================================================*/
 
#ifndef _PARSE_ITERATOR_H
#define _PARSE_ITERATOR_H

#include "chxbody.h"
#include "hxstring.h"
#include "chxavnextline.h"

template<class Parser>
class CHXAvParseIterator : public CHXBody {
public:
    CHXAvParseIterator(const CHXString& file = "");
    ~CHXAvParseIterator();

    bool More() const;
    void Next();
    const Parser& Current() const;
    void Reset();

    int LineNum() const;

private:
    CHXAvNextLine m_nextLine;
    Parser m_current;
};

template<class Parser>
CHXAvParseIterator<Parser>::CHXAvParseIterator(const CHXString& file)
  : m_nextLine(file)
{
    if (m_nextLine.Open())
	Next();
}

template<class Parser>
CHXAvParseIterator<Parser>::~CHXAvParseIterator()
{
    m_nextLine.Close();
}

template<class Parser>
bool CHXAvParseIterator<Parser>::More() const
{
    return m_current.Valid();
}

template<class Parser>
const Parser& CHXAvParseIterator<Parser>::Current() const
{
    return m_current;
}

template<class Parser>
void CHXAvParseIterator<Parser>::Next()
{
    m_current.Reset();
    if (m_nextLine.IsOpen() && !m_nextLine.End())
    {
	CHXString line;
	while (m_nextLine.GetLine(line) && !m_current.Parse(line))
	    ;
    }
}

template<class Parser>
void CHXAvParseIterator<Parser>::Reset()
{
    if (m_nextLine.Reset())
	Next();
}

template<class Parser>
int CHXAvParseIterator<Parser>::LineNum() const
{
    return m_nextLine.LineNum();
}


#endif // _PARSE_ITERATOR_H

⌨️ 快捷键说明

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