00001 //Filename : ORESTXT.H 00002 //Description : Header file of Object Text ResTxt 00003 00004 #ifndef __ORESTXT_H 00005 #define __ORESTXT_H 00006 00007 #ifndef __OFILE_H 00008 #include <OFILE.H> 00009 #endif 00010 00011 //------ Begin of function TxtIndex ------// 00012 00015 struct TxtIndex { 00016 enum { TITLE_LEN=100, PICT_NAME_LEN=8 }; 00017 00018 char title[TITLE_LEN+1]; // Title of the text article 00019 char pict_name[PICT_NAME_LEN+1]; 00020 short text_size; // size of the text body 00021 long file_pos; 00022 }; 00023 00024 //--------- Define class ResTxt ----------// 00025 00027 class ResTxt { 00028 public: 00029 int rec_count; 00030 00031 private: 00032 enum { // default buffer size : 5K 00033 DEF_TXT_BUF_SIZE = 5120 00034 }; 00035 // this size should be large enough for average text unit, also we don't need realloc very frequently 00036 char init_flag; 00037 char res_file_name[MAX_PATH+1]; // e.g. text file name, e.g. BOOK.RTX 00038 // we need to keep the file name, because the file is opened only when reading the content, and close when not necessary 00039 TxtIndex* txt_index_array; 00040 char* txt_buf; 00041 int txt_buf_size; 00042 00043 File file_txt; 00044 char always_open_flag; // always open the text resource file or not 00045 00046 public: 00047 ResTxt() { init_flag=0; } 00048 ~ResTxt() { deinit(); } 00049 00050 void init(char*,int=1); 00051 void deinit(); 00052 00053 char* get_title(int); 00054 char* get_body(int); 00055 char* get_pict_name(int); 00056 00057 int locate_topic(char*); 00058 }; 00059 00060 //-------------------------------------------// 00061 #endif