home *** CD-ROM | disk | FTP | other *** search
- /*
- File: Buffer.c
-
- Author: Bruce Kritt
-
- Description:
- */
-
- #include <stdio.h>
-
- #include "string.h"
-
- #include "String.h"
- #include "Buffer.h"
-
- // constructor
-
- Buffer::Buffer(int init_size)
- {
- if (init_size < 1)
- {
- puts("Buffer constructor: Bad buffer size.");
- exit(1);
- }
-
- size = init_size;
- start = new char[Size()+1];
- Flush();
-
- return;
-
- } // end constructor
-
- // public services
-
- void Buffer::Flush(void)
- {
- end = start;
- *end = 0;
-
- return;
-
- } // end function Flush()
-
- void Buffer::Push(int ch)
- {
- if (!Full())
- {
- *end = ch;
- ++end;
- *end = 0;
- }
-
- return;
-
- } // end function Push()
-