// SrtReader.h: interface for the CSrtReader class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_SRTREADER_H__21CC5E2E_74E5_4BAF_BC46_69FB4ECE94F1__INCLUDED_)
#define AFX_SRTREADER_H__21CC5E2E_74E5_4BAF_BC46_69FB4ECE94F1__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class CSrtReader  
{
public:
    BOOL SaveToFiles(LPCTSTR lpszFileNameFormat) const;
    int Cut(short sHour, short sMinute, short sSecond, short sMillsecond);
    CSrtReader();
    virtual ~CSrtReader();

    BOOL ReadFromFile(LPCTSTR lpszFileName);

protected:
    struct _tagTimestamp
    {
        short sHour;
        short sMinute;
        short sSecond;
        short sMillsecond;
    };

    struct _tagTitle
    {
        int iIndex;
        _tagTimestamp tsStart;
        _tagTimestamp tsEnd;
        TCHAR szText[1024];
    };

    std::vector<_tagTitle*> m_vpTitles;
    std::vector<_tagTimestamp> m_vtsSeparators;

private:
    inline BOOL _TimeSpan(struct _tagTimestamp& ts, const _tagTimestamp& ts1, const _tagTimestamp& ts2) const;
    inline void _WriteText(LPCTSTR lpszText, CString& strLine) const;
    inline void _WriteTimestamp(const struct _tagTimestamp& tsStart, const struct _tagTimestamp& tsEnd, CString& strLine) const;
    inline void _WriteIndex(int iIndex, CString& strLine) const;
    inline BOOL _SaveToFile(int iOffsetIndex, const struct _tagTimestamp& tsOffset, int iStopIndex, LPCTSTR lpszFileName) const;
    inline BOOL _LessThan(const struct _tagTimestamp& ts1, const struct _tagTimestamp& ts2) const;
    inline BOOL _TryToReadText(LPCTSTR lpszLine, LPTSTR lpszText) const;
    inline BOOL _TryToReadTimestamp(LPCTSTR lpszLine, _tagTimestamp& tsStart, _tagTimestamp& tsEnd) const;
    inline BOOL _TryToReadIndex(LPCTSTR lpszLine, int& iIndex) const;
};

#endif // !defined(AFX_SRTREADER_H__21CC5E2E_74E5_4BAF_BC46_69FB4ECE94F1__INCLUDED_)