#ifndef CREADER_H_
#define CREADER_H_

typedef class tagText
{
public:
	CString problem; //题目
	CString explanation; //解释
	CString answer; //答案
	CString picture; //图片 未使用
	CString program; //程序
	tagText()
	{
		problem = "无题目";
		explanation = "无解释";
		answer = "无答案";
		picture = "无图片";
		program = "无程序";
	}
}CText,*pCText;

class CReader
{
private:
	CFile file;
	CString buffer; //缓冲区
	long bufferPos; //指向缓冲区的当前位置
	CString fileName;
	CString getInnerStrIter(CString beginStr,CString endStr,int &ifSuccess);
	//在buffer中从bufferPos开始查找beginChar与endChar中的字符串
	CString *getStrsDevidedBy(char c,CString str,int &count);
	//在str中找出被c分割的字符串（str不含c时count返回0）
public:
	HWND hWnd;
	int getProblemNum(CString chapter,CString type);
	CText text; //存放题目信息
	CReader();
	bool readFile(CString fileName); //将文件内容读入buffer
	bool getText(CString chapterNumber,CString problemType,CString problemNumber);
	void removeSubStr(CString &sourceStr,CString subStr);
	void getInnerStrs(CString &src,CString begin,CString end,CString* &dest,int &num);
};

#endif
