OFILETXT.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Seven Kingdoms: Ancient Adversaries
  3. *
  4. * Copyright 1997,1998 Enlight Software Ltd.
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. *
  19. */
  20. //Filename : OFILETXT.H
  21. //Description : Header file for text file stream
  22. #ifndef __FILETXT_H
  23. #define __FILETXT_H
  24. #ifndef __OFILE_H
  25. #include <OFILE.h>
  26. #endif
  27. //--------- Define control characters ------------//
  28. #define CHAR_EOF '\x1A' // End of file character
  29. #define CHAR_PAGE_BREAK '~' // Page Break
  30. #define CHAR_RETURN '\r' // Carriage return
  31. #define CHAR_LINE_FEED '\n' // Line feed
  32. //--------------------------------------//
  33. class FileTxt : public File
  34. {
  35. public:
  36. char *data_ptr;
  37. private:
  38. enum { MAX_TOKEN_LEN=30 };
  39. char *data_buf;
  40. char token_buf[MAX_TOKEN_LEN];
  41. long file_length;
  42. public:
  43. FileTxt(char* fileName);
  44. FileTxt(File* filePtr, int dataSize);
  45. ~FileTxt();
  46. char* next_line();
  47. char* locate_word(char*);
  48. char get_char(int=1);
  49. char* get_token(int=1);
  50. double get_num();
  51. void read_line(char*,int);
  52. int read_paragraph(char*,int);
  53. long file_size() { return file_length; }
  54. int is_eof() { return *data_ptr == CHAR_EOF; }
  55. };
  56. #endif