home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / microcrn / issue_40.arc / DAIMS.ARC / CHBUFFER.HXX < prev    next >
Text File  |  1988-02-10  |  896b  |  30 lines

  1. #include <stream.h>
  2.  
  3. /* 
  4. -*++ class char_buffer: manipulates characters in a buffer
  5. ** 
  6. ** (*++ history: 
  7. **      7 Dec 87    Bruce Eckel    Creation date
  8. ** ++*)
  9. ** 
  10. ** (*++ detailed: 
  11. ** ++*)
  12. */
  13.  
  14. class char_buffer {
  15.   int length;
  16.   int index;            /* for fifo action */
  17.   char * head;
  18. public:
  19.   char_buffer(int size) { head = new char[length = size + 1]; *head = 0; index = 0;};
  20.   ~char_buffer() { delete head; };
  21.   void error(char * msg) { cerr << msg << "\n"; };
  22.   void put(char c);        /* put a char at the end of the buffer */
  23.   char get();            /* get a char from the end; move end up */
  24.   char * str() { return head;};
  25.   void dump() { cout << str();    index = 0; *head = 0; };
  26.                 /* dump to cout and reset to empty */
  27.   void erase() { index = 0; *head = 0; };
  28.                 /* reset to empty */
  29. };
  30.